Skip to content

feat: windows support #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
11 changes: 11 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="react-native" value="https://pkgs.dev.azure.com/ms/react-native/_packaging/react-native-public/nuget/v3/index.json" />
<add key="Nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />
</disabledPackageSources>
</configuration>
38 changes: 25 additions & 13 deletions app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
View,
ViewStyle,
TextStyle,
Platform,
} from "react-native"

import { Colors } from "react-native/Libraries/NewAppScreen"
Expand All @@ -21,8 +22,8 @@ import { Header } from "./components/Header"
import { HeaderTab } from "./components/HeaderTab"
import { HeaderTitle } from "./components/HeaderTitle"

import IRFontList from "../specs/NativeIRFontList"
import { useEffect, useState } from "react"
// import IRFontList from "../specs/NativeIRFontList"
// import { useEffect, useState } from "react"

if (__DEV__) {
// This is for debugging Reactotron with ... Reactotron!
Expand All @@ -39,14 +40,14 @@ function App(): React.JSX.Element {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
}

const [fonts, setFonts] = useState<string[]>([])
// const [fonts, setFonts] = useState<string[]>([])

useEffect(() => {
// console.log("NatveIRFontList", IRFontList)
IRFontList.getFontList().then((fonts: string[]) => {
setFonts(fonts)
})
}, [])
// useEffect(() => {
// // console.log("NatveIRFontList", IRFontList)
// IRFontList.getFontList().then((fonts: string[]) => {
// setFonts(fonts)
// })
// }, [])

return (
<View style={backgroundStyle}>
Expand All @@ -73,15 +74,26 @@ function App(): React.JSX.Element {
</Header>
<ScrollView style={backgroundStyle}>
<Text style={{ textAlign: "center", fontSize: 32 }}>Default</Text>
<Text style={{ textAlign: "center", fontSize: 32, fontFamily: "Space Grotesk" }}>
<Text
style={{
textAlign: "center",
fontSize: 32,
fontFamily: Platform.select({
windows: "Assets/SpaceGrotesk.ttf#Space Grotesk",
default: "Space Grotesk",
}),
}}
>
Space Grotesk
</Text>
<Text style={{ textAlign: "center", fontSize: 32, fontFamily: "Baskerville" }}>
Baskerville (system)
</Text>
{fonts.map((font) => (
<Text style={{ textAlign: "center", fontSize: 32, fontFamily: font }}>{font}</Text>
))}
{/*
{fonts.map((font) => (
<Text style={{ textAlign: "center", fontSize: 32, fontFamily: font }}>{font}</Text>
))}
*/}
</ScrollView>
</View>
)
Expand Down
3 changes: 3 additions & 0 deletions jest.config.windows.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = {};

module.exports = require('@rnx-kit/jest-preset')('windows', config);
44 changes: 39 additions & 5 deletions metro.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,45 @@
const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config")
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');

const fs = require('fs');
const path = require('path');
const exclusionList = require('metro-config/src/defaults/exclusionList');

const rnwPath = fs.realpathSync(
path.resolve(require.resolve('react-native-windows/package.json'), '..'),
);

//

/**
* Metro configuration
* https://reactnative.dev/docs/metro
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('@react-native/metro-config').MetroConfig}
* @type {import('metro-config').MetroConfig}
*/
const config = {}

module.exports = mergeConfig(getDefaultConfig(__dirname), config)
const config = {
//
resolver: {
blockList: exclusionList([
// 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/,
]),
//
},
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);
Loading