@expo-harmony/template 55.0.0-harmony.3 → 55.0.0-harmony.5

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.
@@ -3,7 +3,7 @@
3
3
  "products": [
4
4
  {
5
5
  "name": "default",
6
- "compatibleSdkVersion": "5.0.1(13)",
6
+ "compatibleSdkVersion": "6.0.0(20)",
7
7
  "targetSdkVersion": "6.1.1(24)",
8
8
  "runtimeOS": "HarmonyOS",
9
9
  "buildOption": {
@@ -1,6 +1,20 @@
1
- import type { RNPackage, RNPackageContext } from '@rnoh/react-native-openharmony';
1
+ import { ExpoReactHostFactory } from '@expo-harmony/expo';
2
+ import { ExpoRuntimeConfig } from '@expo-harmony/expo-modules-core';
3
+ import type { RNInstanceOptions, RNPackage, RNPackageContext } from '@rnoh/react-native-openharmony';
2
4
  import { createRNOHPackages } from './RNOHPackagesFactory';
5
+ import { expoHarmonyHostProvider } from './generated/ExpoHarmonyHostProvider';
3
6
 
4
- export function getRNOHPackages(context: RNPackageContext): RNPackage[] {
5
- return createRNOHPackages(context);
7
+ export function getRNOHPackages(context: RNPackageContext, runtimeConfig?: ExpoRuntimeConfig): RNPackage[] {
8
+ return createRNOHPackages(context, runtimeConfig);
6
9
  }
10
+
11
+ export const expoReactHost = ExpoReactHostFactory.getDefaultReactHost({
12
+ bundlePath: 'hermes_bundle.hbc',
13
+ workerScriptUrl: 'entry/ets/workers/RNOHWorker.ets',
14
+ provider: expoHarmonyHostProvider,
15
+ createRNInstanceOptions: (headless: boolean): RNInstanceOptions => ({
16
+ name: "__EXPO_HARMONY_APP_LABEL__",
17
+ createRNPackages: (context: RNPackageContext): RNPackage[] => getRNOHPackages(context, new ExpoRuntimeConfig({ isHeadless: headless })),
18
+ fontResourceByFontFamily: {},
19
+ }),
20
+ });
@@ -0,0 +1,14 @@
1
+ import { ExpoAbilityStage } from '@expo-harmony/expo';
2
+ import type { ExpoHarmonyHostProvider, ExpoReactHost } from '@expo-harmony/expo';
3
+ import { expoReactHost } from '../PackageProvider';
4
+ import { expoHarmonyHostProvider } from '../generated/ExpoHarmonyHostProvider';
5
+
6
+ export default class EntryAbilityStage extends ExpoAbilityStage {
7
+ protected override getExpoReactHost(): ExpoReactHost {
8
+ return expoReactHost;
9
+ }
10
+
11
+ protected override getExpoHarmonyHostProvider(): ExpoHarmonyHostProvider {
12
+ return expoHarmonyHostProvider;
13
+ }
14
+ }
@@ -2,8 +2,8 @@
2
2
  * Automatically generated by @expo-harmony/prebuild-config.
3
3
  */
4
4
 
5
- import type { ExpoHarmonyHostProvider } from '@expo-harmony/expo-modules-core/Autolinking';
6
- import { ExpoRNAbility } from '@expo-harmony/expo-modules-core/Autolinking';
5
+ import type { ExpoHarmonyHostProvider } from '@expo-harmony/expo';
6
+ import { ExpoRNAbility } from '@expo-harmony/expo';
7
7
  import { expoHarmonyHostProvider } from '../generated/ExpoHarmonyHostProvider';
8
8
 
9
9
  export default class __EXPO_HARMONY_ABILITY_NAME__ extends ExpoRNAbility {
@@ -2,38 +2,25 @@
2
2
  * Automatically generated by @expo-harmony/prebuild-config.
3
3
  */
4
4
 
5
- import type resmgr from '@ohos.resourceManager';
6
5
  import {
7
- MetroJSBundleProvider,
8
6
  RNOHCoreContext,
9
7
  RNOHErrorDialog,
10
- ResourceJSBundleProvider,
11
8
  } from '@rnoh/react-native-openharmony';
12
- import { ExpoRNApp } from '@expo-harmony/expo-modules-core';
13
- import { getRNOHPackages } from '../PackageProvider';
9
+ import type { RNInstanceOptions } from '@rnoh/react-native-openharmony';
10
+ import { ExpoRNApp } from '@expo-harmony/expo';
11
+ import { expoReactHost } from '../PackageProvider';
14
12
  import { ExpoHarmonyRootView } from '../generated/ExpoHarmonyHostProvider';
15
13
 
16
- class InMemoryResourceJSBundleProvider extends ResourceJSBundleProvider {
17
- private readonly ownedResourceManager: resmgr.ResourceManager;
18
- private readonly ownedResourcePath: string;
19
-
20
- constructor(resourceManager: resmgr.ResourceManager, resourcePath: string) {
21
- super(resourceManager, resourcePath);
22
- this.ownedResourceManager = resourceManager;
23
- this.ownedResourcePath = resourcePath;
24
- }
25
-
26
- override async getBundle(): Promise<ArrayBuffer> {
27
- const bytes = await this.ownedResourceManager.getRawFileContent(this.ownedResourcePath);
28
- return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
29
- }
30
- }
31
-
32
14
  @Entry
33
15
  @Component
34
16
  struct Index {
35
17
  @StorageLink('RNOHCoreContext') private rnohCoreContext: RNOHCoreContext | undefined = undefined;
36
18
 
19
+ private instanceOptions(): RNInstanceOptions {
20
+ const options = expoReactHost.createRNInstanceOptions();
21
+ return options;
22
+ }
23
+
37
24
  build(): void {
38
25
  Stack() {
39
26
  ExpoHarmonyRootView()
@@ -43,19 +30,13 @@ struct Index {
43
30
  RNOHErrorDialog({ ctx: this.rnohCoreContext });
44
31
  }
45
32
  ExpoRNApp({
46
- rnInstanceConfig: {
47
- name: "__EXPO_HARMONY_APP_LABEL__",
48
- createRNPackages: getRNOHPackages,
49
- fontResourceByFontFamily: {},
50
- enableDebugger: this.rnohCoreContext.isDebugModeEnabled,
51
- },
33
+ reactHost: expoReactHost,
34
+ rnInstanceConfig: this.instanceOptions(),
52
35
  appKey: 'main',
53
- jsBundleProvider: this.rnohCoreContext.isDebugModeEnabled
54
- ? new MetroJSBundleProvider()
55
- : new InMemoryResourceJSBundleProvider(
56
- this.rnohCoreContext.uiAbilityContext.resourceManager,
57
- 'hermes_bundle.hbc',
58
- ),
36
+ jsBundleProvider: expoReactHost.createJSBundleProvider(
37
+ this.rnohCoreContext.uiAbilityContext,
38
+ this.rnohCoreContext.isDebugModeEnabled,
39
+ ),
59
40
  });
60
41
  }
61
42
  }
@@ -2,6 +2,7 @@
2
2
  "module": {
3
3
  "name": "entry",
4
4
  "type": "entry",
5
+ "srcEntry": "./ets/abilitystage/EntryAbilityStage.ets",
5
6
  "description": "$string:expo_harmony_module_desc",
6
7
  "mainElement": "EntryAbility",
7
8
  "deviceTypes": ["phone", "tablet"],
@@ -13,12 +14,6 @@
13
14
  "name": "ohos.permission.INTERNET"
14
15
  }
15
16
  ],
16
- "metadata": [
17
- {
18
- "name": "expo.harmony.userInterfaceStyle",
19
- "value": "light"
20
- }
21
- ],
22
17
  "abilities": [
23
18
  {
24
19
  "name": "EntryAbility",
@@ -4,6 +4,7 @@ import { createRequire } from 'node:module';
4
4
  import path from 'node:path';
5
5
  import { hvigor } from '@ohos/hvigor';
6
6
  import { appTasks, OhosPluginId } from '@ohos/hvigor-ohos-plugin';
7
+ import { publishHarmonyNativeRuntime } from '@expo-harmony/cli/native-build';
7
8
  import { createRNOHProjectPlugin } from '@rnoh/hvigor-plugin';
8
9
 
9
10
  import { writeStamp } from './native-inputs-stamp';
@@ -20,21 +21,6 @@ const HermesMagic = 'c61fbc03c103191f';
20
21
  let restoreBundle: (() => void) | null = null;
21
22
 
22
23
  writeStamp(ProjectRoot, HarmonyRoot);
23
- hvigor.nodesEvaluated(async () => {
24
- await refreshExpoConstantsResource();
25
- });
26
-
27
- async function refreshExpoConstantsResource(): Promise<void> {
28
- let plugin: { refreshExpoConstantsResourceAsync?: (projectRoot: string, harmonyRoot: string) => Promise<string> };
29
- try {
30
- plugin = ProjectRequire('@expo-harmony/expo-constants/plugin/withConstants');
31
- } catch (error: unknown) {
32
- if (error && typeof error === 'object' && 'code' in error && error.code === 'MODULE_NOT_FOUND') return;
33
- throw error;
34
- }
35
-
36
- await plugin.refreshExpoConstantsResourceAsync?.(ProjectRoot, HarmonyRoot);
37
- }
38
24
 
39
25
  function findNodeModules(): string {
40
26
  let directory = ProjectRoot;
@@ -205,8 +191,11 @@ const BundlerPlugin = {
205
191
  hvigor.nodesEvaluated(() => {
206
192
  const appContext = node.getContext(OhosPluginId.OHOS_APP_PLUGIN);
207
193
  const buildMode = appContext.getBuildMode();
194
+ publishHarmonyNativeRuntime(ProjectRoot, buildMode === 'release' ? 'release' : 'debug');
208
195
 
209
- if (buildMode !== 'release') stashBundle();
196
+ const config = JSON.parse(fs.readFileSync(path.join(path.dirname(EmbeddedBundle), 'expo-updates/config.json'), 'utf8'));
197
+ const embedded = buildMode === 'release' || config.useNativeDebug === true;
198
+ if (!embedded) stashBundle();
210
199
 
211
200
  node.subNodes((moduleNode) => {
212
201
  const hapContext = moduleNode.getContext(OhosPluginId.OHOS_HAP_PLUGIN);
@@ -217,7 +206,7 @@ const BundlerPlugin = {
217
206
  moduleNode.registerTask({
218
207
  name: `${targetName}@ExpoHarmonyBundle`,
219
208
  run: () => {
220
- if (buildMode === 'release') bundleRelease();
209
+ if (embedded) bundleRelease();
221
210
  },
222
211
  dependencies: [`${targetName}@ProcessResource`],
223
212
  postDependencies: [`${targetName}@CompileResource`],
@@ -2,7 +2,7 @@ import crypto from 'node:crypto';
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
 
5
- import { fingerprintHarmonyNativeInputsSync } from '@expo-harmony/config-plugins/native-inputs';
5
+ import { fingerprintHarmonyNativeInputsSync } from '@expo-harmony/config-plugins/internal/native-inputs';
6
6
 
7
7
  const StampPath = '.hvigor/expo-harmony/native-inputs.cmake';
8
8
 
@@ -16,16 +16,16 @@ function readFileIfPresent(file: string): Buffer | null {
16
16
  }
17
17
  }
18
18
 
19
- export function writeStamp(projectRoot: string, harmonyRoot: string): void {
20
- const { artifactCount, fingerprint } = fingerprintHarmonyNativeInputsSync({
21
- lockfile: path.join(harmonyRoot, 'oh-package-lock.json5'),
22
- manifest: path.join(harmonyRoot, 'oh-package.json5'),
23
- projectRoot,
19
+ export function writeStamp(project: string, root: string): void {
20
+ const { artifactCount: count, fingerprint } = fingerprintHarmonyNativeInputsSync({
21
+ lockfile: path.join(root, 'oh-package-lock.json5'),
22
+ manifest: path.join(root, 'oh-package.json5'),
23
+ projectRoot: project,
24
24
  });
25
- const file = path.join(harmonyRoot, ...StampPath.split('/'));
25
+ const file = path.join(root, ...StampPath.split('/'));
26
26
  const content = [
27
27
  '# Generated by @expo-harmony/template. Do not edit.',
28
- `# Native HAR artifacts: ${artifactCount}`,
28
+ `# Native HAR artifacts: ${count}`,
29
29
  `add_compile_definitions(EXPO_HARMONY_NATIVE_INPUTS_SHA256_${fingerprint}=1)`,
30
30
  '',
31
31
  ].join('\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo-harmony/template",
3
- "version": "55.0.0-harmony.3",
3
+ "version": "55.0.0-harmony.5",
4
4
  "keywords": [
5
5
  "react-native",
6
6
  "expo",
@@ -26,8 +26,9 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@babel/core": "7.29.7",
29
- "@expo-harmony/config-plugins": "55.0.10-harmony.2",
30
- "@expo-harmony/expo-modules-core": "55.0.25-harmony.2",
29
+ "@expo-harmony/config-plugins": "55.0.10-harmony.4",
30
+ "@expo-harmony/expo": "55.0.26-harmony.1",
31
+ "@expo-harmony/expo-modules-core": "55.0.25-harmony.3",
31
32
  "@expo/metro-config": "55.0.26",
32
33
  "@expo/metro-runtime": "55.0.12",
33
34
  "@react-native-oh/react-native-harmony": "0.84.1",