@react-native-oh/react-native-harmony-cli 0.77.18 → 0.77.33

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.
Files changed (106) hide show
  1. package/dist/assetResolver.js +74 -43
  2. package/dist/autolinking/Autolinking.js +179 -178
  3. package/dist/codegen/core/CodegenError.js +23 -3
  4. package/dist/codegen/core/EventUtils.js +3 -3
  5. package/dist/codegen/core/TypeAnnotationToTS.js +28 -24
  6. package/dist/codegen/core/UberSchema.js +97 -55
  7. package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +41 -28
  8. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +34 -27
  9. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +33 -25
  10. package/dist/codegen/generators/CppComponentCodeGenerator.js +28 -23
  11. package/dist/codegen/generators/LibGlueCodeGenerator.js +29 -26
  12. package/dist/codegen/generators/NativeModuleCodeGenerator.js +30 -25
  13. package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
  14. package/dist/codegen/generators/UberGeneratorV1.js +24 -18
  15. package/dist/codegen/generators/UberGeneratorV2.js +36 -28
  16. package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +24 -50
  17. package/dist/codegen/templates/BasePackageHTemplate.js +21 -120
  18. package/dist/codegen/templates/ComponentDescriptorHTemplate.js +8 -54
  19. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +27 -75
  20. package/dist/codegen/templates/ComponentUtilsTSTemplate.js +29 -162
  21. package/dist/codegen/templates/IndexTSTemplate.js +17 -37
  22. package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +24 -119
  23. package/dist/codegen/templates/TurboModuleCppTemplate.js +15 -38
  24. package/dist/codegen/templates/TurboModuleHTemplate.js +11 -32
  25. package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +19 -52
  26. package/dist/commands/bundle-harmony.js +221 -118
  27. package/dist/commands/clean-harmony.js +63 -58
  28. package/dist/commands/codegen-harmony.js +175 -104
  29. package/dist/commands/codegen-lib-harmony.js +116 -76
  30. package/dist/commands/init-harmony.js +196 -151
  31. package/dist/commands/init.js +961 -537
  32. package/dist/commands/link-harmony.js +82 -35
  33. package/dist/commands/run-harmony.js +520 -352
  34. package/dist/commands/verify-package-harmony.js +117 -54
  35. package/dist/core/AbsolutePath.js +49 -33
  36. package/dist/core/CodegenConfig.js +22 -24
  37. package/dist/core/DescriptiveError.js +37 -18
  38. package/dist/core/FileSystem.js +18 -14
  39. package/dist/core/OHPackageJSON5.js +23 -17
  40. package/dist/core/PackageJSON.js +42 -26
  41. package/dist/core/ProjectDependenciesManager.js +92 -40
  42. package/dist/core/ValidationError.js +22 -2
  43. package/dist/core/fs.js +7 -10
  44. package/dist/index.js +1 -1
  45. package/dist/init/templates/AppScopeAppJSON5Template.js +8 -21
  46. package/dist/init/templates/AppScopeStringVarTemplate.js +8 -19
  47. package/dist/init/templates/EntryIndexTemplate.js +8 -56
  48. package/dist/init/templates/EntryStringVarTemplate.js +8 -27
  49. package/dist/init/templates/HvigorConfigJson5Template.js +8 -33
  50. package/dist/init/templates/MetroConfigTemplate.js +8 -38
  51. package/dist/init/templates/OhPackageJson5Template.js +8 -28
  52. package/dist/io/CliExecutor.js +98 -46
  53. package/dist/io/Logger.js +46 -40
  54. package/dist/io/RealFS.js +100 -43
  55. package/dist/io/TarGz.js +8 -11
  56. package/dist/io/__fixtures__.js +141 -79
  57. package/dist/io/fsUtils.js +12 -13
  58. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +47 -19
  59. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +41 -13
  60. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +38 -8
  61. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +54 -22
  62. package/dist/package-verifier/verify-package.js +133 -56
  63. package/dist/simulator/LaunchSimulator.js +395 -0
  64. package/dist/simulator/index.js +23 -0
  65. package/package.json +2 -11
  66. package/scripts/sync-hvigor.js +27 -0
  67. package/src/autolinking/Autolinking.ts +1 -1
  68. package/src/codegen/generators/UberGeneratorV1.ts +7 -2
  69. package/src/codegen/generators/UberGeneratorV2.ts +6 -1
  70. package/src/commands/codegen-harmony.ts +17 -7
  71. package/src/commands/run-harmony.ts +67 -41
  72. package/src/init/templates/harmony/entry/src/main/module.json5 +7 -0
  73. package/src/simulator/LaunchSimulator.ts +359 -0
  74. package/src/simulator/index.ts +8 -0
  75. package/dist/init/templates/harmony/AppScope/app.json5 +0 -10
  76. package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +0 -8
  77. package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  78. package/dist/init/templates/harmony/build-profile.json5 +0 -36
  79. package/dist/init/templates/harmony/codelinter.json +0 -32
  80. package/dist/init/templates/harmony/entry/build-profile.json5 +0 -18
  81. package/dist/init/templates/harmony/entry/gitignore +0 -7
  82. package/dist/init/templates/harmony/entry/hvigorfile.ts +0 -13
  83. package/dist/init/templates/harmony/entry/oh-package.json5 +0 -9
  84. package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +0 -27
  85. package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +0 -13
  86. package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +0 -4
  87. package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +0 -8
  88. package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +0 -2
  89. package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +0 -11
  90. package/dist/init/templates/harmony/entry/src/main/ets/gitignore +0 -1
  91. package/dist/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
  92. package/dist/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +0 -16
  93. package/dist/init/templates/harmony/entry/src/main/module.json5 +0 -58
  94. package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +0 -8
  95. package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +0 -16
  96. package/dist/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
  97. package/dist/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
  98. package/dist/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +0 -7
  99. package/dist/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
  100. package/dist/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +0 -5
  101. package/dist/init/templates/harmony/entry/src/main/resources/gitignore +0 -1
  102. package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +0 -2
  103. package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +0 -13
  104. package/dist/init/templates/harmony/gitignore +0 -16
  105. package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +0 -22
  106. package/dist/init/templates/harmony/hvigorfile.ts +0 -7
@@ -0,0 +1,359 @@
1
+ /**
2
+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import path from 'path';
9
+ import fs from 'fs-extra';
10
+ import { spawn } from 'child_process';
11
+ import { AbsolutePath, DescriptiveError } from '../core';
12
+ import { Logger } from '../io';
13
+ import { RealCliExecutor } from '../io/CliExecutor';
14
+
15
+ interface LaunchOptions {
16
+ devEcoStudioToolsPath: AbsolutePath;
17
+ sdkToolchainsPath: AbsolutePath;
18
+ cli: RealCliExecutor;
19
+ logger: Logger;
20
+ env: NodeJS.ProcessEnv;
21
+ }
22
+
23
+ const MIN_SUPPORTED_VERSION = [6, 0, 0, 828];
24
+ function compareVersionTuple(a: number[], b: number[]): number {
25
+ for (let i = 0; i < Math.max(a.length, b.length); i++) {
26
+ const av = a[i] ?? 0;
27
+ const bv = b[i] ?? 0;
28
+ if (av !== bv) return av - bv;
29
+ }
30
+ return 0;
31
+ }
32
+ function isSupportedVersion(versionDir: string): boolean {
33
+ const m = versionDir.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)/);
34
+ if (!m) return false;
35
+ const current = m.slice(1).map(n => parseInt(n, 10));
36
+ return compareVersionTuple(current, MIN_SUPPORTED_VERSION) >= 0;
37
+ }
38
+
39
+ async function getCreatedSimulators(cli: RealCliExecutor, emulator: string): Promise<string[]> {
40
+ try {
41
+ let simulatorInfos = '';
42
+ let simulatorInfosFromStderr = '';
43
+ await cli.run(`"${emulator}"`, {
44
+ args: ['--list'],
45
+ shell: true,
46
+ onStdout: (msg) => {
47
+ simulatorInfos += msg;
48
+ },
49
+ onStderr: (msg) => {
50
+ simulatorInfosFromStderr += msg;
51
+ },
52
+ });
53
+ if (simulatorInfos == null || simulatorInfos.trim() === '') {
54
+ simulatorInfos = simulatorInfosFromStderr;
55
+ }
56
+ if (!simulatorInfos || simulatorInfos.trim() === '' ||
57
+ simulatorInfos.trim() === '[Empty]' ||
58
+ simulatorInfos.includes('not ')) {
59
+ return [];
60
+ }
61
+
62
+ return simulatorInfos.split('\n').filter(line => line.trim() !== '');
63
+ } catch (error) {
64
+ throw new DescriptiveError({
65
+ whatHappened: `Failed to get simulator list: ${(error as any)?.message || error}`,
66
+ whatCanUserDo: [
67
+ 'Ensure DevEco Studio is properly installed and configured.',
68
+ 'Check if the emulator path is correct.',
69
+ 'Verify that the emulator has read/write permissions.'
70
+ ],
71
+ extraData: error,
72
+ });
73
+ }
74
+ }
75
+
76
+ async function getDevEcoVersion(devEcoStudioToolsPath: AbsolutePath): Promise<string | null> {
77
+ try {
78
+ let productInfoPath = path.join(devEcoStudioToolsPath.toString(),
79
+ '..',
80
+ 'Resources',
81
+ 'product-info.json');
82
+ if (process.platform === 'win32') {
83
+ productInfoPath = path.join(devEcoStudioToolsPath.toString(),
84
+ '..',
85
+ 'product-info.json');
86
+ }
87
+ const content = await fs.readFile(productInfoPath, 'utf-8');
88
+ const info = JSON.parse(content);
89
+ return info.version || null;
90
+ } catch (error) {
91
+ throw new DescriptiveError({
92
+ whatHappened: `Failed to read DevEco Studio version from product-info.json: ${(error as any)?.message || error}`,
93
+ whatCanUserDo: [
94
+ 'Verify DevEco Studio installation is complete and not corrupted.',
95
+ 'Check if the DevEco Studio tools path is correct.',
96
+ 'Ensure product-info.json file exists and is readable.'
97
+ ],
98
+ extraData: error,
99
+ });
100
+ }
101
+ }
102
+
103
+ function resolveDeviceManagerXml(env: NodeJS.ProcessEnv, devEcoVersion: string): string[] {
104
+ const candidates: string[] = [];
105
+ if (process.platform === 'darwin') {
106
+ const home = env.HOME || '';
107
+ candidates.push(
108
+ path.join(home,
109
+ 'Library',
110
+ 'Application Support',
111
+ 'Huawei',
112
+ `DevEcoStudio${devEcoVersion}`,
113
+ 'options',
114
+ 'deviceManager.xml'),
115
+ );
116
+ } else if (process.platform === 'win32') {
117
+ const appdata = env.APPDATA || '';
118
+ candidates.push(
119
+ path.join(appdata,
120
+ 'Huawei',
121
+ `DevEcoStudio${devEcoVersion}`,
122
+ 'options',
123
+ 'deviceManager.xml'),
124
+ );
125
+ } else {
126
+ throw new DescriptiveError({
127
+ whatHappened: `Unsupported operating system.`,
128
+ whatCanUserDo: ['Please run the RNOH project on Windows or macOS.']
129
+ });
130
+ }
131
+ return candidates;
132
+ }
133
+
134
+ interface DevicePathInfo {
135
+ instancePath?: string;
136
+ imageRoot?: string;
137
+ }
138
+
139
+ function parseDeviceManagerXml(xmlContent: string): DevicePathInfo {
140
+ const info: DevicePathInfo = {};
141
+ const optionRegex = /<option\b[^>]*?>/gi;
142
+ let m: RegExpExecArray | null;
143
+ while ((m = optionRegex.exec(xmlContent))) {
144
+ const tag = m[0];
145
+ const nameMatch = tag.match(/\bname=["']([^"']+)["']/i);
146
+ if (!nameMatch) continue;
147
+ const valueMatch = tag.match(/\bvalue=["']([^"']+)["']/i);
148
+ if (!valueMatch) continue;
149
+ const name = nameMatch[1];
150
+ const value = valueMatch[1];
151
+ if (name === 'imageDeployPath' && !info.imageRoot) {
152
+ info.imageRoot = value;
153
+ } else if (name === 'openharmonyDeployPath' && !info.instancePath) {
154
+ info.instancePath = value;
155
+ }
156
+ if (info.imageRoot && info.instancePath) break;
157
+ }
158
+ return info;
159
+ }
160
+
161
+ function candidateEmulatorExecutables(devEcoStudioToolsPath: AbsolutePath): string[] {
162
+ const list: string[] = [];
163
+ const add = (...segs: string[]) =>
164
+ list.push(devEcoStudioToolsPath.copyWithNewSegment(...segs).toString());
165
+
166
+ if (process.platform === 'win32') {
167
+ add('emulator', 'Emulator.exe');
168
+ } else {
169
+ add('emulator', 'Emulator');
170
+ }
171
+ return list;
172
+ }
173
+
174
+ function pickExisting(paths: string[]): string | undefined {
175
+ return paths.find(p => fs.existsSync(p));
176
+ }
177
+
178
+ async function resolveInstanceAndImageRoot(
179
+ env: NodeJS.ProcessEnv, devEcoVersion: string
180
+ ): Promise<{ instancePath: string; imageRoot: string } | null> {
181
+ const defaultInstanceCandidates: string[] = [];
182
+ const defaultImageCandidates: string[] = [];
183
+
184
+ if (process.platform === 'darwin') {
185
+ const home = env.HOME || '';
186
+ defaultInstanceCandidates.push(
187
+ path.join(home,
188
+ '.Huawei',
189
+ 'Emulator',
190
+ 'deployed'),
191
+ );
192
+ defaultImageCandidates.push(
193
+ path.join(home,
194
+ 'Library',
195
+ 'Huawei',
196
+ 'Sdk'),
197
+ );
198
+ } else if (process.platform === 'win32') {
199
+ const localAppData = env.LOCALAPPDATA || '';
200
+ defaultInstanceCandidates.push(
201
+ path.join(localAppData,
202
+ 'Huawei',
203
+ 'Emulator',
204
+ 'deployed')
205
+ );
206
+ defaultImageCandidates.push(
207
+ path.join(localAppData,
208
+ 'Huawei',
209
+ 'Sdk')
210
+ );
211
+ } else {
212
+ throw new DescriptiveError({
213
+ whatHappened: `Unsupported operating system.`,
214
+ whatCanUserDo: ['Please run the RNOH project on Windows or macOS.']
215
+ });
216
+ }
217
+
218
+ let xmlInfo: DevicePathInfo = {};
219
+ for (const xmlPath of resolveDeviceManagerXml(env, devEcoVersion)) {
220
+ if (fs.existsSync(xmlPath)) {
221
+ try {
222
+ const content = await fs.readFile(xmlPath, 'utf-8');
223
+ xmlInfo = parseDeviceManagerXml(content);
224
+ if (xmlInfo.instancePath || xmlInfo.imageRoot) break;
225
+ } catch (error) {
226
+ throw new DescriptiveError({
227
+ whatHappened: `Failed to read or parse device manager XML at ${xmlPath}: ${(error as any)?.message || error}`,
228
+ whatCanUserDo: [
229
+ 'Verify that the DevEco Studio deviceManager.xml file exists and is readable.',
230
+ 'Check if DEVECO_SDK_HOME environment variable is set correctly.',
231
+ 'Ensure DevEco Studio has been launched at least once to generate configuration files.',
232
+ 'Check file permissions for the DevEco Studio configuration directory.'
233
+ ],
234
+ extraData: error,
235
+ });
236
+ }
237
+ }
238
+ }
239
+
240
+ let resolvedInstance = pickExisting(defaultInstanceCandidates);
241
+ let resolvedImageRoot = pickExisting(defaultImageCandidates);
242
+ if (xmlInfo.imageRoot) {
243
+ resolvedImageRoot = xmlInfo.imageRoot;
244
+ }
245
+ if (xmlInfo.instancePath) {
246
+ resolvedInstance = xmlInfo.instancePath;
247
+ }
248
+ if (!resolvedInstance || !resolvedImageRoot) {
249
+ throw new DescriptiveError({
250
+ whatHappened: `No simulator instance or image root directory detected.`,
251
+ whatCanUserDo: [
252
+ 'Have you already launched the simulator via DevEco Studio?'
253
+ ]
254
+ });
255
+ }
256
+ return { instancePath: resolvedInstance, imageRoot: resolvedImageRoot };
257
+ }
258
+
259
+ export async function launchHarmonySimulator(opt: LaunchOptions): Promise<void> {
260
+ const {
261
+ devEcoStudioToolsPath,
262
+ cli,
263
+ logger,
264
+ } = opt;
265
+
266
+ const devEcoVersion = await getDevEcoVersion(devEcoStudioToolsPath);
267
+ if (!devEcoVersion) {
268
+ throw new DescriptiveError({
269
+ whatHappened: `DevEco Studio version could not be obtained.`,
270
+ whatCanUserDo: [
271
+ 'Verify DevEco Studio is properly installed and the tools path is correct.',
272
+ 'Check if product-info.json file exists in the DevEco Studio installation directory.',
273
+ 'Ensure you have the latest version of DevEco Studio installed.'
274
+ ]
275
+ });
276
+ }
277
+
278
+ if (!isSupportedVersion(devEcoVersion)) {
279
+ throw new DescriptiveError({
280
+ whatHappened: `Current DevEco SDK version (${devEcoVersion}) does not support launching the simulator via command line (requires >= ${MIN_SUPPORTED_VERSION.join('.')}).`,
281
+ whatCanUserDo: [
282
+ `Update DevEco Studio to version ${MIN_SUPPORTED_VERSION.join('.')} or higher.`,
283
+ 'Check the official DevEco Studio website for the latest version.',
284
+ 'Launch the simulator manually from DevEco Studio IDE.'
285
+ ]
286
+ });
287
+ }
288
+
289
+ const versionList = devEcoVersion.split('.');
290
+ const majorVersion = `${versionList[0]}.${versionList[1]}`;
291
+ const paths = await resolveInstanceAndImageRoot(opt.env, majorVersion);
292
+ if (!paths) {
293
+ throw new DescriptiveError({
294
+ whatHappened: `Could not resolve simulator instance path or image root.`,
295
+ whatCanUserDo: [
296
+ 'Open DevEco Studio and launch the simulator at least once to generate configuration files.',
297
+ 'Check if DEVECO_SDK_HOME environment variable is set correctly.',
298
+ 'Verify that the simulator has been properly configured in DevEco Studio.',
299
+ 'Ensure the default simulator paths exist in your system.'
300
+ ]
301
+ });
302
+ }
303
+
304
+ const emulatorExe = pickExisting(candidateEmulatorExecutables(devEcoStudioToolsPath));
305
+ if (!emulatorExe) {
306
+ throw new DescriptiveError({
307
+ whatHappened: `Emulator executable not found in DevEco Studio installation.`,
308
+ whatCanUserDo: [
309
+ 'Verify DevEco Studio installation is complete and not corrupted.',
310
+ 'Check if the emulator component is installed in DevEco Studio.',
311
+ 'Reinstall DevEco Studio if the emulator binary is missing.',
312
+ 'Ensure the DevEco Studio tools path is correctly configured.'
313
+ ]
314
+ });
315
+ }
316
+ const simulatorName = await getCreatedSimulators(cli, emulatorExe);
317
+ if (simulatorName.length <= 0) {
318
+ throw new DescriptiveError({
319
+ whatHappened: `No existing HarmonyOS simulator instance detected.`,
320
+ whatCanUserDo: [
321
+ 'Create a simulator instance in DevEco Studio first.',
322
+ 'Open DevEco Studio Device Manager and create a new virtual device.',
323
+ 'Ensure the simulator instance is properly configured and available.',
324
+ 'Check if the emulator --list command returns any valid instances.'
325
+ ]
326
+ });
327
+ }
328
+
329
+ try {
330
+ const quoteIfNeeded = (p: string) =>
331
+ process.platform === 'win32' ? `"${p}"` : p;
332
+ const args = [
333
+ '-hvd',
334
+ quoteIfNeeded(simulatorName[0].trim()),
335
+ '-path',
336
+ quoteIfNeeded(paths.instancePath),
337
+ '-imageRoot',
338
+ quoteIfNeeded(paths.imageRoot),
339
+ ];
340
+ const child = spawn(quoteIfNeeded(emulatorExe), args, {
341
+ cwd: path.dirname(emulatorExe),
342
+ detached: true,
343
+ stdio: 'ignore',
344
+ shell: process.platform === 'win32',
345
+ });
346
+ child.unref();
347
+ logger.info(() => `Launching HarmonyOS simulator in background: ${simulatorName[0]}`);
348
+ } catch (e) {
349
+ throw new DescriptiveError({
350
+ whatHappened: `Failed to start simulator process: ${(e as any)?.message || e}`,
351
+ whatCanUserDo: [
352
+ 'Confirm that the DevEco Simulator can be started manually from DevEco Studio.',
353
+ 'Ensure no stale simulator process is blocking required ports.',
354
+ 'Reinstall or repair DevEco Studio if the simulator binary is corrupted.'
355
+ ],
356
+ extraData: e,
357
+ });
358
+ }
359
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ export * from './LaunchSimulator';
@@ -1,10 +0,0 @@
1
- {
2
- "app": {
3
- "bundleName": "com.example",
4
- "vendor": "example",
5
- "versionCode": 1000000,
6
- "versionName": "1.0.0",
7
- "icon": "$media:app_icon",
8
- "label": "$string:app_name",
9
- }
10
- }
@@ -1,8 +0,0 @@
1
- {
2
- "string": [
3
- {
4
- "name": "app_name",
5
- "value": "example"
6
- }
7
- ]
8
- }
@@ -1,36 +0,0 @@
1
- {
2
- app: {
3
- products: [
4
- {
5
- name: 'default',
6
- signingConfig: 'default',
7
- compatibleSdkVersion: '5.0.0(12)',
8
- runtimeOS: 'HarmonyOS',
9
- buildOption: {
10
- nativeCompiler: 'BiSheng'
11
- }
12
- },
13
- ],
14
- buildModeSet: [
15
- {
16
- name: 'debug',
17
- },
18
- {
19
- name: 'release',
20
- },
21
- ],
22
- signingConfigs: [],
23
- },
24
- modules: [
25
- {
26
- name: 'entry',
27
- srcPath: './entry',
28
- targets: [
29
- {
30
- name: 'default',
31
- applyToProducts: ['default'],
32
- },
33
- ],
34
- },
35
- ],
36
- }
@@ -1,32 +0,0 @@
1
- {
2
- "files": ["**/*.ts", "**/*.ets"],
3
- "ignore": [
4
- "**/ohosTest/**/*",
5
- "**/node_modules/**/*",
6
- "**/hvigorfile.ts",
7
- "**/node_modules/**/*",
8
- "**/oh_modules/**/*",
9
- "**/build/**/*",
10
- "**/.preview/**/*"
11
- ],
12
- "plugins": ["@typescript-eslint"],
13
- "ruleSet": [],
14
- "rules": {
15
- "@typescript-eslint/await-thenable": "warn",
16
- "@typescript-eslint/consistent-type-imports": "warn",
17
- "@typescript-eslint/explicit-function-return-type": "warn",
18
- "@typescript-eslint/explicit-module-boundary-types": "warn",
19
- "@typescript-eslint/no-dynamic-delete": "warn",
20
- "@typescript-eslint/no-explicit-any": "warn",
21
- "@typescript-eslint/no-for-in-array": "warn",
22
- "@typescript-eslint/no-this-alias": "warn",
23
- "@typescript-eslint/no-unnecessary-type-constraint": "warn",
24
- "@typescript-eslint/no-unsafe-argument": "warn",
25
- "@typescript-eslint/no-unsafe-assignment": "warn",
26
- "@typescript-eslint/no-unsafe-call": "warn",
27
- "@typescript-eslint/no-unsafe-member-access": "warn",
28
- "@typescript-eslint/no-unsafe-return": "warn",
29
- "@typescript-eslint/prefer-literal-enum-member": "warn"
30
- },
31
- "overrides": []
32
- }
@@ -1,18 +0,0 @@
1
- {
2
- "apiType": 'stageMode',
3
- "buildOption": {
4
- "externalNativeOptions": {
5
- "path": "./src/main/cpp/CMakeLists.txt",
6
- "arguments": "",
7
- },
8
- },
9
- "targets": [
10
- {
11
- "name": "default",
12
- "runtimeOS": "HarmonyOS"
13
- },
14
- {
15
- "name": "ohosTest",
16
- }
17
- ]
18
- }
@@ -1,7 +0,0 @@
1
- /node_modules
2
- /.preview
3
- /build
4
- /.cxx
5
- package-lock.json
6
- /oh_modules
7
- /assets
@@ -1,13 +0,0 @@
1
- import { hapTasks } from '@ohos/hvigor-ohos-plugin';
2
- import { createRNOHModulePlugin } from '@rnoh/hvigor-plugin';
3
-
4
- export default {
5
- system: hapTasks,
6
- plugins: [
7
- createRNOHModulePlugin({
8
- codegen: {
9
- rnohModulePath: './oh_modules/@rnoh/react-native-openharmony',
10
- },
11
- }),
12
- ],
13
- };
@@ -1,9 +0,0 @@
1
- {
2
- "license": "ISC",
3
- "devDependencies": {},
4
- "name": "entry",
5
- "description": "example description",
6
- "version": "1.0.0",
7
- "dependencies": {
8
- }
9
- }
@@ -1,27 +0,0 @@
1
- cmake_minimum_required(VERSION 3.11)
2
- project(rnapp)
3
-
4
- set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
5
- set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
6
- set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../oh_modules/@rnoh/react-native-openharmony/src/main/cpp")
7
- set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated")
8
- set(LOG_VERBOSITY_LEVEL 1)
9
- set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
10
- set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
11
- set(WITH_HITRACE_SYSTRACE ON)
12
- set(WITH_HITRACE_REACT_MARKER ON)
13
- set(OH_MODULES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../oh_modules") # required by 'autolink_libraries'
14
-
15
- add_subdirectory("${RNOH_CPP_DIR}" ./rn)
16
-
17
- include("${CMAKE_CURRENT_SOURCE_DIR}/autolinking.cmake")
18
-
19
- file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp") # this line is needed by codegen v1
20
- add_library(rnoh_app SHARED
21
- ${GENERATED_CPP_FILES}
22
- "./PackageProvider.cpp"
23
- "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
24
- )
25
- target_link_libraries(rnoh_app PUBLIC rnoh)
26
-
27
- autolink_libraries(rnoh_app)
@@ -1,13 +0,0 @@
1
- #include "RNOH/PackageProvider.h"
2
- #include "RNOHPackagesFactory.h"
3
- #include "generated/RNOHGeneratedPackage.h"
4
-
5
- using namespace rnoh;
6
-
7
- std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(
8
- Package::Context ctx) {
9
- auto packages = createRNOHPackages(ctx); // <= autolinking
10
- packages.push_back(std::make_shared<RNOHGeneratedPackage>(
11
- ctx)); // generated by codegen-harmony v1 on app preBuilt stage)
12
- return packages;
13
- }
@@ -1,4 +0,0 @@
1
- generated/
2
- /RNOHPackagesFactory.h
3
- autolinking.cmake
4
-
@@ -1,8 +0,0 @@
1
- import type { RNPackageContext, RNOHPackage } from '@rnoh/react-native-openharmony';
2
- import { createRNOHPackages as createRNOHPackagesAutolinking } from "./RNOHPackagesFactory"
3
-
4
- export function getRNOHPackages(ctx: RNPackageContext): RNOHPackage[] {
5
- return [
6
- ...createRNOHPackagesAutolinking(ctx)
7
- ]
8
- }
@@ -1,11 +0,0 @@
1
- import {RNAbility} from '@rnoh/react-native-openharmony';
2
-
3
- export default class EntryAbility extends RNAbility {
4
- override getPagePath() {
5
- return 'pages/Index';
6
- }
7
-
8
- override getRNOHWorkerScriptUrl() {
9
- return "entry/ets/workers/RNOHWorker.ets"
10
- }
11
- }
@@ -1 +0,0 @@
1
- /RNOHPackagesFactory.ets
@@ -1,16 +0,0 @@
1
- /**
2
- * Importing some ets files in the following way results in runtime errors e.g.
3
- * import { setupRNOHWorker } from "@rnoh/react-native-openharmony"
4
- *
5
- * It looks like this is ArkTS problem and it may be fixed in the future.
6
- * For the time being, use direct imports.
7
- */
8
- import { setupRNOHWorker } from "@rnoh/react-native-openharmony/src/main/ets/setupRNOHWorker"
9
- import { getRNOHPackages } from "../PackageProvider"
10
-
11
- setupRNOHWorker({
12
- createWorkerRNInstanceConfig: (_rnInstanceName) => {
13
- return { thirdPartyPackagesFactory: getRNOHPackages }
14
- }
15
- })
16
-
@@ -1,58 +0,0 @@
1
- {
2
- "module": {
3
- "name": "entry",
4
- "type": "entry",
5
- "description": "$string:module_desc",
6
- "mainElement": "EntryAbility",
7
- "deviceTypes": [
8
- "default"
9
- ],
10
- "deliveryWithInstall": true,
11
- "installationFree": false,
12
- "pages": "$profile:main_pages",
13
- "requestPermissions": [
14
- {
15
- "name": "ohos.permission.INTERNET"
16
- },
17
- {
18
- "name": "ohos.permission.VIBRATE"
19
- }
20
- ],
21
- "metadata": [
22
- {
23
- "name": "OPTLazyForEach",
24
- "value": "true",
25
- },
26
- {
27
- "name": "can_preview_text",
28
- "value": "true",
29
- },
30
- {
31
- "name": "halfLeading",
32
- "value": "true",
33
- },
34
- ],
35
- "abilities": [
36
- {
37
- "name": "EntryAbility",
38
- "srcEntry": "./ets/entryability/EntryAbility.ets",
39
- "description": "$string:EntryAbility_desc",
40
- "icon": "$media:layered_image",
41
- "label": "$string:EntryAbility_label",
42
- "startWindowIcon": "$media:startIcon",
43
- "startWindowBackground": "$color:start_window_background",
44
- "visible": true,
45
- "skills": [
46
- {
47
- "entities": [
48
- "entity.system.home"
49
- ],
50
- "actions": [
51
- "action.system.home"
52
- ],
53
- }
54
- ]
55
- }
56
- ]
57
- }
58
- }
@@ -1,8 +0,0 @@
1
- {
2
- "color": [
3
- {
4
- "name": "start_window_background",
5
- "value": "#FFFFFF"
6
- }
7
- ]
8
- }