diff --git a/samples/NativeModuleSample/cpp-lib/README.md b/samples/NativeModuleSample/cpp-lib/README.md index 21f6b9edd..0b134f531 100644 --- a/samples/NativeModuleSample/cpp-lib/README.md +++ b/samples/NativeModuleSample/cpp-lib/README.md @@ -23,12 +23,6 @@ To run the example app (targeting the New Architecture) and see that the module yarn example windows ``` -Alternatively, to run the old example app (targeting the Old Architecture) and see that the module works: - -``` -yarn example-old windows -``` - ### Upgrade First run the **Setup** steps above. Then run the `UpgradeSmokeTest.ps1` script with the target RNW version (usually `latest`): @@ -44,4 +38,4 @@ yarn prepare yarn codegen-windows ``` -Finally, build and verify *both* example apps as per the **Run** steps above. If both apps work without issue, then go ahead and submit the PR with your changes. +Finally, build and verify the example app as per the **Run** steps above. If the app works without issue, then go ahead and submit the PR with your changes. diff --git a/samples/NativeModuleSample/cpp-lib/example-old/.bundle/config b/samples/NativeModuleSample/cpp-lib/example-old/.bundle/config deleted file mode 100644 index 848943bb5..000000000 --- a/samples/NativeModuleSample/cpp-lib/example-old/.bundle/config +++ /dev/null @@ -1,2 +0,0 @@ -BUNDLE_PATH: "vendor/bundle" -BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/samples/NativeModuleSample/cpp-lib/example-old/.watchmanconfig b/samples/NativeModuleSample/cpp-lib/example-old/.watchmanconfig deleted file mode 100644 index 0967ef424..000000000 --- a/samples/NativeModuleSample/cpp-lib/example-old/.watchmanconfig +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/samples/NativeModuleSample/cpp-lib/example-old/app.json b/samples/NativeModuleSample/cpp-lib/example-old/app.json deleted file mode 100644 index 4c9667bff..000000000 --- a/samples/NativeModuleSample/cpp-lib/example-old/app.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "NativeModuleSampleExampleOld", - "displayName": "NativeModuleSampleExampleOld" -} diff --git a/samples/NativeModuleSample/cpp-lib/example-old/babel.config.js b/samples/NativeModuleSample/cpp-lib/example-old/babel.config.js deleted file mode 100644 index 486a09304..000000000 --- a/samples/NativeModuleSample/cpp-lib/example-old/babel.config.js +++ /dev/null @@ -1,12 +0,0 @@ -const path = require('path'); -const { getConfig } = require('react-native-builder-bob/babel-config'); -const pkg = require('../package.json'); - -const root = path.resolve(__dirname, '..'); - -module.exports = getConfig( - { - presets: ['module:@react-native/babel-preset'], - }, - { root, pkg } -); diff --git a/samples/NativeModuleSample/cpp-lib/example-old/index.js b/samples/NativeModuleSample/cpp-lib/example-old/index.js deleted file mode 100644 index 2eddcb2b1..000000000 --- a/samples/NativeModuleSample/cpp-lib/example-old/index.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { AppRegistry } from 'react-native'; -import App from './src/App'; -import { name as appName } from './app.json'; - -AppRegistry.registerComponent(appName, () => App); diff --git a/samples/NativeModuleSample/cpp-lib/example-old/jest.config.js b/samples/NativeModuleSample/cpp-lib/example-old/jest.config.js deleted file mode 100644 index 8eb675e9b..000000000 --- a/samples/NativeModuleSample/cpp-lib/example-old/jest.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - preset: 'react-native', -}; diff --git a/samples/NativeModuleSample/cpp-lib/example-old/metro.config.js b/samples/NativeModuleSample/cpp-lib/example-old/metro.config.js deleted file mode 100644 index 474fa5bf4..000000000 --- a/samples/NativeModuleSample/cpp-lib/example-old/metro.config.js +++ /dev/null @@ -1,67 +0,0 @@ -const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); -const fs = require('fs'); -const path = require('path'); -const escape = require('escape-string-regexp'); -const exclusionList = require('metro-config/src/defaults/exclusionList'); -const pack = require('../package.json'); - -const root = path.resolve(__dirname, '..'); -const modules = Object.keys({ ...pack.peerDependencies }); - -const rnwPath = fs.realpathSync( - path.resolve(require.resolve('react-native-windows/package.json'), '..'), -); - -// - -/** - * Metro configuration - * https://facebook.github.io/metro/docs/configuration - * - * @type {import('metro-config').MetroConfig} - */ -const config = { - watchFolders: [root, - // - ], - - // We need to make sure that only one version is loaded for peerDependencies - // So we block them at the root, and alias them to the versions in example's node_modules - resolver: { - blacklistRE: exclusionList( - modules.map( - (m) => - new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`) - ).concat([ - // This stops "npx @react-native-community/cli run-windows" from causing the metro server to crash if its already running - new RegExp( - `${path.resolve(__dirname, 'windows').replace(/[/\\]/g, '/')}.*`, - ), - // This prevents "npx @react-native-community/cli run-windows" from hitting: EBUSY: resource busy or locked, open msbuild.ProjectImports.zip or other files produced by msbuild - new RegExp(`${rnwPath}/build/.*`), - new RegExp(`${rnwPath}/target/.*`), - /.*\.ProjectImports\.zip/, - ]) - ), - - extraNodeModules: modules.reduce((acc, name) => { - acc[name] = path.join(__dirname, 'node_modules', name); - return acc; - }, - { - // - } - ), - }, - - transformer: { - getTransformOptions: async () => ({ - transform: { - experimentalImportSupport: false, - inlineRequires: true, - }, - }), - }, -}; - -module.exports = mergeConfig(getDefaultConfig(__dirname), config); diff --git a/samples/NativeModuleSample/cpp-lib/example-old/package.json b/samples/NativeModuleSample/cpp-lib/example-old/package.json deleted file mode 100644 index 532b3193a..000000000 --- a/samples/NativeModuleSample/cpp-lib/example-old/package.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "native-module-sample-example-old", - "version": "0.0.1", - "private": true, - "scripts": { - "start": "react-native start", - "windows": "npx @react-native-community/cli run-windows", - "test:windows": "jest --config jest.config.windows.js" - }, - "dependencies": { - "react": "19.1.0", - "react-native": "0.81.5", - "react-native-windows": "0.81.0" - }, - "devDependencies": { - "@babel/core": "^7.25.2", - "@babel/preset-env": "^7.25.3", - "@babel/runtime": "^7.25.0", - "@react-native-community/cli": "17.0.0", - "@react-native-community/cli-platform-android": "17.0.0", - "@react-native-community/cli-platform-ios": "17.0.0", - "@react-native/babel-preset": "0.81.0", - "@react-native/metro-config": "0.81.0", - "@react-native/typescript-config": "0.81.0", - "@rnx-kit/jest-preset": "^0.1.17" - }, - "engines": { - "node": ">=18" - }, - "react-native-windows": { - "init-windows": { - "name": "NativeModuleSampleExampleOld", - "namespace": "NativeModuleSampleExampleOld", - "template": "old/uwp-cpp-app" - } - } -} diff --git a/samples/NativeModuleSample/cpp-lib/example-old/react-native.config.js b/samples/NativeModuleSample/cpp-lib/example-old/react-native.config.js deleted file mode 100644 index 312c44df3..000000000 --- a/samples/NativeModuleSample/cpp-lib/example-old/react-native.config.js +++ /dev/null @@ -1,10 +0,0 @@ -const path = require('path'); -const pkg = require('../package.json'); - -module.exports = { - dependencies: { - [pkg.name]: { - root: path.join(__dirname, '..'), - }, - }, -}; diff --git a/samples/NativeModuleSample/cpp-lib/example-old/src/App.tsx b/samples/NativeModuleSample/cpp-lib/example-old/src/App.tsx deleted file mode 100644 index 807d6c5f3..000000000 --- a/samples/NativeModuleSample/cpp-lib/example-old/src/App.tsx +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { useState, useEffect } from 'react'; -import { StyleSheet, View, Text, Button, ScrollView } from 'react-native'; -import { - FancyMath, - type Response, - SimpleHttpModule, - type Point, - DataMarshallingExamples, - CircleMask, -} from 'native-module-sample'; -import type { Int32 } from 'react-native/Libraries/Types/CodegenTypes'; - -/* eslint-disable react-native/no-inline-styles */ - -export default function App() { - const [fancyMathAddResult, setFancyMathAddResult] = useState< - number | undefined - >(); - - const [simpleHttpModuleResponse, setSimpleHttpModuleResponse] = useState< - Response | undefined - >(); - - const [boolResult, setBoolResult] = useState(); - const [intResult, setIntResult] = useState(); - const [doubleResult, setDoubleResult] = useState(); - const [stringResult, setStringResult] = useState(); - const [midpointResult, setMidpointResult] = useState(); - const [lengthResult, setLengthResult] = useState(); - const [averageResult, setAverageResult] = useState(); - const [concatenateResult, setConcatenateResult] = useState< - string | undefined - >(); - const [splitResult, setSplitResult] = useState | undefined>(); - const [midpointByJSValueResult, setMidpointByJSValueResult] = useState< - Object | undefined - >(); - - useEffect(() => { - FancyMath.add(3, 7, setFancyMathAddResult); - - SimpleHttpModule.GetHttpResponse('http://example.com').then( - setSimpleHttpModuleResponse - ); - - DataMarshallingExamples.ReturnExplicitBoolean(setBoolResult); - DataMarshallingExamples.ReturnExplicitInteger(setIntResult); - DataMarshallingExamples.ReturnExplicitDouble(setDoubleResult); - DataMarshallingExamples.ReturnExplicitString(setStringResult); - DataMarshallingExamples.GetMidpoint( - { X: 0, Y: 0 }, - { X: 1, Y: 1 }, - setMidpointResult - ); - DataMarshallingExamples.GetLength( - { - Start: { X: 0, Y: 0 }, - End: { X: 1, Y: 1 }, - }, - setLengthResult - ); - DataMarshallingExamples.GetAverage([1, 2, 3, 4, 5, 6], setAverageResult); - DataMarshallingExamples.Concatenate( - ['hello', 'world'], - setConcatenateResult - ); - DataMarshallingExamples.Split('hello world', ' ', setSplitResult); - DataMarshallingExamples.GetMidpointByJSValue( - { x: 0, y: 0 }, - { x: 1, y: 1 }, - setMidpointByJSValueResult - ); - }, []); - - return ( - - - - FancyMath: - - E: {FancyMath.E} - - - Pi: {FancyMath.Pi} - - - add(3, 7):{' '} - {fancyMathAddResult ?? '???'} - - - SimpleHttpModule: - - - GetHttpResponse("http://example.com"): - {' '} - {simpleHttpModuleResponse?.statusCode ?? '???'} - - - DataMarshallingExamples: -