React Native for Windows

repository·main·Indexed 12 days ago

https://github.com/microsoft/react-native-windows

An extension of the React Native framework that provides support for the Windows 10 SDK, enabling the development of native applications for PCs, tablets, Xbox, and Mixed Reality devices using JavaScript and React. Includes tooling for project initialization (init-windows), native code generation (codegen-windows), and building/running apps (run-windows), as well as specialized packages for RPC automation, .NET tool discovery, and performance testing.

Tokens
99K
Snippets
308
Records
482
Agent score
96%

What's inside React Native for Windows

  1. Overview of React Native Windows Build Pipelines

    main

    React Native Windows utilizes three distinct Azure DevOps pipelines to manage Continuous Integration (CI), Pull Requests (PR), and Releases.

    • CI Pipeline: Triggered by pushes to main or *-stable branches. It handles building, testing, signing, and packaging.
    • PR Pipeline: Triggered by Pull Requests to main or *-stable. It focuses on validation and change checks.
    • Release Pipeline: Triggered automatically upon a successful CI run to publish packages to npm and NuGet feeds.

    Both CI and PR pipelines share a core build-template.yml file. The behavior is toggled using the buildEnvironment parameter, which can be set to Continuous (for CI) or PullRequest (for PRs).

  2. Overview of the {fmt} library

    main

    The {fmt} library is a high-performance C++ formatting library designed to address the limitations of existing methods like printf, iostreams, and Boost Format. It provides a fast, safe, and feature-rich alternative for string formatting, supporting user-defined types and positional arguments (useful for i18n). It is used by major projects including Windows Terminal, PyTorch, and ClickHouse.

    Key advantages include:

    • Performance: Significantly faster than Boost Format and Boost Spirit.Karma.
    • Safety: Provides better type safety than the printf family.
    • Ease of Use: Avoids the "chevron hell" of iostreams by using concise format strings.
    • Feature Completeness: Unlike FastFormat, it supports leading zeros, non-space padding, octal/hexadecimal encoding, and runtime width/alignment specification.
  3. Introduction to {fmt}

    main
    {fmt} is an open-source C++ formatting library that provides a fast and safe alternative to C stdio and C++ iostreams. It implements features from C++20 std::format and C++23 std::print, using a syntax similar to Python's format method. Key benefits include high performance, type safety (with compile-time error reporting in C++20), portable Unicode support, and a small code footprint.
  4. Overview of @office-iss/react-native-win32

    main

    The @office-iss/react-native-win32 package is a JavaScript package used by Microsoft Office on the Win32 platform.

    Note: This package is primarily intended for internal use and is not generally consumable by the public because it requires the Office UI framework, which is not open source. Its primary purpose is to enable cross-platform efforts (such as component libraries) to be open-sourced by providing a bridge for Win32 targets that were previously restricted by Office's proprietary nature.

  5. Overview of the {fmt} library API components

    main

    The {fmt} library is organized into several headers providing different functionalities. All functions and types reside in the fmt namespace, and macros are prefixed with FMT_.

    Key components include:

    • fmt/base.h: Base API for char/UTF-8 with C++20 compile-time checks. Minimal dependencies.
    • fmt/format.h: Main formatting functions (fmt::format, etc.) and locale support.
    • fmt/ranges.h: Formatting for ranges and tuples (e.g., std::vector).
    • fmt/chrono.h: Date and time formatting.
    • fmt/std.h: Formatters for standard library types.
    • fmt/compile.h: Format string compilation.
    • fmt/color.h: Terminal colors and text styles.
    • fmt/os.h: System APIs.
    • fmt/ostream.h: std::ostream support.
    • fmt/args.h: Dynamic argument lists.
    • fmt/printf.h: Safe printf implementation.
    • fmt/xchar.h: Optional wchar_t support.
  6. Understand the React Native Windows package scopes

    main

    The react-native-windows repository uses several npm scopes to organize its packages. Understanding these scopes helps you identify the purpose of the packages you are consuming:

    • @office-iss: Contains Office internal packages.
    • @react-native: Contains copies of private upstream packages that already use the @react-native scope (e.g., @react-native/tester).
    • @react-native-windows: Contains internal packages used by the react-native-windows framework itself. These are versioned and published alongside RNW.
    • @rnw-scripts: Contains scripts used for repository tooling, published as part of the main branch.

    Some packages are unscoped for specific reasons, such as react-native-platform-override (which is not RNW-specific) or react-native-windows-init (which is intended to be run by name).

  7. Accessing React Native for Windows documentation and resources

    main

    While standard React Native documentation covers core JavaScript and React concepts, platform-specific information for Windows and macOS (including API documentation and updates) is maintained separately.

  8. Understand react-native-platform-override

    main
    The react-native-platform-override tool is designed for managing "platform overrides" in out-of-tree React Native platforms. It provides mechanisms to inventory changes and integrate new upstream changes from React Native into your specific platform implementation. It works by managing a JSON manifest file that tracks how files in your package differ from or supplement the standard React Native distribution.
  9. Key features of the {fmt} library

    main

    The {fmt} library is a modern C++ formatting library designed as a safe, fast, and extensible replacement for the printf family of functions and iostreams.

    Core Capabilities:

    • Safety: Provides compile-time checks for format strings to prevent vulnerabilities and uses automatic memory management to prevent buffer overflows.
    • Extensibility: Supports standard types (including containers, dates, and times) out-of-the-box and allows users to define custom formatters for user-defined types (UDTs).
    • Performance: Significantly faster than iostreams and sprintf (up to 20-30x faster for numeric formatting) by minimizing dynamic memory allocations.
    • Unicode Support: Offers portable UTF-8 support across Linux, macOS, and Windows, ensuring correct printing of Unicode characters regardless of system codepages.
    • Fast Compilation & Small Footprint: Uses type erasure to minimize template bloat and reduce compilation times. It features a small binary footprint and allows disabling certain components (like floating-point formatting) for resource-constrained environments.
    • Portability: A self-contained codebase with no external dependencies, requiring only a minimal subset of C++11 (compatible with GCC 4.8, Clang 3.4, and MSVC 19.0+).
  10. Use @react-native-windows/automation-channel for RPC

    main

    The @react-native-windows/automation-channel package enables Remote Procedure Calls (RPC) between a Node.js client and a React Native Windows server running on the same machine. This is particularly useful for bypassing UWP AppContainer inbound loopback restrictions by using a reverse TCP server architecture where the Node client connects to a server hosted within the app.

    import {waitForConnection} from '@react-native-windows/automation-channel'
    
    const rpcConnection = await waitForConnection({port: 8305});
    const result = await rpcConnection.invoke("add", [2, 2])