├── .clang-format ├── .cspell.json ├── .gitattributes ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug-report.yaml │ ├── config.yml │ └── feature-request.yaml ├── policies │ └── resourceManagement.yml └── workflows │ ├── main.yml │ ├── pr.yml │ ├── publish.yml │ ├── template-buildexample.yml │ ├── template-buildnpmpackage.yml │ ├── template-buildrnx.yml │ ├── template-runcodegen.yml │ └── template-testcli.yml ├── .gitignore ├── .spelling ├── .vscode └── extensions.json ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── TechnicalGuide.md ├── USAGE.md ├── change └── react-native-xaml-ae47b51e-39d3-4b8b-8816-3a2b003ce391.json ├── directory.build.props ├── example ├── .buckconfig ├── .eslintrc.js ├── .flowconfig ├── .gitignore ├── .prettierrc.js ├── .watchmanconfig ├── App.tsx ├── README.md ├── __tests__ │ └── App.test.tsx ├── app.json ├── babel.config.js ├── index.js ├── jest.config.js ├── metro.config.js ├── package.json ├── rnx.gif ├── tsconfig.json └── windows │ ├── .gitignore │ ├── ExperimentalFeatures.props │ ├── NuGet.Config │ ├── RuntimeComponent1 │ ├── BlankUserControl.cpp │ ├── BlankUserControl.h │ ├── BlankUserControl.idl │ ├── BlankUserControl.xaml │ ├── Class.cpp │ ├── Class.h │ ├── Class.idl │ ├── PropertySheet.props │ ├── RuntimeComponent1.def │ ├── RuntimeComponent1.vcxproj │ ├── RuntimeComponent1.vcxproj.filters │ ├── packages.config │ ├── pch.cpp │ ├── pch.h │ └── readme.txt │ ├── example.sln │ └── example │ ├── .gitignore │ ├── App.cpp │ ├── App.h │ ├── App.idl │ ├── App.xaml │ ├── Assets │ ├── LockScreenLogo.scale-200.png │ ├── SplashScreen.scale-200.png │ ├── Square150x150Logo.scale-200.png │ ├── Square44x44Logo.scale-200.png │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── StoreLogo.png │ └── Wide310x150Logo.scale-200.png │ ├── AutolinkedNativeModules.g.cpp │ ├── AutolinkedNativeModules.g.h │ ├── AutolinkedNativeModules.g.props │ ├── AutolinkedNativeModules.g.targets │ ├── MainPage.cpp │ ├── MainPage.h │ ├── MainPage.idl │ ├── MainPage.xaml │ ├── Package.appxmanifest │ ├── PropertySheet.props │ ├── ReactPackageProvider.cpp │ ├── ReactPackageProvider.h │ ├── example.vcxproj │ ├── example.vcxproj.filters │ ├── packages.lock.json │ ├── pch.cpp │ └── pch.h ├── examplenuget ├── .eslintrc.js ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .prettierrc.js ├── .watchmanconfig ├── App.tsx ├── __tests__ │ └── App.test.tsx ├── _editorconfig ├── app.json ├── babel.config.js ├── index.js ├── jest.config.js ├── metro.config.js ├── package.json ├── tsconfig.json └── windows │ ├── .gitignore │ ├── ExperimentalFeatures.props │ ├── NuGet.Config │ ├── examplenuget.sln │ └── examplenuget │ ├── .gitignore │ ├── App.cpp │ ├── App.h │ ├── App.idl │ ├── App.xaml │ ├── Assets │ ├── LockScreenLogo.scale-200.png │ ├── SplashScreen.scale-200.png │ ├── Square150x150Logo.scale-200.png │ ├── Square44x44Logo.scale-200.png │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── StoreLogo.png │ └── Wide310x150Logo.scale-200.png │ ├── AutolinkedNativeModules.g.cpp │ ├── AutolinkedNativeModules.g.h │ ├── AutolinkedNativeModules.g.props │ ├── AutolinkedNativeModules.g.targets │ ├── MainPage.cpp │ ├── MainPage.h │ ├── MainPage.idl │ ├── MainPage.xaml │ ├── Package.appxmanifest │ ├── PropertySheet.props │ ├── ReactPackageProvider.cpp │ ├── ReactPackageProvider.h │ ├── examplenuget.vcxproj │ ├── examplenuget.vcxproj.filters │ ├── packages.lock.json │ ├── pch.cpp │ └── pch.h ├── package.json ├── package ├── .gitignore ├── .npmignore ├── CHANGELOG.json ├── CHANGELOG.md ├── Codegen │ ├── Codegen.csproj │ ├── EventArgsTypeProperties.cs │ ├── EventArgsTypeProperties.tt │ ├── Model.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── SyntheticProperty.cs │ ├── TSEnums.cs │ ├── TSEnums.tt │ ├── TSProps.cs │ ├── TSProps.tt │ ├── TSTypes.cs │ ├── TSTypes.tt │ ├── TypeCreator.cs │ ├── TypeCreator.tt │ ├── TypeEnums.cs │ ├── TypeEnums.tt │ ├── TypeEvents.cs │ ├── TypeEvents.tt │ ├── TypeProperties.cs │ ├── TypeProperties.tt │ ├── Util.cs │ ├── VersionHeader.cs │ ├── VersionHeader.tt │ ├── Windows.UI.Xaml.json │ └── XamlNames.cs ├── LICENSE ├── README.md ├── package.json ├── rebuild_projection.cmd ├── src │ ├── Enums.ts │ ├── NativeXamlControl.tsx │ ├── Props.ts │ ├── Types.tsx │ └── index.ts ├── tsconfig.json └── windows │ ├── .gitignore │ ├── ExperimentalFeatures.props │ ├── ReactNativeXaml.sln │ └── ReactNativeXaml │ ├── CodeAnalysis.ruleset │ ├── Codegen │ ├── EventArgsTypeProperties.g.h │ ├── TypeCreator.g.cpp │ ├── TypeEnums.g.h │ ├── TypeEvents.g.h │ ├── TypeProperties.g.h │ └── Version.g.h │ ├── Crc32Str.h │ ├── JSValueXaml_local.h │ ├── PropertySheet.props │ ├── ReactNativeModule.h │ ├── ReactNativeXaml.def │ ├── ReactNativeXaml.rc │ ├── ReactNativeXaml.vcxproj │ ├── ReactNativeXaml.vcxproj.filters │ ├── ReactPackageProvider.cpp │ ├── ReactPackageProvider.h │ ├── ReactPackageProvider.idl │ ├── Serialize.cpp │ ├── Serialize.h │ ├── Styling.cpp │ ├── Styling.h │ ├── Version.h │ ├── Wrapper.cpp │ ├── Wrapper.h │ ├── Wrapper.idl │ ├── XamlMetadata.cpp │ ├── XamlMetadata.h │ ├── XamlObject.cpp │ ├── XamlObject.h │ ├── XamlViewManager.cpp │ ├── XamlViewManager.h │ ├── packages.config │ ├── packages.lock.json │ ├── pch.cpp │ ├── pch.h │ └── resource.h └── yarn.lock /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | AccessModifierOffset: -1 3 | AlignAfterOpenBracket: AlwaysBreak 4 | AlignConsecutiveAssignments: false 5 | AlignConsecutiveDeclarations: false 6 | AlignEscapedNewlinesLeft: true 7 | AlignOperands: false 8 | AlignTrailingComments: false 9 | AllowAllParametersOfDeclarationOnNextLine: false 10 | AllowShortBlocksOnASingleLine: false 11 | AllowShortCaseLabelsOnASingleLine: false 12 | AllowShortFunctionsOnASingleLine: Empty 13 | AllowShortIfStatementsOnASingleLine: false 14 | AllowShortLoopsOnASingleLine: false 15 | AlwaysBreakAfterReturnType: None 16 | AlwaysBreakBeforeMultilineStrings: true 17 | AlwaysBreakTemplateDeclarations: true 18 | BinPackArguments: false 19 | BinPackParameters: false 20 | BraceWrapping: 21 | AfterClass: false 22 | AfterControlStatement: false 23 | AfterEnum: false 24 | AfterFunction: false 25 | AfterNamespace: false 26 | AfterObjCDeclaration: false 27 | AfterStruct: false 28 | AfterUnion: false 29 | BeforeCatch: false 30 | BeforeElse: false 31 | IndentBraces: false 32 | BreakBeforeBinaryOperators: None 33 | BreakBeforeBraces: Attach 34 | BreakBeforeTernaryOperators: true 35 | BreakConstructorInitializersBeforeComma: false 36 | BreakAfterJavaFieldAnnotations: false 37 | BreakStringLiterals: false 38 | ColumnLimit: 120 39 | CommentPragmas: '^ IWYU pragma:' 40 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 41 | ConstructorInitializerIndentWidth: 4 42 | ContinuationIndentWidth: 4 43 | Cpp11BracedListStyle: true 44 | DerivePointerAlignment: false 45 | DisableFormat: false 46 | ForEachMacros: [ FOR_EACH_RANGE, FOR_EACH, TEST_CLASS, TEST_CLASS_EX ] 47 | IncludeBlocks: Preserve 48 | IncludeCategories: 49 | - Regex: 'pch.h' 50 | Priority: -1 51 | - Regex: '.*\.g\..*' 52 | Priority: 1 53 | - Regex: '^<.*\.h(pp)?>' 54 | Priority: 2 55 | - Regex: '^<.*' 56 | Priority: 3 57 | - Regex: '.*' 58 | Priority: 4 59 | IndentCaseLabels: true 60 | IndentWidth: 2 61 | IndentWrappedFunctionNames: false 62 | KeepEmptyLinesAtTheStartOfBlocks: false 63 | MacroBlockBegin: '' 64 | MacroBlockEnd: '' 65 | MaxEmptyLinesToKeep: 1 66 | NamespaceIndentation: None 67 | ObjCBlockIndentWidth: 2 68 | ObjCSpaceAfterProperty: true 69 | ObjCSpaceBeforeProtocolList: true 70 | PenaltyBreakBeforeFirstCallParameter: 1 71 | PenaltyBreakComment: 300 72 | PenaltyBreakFirstLessLess: 120 73 | PenaltyBreakString: 1000 74 | PenaltyExcessCharacter: 1000000 75 | PenaltyReturnTypeOnItsOwnLine: 200 76 | PointerAlignment: Right 77 | ReflowComments: true 78 | SortIncludes: true 79 | SpaceAfterCStyleCast: false 80 | SpaceBeforeAssignmentOperators: true 81 | SpaceBeforeParens: ControlStatements 82 | SpaceInEmptyParentheses: false 83 | SpacesBeforeTrailingComments: 1 84 | SpacesInAngles: false 85 | SpacesInContainerLiterals: true 86 | SpacesInCStyleCastParentheses: false 87 | SpacesInParentheses: false 88 | SpacesInSquareBrackets: false 89 | Standard: Cpp11 90 | TabWidth: 8 91 | UseTab: Never 92 | ... 93 | -------------------------------------------------------------------------------- /.cspell.json: -------------------------------------------------------------------------------- 1 | // cSpell Settings 2 | { 3 | "version": "0.2", 4 | "language": "en", 5 | "dictionaryDefinitions": [ 6 | { 7 | "name": "project-words", 8 | "path": "./.spelling", 9 | "addWords": true 10 | } 11 | ], 12 | "dictionaries": ["project-words"], 13 | "files": ["**/*.{cpp,h,idl,cs,js,jsx,ts,tsx,tt}"], 14 | "ignorePaths": [ 15 | "**/*.g.*", 16 | "package/Codegen/EventArgsTypeProperties.cs", 17 | "package/Codegen/TSEnums.cs", 18 | "package/Codegen/TSProps.cs", 19 | "package/Codegen/TSTypes.cs", 20 | "package/Codegen/TypeCreator.cs", 21 | "package/Codegen/TypeEnums.cs", 22 | "package/Codegen/TypeEvents.cs", 23 | "package/Codegen/TypeProperties.cs", 24 | "package/Codegen/VersionHeader.cs" 25 | ], 26 | "useGitignore": true, 27 | "ignoreRegExpList": [ 28 | "require\\('.+'\\)", // Node require 29 | " from '.+';", // Node import from 30 | "[@#][a-z\\-\\.]+", // Ignore @name or #name tags 31 | ] 32 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | 2 | # Auto detect text files and perform LF normalization 3 | 4 | * text=auto 5 | 6 | # C# files should use CRLF. 7 | *.tt text eol=crlf 8 | *.cs text eol=crlf 9 | 10 | # C++ files should use CRLF. 11 | *.c text eol=crlf 12 | *.cpp text eol=crlf 13 | *.h text eol=crlf 14 | *.hpp text eol=crlf 15 | 16 | # Force Visual Studio project files (mostly XML) to CRLF 17 | # This helps avoid conflict which occurs when Xmarian/Mac contributors with AutoCRLF=input (or off) 18 | # check in these files as CRLFs, and then Windows contributors with AutoCRLF=true end up checking then 19 | # files in as LFs (due to AutoCRLF=true normalizing CRLF->LF on check-in). 20 | 21 | *.sln text eol=crlf 22 | *.csproj text eol=crlf 23 | *.vbproj text eol=crlf 24 | *.fsproj text eol=crlf 25 | *.pyproj text eol=crlf 26 | *.dbproj text eol=crlf 27 | *.vcxproj text eol=crlf 28 | *.shproj text eol=crlf 29 | *.projitems text eol=crlf 30 | *.vcxitems text eol=crlf 31 | *.props text eol=crlf 32 | *.filters text eol=crlf 33 | 34 | *.js text eol=lf 35 | *.jsx text eol=lf 36 | *.js text eol=lf 37 | *.ts text eol=lf 38 | *.tsx text eol=lf 39 | *.ps1 text eol=lf 40 | *.yml text eol=lf 41 | .editorconfig text eol=lf 42 | .gitattributes text eol=lf 43 | package.json text eol=lf 44 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Global Catch-All 2 | * @microsoft/react-native-windows-write -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.yaml: -------------------------------------------------------------------------------- 1 | name: Bug report 2 | description: File a bug report 3 | title: Describe the problem 4 | labels: [bug] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Your issue will be triaged by the team according to [this process](https://github.com/microsoft/react-native-windows/wiki/Triage-Process). 10 | - type: textarea 11 | validations: 12 | required: true 13 | attributes: 14 | label: Problem Description 15 | description: Please enter a description of the issue. If you just have a question, please post on [Discussions](https://github.com/microsoft/react-native-windows/discussions). 16 | - type: textarea 17 | validations: 18 | required: true 19 | attributes: 20 | label: Steps To Reproduce 21 | description: Provide a detailed list of steps that reproduce the issue. 22 | placeholder: | 23 | 1. 24 | 2. 25 | - type: textarea 26 | attributes: 27 | label: Expected Results 28 | description: Describe what you expected to happen. 29 | - type: textarea 30 | validations: 31 | required: true 32 | attributes: 33 | label: Environment 34 | description: | 35 | Run the command `npx @react-native-community/cli info` in your terminal and copy the results here 36 | value: "npx @react-native-community/cli info" 37 | render: markdown -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: React Native for Windows 4 | url: https://github.com/microsoft/react-native-windows/issues/new/choose 5 | about: I have an issue with React Native for Windows that is not specific to react-native-xaml -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yaml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Suggest a new feature or idea 3 | title: Your feature request 4 | labels: [enhancement] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Your issue will be triaged by the team according to [this process](https://github.com/microsoft/react-native-windows/wiki/Triage-Process). 10 | - type: textarea 11 | validations: 12 | required: true 13 | attributes: 14 | label: Summary 15 | description: Brief explanation of the new API or change. 16 | - type: textarea 17 | validations: 18 | required: true 19 | attributes: 20 | label: Motivation 21 | description: | 22 | Why do this? What use cases does it support? What is the expected outcome? 23 | - type: textarea 24 | attributes: 25 | label: Basic Example 26 | description: | 27 | If the proposal involves a new or changed API, include a basic code example. Omit this section if it's not applicable. 28 | - type: textarea 29 | attributes: 30 | label: Open Questions 31 | description: | 32 | Please list any open issues that you think still need to be addressed. -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | schedule: 5 | - cron: '0 15 * * 2' # Tuesday 3PM UTC (8AM PST) 6 | push: 7 | branches: [ main ] 8 | workflow_dispatch: 9 | 10 | jobs: 11 | call-runcodegen: 12 | name: Run CodeGen 13 | uses: ./.github/workflows/template-runcodegen.yml 14 | with: 15 | vmImage: windows-2022 16 | 17 | call-buildexample: 18 | name: Build Example 19 | strategy: 20 | fail-fast: false 21 | matrix: 22 | exampleName: ['example', 'examplenuget'] # build both examples 23 | uses: ./.github/workflows/template-buildexample.yml 24 | with: 25 | vmImage: windows-2022 26 | exampleName: ${{ matrix.exampleName }} 27 | 28 | call-testcli: 29 | name: Test CLI (VS 2022) 30 | strategy: 31 | fail-fast: false 32 | matrix: 33 | rnwVersion: ['latest', 'v0.76-stable', 'v0.75-stable', 'v0.72-stable'] # test *key* versions that use VS 2022. aka any RNW version >= 0.72 used by supported partners and/or Active/Maintenance from https://microsoft.github.io/react-native-windows/support 34 | uses: ./.github/workflows/template-testcli.yml 35 | with: 36 | vmImage: windows-2022 37 | rnwVersion: ${{ matrix.rnwVersion }} 38 | useRnwWindowsInit: ${{ matrix.rnwVersion == 'v0.72-stable' }} 39 | 40 | call-buildnpmpackage: 41 | name: Build NPM Package 42 | uses: ./.github/workflows/template-buildnpmpackage.yml 43 | with: 44 | vmImage: windows-2022 45 | 46 | call-buildrnx: 47 | name: Build RNX 48 | strategy: 49 | fail-fast: false 50 | matrix: 51 | configuration: ['Debug', 'Release'] 52 | platform: ['x64'] 53 | uses: ./.github/workflows/template-buildrnx.yml 54 | with: 55 | vmImage: windows-2022 56 | configuration: ${{ matrix.configuration }} 57 | platform: ${{ matrix.platform }} 58 | -------------------------------------------------------------------------------- /.github/workflows/pr.yml: -------------------------------------------------------------------------------- 1 | name: PR 2 | 3 | on: 4 | pull_request: 5 | branches: [ main ] 6 | 7 | jobs: 8 | setupcheck: 9 | name: Setup Check 10 | runs-on: windows-2022 11 | steps: 12 | - uses: actions/checkout@v4 13 | 14 | - name: yarn install 15 | run: yarn install 16 | 17 | - name: beachball check 18 | run: npx beachball check --verbose --changehint "::error::Run `yarn change` from root of repo to generate a change file." 19 | 20 | call-runcodegen: 21 | name: Run CodeGen 22 | needs: setupcheck 23 | uses: ./.github/workflows/template-runcodegen.yml 24 | with: 25 | vmImage: windows-2022 26 | 27 | call-buildexample: 28 | name: Build Example 29 | needs: setupcheck 30 | strategy: 31 | fail-fast: true 32 | matrix: 33 | exampleName: ['example', 'examplenuget'] # build both examples 34 | uses: ./.github/workflows/template-buildexample.yml 35 | with: 36 | vmImage: windows-2022 37 | exampleName: ${{ matrix.exampleName }} 38 | 39 | call-testcli: 40 | name: Test CLI (VS 2022) 41 | needs: setupcheck 42 | strategy: 43 | fail-fast: true 44 | matrix: 45 | rnwVersion: ['latest', 'v0.76-stable', 'v0.75-stable', 'v0.72-stable'] # test *key* versions that use VS 2022. aka any RNW version >= 0.72 used by supported partners and/or Active/Maintenance from https://microsoft.github.io/react-native-windows/support 46 | uses: ./.github/workflows/template-testcli.yml 47 | with: 48 | vmImage: windows-2022 49 | rnwVersion: ${{ matrix.rnwVersion }} 50 | useRnwWindowsInit: ${{ matrix.rnwVersion == 'v0.72-stable' }} 51 | 52 | call-buildnpmpackage: 53 | name: Build NPM Package 54 | needs: setupcheck 55 | uses: ./.github/workflows/template-buildnpmpackage.yml 56 | with: 57 | vmImage: windows-2022 58 | 59 | call-buildrnx: 60 | name: Build RNX 61 | needs: setupcheck 62 | strategy: 63 | fail-fast: true 64 | matrix: 65 | configuration: ['Release'] 66 | platform: ['x64'] 67 | uses: ./.github/workflows/template-buildrnx.yml 68 | with: 69 | vmImage: windows-2022 70 | configuration: ${{ matrix.configuration }} 71 | platform: ${{ matrix.platform }} 72 | 73 | prcheck: 74 | name: Successful PR Check 75 | runs-on: ubuntu-latest 76 | needs: [setupcheck, call-runcodegen, call-testcli, call-buildnpmpackage, call-buildrnx] 77 | steps: 78 | - uses: actions/checkout@v4 79 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | release: 5 | types: [published] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | call-runcodegen: 10 | name: Run CodeGen 11 | uses: ./.github/workflows/template-runcodegen.yml 12 | with: 13 | vmImage: windows-2022 14 | 15 | publish-npm: 16 | runs-on: ubuntu-latest 17 | needs: call-runcodegen 18 | 19 | steps: 20 | - uses: actions/checkout@v4 21 | 22 | - name: Use Node.js 23 | uses: actions/setup-node@v4 24 | with: 25 | node-version: 18 26 | registry-url: https://registry.npmjs.org/ 27 | 28 | - name: yarn install 29 | run: yarn install 30 | 31 | - name: build TS 32 | run: yarn build 33 | 34 | - name: publish to npm 35 | run: npm publish 36 | env: 37 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 38 | working-directory: package 39 | 40 | - name: upload npm logs 41 | uses: actions/upload-artifact@v4 42 | with: 43 | name: npm-logs 44 | path: /home/runner/.npm/_logs 45 | continue-on-error: true 46 | if: always() 47 | -------------------------------------------------------------------------------- /.github/workflows/template-buildexample.yml: -------------------------------------------------------------------------------- 1 | name: Build Example 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | vmImage: 7 | required: false 8 | default: 'windows-latest' 9 | type: string 10 | exampleName: 11 | required: false 12 | default: 'example' 13 | type: string 14 | useBuildCertificate: 15 | required: false 16 | default: false 17 | type: boolean 18 | 19 | jobs: 20 | build-example: 21 | name: Build ${{ inputs.exampleName }} 22 | runs-on: ${{ inputs.vmImage }} 23 | steps: 24 | - uses: actions/checkout@v4 25 | 26 | - name: yarn install 27 | run: yarn install 28 | 29 | - name: build TS 30 | run: yarn build 31 | 32 | - name: Decode the pfx 33 | if: ${{ inputs.useBuildCertificate }} 34 | run: | 35 | $PfxBytes = [System.Convert]::FromBase64String("${{ secrets.EXAMPES_BASE64_ENCODED_PFX }}") 36 | $PfxPath = [System.IO.Path]::GetFullPath("${{github.workspace}}\GitHubActionsWorkflow.pfx") 37 | Write-Host $PfxPath 38 | [System.IO.File]::WriteAllBytes("$PfxPath", $PfxBytes) 39 | working-directory: ${{ inputs.exampleName }} 40 | 41 | - name: yarn windows 42 | run: npx @react-native-community/cli run-windows --no-launch --no-deploy --no-packager --logging ${{ inputs.useBuildCertificate && '--msbuildprops PackageCertificateKeyFile=${{github.workspace}}\GitHubActionsWorkflow.pfx' || '' }} 43 | working-directory: ${{ inputs.exampleName }} 44 | 45 | - name: Remove the pfx 46 | if: ${{ inputs.useBuildCertificate }} 47 | run: | 48 | $certificatePath = [System.IO.Path]::GetFullPath("${{github.workspace}}\GitHubActionsWorkflow.pfx") 49 | Write-Host $certificatePath 50 | Remove-Item -path $certificatePath 51 | working-directory: ${{ inputs.exampleName }} 52 | 53 | - name: test app 54 | run: yarn test 55 | working-directory: ${{ inputs.exampleName }} 56 | 57 | - name: Upload appx 58 | uses: actions/upload-artifact@v4 59 | with: 60 | name: ${{ inputs.exampleName }} appx 61 | path: ${{ inputs.exampleName }}\windows\AppPackages\${{ inputs.exampleName }}\${{ inputs.exampleName }}_1.0.0.0_x64_Debug_Test 62 | if-no-files-found: error -------------------------------------------------------------------------------- /.github/workflows/template-buildnpmpackage.yml: -------------------------------------------------------------------------------- 1 | name: Build NPM Package 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | vmImage: 7 | required: false 8 | default: 'windows-latest' 9 | type: string 10 | 11 | jobs: 12 | package: 13 | name: Build NPM Package 14 | runs-on: ${{ inputs.vmImage }} 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - name: yarn install 19 | run: yarn install 20 | 21 | - name: build TS 22 | run: yarn build 23 | 24 | - name: npm pack 25 | run: npm pack 26 | working-directory: package 27 | 28 | - name: Upload npm package 29 | uses: actions/upload-artifact@v4 30 | with: 31 | name: RNX npm package 32 | path: package\*.tgz 33 | if-no-files-found: error 34 | -------------------------------------------------------------------------------- /.github/workflows/template-buildrnx.yml: -------------------------------------------------------------------------------- 1 | name: Build RNX 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | vmImage: 7 | required: false 8 | default: 'windows-latest' 9 | type: string 10 | configuration: 11 | required: false 12 | default: 'Debug' 13 | type: string 14 | platform: 15 | required: false 16 | default: 'x64' 17 | type: string 18 | 19 | jobs: 20 | package: 21 | name: Build RNX ${{ inputs.configuration }} ${{ inputs.platform }} 22 | runs-on: ${{ inputs.vmImage }} 23 | steps: 24 | - uses: actions/checkout@v4 25 | 26 | - name: setup-msbuild 27 | uses: microsoft/setup-msbuild@v2 28 | 29 | - name: yarn install 30 | run: yarn install 31 | 32 | - name: build TS 33 | run: yarn build 34 | 35 | - name: build ReactNativeXaml.sln 36 | run: msbuild /restore /p:RestoreLockedMode=true /p:RestorePackagesConfig=true package\windows\ReactNativeXaml.sln /p:configuration=${{ inputs.configuration }} /p:platform=${{ inputs.platform }} 37 | 38 | - name: Upload build output 39 | uses: actions/upload-artifact@v4 40 | with: 41 | name: RNX ${{ inputs.configuration }} ${{ inputs.platform }} Build Output 42 | path: package\windows\${{ inputs.platform }}\${{ inputs.configuration }}\ReactNativeXaml\*.* 43 | if-no-files-found: error 44 | -------------------------------------------------------------------------------- /.github/workflows/template-runcodegen.yml: -------------------------------------------------------------------------------- 1 | name: Run CodeGen 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | vmImage: 7 | required: false 8 | default: 'windows-latest' 9 | type: string 10 | 11 | jobs: 12 | codegen: 13 | name: Run CodeGen 14 | runs-on: ${{ inputs.vmImage }} 15 | steps: 16 | - name: setup git 17 | run: | 18 | git config --global core.autocrlf false 19 | git config --global core.filemode false 20 | 21 | - uses: actions/checkout@v4 22 | 23 | - name: yarn install 24 | run: yarn install 25 | 26 | - uses: nuget/setup-nuget@v1 27 | 28 | - name: NuGet restore 29 | run: nuget restore -LockedMode package\windows\ReactNativeXaml.sln 30 | 31 | - name: run CodeGen 32 | run: yarn codegen 33 | working-directory: package 34 | 35 | - name: build TS 36 | run: yarn build 37 | 38 | - name: verify no changes from CodeGen 39 | shell: powershell 40 | run: | 41 | $changed = git status --porcelain=v1 package/ 42 | $changed 43 | if ($changed -ne $null) { throw "CodeGen detected changes" } -------------------------------------------------------------------------------- /.github/workflows/template-testcli.yml: -------------------------------------------------------------------------------- 1 | name: Test CLI 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | vmImage: 7 | required: false 8 | default: 'windows-latest' 9 | type: string 10 | rnwVersion: 11 | required: false 12 | default: 'latest' 13 | type: string 14 | useRnwWindowsInit: 15 | required: false 16 | default: false 17 | type: boolean 18 | 19 | jobs: 20 | testcli: 21 | name: New RNW@${{ inputs.rnwVersion }} App 22 | runs-on: ${{ inputs.vmImage }} 23 | steps: 24 | - uses: actions/checkout@v4 25 | 26 | - name: yarn install 27 | run: yarn install 28 | 29 | - name: build TS 30 | run: yarn build 31 | 32 | - name: yarn link 33 | run: yarn link 34 | working-directory: package 35 | 36 | - name: determine RN versions 37 | run: | 38 | $rnwVersion = & npm show react-native-windows@${{ inputs.rnwVersion }} version 39 | echo "RNW_VERSION=$rnwVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append 40 | $rnVersion = & npm show react-native-windows@$rnwVersion peerDependencies.react-native 41 | echo "RN_VERSION=$rnVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append 42 | Write-Host "Using react-native-windows@$rnwVersion with react-native@$rnVersion" 43 | 44 | - name: create react-native app 45 | run: | 46 | Write-Host "Using react-native@$Env:RN_VERSION" 47 | npx @react-native-community/cli init testrnx --version $Env:RN_VERSION --skip-install --install-pods false --verbose --skip-git-init true 48 | working-directory: ../ 49 | 50 | - name: yarn install 51 | run: yarn install 52 | working-directory: ../testrnx 53 | 54 | - name: react-native-windows-init 55 | if: ${{ inputs.useRnwWindowsInit }} 56 | run: | 57 | Write-Host "Using react-native-windows@$Env:RNW_VERSION" 58 | npx --yes react-native-windows-init --overwrite --verbose --version $Env:RNW_VERSION 59 | yarn install 60 | working-directory: ../testrnx 61 | 62 | - name: react-native init-windows 63 | if: ${{ !inputs.useRnwWindowsInit }} 64 | run: | 65 | Write-Host "Using react-native-windows@$Env:RNW_VERSION" 66 | yarn add react-native-windows@$Env:RNW_VERSION 67 | yarn install 68 | npx @react-native-community/cli@latest init-windows --overwrite --logging 69 | yarn install 70 | working-directory: ../testrnx 71 | 72 | - name: add react-native-xaml 73 | run: | 74 | yarn add react-native-xaml 75 | yarn link react-native-xaml 76 | yarn install 77 | working-directory: ../testrnx 78 | 79 | - name: autolink 80 | run: npx @react-native-community/cli autolink-windows --logging 81 | working-directory: ../testrnx 82 | 83 | - name: build app 84 | run: npx @react-native-community/cli run-windows --no-launch --no-deploy --no-packager --logging 85 | working-directory: ../testrnx 86 | -------------------------------------------------------------------------------- /.spelling: -------------------------------------------------------------------------------- 1 | # Static list for misspelled API names 2 | 3 | # Dynamic list extracted from our repo. To update, truncate the list and run: 4 | # npx cspell --words-only --unique | sort /uniq >> .spelling 5 | Activatable 6 | APSTUDIO 7 | ARRAYSIZE 8 | Behaviour 9 | cdebug 10 | clsid 11 | cppout 12 | CXXUNITTESTS 13 | declspec 14 | endregion 15 | examplenuget 16 | FILEFLAGS 17 | FILEOS 18 | Hanja 19 | Hojo 20 | hostspecific 21 | hresult 22 | HSTRING 23 | inspectable 24 | JSVALUEXAML 25 | Junja 26 | Linq 27 | msbuild 28 | noexcept 29 | noinline 30 | NOMINMAX 31 | nullptr 32 | PRODUCTNAME 33 | REACTNATIVE 34 | REACTTAG 35 | runtimeclass 36 | STRINGIZE 37 | struct 38 | svgz 39 | SYMED 40 | Thumbstick 41 | tsout 42 | Unicase 43 | Unviewable 44 | Viewbox 45 | wchar 46 | wcslen 47 | webhosthidden 48 | winmd 49 | winmds 50 | winrt 51 | winstring 52 | wstring 53 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "xaver.clang-format", 4 | "dbaeumer.vscode-eslint", 5 | "streetsidesoftware.code-spell-checker", 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change. 3 | 4 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 5 | 6 | ## Pull Request Process 7 | 8 | ### Initial setup 9 | 1. Fork repository and create your feature branch out of main. 10 | 2. Run `yarn` in the repo root to install NPM dependencies. 11 | 3. Open the [example solution](./example/windows/example.sln) in Visual Studio. 12 | 4. In the Solution Explorer, right-click on `Solution 'example'` and select `Restore NuGet Packages`. 13 | 14 | ### Build and run Codegen 15 | 1. In the Solution Explorer, right-click on the `Codegen` project and select `Set as Startup Project`. 16 | 2. Build the Codegen project (`Build > Build Codegen`). Once completed, you are ready to run the project, see output, and make your desired changes. 17 | 3. Run the Codegen project (`Debug > Start Debugging`). 18 | 19 | ### Make and verify your Codegen changes 20 | 21 | If you make changes to the Codegen project, be sure to build and re-run the Codegen. 22 | 23 | 1. If you make changes in a .tt file in Visual Studio, all you need to do is save the file and that will generate corresponding .cs file that reflects your change. 24 | 2. Run the Codegen steps above in Visual Studio to verify your changes to the 25 | [output files](./package/windows/ReactNativeXaml/Codegen/). 26 | 27 | ### Make and verify your ReactNativeXaml changes 28 | 29 | If you make changes to the ReactNativeXaml project, or to the Codegen output files (above), make sure that the ReactNativeXaml project still builds. 30 | 31 | 1. Make sure the example.sln is loaded in Visual Studio, see [Initial setup](#initial-setup) 32 | 2. Set the Solution Configuration to `Debug` or `Release`. 33 | 3. Set the Solution Platforms to `x86` or `x64` (not `AnyCPU`). 34 | 4. Run `Build > Build Solution`. 35 | 36 | ### Make and verify your TS changes 37 | 38 | If you make changes to the [package TypeScript files](./package/src/), be sure to build them. 39 | 40 | 1. Run `yarn build` from the repo root. 41 | 42 | ### Prepare and submit a PR 43 | 1. Once changes are ready, run `yarn change` at the root of the repository to create a patch (it will ask for a description of the change). The version scheme we use is [SemVer](https://semver.org/) 44 | 3. Open a pull request and address review feedback. 45 | 46 | ## Technical details 47 | You can find more details to setting up in the [Technical Guide](TechnicalGuide.md). -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![CI](https://github.com/microsoft/react-native-xaml/actions/workflows/main.yml/badge.svg)](https://github.com/microsoft/react-native-xaml/actions/workflows/main.yml) 2 | # react-native-xaml 3 | A React Native Windows view manager that allows directly using the [Windows XAML](https://docs.microsoft.com/windows/uwp/xaml-platform/xaml-overview) framework. 4 | 5 | ## Cheat sheet 6 | To see examples of the syntax and available controls, check out the [Usage guide](https://github.com/microsoft/react-native-xaml/tree/main/USAGE.md). 7 | 8 | ## Main advantages 9 | - Allows developers writing [react-native-windows](https://microsoft.github.io/react-native-windows/) apps (React Native apps targeting Windows 10) to quickly get started, if they are familiar with XAML. 10 | - Developers are not limited by the set of controls present today in RNW and community modules that support Windows. 11 | - Best of all, this solution is available *today*! 12 | - The set of types/properties/events are the XAML ones, however JS libraries can wrap those to expose the Windows control in a platform-agnostic way (e.g. as a way to implement a cross-plat control for Windows). 13 | 14 | react-native-xaml works by leveraging metadata for XAML properties, types and events. This metadata is automatically generated ([code-gen](https://github.com/microsoft/react-native-xaml/tree/main/package/Codegen)) from the Windows SDK. 15 | This means we can have a full projection of all of XAML – or any WinRT components written by app devs, that export a [UserControl](https://docs.microsoft.com/uwp/api/Windows.UI.Xaml.Controls.UserControl) – without manual intervention. 16 | 17 | ## Technical details 18 | See [Technical Guide](TechnicalGuide.md). 19 | 20 | ## Contributing 21 | Pull Requests are welcome. See [Contribution Guide](CONTRIBUTING.md) for details. 22 | 23 | ## Demo 24 | 25 | ![react-native-xaml demo](https://raw.githubusercontent.com/microsoft/react-native-xaml/main/example/rnx.gif) 26 | 27 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /change/react-native-xaml-ae47b51e-39d3-4b8b-8816-3a2b003ce391.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "patch", 3 | "comment": "Upgrade RNX to target RNW 0.77", 4 | "packageName": "react-native-xaml", 5 | "email": "jthysell@microsoft.com", 6 | "dependentChangeType": "patch" 7 | } 8 | -------------------------------------------------------------------------------- /directory.build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /example/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native', 4 | }; 5 | -------------------------------------------------------------------------------- /example/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore polyfills 9 | node_modules/react-native/Libraries/polyfills/.* 10 | 11 | ; Flow doesn't support platforms 12 | .*/Libraries/Utilities/LoadingView.js 13 | 14 | [untyped] 15 | .*/node_modules/@react-native-community/cli/.*/.* 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/interface.js 21 | node_modules/react-native/flow/ 22 | 23 | [options] 24 | emoji=true 25 | 26 | esproposal.optional_chaining=enable 27 | esproposal.nullish_coalescing=enable 28 | 29 | exact_by_default=true 30 | 31 | module.file_ext=.js 32 | module.file_ext=.json 33 | module.file_ext=.ios.js 34 | 35 | munge_underscores=true 36 | 37 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' 38 | module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' 39 | 40 | suppress_type=$FlowIssue 41 | suppress_type=$FlowFixMe 42 | suppress_type=$FlowFixMeProps 43 | suppress_type=$FlowFixMeState 44 | 45 | [lints] 46 | sketchy-null-number=warn 47 | sketchy-null-mixed=warn 48 | sketchy-number=warn 49 | untyped-type-import=warn 50 | nonstrict-import=warn 51 | deprecated-type=warn 52 | unsafe-getters-setters=warn 53 | unnecessary-invariant=warn 54 | signature-verification-failure=warn 55 | 56 | [strict] 57 | deprecated-type 58 | nonstrict-import 59 | sketchy-null 60 | unclear-type 61 | unsafe-getters-setters 62 | untyped-import 63 | untyped-type-import 64 | 65 | [version] 66 | ^0.137.0 67 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | yarn-error.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | *.keystore 42 | !debug.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # CocoaPods 59 | /ios/Pods/ 60 | -------------------------------------------------------------------------------- /example/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: false, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | arrowParens: 'avoid', 7 | }; 8 | -------------------------------------------------------------------------------- /example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # Building the example app 2 | 1. Make sure you have the [React Native for Windows development dependencies](https://aka.ms/rnw-deps) 3 | 1. Clone this repo 4 | 1. `cd react-native-xaml` 5 | 1. `yarn` 6 | 3. `cd package` 7 | 4. `yarn build` 8 | 9 | # Running the example app 10 | 11 | ## Using Visual Studio 12 | 1. From the root folder 13 | 1. `cd example` 14 | 1. `yarn start` 15 | 16 | Now you can build and run the solution in **Debug** mode at `example\windows\example.sln` from Visual Studio by pressing F5 (make sure you select x64 or x86). 17 | 18 | ## Using the CLI 19 | 20 | If you want to use the `react-native` CLI you can run `yarn windows`. 21 | 22 | -------------------------------------------------------------------------------- /example/__tests__/App.test.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import 'react-native'; 6 | import React from 'react'; 7 | import App from '../App'; 8 | 9 | // Note: import explicitly to use the types shipped with jest. 10 | import {it} from '@jest/globals'; 11 | 12 | // Note: test renderer must be required after react-native. 13 | import renderer from 'react-test-renderer'; 14 | 15 | it('renders correctly', () => { 16 | renderer.create(); 17 | }); 18 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "displayName": "example" 4 | } -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:@react-native/babel-preset'], 3 | }; -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import {AppRegistry} from 'react-native'; 6 | import App from './App'; 7 | import {name as appName} from './app.json'; 8 | 9 | AppRegistry.registerComponent(appName, () => App); 10 | -------------------------------------------------------------------------------- /example/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'react-native', 3 | }; -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | const MetroConfig = require('@rnx-kit/metro-config'); 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | 6 | const rnwPath = fs.realpathSync( 7 | path.resolve(require.resolve('react-native-windows/package.json'), '..'), 8 | ); 9 | 10 | // 11 | 12 | /** 13 | * Metro configuration 14 | * https://facebook.github.io/metro/docs/configuration 15 | * 16 | * @type {import('metro-config').MetroConfig} 17 | */ 18 | 19 | const config = { 20 | // 21 | resolver: { 22 | blockList: MetroConfig.exclusionList([ 23 | // This stops "npx @react-native-community/cli run-windows" from causing the metro server to crash if its already running 24 | new RegExp( 25 | `${path.resolve(__dirname, 'windows').replace(/[/\\]/g, '/')}.*`, 26 | ), 27 | // 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 28 | new RegExp(`${rnwPath}/build/.*`), 29 | new RegExp(`${rnwPath}/target/.*`), 30 | /.*\.ProjectImports\.zip/, 31 | ]), 32 | // 33 | }, 34 | transformer: { 35 | getTransformOptions: async () => ({ 36 | transform: { 37 | experimentalImportSupport: false, 38 | inlineRequires: true, 39 | }, 40 | }), 41 | }, 42 | projectRoot: __dirname, 43 | }; 44 | 45 | module.exports = MetroConfig.makeMetroConfig(config); 46 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "lint": "eslint .", 7 | "start": "react-native start", 8 | "test": "jest", 9 | "windows": "npx @react-native-community/cli run-windows" 10 | }, 11 | "dependencies": { 12 | "react": "18.3.1", 13 | "react-native": "0.77.0", 14 | "react-native-windows": "0.77.2", 15 | "react-native-xaml": "*" 16 | }, 17 | "devDependencies": { 18 | "@babel/core": "^7.25.2", 19 | "@babel/preset-env": "^7.25.3", 20 | "@babel/runtime": "^7.25.0", 21 | "@react-native-community/cli": "15.0.1", 22 | "@react-native-community/cli-platform-android": "15.0.1", 23 | "@react-native-community/cli-platform-ios": "15.0.1", 24 | "@react-native/babel-preset": "0.77.0", 25 | "@react-native/eslint-config": "0.77.0", 26 | "@react-native/metro-config": "0.77.0", 27 | "@react-native/typescript-config": "0.77.0", 28 | "@rnx-kit/metro-config": "^1.3.5", 29 | "@types/jest": "^29.5.13", 30 | "@types/react": "^18.2.6", 31 | "@types/react-test-renderer": "^18.0.0", 32 | "eslint": "^8.19.0", 33 | "jest": "^29.6.3", 34 | "prettier": "2.8.8", 35 | "react-test-renderer": "18.3.1", 36 | "typescript": "5.0.4", 37 | "metro-config": "^0.81.1" 38 | }, 39 | "engines": { 40 | "node": ">=18" 41 | } 42 | } -------------------------------------------------------------------------------- /example/rnx.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/example/rnx.gif -------------------------------------------------------------------------------- /example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@react-native/typescript-config/tsconfig.json" 3 | } -------------------------------------------------------------------------------- /example/windows/.gitignore: -------------------------------------------------------------------------------- 1 | *AppPackages* 2 | *BundleArtifacts* 3 | 4 | #OS junk files 5 | [Tt]humbs.db 6 | *.DS_Store 7 | 8 | #Visual Studio files 9 | *.[Oo]bj 10 | *.user 11 | *.aps 12 | *.pch 13 | *.vspscc 14 | *.vssscc 15 | *_i.c 16 | *_p.c 17 | *.ncb 18 | *.suo 19 | *.tlb 20 | *.tlh 21 | *.bak 22 | *.[Cc]ache 23 | *.ilk 24 | *.log 25 | *.lib 26 | *.sbr 27 | *.sdf 28 | *.opensdf 29 | *.opendb 30 | *.unsuccessfulbuild 31 | ipch/ 32 | [Oo]bj/ 33 | [Bb]in 34 | [Dd]ebug*/ 35 | [Rr]elease*/ 36 | Ankh.NoLoad 37 | 38 | # Visual C++ cache files 39 | ipch/ 40 | *.aps 41 | *.ncb 42 | *.opendb 43 | *.opensdf 44 | *.sdf 45 | *.cachefile 46 | *.VC.db 47 | *.VC.VC.opendb 48 | 49 | #MonoDevelop 50 | *.pidb 51 | *.userprefs 52 | 53 | #Tooling 54 | _ReSharper*/ 55 | *.resharper 56 | [Tt]est[Rr]esult* 57 | *.sass-cache 58 | 59 | #Project files 60 | [Bb]uild/ 61 | 62 | #Subversion files 63 | .svn 64 | 65 | # Office Temp Files 66 | ~$* 67 | 68 | # vim Temp Files 69 | *~ 70 | 71 | #NuGet 72 | packages/ 73 | *.nupkg 74 | 75 | #ncrunch 76 | *ncrunch* 77 | *crunch*.local.xml 78 | 79 | # visual studio database projects 80 | *.dbmdl 81 | 82 | #Test files 83 | *.testsettings 84 | 85 | #Other files 86 | *.DotSettings 87 | .vs/ 88 | *project.lock.json 89 | 90 | #Files generated by the VS build 91 | **/Generated Files/** 92 | 93 | -------------------------------------------------------------------------------- /example/windows/ExperimentalFeatures.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 17 | true 18 | 19 | 25 | false 26 | 27 | 34 | false 35 | 36 | true 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /example/windows/NuGet.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /example/windows/RuntimeComponent1/BlankUserControl.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "BlankUserControl.h" 3 | #if __has_include("BlankUserControl.g.cpp") 4 | #include "BlankUserControl.g.cpp" 5 | #endif 6 | 7 | using namespace winrt; 8 | using namespace Windows::UI::Xaml; 9 | 10 | namespace winrt::RuntimeComponent1::implementation 11 | { 12 | BlankUserControl::BlankUserControl() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | int32_t BlankUserControl::MyProperty() 18 | { 19 | auto value = this->GetValue(MyPropertyProperty()); 20 | return winrt::unbox_value(value); 21 | } 22 | 23 | void BlankUserControl::MyProperty(int32_t value) 24 | { 25 | this->SetValue(MyPropertyProperty(), winrt::box_value(value)); 26 | } 27 | 28 | winrt::event_token BlankUserControl::Happened(Windows::Foundation::EventHandler const 29 | & handler) noexcept { 30 | return m_happened.add(handler); 31 | } 32 | void BlankUserControl::Happened(winrt::event_token const& token) { 33 | m_happened.remove(token); 34 | } 35 | 36 | 37 | void BlankUserControl::ClickHandler(IInspectable const&, RoutedEventArgs const&) 38 | { 39 | auto v = MyProperty() + 1; 40 | MyProperty(v); 41 | Button().Content(box_value(L"Clicked " + std::to_wstring(v))); 42 | 43 | m_happened(*this, nullptr); 44 | } 45 | 46 | winrt::Windows::UI::Xaml::DependencyProperty BlankUserControl::MyPropertyProperty() { 47 | if (m_myPropertyProperty == nullptr) { 48 | auto typeMetadata = PropertyMetadata::Create(winrt::box_value(0), [](const DependencyObject& sender, const DependencyPropertyChangedEventArgs& args) { 49 | if (auto control = sender.try_as()) { 50 | auto v = winrt::unbox_value(args.NewValue()); 51 | control.MyProperty(v); 52 | } 53 | }); 54 | m_myPropertyProperty = winrt::Windows::UI::Xaml::DependencyProperty::Register(L"MyProperty", winrt::xaml_typename(), winrt::xaml_typename(), typeMetadata); 55 | } 56 | return m_myPropertyProperty; 57 | } 58 | winrt::Windows::UI::Xaml::DependencyProperty BlankUserControl::m_myPropertyProperty = nullptr; 59 | 60 | } 61 | 62 | -------------------------------------------------------------------------------- /example/windows/RuntimeComponent1/BlankUserControl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "winrt/Windows.UI.Xaml.h" 4 | #include "winrt/Windows.UI.Xaml.Markup.h" 5 | #include "winrt/Windows.UI.Xaml.Interop.h" 6 | #include "winrt/Windows.UI.Xaml.Controls.Primitives.h" 7 | #include "BlankUserControl.g.h" 8 | 9 | namespace winrt::RuntimeComponent1::implementation 10 | { 11 | struct BlankUserControl : BlankUserControlT 12 | { 13 | BlankUserControl(); 14 | 15 | int32_t MyProperty(); 16 | void MyProperty(int32_t value); 17 | 18 | void ClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); 19 | 20 | static winrt::Windows::UI::Xaml::DependencyProperty MyPropertyProperty(); 21 | 22 | winrt::event_token Happened(Windows::Foundation::EventHandler const 23 | & handler) noexcept; 24 | void Happened(winrt::event_token const& token); 25 | 26 | 27 | private: 28 | static winrt::Windows::UI::Xaml::DependencyProperty m_myPropertyProperty; 29 | winrt::event> m_happened; 30 | 31 | }; 32 | } 33 | 34 | namespace winrt::RuntimeComponent1::factory_implementation 35 | { 36 | struct BlankUserControl : BlankUserControlT 37 | { 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /example/windows/RuntimeComponent1/BlankUserControl.idl: -------------------------------------------------------------------------------- 1 | namespace RuntimeComponent1 2 | { 3 | [default_interface] 4 | runtimeclass BlankUserControl : Windows.UI.Xaml.Controls.UserControl 5 | { 6 | BlankUserControl(); 7 | Int32 MyProperty; 8 | event Windows.Foundation.EventHandler Happened; 9 | static Windows.UI.Xaml.DependencyProperty MyPropertyProperty{ get; }; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /example/windows/RuntimeComponent1/BlankUserControl.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /example/windows/RuntimeComponent1/Class.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Class.h" 3 | #include "Class.g.cpp" 4 | 5 | namespace winrt::RuntimeComponent1::implementation 6 | { 7 | int32_t Class::MyProperty() 8 | { 9 | throw hresult_not_implemented(); 10 | } 11 | 12 | void Class::MyProperty(int32_t /* value */) 13 | { 14 | throw hresult_not_implemented(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /example/windows/RuntimeComponent1/Class.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Class.g.h" 4 | 5 | namespace winrt::RuntimeComponent1::implementation 6 | { 7 | struct Class : ClassT 8 | { 9 | Class() = default; 10 | 11 | int32_t MyProperty(); 12 | void MyProperty(int32_t value); 13 | }; 14 | } 15 | 16 | namespace winrt::RuntimeComponent1::factory_implementation 17 | { 18 | struct Class : ClassT 19 | { 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /example/windows/RuntimeComponent1/Class.idl: -------------------------------------------------------------------------------- 1 | namespace RuntimeComponent1 2 | { 3 | [default_interface] 4 | runtimeclass Class 5 | { 6 | Class(); 7 | Int32 MyProperty; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/windows/RuntimeComponent1/PropertySheet.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /example/windows/RuntimeComponent1/RuntimeComponent1.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE 3 | DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE 4 | -------------------------------------------------------------------------------- /example/windows/RuntimeComponent1/RuntimeComponent1.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | accd3aa8-1ba0-4223-9bbe-0c431709210b 6 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms 7 | 8 | 9 | {926ab91d-31b4-48c3-b9a4-e681349f27f0} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /example/windows/RuntimeComponent1/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /example/windows/RuntimeComponent1/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /example/windows/RuntimeComponent1/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | -------------------------------------------------------------------------------- /example/windows/RuntimeComponent1/readme.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | C++/WinRT RuntimeComponent1 Project Overview 3 | ======================================================================== 4 | 5 | This project demonstrates how to get started authoring Windows Runtime 6 | classes directly with standard C++, using the C++/WinRT SDK component 7 | to generate implementation headers from interface (IDL) files. The 8 | generated Windows Runtime component binary and WinMD files should then 9 | be bundled with the Universal Windows Platform (UWP) app consuming them. 10 | 11 | Steps: 12 | 1. Create an interface (IDL) file to define your Windows Runtime class, 13 | its default interface, and any other interfaces it implements. 14 | 2. Build the project once to generate module.g.cpp, module.h.cpp, and 15 | implementation templates under the "Generated Files" folder, as 16 | well as skeleton class definitions under "Generated Files\sources". 17 | 3. Use the skeleton class definitions for reference to implement your 18 | Windows Runtime classes. 19 | 20 | ======================================================================== 21 | Learn more about C++/WinRT here: 22 | http://aka.ms/cppwinrt/ 23 | ======================================================================== 24 | -------------------------------------------------------------------------------- /example/windows/example/.gitignore: -------------------------------------------------------------------------------- 1 | /Bundle 2 | -------------------------------------------------------------------------------- /example/windows/example/App.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | 3 | #include "App.h" 4 | 5 | #include "AutolinkedNativeModules.g.h" 6 | #include "ReactPackageProvider.h" 7 | 8 | using namespace winrt; 9 | using namespace xaml; 10 | using namespace xaml::Controls; 11 | using namespace xaml::Navigation; 12 | 13 | using namespace Windows::ApplicationModel; 14 | namespace winrt::example::implementation 15 | { 16 | /// 17 | /// Initializes the singleton application object. This is the first line of 18 | /// authored code executed, and as such is the logical equivalent of main() or 19 | /// WinMain(). 20 | /// 21 | App::App() noexcept 22 | { 23 | #if BUNDLE 24 | JavaScriptBundleFile(L"index.windows"); 25 | InstanceSettings().UseFastRefresh(false); 26 | #else 27 | JavaScriptBundleFile(L"index"); 28 | InstanceSettings().UseFastRefresh(true); 29 | #endif 30 | 31 | #if _DEBUG 32 | InstanceSettings().UseDirectDebugger(true); 33 | InstanceSettings().UseDeveloperSupport(true); 34 | #else 35 | InstanceSettings().UseDirectDebugger(false); 36 | InstanceSettings().UseDeveloperSupport(false); 37 | #endif 38 | 39 | RegisterAutolinkedNativeModulePackages(PackageProviders()); // Includes any autolinked modules 40 | 41 | PackageProviders().Append(make()); // Includes all modules in this project 42 | 43 | InitializeComponent(); 44 | } 45 | 46 | /// 47 | /// Invoked when the application is launched normally by the end user. Other entry points 48 | /// will be used such as when the application is launched to open a specific file. 49 | /// 50 | /// Details about the launch request and process. 51 | void App::OnLaunched(activation::LaunchActivatedEventArgs const& e) 52 | { 53 | super::OnLaunched(e); 54 | 55 | Frame rootFrame = Window::Current().Content().as(); 56 | rootFrame.Navigate(xaml_typename(), box_value(e.Arguments())); 57 | } 58 | 59 | /// 60 | /// Invoked when the application is activated by some means other than normal launching. 61 | /// 62 | void App::OnActivated(Activation::IActivatedEventArgs const &e) { 63 | auto preActivationContent = Window::Current().Content(); 64 | super::OnActivated(e); 65 | if (!preActivationContent && Window::Current()) { 66 | Frame rootFrame = Window::Current().Content().as(); 67 | rootFrame.Navigate(xaml_typename(), nullptr); 68 | } 69 | } 70 | 71 | /// 72 | /// Invoked when application execution is being suspended. Application state is saved 73 | /// without knowing whether the application will be terminated or resumed with the contents 74 | /// of memory still intact. 75 | /// 76 | /// The source of the suspend request. 77 | /// Details about the suspend request. 78 | void App::OnSuspending([[maybe_unused]] IInspectable const& sender, [[maybe_unused]] SuspendingEventArgs const& e) 79 | { 80 | // Save application state and stop any background activity 81 | } 82 | 83 | /// 84 | /// Invoked when Navigation to a certain page fails 85 | /// 86 | /// The Frame which failed navigation 87 | /// Details about the navigation failure 88 | void App::OnNavigationFailed(IInspectable const&, NavigationFailedEventArgs const& e) 89 | { 90 | throw hresult_error(E_FAIL, hstring(L"Failed to load Page ") + e.SourcePageType().Name); 91 | } 92 | 93 | } // namespace winrt::example::implementation 94 | -------------------------------------------------------------------------------- /example/windows/example/App.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "App.xaml.g.h" 4 | 5 | #include 6 | 7 | namespace activation = winrt::Windows::ApplicationModel::Activation; 8 | 9 | namespace winrt::example::implementation 10 | { 11 | struct App : AppT 12 | { 13 | App() noexcept; 14 | void OnLaunched(activation::LaunchActivatedEventArgs const&); 15 | void OnActivated(Windows::ApplicationModel::Activation::IActivatedEventArgs const &e); 16 | void OnSuspending(IInspectable const&, Windows::ApplicationModel::SuspendingEventArgs const&); 17 | void OnNavigationFailed(IInspectable const&, xaml::Navigation::NavigationFailedEventArgs const&); 18 | private: 19 | using super = AppT; 20 | }; 21 | } // namespace winrt::example::implementation 22 | -------------------------------------------------------------------------------- /example/windows/example/App.idl: -------------------------------------------------------------------------------- 1 | namespace example 2 | { 3 | } 4 | -------------------------------------------------------------------------------- /example/windows/example/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/windows/example/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/example/windows/example/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /example/windows/example/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/example/windows/example/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /example/windows/example/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/example/windows/example/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /example/windows/example/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/example/windows/example/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /example/windows/example/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/example/windows/example/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /example/windows/example/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/example/windows/example/Assets/StoreLogo.png -------------------------------------------------------------------------------- /example/windows/example/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/example/windows/example/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /example/windows/example/AutolinkedNativeModules.g.cpp: -------------------------------------------------------------------------------- 1 | // AutolinkedNativeModules.g.cpp contents generated by "npx @react-native-community/cli autolink-windows" 2 | // clang-format off 3 | #include "pch.h" 4 | #include "AutolinkedNativeModules.g.h" 5 | 6 | // Includes from react-native-xaml 7 | #include 8 | 9 | namespace winrt::Microsoft::ReactNative 10 | { 11 | 12 | void RegisterAutolinkedNativeModulePackages(winrt::Windows::Foundation::Collections::IVector const& packageProviders) 13 | { 14 | // IReactPackageProviders from react-native-xaml 15 | packageProviders.Append(winrt::ReactNativeXaml::ReactPackageProvider()); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /example/windows/example/AutolinkedNativeModules.g.h: -------------------------------------------------------------------------------- 1 | // AutolinkedNativeModules.g.h contents generated by "npx @react-native-community/cli autolink-windows" 2 | // clang-format off 3 | #pragma once 4 | 5 | namespace winrt::Microsoft::ReactNative 6 | { 7 | 8 | void RegisterAutolinkedNativeModulePackages(winrt::Windows::Foundation::Collections::IVector const& packageProviders); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /example/windows/example/AutolinkedNativeModules.g.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /example/windows/example/AutolinkedNativeModules.g.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {0ff7027a-222c-4ffb-8f17-91d18bbaf7a8} 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/windows/example/MainPage.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "MainPage.h" 3 | #if __has_include("MainPage.g.cpp") 4 | #include "MainPage.g.cpp" 5 | #endif 6 | 7 | #include "App.h" 8 | 9 | using namespace winrt; 10 | using namespace xaml; 11 | 12 | namespace winrt::example::implementation 13 | { 14 | MainPage::MainPage() 15 | { 16 | InitializeComponent(); 17 | auto app = Application::Current().as(); 18 | ReactRootView().ReactNativeHost(app->Host()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /example/windows/example/MainPage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "MainPage.g.h" 3 | #include 4 | 5 | namespace winrt::example::implementation 6 | { 7 | struct MainPage : MainPageT 8 | { 9 | MainPage(); 10 | }; 11 | } 12 | 13 | namespace winrt::example::factory_implementation 14 | { 15 | struct MainPage : MainPageT 16 | { 17 | }; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /example/windows/example/MainPage.idl: -------------------------------------------------------------------------------- 1 | #include "NamespaceRedirect.h" 2 | 3 | namespace example 4 | { 5 | [default_interface] 6 | runtimeclass MainPage : XAML_NAMESPACE.Controls.Page 7 | { 8 | MainPage(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /example/windows/example/MainPage.xaml: -------------------------------------------------------------------------------- 1 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /example/windows/example/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | example 18 | RNX Test Cert 19 | Assets\StoreLogo.png 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 35 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /example/windows/example/PropertySheet.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /example/windows/example/ReactPackageProvider.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ReactPackageProvider.h" 3 | #include "NativeModules.h" 4 | 5 | using namespace winrt::Microsoft::ReactNative; 6 | 7 | namespace winrt::example::implementation 8 | { 9 | 10 | void ReactPackageProvider::CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept 11 | { 12 | AddAttributedModules(packageBuilder, false); 13 | } 14 | 15 | } // namespace winrt::example::implementation 16 | -------------------------------------------------------------------------------- /example/windows/example/ReactPackageProvider.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "winrt/Microsoft.ReactNative.h" 4 | 5 | namespace winrt::example::implementation 6 | { 7 | struct ReactPackageProvider : winrt::implements 8 | { 9 | public: // IReactPackageProvider 10 | void CreatePackage(winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder) noexcept; 11 | }; 12 | } // namespace winrt::example::implementation 13 | 14 | -------------------------------------------------------------------------------- /example/windows/example/example.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Assets 25 | 26 | 27 | Assets 28 | 29 | 30 | Assets 31 | 32 | 33 | Assets 34 | 35 | 36 | Assets 37 | 38 | 39 | Assets 40 | 41 | 42 | Assets 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {e48dc53e-40b1-40cb-970a-f89935452892} 51 | 52 | 53 | {2443e9bf-f217-47b5-b226-8ee99297c961} 54 | 55 | 56 | 57 | 58 | 59 | 60 | JS 61 | 62 | 63 | JS 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /example/windows/example/packages.lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "dependencies": { 4 | "native,Version=v0.0": { 5 | "Microsoft.JavaScript.Hermes": { 6 | "type": "Direct", 7 | "requested": "[0.1.23, )", 8 | "resolved": "0.1.23", 9 | "contentHash": "cA9t1GjY4Yo0JD1AfA//e1lOwk48hLANfuX6GXrikmEBNZVr2TIX5ONJt5tqCnpZyLz6xGiPDgTfFNKbSfb21g==" 10 | }, 11 | "Microsoft.UI.Xaml": { 12 | "type": "Direct", 13 | "requested": "[2.8.0, )", 14 | "resolved": "2.8.0", 15 | "contentHash": "vxdHxTr63s5KVtNddMFpgvjBjUH50z7seq/5jLWmmSuf8poxg+sXrywkofUdE8ZstbpO9y3FL/IXXUcPYbeesA==", 16 | "dependencies": { 17 | "Microsoft.Web.WebView2": "1.0.1264.42" 18 | } 19 | }, 20 | "Microsoft.Windows.CppWinRT": { 21 | "type": "Direct", 22 | "requested": "[2.0.230706.1, )", 23 | "resolved": "2.0.230706.1", 24 | "contentHash": "l0D7oCw/5X+xIKHqZTi62TtV+1qeSz7KVluNFdrJ9hXsst4ghvqQ/Yhura7JqRdZWBXAuDS0G0KwALptdoxweQ==" 25 | }, 26 | "boost": { 27 | "type": "Transitive", 28 | "resolved": "1.83.0", 29 | "contentHash": "cy53VNMzysEMvhBixDe8ujPk67Fcj3v6FPHQnH91NYJNLHpc6jxa2xq9ruCaaJjE4M3YrGSHDi4uUSTGBWw6EQ==" 30 | }, 31 | "CDebug": { 32 | "type": "Transitive", 33 | "resolved": "0.0.3", 34 | "contentHash": "C6pojNJ2rdJuOdhe0xhJ/FedNLRJkpCVLEEHsfgoU5d5kkOOVKK+7xlGWYgttB51nDB5dLDu/O8j03jSxu81oA==" 35 | }, 36 | "Microsoft.Web.WebView2": { 37 | "type": "Transitive", 38 | "resolved": "1.0.1264.42", 39 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 40 | }, 41 | "common": { 42 | "type": "Project", 43 | "dependencies": { 44 | "boost": "[1.83.0, )" 45 | } 46 | }, 47 | "fmt": { 48 | "type": "Project" 49 | }, 50 | "folly": { 51 | "type": "Project", 52 | "dependencies": { 53 | "boost": "[1.83.0, )", 54 | "fmt": "[1.0.0, )" 55 | } 56 | }, 57 | "microsoft.reactnative": { 58 | "type": "Project", 59 | "dependencies": { 60 | "Common": "[1.0.0, )", 61 | "Folly": "[1.0.0, )", 62 | "Microsoft.JavaScript.Hermes": "[0.1.23, )", 63 | "Microsoft.UI.Xaml": "[2.8.0, )", 64 | "ReactCommon": "[1.0.0, )", 65 | "boost": "[1.83.0, )" 66 | } 67 | }, 68 | "reactcommon": { 69 | "type": "Project", 70 | "dependencies": { 71 | "Folly": "[1.0.0, )", 72 | "boost": "[1.83.0, )" 73 | } 74 | }, 75 | "reactnativexaml": { 76 | "type": "Project", 77 | "dependencies": { 78 | "CDebug": "[0.0.3, )", 79 | "Microsoft.ReactNative": "[1.0.0, )", 80 | "Microsoft.UI.Xaml": "[2.8.0, )" 81 | } 82 | } 83 | }, 84 | "native,Version=v0.0/win10-arm": { 85 | "Microsoft.Web.WebView2": { 86 | "type": "Transitive", 87 | "resolved": "1.0.1264.42", 88 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 89 | } 90 | }, 91 | "native,Version=v0.0/win10-arm-aot": { 92 | "Microsoft.Web.WebView2": { 93 | "type": "Transitive", 94 | "resolved": "1.0.1264.42", 95 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 96 | } 97 | }, 98 | "native,Version=v0.0/win10-arm64-aot": { 99 | "Microsoft.Web.WebView2": { 100 | "type": "Transitive", 101 | "resolved": "1.0.1264.42", 102 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 103 | } 104 | }, 105 | "native,Version=v0.0/win10-x64": { 106 | "Microsoft.Web.WebView2": { 107 | "type": "Transitive", 108 | "resolved": "1.0.1264.42", 109 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 110 | } 111 | }, 112 | "native,Version=v0.0/win10-x64-aot": { 113 | "Microsoft.Web.WebView2": { 114 | "type": "Transitive", 115 | "resolved": "1.0.1264.42", 116 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 117 | } 118 | }, 119 | "native,Version=v0.0/win10-x86": { 120 | "Microsoft.Web.WebView2": { 121 | "type": "Transitive", 122 | "resolved": "1.0.1264.42", 123 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 124 | } 125 | }, 126 | "native,Version=v0.0/win10-x86-aot": { 127 | "Microsoft.Web.WebView2": { 128 | "type": "Transitive", 129 | "resolved": "1.0.1264.42", 130 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 131 | } 132 | } 133 | } 134 | } -------------------------------------------------------------------------------- /example/windows/example/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /example/windows/example/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define NOMINMAX 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | using namespace winrt::Windows::Foundation; 25 | -------------------------------------------------------------------------------- /examplenuget/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native', 4 | }; -------------------------------------------------------------------------------- /examplenuget/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore polyfills 9 | node_modules/react-native/Libraries/polyfills/.* 10 | 11 | ; Flow doesn't support platforms 12 | .*/Libraries/Utilities/LoadingView.js 13 | 14 | [untyped] 15 | .*/node_modules/@react-native-community/cli/.*/.* 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/interface.js 21 | node_modules/react-native/flow/ 22 | 23 | [options] 24 | emoji=true 25 | 26 | esproposal.optional_chaining=enable 27 | esproposal.nullish_coalescing=enable 28 | 29 | exact_by_default=true 30 | 31 | module.file_ext=.js 32 | module.file_ext=.json 33 | module.file_ext=.ios.js 34 | 35 | munge_underscores=true 36 | 37 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' 38 | module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' 39 | 40 | suppress_type=$FlowIssue 41 | suppress_type=$FlowFixMe 42 | suppress_type=$FlowFixMeProps 43 | suppress_type=$FlowFixMeState 44 | 45 | [lints] 46 | sketchy-null-number=warn 47 | sketchy-null-mixed=warn 48 | sketchy-number=warn 49 | untyped-type-import=warn 50 | nonstrict-import=warn 51 | deprecated-type=warn 52 | unsafe-getters-setters=warn 53 | unnecessary-invariant=warn 54 | signature-verification-failure=warn 55 | 56 | [strict] 57 | deprecated-type 58 | nonstrict-import 59 | sketchy-null 60 | unclear-type 61 | unsafe-getters-setters 62 | untyped-import 63 | untyped-type-import 64 | 65 | [version] 66 | ^0.137.0 67 | -------------------------------------------------------------------------------- /examplenuget/.gitattributes: -------------------------------------------------------------------------------- 1 | # Windows files should use crlf line endings 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | *.bat text eol=crlf 4 | -------------------------------------------------------------------------------- /examplenuget/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | yarn-error.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | *.keystore 42 | !debug.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # CocoaPods 59 | /ios/Pods/ 60 | -------------------------------------------------------------------------------- /examplenuget/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: false, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | arrowParens: 'avoid', 7 | }; 8 | -------------------------------------------------------------------------------- /examplenuget/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /examplenuget/__tests__/App.test.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import 'react-native'; 6 | import React from 'react'; 7 | import App from '../App'; 8 | 9 | // Note: import explicitly to use the types shipped with jest. 10 | import {it} from '@jest/globals'; 11 | 12 | // Note: test renderer must be required after react-native. 13 | import renderer from 'react-test-renderer'; 14 | 15 | it('renders correctly', () => { 16 | renderer.create(); 17 | }); 18 | -------------------------------------------------------------------------------- /examplenuget/_editorconfig: -------------------------------------------------------------------------------- 1 | # Windows files 2 | [*.bat] 3 | end_of_line = crlf 4 | -------------------------------------------------------------------------------- /examplenuget/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "examplenuget", 3 | "displayName": "examplenuget" 4 | } -------------------------------------------------------------------------------- /examplenuget/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:@react-native/babel-preset'], 3 | }; -------------------------------------------------------------------------------- /examplenuget/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import {AppRegistry} from 'react-native'; 6 | import App from './App'; 7 | import {name as appName} from './app.json'; 8 | 9 | AppRegistry.registerComponent(appName, () => App); 10 | -------------------------------------------------------------------------------- /examplenuget/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'react-native', 3 | }; -------------------------------------------------------------------------------- /examplenuget/metro.config.js: -------------------------------------------------------------------------------- 1 | const MetroConfig = require('@rnx-kit/metro-config'); 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | 6 | const rnwPath = fs.realpathSync( 7 | path.resolve(require.resolve('react-native-windows/package.json'), '..'), 8 | ); 9 | 10 | // 11 | 12 | /** 13 | * Metro configuration 14 | * https://facebook.github.io/metro/docs/configuration 15 | * 16 | * @type {import('metro-config').MetroConfig} 17 | */ 18 | 19 | const config = { 20 | // 21 | resolver: { 22 | blockList: MetroConfig.exclusionList([ 23 | // This stops "npx @react-native-community/cli run-windows" from causing the metro server to crash if its already running 24 | new RegExp( 25 | `${path.resolve(__dirname, 'windows').replace(/[/\\]/g, '/')}.*`, 26 | ), 27 | // 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 28 | new RegExp(`${rnwPath}/build/.*`), 29 | new RegExp(`${rnwPath}/target/.*`), 30 | /.*\.ProjectImports\.zip/, 31 | ]), 32 | // 33 | }, 34 | transformer: { 35 | getTransformOptions: async () => ({ 36 | transform: { 37 | experimentalImportSupport: false, 38 | inlineRequires: true, 39 | }, 40 | }), 41 | }, 42 | projectRoot: __dirname, 43 | }; 44 | 45 | module.exports = MetroConfig.makeMetroConfig(config); 46 | -------------------------------------------------------------------------------- /examplenuget/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "examplenuget", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "lint": "eslint .", 7 | "start": "react-native start", 8 | "test": "jest", 9 | "windows": "npx @react-native-community/cli run-windows" 10 | }, 11 | "dependencies": { 12 | "react": "18.3.1", 13 | "react-native": "0.77.0", 14 | "react-native-windows": "0.77.2", 15 | "react-native-xaml": "*" 16 | }, 17 | "devDependencies": { 18 | "@babel/core": "^7.25.2", 19 | "@babel/preset-env": "^7.25.3", 20 | "@babel/runtime": "^7.25.0", 21 | "@react-native-community/cli": "15.0.1", 22 | "@react-native-community/cli-platform-android": "15.0.1", 23 | "@react-native-community/cli-platform-ios": "15.0.1", 24 | "@react-native/babel-preset": "0.77.0", 25 | "@react-native/eslint-config": "0.77.0", 26 | "@react-native/metro-config": "0.77.0", 27 | "@react-native/typescript-config": "0.77.0", 28 | "@rnx-kit/metro-config": "^1.3.5", 29 | "@types/jest": "^29.5.13", 30 | "@types/react": "^18.2.6", 31 | "@types/react-test-renderer": "^18.0.0", 32 | "eslint": "^8.19.0", 33 | "jest": "^29.6.3", 34 | "prettier": "2.8.8", 35 | "react-test-renderer": "18.3.1", 36 | "typescript": "5.0.4", 37 | "metro-config": "^0.81.1" 38 | }, 39 | "engines": { 40 | "node": ">=18" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /examplenuget/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@react-native/typescript-config/tsconfig.json" 3 | } -------------------------------------------------------------------------------- /examplenuget/windows/.gitignore: -------------------------------------------------------------------------------- 1 | *AppPackages* 2 | *BundleArtifacts* 3 | 4 | #OS junk files 5 | [Tt]humbs.db 6 | *.DS_Store 7 | 8 | #Visual Studio files 9 | *.[Oo]bj 10 | *.user 11 | *.aps 12 | *.pch 13 | *.vspscc 14 | *.vssscc 15 | *_i.c 16 | *_p.c 17 | *.ncb 18 | *.suo 19 | *.tlb 20 | *.tlh 21 | *.bak 22 | *.[Cc]ache 23 | *.ilk 24 | *.log 25 | *.lib 26 | *.sbr 27 | *.sdf 28 | *.opensdf 29 | *.opendb 30 | *.unsuccessfulbuild 31 | ipch/ 32 | [Oo]bj/ 33 | [Bb]in 34 | [Dd]ebug*/ 35 | [Rr]elease*/ 36 | Ankh.NoLoad 37 | 38 | # Visual C++ cache files 39 | ipch/ 40 | *.aps 41 | *.ncb 42 | *.opendb 43 | *.opensdf 44 | *.sdf 45 | *.cachefile 46 | *.VC.db 47 | *.VC.VC.opendb 48 | 49 | #MonoDevelop 50 | *.pidb 51 | *.userprefs 52 | 53 | #Tooling 54 | _ReSharper*/ 55 | *.resharper 56 | [Tt]est[Rr]esult* 57 | *.sass-cache 58 | 59 | #Project files 60 | [Bb]uild/ 61 | 62 | #Subversion files 63 | .svn 64 | 65 | # Office Temp Files 66 | ~$* 67 | 68 | # vim Temp Files 69 | *~ 70 | 71 | #NuGet 72 | packages/ 73 | *.nupkg 74 | 75 | #ncrunch 76 | *ncrunch* 77 | *crunch*.local.xml 78 | 79 | # visual studio database projects 80 | *.dbmdl 81 | 82 | #Test files 83 | *.testsettings 84 | 85 | #Other files 86 | *.DotSettings 87 | .vs/ 88 | *project.lock.json 89 | 90 | #Files generated by the VS build 91 | **/Generated Files/** 92 | 93 | -------------------------------------------------------------------------------- /examplenuget/windows/ExperimentalFeatures.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 17 | true 18 | 19 | 25 | false 26 | 27 | 34 | true 35 | 36 | true 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /examplenuget/windows/NuGet.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32929.385 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examplenuget", "examplenuget\examplenuget.vcxproj", "{0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReactNativeXaml", "..\..\node_modules\react-native-xaml\windows\ReactNativeXaml\ReactNativeXaml.vcxproj", "{0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codegen", "..\..\package\Codegen\Codegen.csproj", "{A9EBFB79-DB42-4839-B369-EFA601A98706}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|ARM64 = Debug|ARM64 15 | Debug|x64 = Debug|x64 16 | Debug|x86 = Debug|x86 17 | Release|ARM64 = Release|ARM64 18 | Release|x64 = Release|x64 19 | Release|x86 = Release|x86 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Debug|ARM64.ActiveCfg = Debug|ARM64 23 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Debug|ARM64.Build.0 = Debug|ARM64 24 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Debug|ARM64.Deploy.0 = Debug|ARM64 25 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Debug|x64.ActiveCfg = Debug|x64 26 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Debug|x64.Build.0 = Debug|x64 27 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Debug|x64.Deploy.0 = Debug|x64 28 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Debug|x86.ActiveCfg = Debug|Win32 29 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Debug|x86.Build.0 = Debug|Win32 30 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Debug|x86.Deploy.0 = Debug|Win32 31 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Release|ARM64.ActiveCfg = Release|ARM64 32 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Release|ARM64.Build.0 = Release|ARM64 33 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Release|ARM64.Deploy.0 = Release|ARM64 34 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Release|x64.ActiveCfg = Release|x64 35 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Release|x64.Build.0 = Release|x64 36 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Release|x64.Deploy.0 = Release|x64 37 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Release|x86.ActiveCfg = Release|Win32 38 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Release|x86.Build.0 = Release|Win32 39 | {0E5E86FE-DB24-4DB3-96CF-5F97DA8558F1}.Release|x86.Deploy.0 = Release|Win32 40 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Debug|ARM64.ActiveCfg = Debug|ARM64 41 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Debug|ARM64.Build.0 = Debug|ARM64 42 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Debug|x64.ActiveCfg = Debug|x64 43 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Debug|x64.Build.0 = Debug|x64 44 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Debug|x64.Deploy.0 = Debug|x64 45 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Debug|x86.ActiveCfg = Debug|Win32 46 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Debug|x86.Build.0 = Debug|Win32 47 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Debug|x86.Deploy.0 = Debug|Win32 48 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Release|ARM64.ActiveCfg = Release|ARM64 49 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Release|ARM64.Build.0 = Release|ARM64 50 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Release|x64.ActiveCfg = Release|x64 51 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Release|x64.Build.0 = Release|x64 52 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Release|x64.Deploy.0 = Release|x64 53 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Release|x86.ActiveCfg = Release|Win32 54 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Release|x86.Build.0 = Release|Win32 55 | {0FF7027A-222C-4FFB-8F17-91D18BBAF7A8}.Release|x86.Deploy.0 = Release|Win32 56 | {A9EBFB79-DB42-4839-B369-EFA601A98706}.Debug|ARM64.ActiveCfg = Debug|Any CPU 57 | {A9EBFB79-DB42-4839-B369-EFA601A98706}.Debug|ARM64.Build.0 = Debug|Any CPU 58 | {A9EBFB79-DB42-4839-B369-EFA601A98706}.Debug|x64.ActiveCfg = Debug|Any CPU 59 | {A9EBFB79-DB42-4839-B369-EFA601A98706}.Debug|x64.Build.0 = Debug|Any CPU 60 | {A9EBFB79-DB42-4839-B369-EFA601A98706}.Debug|x86.ActiveCfg = Debug|Any CPU 61 | {A9EBFB79-DB42-4839-B369-EFA601A98706}.Debug|x86.Build.0 = Debug|Any CPU 62 | {A9EBFB79-DB42-4839-B369-EFA601A98706}.Release|ARM64.ActiveCfg = Release|Any CPU 63 | {A9EBFB79-DB42-4839-B369-EFA601A98706}.Release|ARM64.Build.0 = Release|Any CPU 64 | {A9EBFB79-DB42-4839-B369-EFA601A98706}.Release|x64.ActiveCfg = Release|Any CPU 65 | {A9EBFB79-DB42-4839-B369-EFA601A98706}.Release|x64.Build.0 = Release|Any CPU 66 | {A9EBFB79-DB42-4839-B369-EFA601A98706}.Release|x86.ActiveCfg = Release|Any CPU 67 | {A9EBFB79-DB42-4839-B369-EFA601A98706}.Release|x86.Build.0 = Release|Any CPU 68 | EndGlobalSection 69 | GlobalSection(SolutionProperties) = preSolution 70 | HideSolutionNode = FALSE 71 | EndGlobalSection 72 | GlobalSection(ExtensibilityGlobals) = postSolution 73 | SolutionGuid = {D43FAD39-F619-437D-BB40-04A3982ACB6A} 74 | EndGlobalSection 75 | EndGlobal 76 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/.gitignore: -------------------------------------------------------------------------------- 1 | /Bundle 2 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/App.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | 3 | #include "App.h" 4 | 5 | #include "AutolinkedNativeModules.g.h" 6 | #include "ReactPackageProvider.h" 7 | 8 | using namespace winrt; 9 | using namespace xaml; 10 | using namespace xaml::Controls; 11 | using namespace xaml::Navigation; 12 | 13 | using namespace Windows::ApplicationModel; 14 | namespace winrt::examplenuget::implementation 15 | { 16 | /// 17 | /// Initializes the singleton application object. This is the first line of 18 | /// authored code executed, and as such is the logical equivalent of main() or 19 | /// WinMain(). 20 | /// 21 | App::App() noexcept 22 | { 23 | #if BUNDLE 24 | JavaScriptBundleFile(L"index.windows"); 25 | InstanceSettings().UseFastRefresh(false); 26 | #else 27 | JavaScriptBundleFile(L"index"); 28 | InstanceSettings().UseFastRefresh(true); 29 | #endif 30 | 31 | #if _DEBUG 32 | InstanceSettings().UseDirectDebugger(true); 33 | InstanceSettings().UseDeveloperSupport(true); 34 | #else 35 | InstanceSettings().UseDirectDebugger(false); 36 | InstanceSettings().UseDeveloperSupport(false); 37 | #endif 38 | 39 | RegisterAutolinkedNativeModulePackages(PackageProviders()); // Includes any autolinked modules 40 | 41 | PackageProviders().Append(make()); // Includes all modules in this project 42 | 43 | InitializeComponent(); 44 | } 45 | 46 | /// 47 | /// Invoked when the application is launched normally by the end user. Other entry points 48 | /// will be used such as when the application is launched to open a specific file. 49 | /// 50 | /// Details about the launch request and process. 51 | void App::OnLaunched(activation::LaunchActivatedEventArgs const& e) 52 | { 53 | super::OnLaunched(e); 54 | 55 | Frame rootFrame = Window::Current().Content().as(); 56 | rootFrame.Navigate(xaml_typename(), box_value(e.Arguments())); 57 | } 58 | 59 | /// 60 | /// Invoked when the application is activated by some means other than normal launching. 61 | /// 62 | void App::OnActivated(Activation::IActivatedEventArgs const &e) { 63 | auto preActivationContent = Window::Current().Content(); 64 | super::OnActivated(e); 65 | if (!preActivationContent && Window::Current()) { 66 | Frame rootFrame = Window::Current().Content().as(); 67 | rootFrame.Navigate(xaml_typename(), nullptr); 68 | } 69 | } 70 | 71 | /// 72 | /// Invoked when application execution is being suspended. Application state is saved 73 | /// without knowing whether the application will be terminated or resumed with the contents 74 | /// of memory still intact. 75 | /// 76 | /// The source of the suspend request. 77 | /// Details about the suspend request. 78 | void App::OnSuspending([[maybe_unused]] IInspectable const& sender, [[maybe_unused]] SuspendingEventArgs const& e) 79 | { 80 | // Save application state and stop any background activity 81 | } 82 | 83 | /// 84 | /// Invoked when Navigation to a certain page fails 85 | /// 86 | /// The Frame which failed navigation 87 | /// Details about the navigation failure 88 | void App::OnNavigationFailed(IInspectable const&, NavigationFailedEventArgs const& e) 89 | { 90 | throw hresult_error(E_FAIL, hstring(L"Failed to load Page ") + e.SourcePageType().Name); 91 | } 92 | 93 | } // namespace winrt::examplenuget::implementation 94 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/App.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "App.xaml.g.h" 4 | 5 | #include 6 | 7 | namespace activation = winrt::Windows::ApplicationModel::Activation; 8 | 9 | namespace winrt::examplenuget::implementation 10 | { 11 | struct App : AppT 12 | { 13 | App() noexcept; 14 | void OnLaunched(activation::LaunchActivatedEventArgs const&); 15 | void OnActivated(Windows::ApplicationModel::Activation::IActivatedEventArgs const &e); 16 | void OnSuspending(IInspectable const&, Windows::ApplicationModel::SuspendingEventArgs const&); 17 | void OnNavigationFailed(IInspectable const&, xaml::Navigation::NavigationFailedEventArgs const&); 18 | private: 19 | using super = AppT; 20 | }; 21 | } // namespace winrt::examplenuget::implementation 22 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/App.idl: -------------------------------------------------------------------------------- 1 | namespace examplenuget 2 | { 3 | } 4 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/examplenuget/windows/examplenuget/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/examplenuget/windows/examplenuget/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/examplenuget/windows/examplenuget/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/examplenuget/windows/examplenuget/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/examplenuget/windows/examplenuget/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/examplenuget/windows/examplenuget/Assets/StoreLogo.png -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/examplenuget/windows/examplenuget/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/AutolinkedNativeModules.g.cpp: -------------------------------------------------------------------------------- 1 | // AutolinkedNativeModules.g.cpp contents generated by "npx @react-native-community/cli autolink-windows" 2 | // clang-format off 3 | #include "pch.h" 4 | #include "AutolinkedNativeModules.g.h" 5 | 6 | // Includes from react-native-xaml 7 | #include 8 | 9 | namespace winrt::Microsoft::ReactNative 10 | { 11 | 12 | void RegisterAutolinkedNativeModulePackages(winrt::Windows::Foundation::Collections::IVector const& packageProviders) 13 | { 14 | // IReactPackageProviders from react-native-xaml 15 | packageProviders.Append(winrt::ReactNativeXaml::ReactPackageProvider()); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/AutolinkedNativeModules.g.h: -------------------------------------------------------------------------------- 1 | // AutolinkedNativeModules.g.h contents generated by "npx @react-native-community/cli autolink-windows" 2 | // clang-format off 3 | #pragma once 4 | 5 | namespace winrt::Microsoft::ReactNative 6 | { 7 | 8 | void RegisterAutolinkedNativeModulePackages(winrt::Windows::Foundation::Collections::IVector const& packageProviders); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/AutolinkedNativeModules.g.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/AutolinkedNativeModules.g.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {0ff7027a-222c-4ffb-8f17-91d18bbaf7a8} 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/MainPage.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "MainPage.h" 3 | #if __has_include("MainPage.g.cpp") 4 | #include "MainPage.g.cpp" 5 | #endif 6 | 7 | #include "App.h" 8 | 9 | using namespace winrt; 10 | using namespace xaml; 11 | 12 | namespace winrt::examplenuget::implementation 13 | { 14 | MainPage::MainPage() 15 | { 16 | InitializeComponent(); 17 | auto app = Application::Current().as(); 18 | ReactRootView().ReactNativeHost(app->Host()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/MainPage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "MainPage.g.h" 3 | #include 4 | 5 | namespace winrt::examplenuget::implementation 6 | { 7 | struct MainPage : MainPageT 8 | { 9 | MainPage(); 10 | }; 11 | } 12 | 13 | namespace winrt::examplenuget::factory_implementation 14 | { 15 | struct MainPage : MainPageT 16 | { 17 | }; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/MainPage.idl: -------------------------------------------------------------------------------- 1 | #include "NamespaceRedirect.h" 2 | 3 | namespace examplenuget 4 | { 5 | [default_interface] 6 | runtimeclass MainPage : XAML_NAMESPACE.Controls.Page 7 | { 8 | MainPage(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/MainPage.xaml: -------------------------------------------------------------------------------- 1 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | examplenuget 18 | RNX Test Cert 19 | Assets\StoreLogo.png 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 35 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/PropertySheet.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/ReactPackageProvider.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ReactPackageProvider.h" 3 | #include "NativeModules.h" 4 | 5 | using namespace winrt::Microsoft::ReactNative; 6 | 7 | namespace winrt::examplenuget::implementation 8 | { 9 | 10 | void ReactPackageProvider::CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept 11 | { 12 | AddAttributedModules(packageBuilder, true); 13 | } 14 | 15 | } // namespace winrt::examplenuget::implementation 16 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/ReactPackageProvider.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "winrt/Microsoft.ReactNative.h" 4 | 5 | namespace winrt::examplenuget::implementation 6 | { 7 | struct ReactPackageProvider : winrt::implements 8 | { 9 | public: // IReactPackageProvider 10 | void CreatePackage(winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder) noexcept; 11 | }; 12 | } // namespace winrt::examplenuget::implementation 13 | 14 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/examplenuget.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Assets 25 | 26 | 27 | Assets 28 | 29 | 30 | Assets 31 | 32 | 33 | Assets 34 | 35 | 36 | Assets 37 | 38 | 39 | Assets 40 | 41 | 42 | Assets 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {e48dc53e-40b1-40cb-970a-f89935452892} 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /examplenuget/windows/examplenuget/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define NOMINMAX 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | using namespace winrt::Windows::Foundation; 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-xaml-repo", 3 | "version": "0.0.3", 4 | "private": true, 5 | "scripts": { 6 | "build": "tsc --project package", 7 | "change": "beachball change", 8 | "bump": "beachball bump && nuget restore example\\windows && pushd package && yarn codegen && popd" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/microsoft/react-native-xaml.git", 13 | "baseUrl": "https://github.com/microsoft/react-native-xaml" 14 | }, 15 | "license": "MIT", 16 | "workspaces": { 17 | "packages": [ 18 | "example", 19 | "examplenuget", 20 | "package" 21 | ] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /package/.npmignore: -------------------------------------------------------------------------------- 1 | example/ 2 | *.tgz -------------------------------------------------------------------------------- /package/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log - react-native-xaml 2 | 3 | This log was last generated on Thu, 21 Nov 2024 23:01:02 GMT and should not be manually modified. 4 | 5 | 6 | 7 | ## 0.0.79 8 | 9 | Thu, 21 Nov 2024 23:01:02 GMT 10 | 11 | ### Patches 12 | 13 | - [object Object] (virendra.chaudhary@gmail.com) 14 | - Bump to RNW 0.73.21 (jthysell@microsoft.com) 15 | 16 | ## 0.0.78 17 | 18 | Mon, 26 Feb 2024 19:13:51 GMT 19 | 20 | ### Patches 21 | 22 | - Require RNW >= 0.69.0 (jthysell@microsoft.com) 23 | - Remove dependency on @types/react-native (30809111+acoates-ms@users.noreply.github.com) 24 | 25 | ## 0.0.77 26 | 27 | Tue, 06 Feb 2024 18:55:04 GMT 28 | 29 | ### Patches 30 | 31 | - Upgrade to RNW 0.73 (jthysell@microsoft.com) 32 | - Fix EventAttachInfo struct so it holds onto a ref-counted instance of XamlMetadata, as well as removes dangerous pass-by-reference instances when dealing with async code. (maxben@microsoft.com) 33 | 34 | ## 0.0.76 35 | 36 | Tue, 22 Aug 2023 17:45:12 GMT 37 | 38 | ### Patches 39 | 40 | - Fix unquoted properties in vcxproj conditions (jthysell@microsoft.com) 41 | 42 | ## 0.0.75 43 | 44 | Mon, 21 Aug 2023 21:51:27 GMT 45 | 46 | ### Patches 47 | 48 | - Clean up formatting and licenses (jthysell@microsoft.com) 49 | - Upgrade RNX to target RN and RNW 0.72 (jthysell@microsoft.com) 50 | - bump windowsTargetMin (tatianakapos@microsoft.com) 51 | 52 | ## 0.0.74 53 | 54 | Tue, 14 Mar 2023 21:30:43 GMT 55 | 56 | ### Patches 57 | 58 | - simplify overload resolution for SetPropValue (asklar@microsoft.com) 59 | 60 | ## 0.0.73 61 | 62 | Wed, 08 Mar 2023 18:09:16 GMT 63 | 64 | ### Patches 65 | 66 | - Avoid throwing away native module calls. (30809111+acoates-ms@users.noreply.github.com) 67 | 68 | ## 0.0.72 69 | 70 | Thu, 02 Mar 2023 01:29:44 GMT 71 | 72 | ### Patches 73 | 74 | - Upgrade to WinUI 2.7 (jthysell@microsoft.com) 75 | - Upgrade minimum RNW dependency to 0.67.11 (jthysell@microsoft.com) 76 | 77 | ## 0.0.71 78 | 79 | Mon, 07 Nov 2022 22:45:17 GMT 80 | 81 | ### Patches 82 | 83 | - Add target to optionally run CodeGen before ReactNativeXaml build (jthysell@microsoft.com) 84 | - Enable PackageReference support if available (jthysell@microsoft.com) 85 | 86 | ## 0.0.70 87 | 88 | Sun, 25 Sep 2022 05:36:46 GMT 89 | 90 | ### Patches 91 | 92 | - restore OnContentDialogClosed since we need the return value from the show operation (asklar@microsoft.com) 93 | 94 | ## 0.0.69 95 | 96 | Tue, 13 Sep 2022 21:38:24 GMT 97 | 98 | ### Patches 99 | 100 | - Redo typings and how we handle references so that we can call focus (and blur) (asklar@microsoft.com) 101 | 102 | ## 0.0.68 103 | 104 | Fri, 02 Sep 2022 20:18:20 GMT 105 | 106 | ### Patches 107 | 108 | - Fix build break when RNW_REACTTAG_API is defined (jthysell@microsoft.com) 109 | 110 | ## 0.0.67 111 | 112 | Thu, 01 Sep 2022 19:01:22 GMT 113 | 114 | ### Patches 115 | 116 | - Update to consume new ReactTag APIs (jthysell@microsoft.com) 117 | 118 | ## 0.0.66 119 | 120 | Tue, 30 Aug 2022 19:18:51 GMT 121 | 122 | ### Patches 123 | 124 | - Adjust TSTypes (34109996+chiaramooney@users.noreply.github.com) 125 | 126 | ## 0.0.65 127 | 128 | Tue, 30 Aug 2022 00:15:16 GMT 129 | 130 | ### Patches 131 | 132 | - codeql_fix (agnel@microsoft.com) 133 | 134 | ## 0.0.64 135 | 136 | Tue, 21 Jun 2022 18:27:36 GMT 137 | 138 | ### Patches 139 | 140 | - Add support for MenuFlyoutSubitem (asklar@microsoft.com) 141 | 142 | ## 0.0.63 143 | 144 | Wed, 13 Apr 2022 21:16:52 GMT 145 | 146 | ### Patches 147 | 148 | - Remove implicit dependency on ColorHelper (asklar@microsoft.com) 149 | 150 | ## 0.0.62 151 | 152 | Sun, 20 Feb 2022 03:58:46 GMT 153 | 154 | ### Patches 155 | 156 | - Export event args types from Types.tsx as well so they can be mentioned in apps (asklar@microsoft.com) 157 | 158 | ## 0.0.61 159 | 160 | Mon, 14 Feb 2022 08:09:35 GMT 161 | 162 | ### Patches 163 | 164 | - Fix some prop types not being codegen'd because they are treated as nullable, like Color (asklar@microsoft.com) 165 | 166 | ## 0.0.60 167 | 168 | Thu, 10 Feb 2022 17:17:17 GMT 169 | 170 | ### Patches 171 | 172 | - Fix Bug in MenuBar (34109996+chiaramooney@users.noreply.github.com) 173 | 174 | ## 0.0.59 175 | 176 | Thu, 27 Jan 2022 14:11:26 GMT 177 | 178 | ### Patches 179 | 180 | - Reorder TS enums to work around babel bug (asklar@microsoft.com) 181 | 182 | ## 0.0.58 183 | 184 | Wed, 26 Jan 2022 23:21:29 GMT 185 | 186 | ### Patches 187 | 188 | - format (asklar@microsoft.com) 189 | 190 | ## 0.0.57 191 | 192 | Mon, 24 Jan 2022 21:16:18 GMT 193 | 194 | ### Patches 195 | 196 | - Codegen event arg methods (asklar@microsoft.com) 197 | 198 | ## 0.0.56 199 | 200 | Fri, 21 Jan 2022 17:41:16 GMT 201 | 202 | ### Patches 203 | 204 | - Update version (asklar@microsoft.com) 205 | 206 | ## 0.0.54 207 | 208 | Fri, 21 Jan 2022 02:47:33 GMT 209 | 210 | ### Patches 211 | 212 | - Enable calling some methods on EventArgs objects (asklar@microsoft.com) 213 | 214 | ## 0.0.53 215 | 216 | Sat, 13 Nov 2021 02:37:41 GMT 217 | 218 | ### Patches 219 | 220 | - MenuFlyout ShowAt command (asklar@microsoft.com) 221 | 222 | ## 0.0.52 223 | 224 | Thu, 11 Nov 2021 22:24:47 GMT 225 | 226 | ### Patches 227 | 228 | - Support infobar ActionButton (asklar@microsoft.com) 229 | 230 | ## 0.0.51 231 | 232 | Sun, 07 Nov 2021 21:01:35 GMT 233 | 234 | ### Patches 235 | 236 | - ado pipeline builds nuget example (asklar@microsoft.com) 237 | 238 | ## 0.0.50 239 | 240 | Fri, 05 Nov 2021 22:29:53 GMT 241 | 242 | ### Patches 243 | 244 | - Include version information in the DLL (asklar@microsoft.com) 245 | 246 | ## 0.0.49 247 | 248 | Fri, 05 Nov 2021 17:42:39 GMT 249 | 250 | ### Patches 251 | 252 | - Introduce MenuFlyoutPriority (asklar@microsoft.com) 253 | 254 | ## 0.0.48 255 | 256 | Fri, 05 Nov 2021 16:43:47 GMT 257 | 258 | ### Patches 259 | 260 | - Fix isOpen (asklar@microsoft.com) 261 | - MenuFlyoutItem Icon support (asklar@microsoft.com) 262 | 263 | ## 0.0.47 264 | 265 | Fri, 05 Nov 2021 04:42:35 GMT 266 | 267 | ### Patches 268 | 269 | - MenuFlyoutItem Icon support (asklar@microsoft.com) 270 | - Support SVG and PNG inline data (asklar@microsoft.com) 271 | - MenuFlyoutItem Icon support (asklar@microsoft.com) 272 | 273 | ## 0.0.46 274 | 275 | Tue, 05 Oct 2021 19:13:22 GMT 276 | 277 | ### Patches 278 | 279 | - Use beachball (asklar@microsoft.com) 280 | -------------------------------------------------------------------------------- /package/Codegen/Codegen.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net6.0 6 | preview 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | PreserveNewest 16 | 17 | 18 | 19 | 20 | 21 | True 22 | True 23 | TypeEnums.tt 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | True 39 | True 40 | EventArgsTypeProperties.tt 41 | 42 | 43 | True 44 | True 45 | TSEnums.tt 46 | 47 | 48 | True 49 | True 50 | TSProps.tt 51 | 52 | 53 | True 54 | True 55 | TypeCreator.tt 56 | 57 | 58 | True 59 | True 60 | TypeEnums.tt 61 | 62 | 63 | True 64 | True 65 | TypeEvents.tt 66 | 67 | 68 | True 69 | True 70 | TypeProperties.tt 71 | 72 | 73 | True 74 | True 75 | TSTypes.tt 76 | 77 | 78 | True 79 | True 80 | VersionHeader.tt 81 | 82 | 83 | 84 | 85 | 86 | TextTemplatingFilePreprocessor 87 | EventArgsTypeProperties.cs 88 | 89 | 90 | TextTemplatingFilePreprocessor 91 | TSEnums.cs 92 | 93 | 94 | TextTemplatingFilePreprocessor 95 | TSProps.cs 96 | 97 | 98 | TextTemplatingFilePreprocessor 99 | TypeCreator.cs 100 | 101 | 102 | TextTemplatingFilePreprocessor 103 | TypeEnums.cs 104 | 105 | 106 | TextTemplatingFilePreprocessor 107 | TypeEvents.cs 108 | 109 | 110 | TextTemplatingFilePreprocessor 111 | TypeProperties.cs 112 | 113 | 114 | TextTemplatingFilePreprocessor 115 | TSTypes.cs 116 | 117 | 118 | TextTemplatingFilePreprocessor 119 | VersionHeader.cs 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /package/Codegen/EventArgsTypeProperties.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" linePragmas="false" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | #pragma once 7 | #include "pch.h" 8 | #include "XamlMetadata.h" 9 | #include "Crc32Str.h" 10 | 11 | /************************************************************* 12 | THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY 13 | SOURCE WINMDS USED: 14 | <# 15 | foreach (var winmd in WinMDs) { 16 | #> 17 | - <#= winmd #> 18 | <# 19 | } 20 | #> 21 | **************************************************************/ 22 | 23 | <# foreach (var ns in Properties.Select(p => p.DeclaringType.GetNamespace()).Distinct()) { #> 24 | #include .h> 25 | <# } #> 26 | 27 | struct EventArgsProperty { 28 | const char* const name; 29 | 30 | using isType_t = bool (*) (const winrt::Windows::Foundation::IInspectable& ea); 31 | const isType_t isType; 32 | 33 | using getter_t = winrt::Windows::Foundation::IInspectable (*) (const winrt::Windows::Foundation::IInspectable& ea); 34 | const getter_t getter; 35 | }; 36 | 37 | const EventArgsProperty eventArgsProperties[] = { 38 | <# foreach (var prop in Properties) { 39 | if (prop.Property != null) { #> 40 | { "<#= Util.ToJsName(prop.Name) #>", IsType<<#= Util.GetCppWinRTType(prop.DeclaringType) #>>, [](const winrt::Windows::Foundation::IInspectable& obj) { auto ea = obj.as<<#= Util.GetCppWinRTType(prop.DeclaringType) #>>(); return <#= Util.MaybeBox("ea", prop.Property) #>; } }, 41 | <# } else { #> 42 | { "<#= Util.ToJsName(prop.Name) #>", IsType<<#= Util.GetCppWinRTType(prop.DeclaringType) #>>, [](const winrt::Windows::Foundation::IInspectable& obj) { auto ea = obj.as<<#= Util.GetCppWinRTType(prop.DeclaringType) #>>(); return Get<#= prop.Name #>_<#= prop.DeclaringType.GetName() #>(); }, 43 | <#} #> 44 | <# } #> 45 | }; 46 | 47 | struct EventArgsMethod { 48 | const char* const name; 49 | 50 | using isType_t = bool (*) (const winrt::Windows::Foundation::IInspectable& ea); 51 | const isType_t isType; 52 | 53 | using getter_t = facebook::jsi::Value(*) (facebook::jsi::Runtime& rt, std::shared_ptr thisVal, const facebook::jsi::Value* args, size_t count); 54 | const getter_t getter; 55 | }; 56 | 57 | <# foreach (var t in Util.eventArgsMethods) { 58 | foreach (var m in t.Value) { 59 | #> 60 | facebook::jsi::Value <#= t.Key.Replace(".", "_") #>_<#= m #>(facebook::jsi::Runtime& rt, std::shared_ptr thisVal, const facebook::jsi::Value* args, size_t count); 61 | <# } } #> 62 | 63 | const EventArgsMethod eventArgsMethods[] = { 64 | <# foreach (var t in Util.eventArgsMethods) { 65 | foreach (var m in t.Value) { 66 | #> 67 | { "<#= m #>", IsType<<#= Util.GetCppWinRTType(t.Key) #>>, <#= t.Key.Replace(".", "_") #>_<#= m #> }, 68 | <# } } #> 69 | }; 70 | -------------------------------------------------------------------------------- /package/Codegen/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Codegen": { 4 | "commandName": "Project", 5 | "commandLineArgs": "-verbose -winmd %USERPROFILE%\\.nuget\\packages\\microsoft.ui.xaml\\2.8.0\\lib\\uap10.0\\Microsoft.UI.Xaml.winmd" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /package/Codegen/SyntheticProperty.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | 6 | using MiddleweightReflection; 7 | 8 | namespace Codegen 9 | { 10 | public class SyntheticProperty : IEquatable 11 | { 12 | public string Name { get; set; } 13 | public MrType DeclaringType { get; set; } 14 | public MrProperty Property { get; set; } 15 | public MrType PropertyType { get; set; } 16 | public string FakePropertyType { get; set; } 17 | public string Comment { get; set; } 18 | 19 | public string SimpleName { get => Name.Substring(Name.LastIndexOf('.') + 1); } 20 | public string SimpleNameForJs 21 | { 22 | get 23 | { 24 | if (Property != null) 25 | { 26 | string fullPropertyName = Property.DeclaringType.GetFullName() + "." + Property.GetName(); 27 | 28 | if (Util.propNameMap.TryGetValue(fullPropertyName, out string realName)) 29 | { 30 | return realName.Substring(realName.LastIndexOf('.') + 1); 31 | } 32 | else if (Util.IsDependencyProperty(Property)) 33 | { 34 | return Property.DeclaringType.GetName() + SimpleName; 35 | } 36 | } 37 | return SimpleName; 38 | } 39 | } 40 | 41 | public bool Equals(SyntheticProperty other) 42 | { 43 | return SimpleName == other.SimpleName; 44 | } 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /package/Codegen/TSEnums.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" linePragmas="false" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | 7 | /************************************************************* 8 | THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY 9 | SOURCE WINMDS USED: 10 | <# 11 | foreach (var winmd in WinMDs) { 12 | #> 13 | - <#= winmd #> 14 | <# 15 | } 16 | #> 17 | **************************************************************/ 18 | 19 | <# 20 | var enumsToGenerateConvertersFor = Util.GetEnums(); 21 | foreach (var enumType in enumsToGenerateConvertersFor) { 22 | var ns = Util.GetTSNamespace(enumType); 23 | if (ns != "") { #> 24 | export namespace <#= ns #>Enums { 25 | <# } #> 26 | export enum <#= Util.ToJsName(enumType) #> { 27 | <# foreach (var value in enumType.GetFields().Skip(1)) { #> 28 | <#= value.GetName() #> = <#= (int)value.GetConstantValue(out System.Reflection.Metadata.ConstantTypeCode typeCode) #>, 29 | <# } #>} 30 | <# if (ns != "") { #> 31 | } 32 | 33 | <# } #> 34 | <# } #> 35 | 36 | 37 | <# foreach (var enumType in Util.fakeEnums) { #> 38 | export enum <#= enumType.Name #> { 39 | <# foreach (var value in enumType.Values) { #> 40 | <#= value.Key #> = <#= value.Value #>, 41 | <# } #> 42 | } 43 | 44 | <# } #> 45 | -------------------------------------------------------------------------------- /package/Codegen/TSProps.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" linePragmas="false" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | 7 | /************************************************************* 8 | THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY 9 | SOURCE WINMDS USED: 10 | <# 11 | foreach (var winmd in WinMDs) { 12 | #> 13 | - <#= winmd #> 14 | <# 15 | } 16 | #> 17 | **************************************************************/ 18 | 19 | import type { ViewProps, NativeSyntheticEvent, ColorValue } from 'react-native'; 20 | import type * as Enums from './Enums'; 21 | 22 | export type Thickness = number | { left?: number, top?: number, right?: number, bottom?: number }; 23 | 24 | export type GridLength = number | '*' | 'auto' | `${number}*`; 25 | 26 | export type CornerRadius = number | { topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number}; 27 | 28 | export type Point = { x: number, y: number }; 29 | 30 | export type Color = { a: number, r: number, g: number, b: number }; 31 | 32 | export type TypedEvent = { 33 | sender: any; 34 | args: TArgs; 35 | } 36 | 37 | <# foreach (var t in Util.eventArgsTypes) { 38 | var ns = Util.GetTSNamespace(t); 39 | if (ns != "") { #> 40 | export namespace Native<#= ns #> { 41 | <# } #> 42 | export type Native<#= Util.ToJsName(t) #> = { 43 | <# foreach (var m in Util.GetEventArgsMethods(t.GetFullName())) { #> 44 | <#= m #>(<#= Util.GetEventArgsMethodArgs(t, m) #>): <#= Util.GetEventArgsMethodReturnType(t, m) #> 45 | <# } 46 | foreach (var prop in t.GetProperties().Where(p => Util.IsInstanceProperty(p))) { 47 | var tsType = Util.GetTypeScriptType(prop); 48 | if (tsType != "any") { 49 | #> 50 | readonly <#= Util.ToJsName(prop) #>: <#= tsType #>; 51 | <# 52 | } 53 | } 54 | #> 55 | } 56 | <# if (ns != "") { #> 57 | } 58 | <# } #> 59 | <# } #> 60 | 61 | <# var derived = Util.GetDerivedTypes(Types); 62 | foreach (var type in Types) { #> 63 | <# var ns = Util.GetTSNamespace(type); 64 | if (ns != "") { #> 65 | export namespace Native<#= ns #> { 66 | <# } #> 67 | export interface Native<#= Util.ToJsName(type) #>Props extends <#= Util.GetBaseClassProps(type) #> { 68 | <# var typeProp = Util.GetJsTypeProperty(type, derived); 69 | if (typeProp != "") { #> 70 | type: <#= typeProp #>; 71 | <# } 72 | foreach (var prop in type.GetProperties().Where(p => Util.ShouldEmitPropertyMetadata(p))) { #> 73 | <#= Util.ToJsName(prop) #>?: <#= Util.GetTypeScriptType(prop) #>; 74 | <# } 75 | foreach (var prop in FakeProps.Where(p => type == p.DeclaringType)) { #> 76 | <#= Util.ToJsName(prop) #>?: <#= Util.GetTypeScriptType(prop) #>; // synthetic property 77 | <# } 78 | foreach (var prop in SyntheticProps.Where(p => type == p.DeclaringType)) { #> 79 | /** 80 | * <#= prop.Comment #> 81 | */ 82 | <#= Util.ToJsName(prop.Name) #>?: <#= Util.GetTypeScriptType(prop) #>; // synthetic property 83 | <# } 84 | foreach (var attachedDP in Util.AttachedProperties.Where(p => Properties.Any(sp => sp.Property == p && sp.DeclaringType == type))) {#> 85 | <#= Util.ToJsName(attachedDP) #>?: <#= Util.GetTypeScriptType(attachedDP) #>; // attached property 86 | <# } 87 | foreach (var evt in type.GetEvents()) { #> 88 | on<#= evt.GetName() #>?: (event: NativeSyntheticEvent<<#= Util.GetEventArgsTSName(evt, "Native") #>>) => void; 89 | <# } 90 | foreach (var evt in SyntheticEvents.Where(e => type == e.DeclaringType)) { #> 91 | on<#= evt.Name #>?: (event: NativeSyntheticEvent<<#= Util.GetTypeScriptType(evt) #>>) => void; 92 | <# } #> 93 | } 94 | <# if (ns != "") { #> 95 | } 96 | <# } #> 97 | <# } #> 98 | 99 | export type XamlControlProps =<# var first = true; foreach (var type in Types) { 100 | if (Util.HasCtor(type) || !type.IsSealed) { 101 | if (!first) #> | <# ; 102 | 103 | first = false; 104 | #> <#= Util.GetNativePropsName(type) #> 105 | <# } 106 | } #>; 107 | 108 | 109 | -------------------------------------------------------------------------------- /package/Codegen/TSTypes.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" linePragmas="false" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | 7 | /************************************************************* 8 | THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY 9 | SOURCE WINMDS USED: 10 | <# 11 | foreach (var winmd in WinMDs) { 12 | #> 13 | - <#= winmd #> 14 | <# 15 | } 16 | #> 17 | **************************************************************/ 18 | 19 | import type { 20 | // Controls 21 | <# foreach (var type in Types.Where(t => Util.HasCtor(t) && Util.GetTSNamespace(t) == "")) { #> 22 | <#= Util.GetNativePropsName(type) #>, 23 | <# } #> 24 | 25 | // EventArgs 26 | <# foreach (var type in Util.eventArgsTypes.Where(t => Util.GetTSNamespace(t) == "")) { #> 27 | Native<#= type.GetName() #>, 28 | <# } #> 29 | } from './Props'; 30 | 31 | <# foreach (var ns in Types.Where(t => Util.HasCtor(t) && Util.GetTSNamespace(t) != "").Union(Util.eventArgsTypes.Where(t => Util.GetTSNamespace(t) != "")).Select(t => Util.GetTSNamespace(t)).Distinct()) { #> 32 | import type { Native<#= ns #> } from './Props'; 33 | <# } #> 34 | 35 | import React, { ForwardRefExoticComponent, RefAttributes } from 'react'; 36 | import { NativeXamlControl } from './NativeXamlControl'; 37 | import { findNodeHandle, NativeMethods, UIManager } from 'react-native'; 38 | 39 | import type { Point, Color } from './Props'; 40 | 41 | export type { Point, Color }; 42 | 43 | <# 44 | foreach (var type in Types.Where(t => Util.HasCtor(t))) { 45 | var ns = Util.GetTSNamespace(type); 46 | var PropsTypeName = $"{Util.ToJsName(type)}Props"; 47 | var RefTypeName = $"{Util.ToJsName(type)}Ref"; 48 | var PartialTypeName = $"_{Util.ToJsName(type)}"; 49 | var NativePropsName = Util.GetNativePropsName(type); 50 | if (ns != "") { #> 51 | export namespace <#= ns #> { 52 | <# } #> 53 | export type <#= PropsTypeName #> = Omit<<#= NativePropsName #>, 'type'>; 54 | export type <#= RefTypeName #> = React.Component<<#= NativePropsName #>> & Readonly; 55 | <# 56 | var commands = Util.GetCommands(type.GetFullName()); 57 | string NativeMethodsFor = commands.Count() == 0 ? string.Empty : $" & NativeMethodsFor_{Util.ToJsName(type)}"; 58 | string PartialNativeMethodsFor = commands.Count() == 0 ? string.Empty : $" & Partial"; 59 | 60 | if (NativeMethodsFor != string.Empty) { 61 | #> 62 | export interface NativeMethodsFor_<#= Util.ToJsName(type) #> { 63 | <# foreach (var command in commands) { #> 64 | <#= command.Name #>: (ref: React.RefObject<<#= RefTypeName #>>, args: <#= command.TSArgTypes != null ? command.TSArgTypes : "any[]" #>) => void; 65 | <# } #> 66 | } 67 | <# } #> 68 | const <#= PartialTypeName #> : (ForwardRefExoticComponent> & RefAttributes<<#= RefTypeName #>>><#= PartialNativeMethodsFor #>) = React.forwardRef((props: React.PropsWithChildren<<#= PropsTypeName #>>, ref: React.ForwardedRef<<#= RefTypeName #>>) => ); 69 | <# 70 | foreach (var command in commands) { #> 71 | <#= PartialTypeName #>.<#= command.Name #> = (ref: React.RefObject<<#= RefTypeName #>>, args: <#= command.TSArgTypes != null ? command.TSArgTypes : "any[]" #>) => { 72 | const tag = findNodeHandle(ref.current); 73 | UIManager.dispatchViewManagerCommand(tag, UIManager.getViewManagerConfig('XamlControl').Commands.<#= command.Name #>, <#= command.TSArgTypes != null ? "[args]" : "args" #>); 74 | }; 75 | <# } #> 76 | export const <#= Util.ToJsName(type) #> = (<#= PartialTypeName #> as (ForwardRefExoticComponent> & RefAttributes<<#= RefTypeName #>>><#= NativeMethodsFor #>)); 77 | 78 | <# if (ns != "") { #> 79 | } 80 | <# } #> 81 | <# 82 | } #> 83 | 84 | <# 85 | foreach (var ea in Util.eventArgsTypes) { 86 | var ns = Util.GetTSNamespace(ea); 87 | if (ns != "") { #> 88 | export namespace <#= ns #> { 89 | <# 90 | } 91 | #> 92 | export type <#= ea.GetName() #> = <#= Util.GetEventArgsTSType(ea, "Native") #>; // <#= ea.GetFullName() #> 93 | <# if (ns != "") { #> 94 | } 95 | <# } #> 96 | <# 97 | } #> -------------------------------------------------------------------------------- /package/Codegen/TypeCreator.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" linePragmas="false" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | #include "pch.h" 7 | #include "XamlMetadata.h" 8 | #include "Crc32Str.h" 9 | #include 10 | 11 | <# foreach (var ns in Types.Select(x => x.GetNamespace()).Distinct()) { #> 12 | #include "winrt/<#= ns #>.h" 13 | <# } #> 14 | 15 | /************************************************************* 16 | THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY 17 | SOURCE WINMDS USED: 18 | <# 19 | foreach (var winmd in WinMDs) { 20 | #> 21 | - <#= winmd #> 22 | <# 23 | } 24 | #> 25 | **************************************************************/ 26 | 27 | winrt::Windows::Foundation::IInspectable XamlMetadata::Create(const std::string_view& typeName) const { 28 | wchar_t buf[128]{}; 29 | for (size_t i = 0; i < typeName.size() && i < ARRAYSIZE(buf) - 1; i++) { 30 | buf[i] = static_cast(typeName[i]); 31 | } 32 | 33 | HSTRING clsid = nullptr; 34 | if (SUCCEEDED(WindowsCreateString(buf, static_cast(wcslen(buf)), &clsid))) { 35 | winrt::com_ptr<::IInspectable> insp{ nullptr }; 36 | if (SUCCEEDED(RoActivateInstance(clsid, insp.put()))) { 37 | winrt::IUnknown unk{ nullptr }; 38 | winrt::copy_from_abi(unk, insp.get()); 39 | WindowsDeleteString(clsid); 40 | return unk.as(); 41 | } else { 42 | // type probably has a custom activation factory, use C++/WinRT to create it 43 | WindowsDeleteString(clsid); 44 | clsid = nullptr; 45 | const auto key = COMPILE_TIME_CRC32_STR(typeName.data()); 46 | switch (key) { 47 | <# foreach (var t in Types.Where(t => Util.GetComposableFactoryType(t) != null)) { #> 48 | case COMPILE_TIME_CRC32_STR("<#= t.GetFullName() #>"): { return <#= Util.GetCppWinRTType(t) #>(); } 49 | <# } #> 50 | } 51 | } 52 | } 53 | assert(false && "xaml type not found"); 54 | return nullptr; 55 | } 56 | 57 | 58 | -------------------------------------------------------------------------------- /package/Codegen/TypeEnums.tt: -------------------------------------------------------------------------------- 1 | <#@ template debug="false" hostspecific="false" language="C#" linePragmas="false" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".h" #> 7 | #pragma once 8 | /************************************************************* 9 | THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY 10 | SOURCE WINMDS USED: 11 | <# 12 | foreach (var winmd in WinMDs) { 13 | #> 14 | - <#= winmd #> 15 | <# 16 | } 17 | #> 18 | **************************************************************/ 19 | 20 | <# foreach (var p in Util.fakeEnums.Where(p => p.Name.EndsWith("Priority"))) { #> 21 | enum class <#= p.Name #> { 22 | <# foreach (var value in p.Values) { #> 23 | <#= value.Key #> = <#= value.Value #>, 24 | <# } #> 25 | }; 26 | 27 | <# } #> 28 | -------------------------------------------------------------------------------- /package/Codegen/TypeEvents.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" linePragmas="false" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | #pragma once 7 | #include "pch.h" 8 | #include "XamlMetadata.h" 9 | #include "Serialize.h" 10 | #include "Crc32Str.h" 11 | #include 12 | 13 | /************************************************************* 14 | THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY 15 | SOURCE WINMDS USED: 16 | <# 17 | foreach (var winmd in WinMDs) { 18 | #> 19 | - <#= winmd #> 20 | <# 21 | } 22 | #> 23 | **************************************************************/ 24 | 25 | <# foreach (var ns in Events.Select(p => p.DeclaringType.GetNamespace()).Distinct()) { #> 26 | #include .h> 27 | <# } #> 28 | #include .Input.h> 29 | 30 | /////// Events 31 | template 32 | void SerializeEventArgs(winrt::Microsoft::ReactNative::IJSValueWriter const& writer, const winrt::Windows::Foundation::IInspectable& sender, const TArgs& args); 33 | 34 | 35 | template 36 | __declspec(noinline) T DoTheTypeChecking(const winrt::Windows::Foundation::IInspectable& ii, bool isWrapped) { 37 | auto o = isWrapped ? Unwrap(ii) : ii.try_as(); 38 | return o; 39 | } 40 | 41 | template 42 | __declspec(noinline) void DispatchTheEvent(const EventAttachInfo eai, const winrt::Windows::Foundation::IInspectable& sender, const T& args) { 43 | auto senderAsFE = sender.try_as(); 44 | auto wEN = winrt::to_hstring(eai.jsEventName); 45 | if (eai.xamlMetadata->m_receiveEvent.has_value()) { 46 | const auto tag = XamlMetadata::TagFromElement(eai.obj.as()); 47 | ExecuteJsi(eai.context, [metadata = eai.xamlMetadata, tag, senderAsFE, args, eventName = eai.jsEventName](facebook::jsi::Runtime& rt) { 48 | auto objSender = std::make_shared(senderAsFE, metadata); 49 | auto objArgs = std::make_shared(args, metadata); 50 | auto obj = std::make_shared(rt); 51 | obj->setProperty(rt, "sender", rt.global().createFromHostObject(rt, objSender)); 52 | obj->setProperty(rt, "args", rt.global().createFromHostObject(rt, objArgs)); 53 | 54 | metadata->JsiDispatchEvent(rt, tag, std::string(eventName), obj); 55 | }); 56 | } 57 | else { 58 | XamlUIService::FromContext(eai.context).DispatchEvent(eai.obj.try_as(), wEN.c_str(), 59 | [senderAsFE, args](const winrt::Microsoft::ReactNative::IJSValueWriter& evtDataWriter) { 60 | SerializeEventArgs(evtDataWriter, senderAsFE, args); 61 | }); 62 | } 63 | }; 64 | 65 | /*static*/ const EventInfo EventInfo::xamlEventMap[] = { 66 | <# foreach (var evt in Events) { #> 67 | {"<#= evt.GetName() #>", [](const EventAttachInfo eai, bool isWrapped, winrt::event_token token) noexcept { 68 | if (const auto& c = DoTheTypeChecking<<#= Util.GetCppWinRTType(evt.DeclaringType) #>>(eai.obj, isWrapped)) { 69 | if (!token) { 70 | return c.<#= evt.GetName() #>([eai] (<#= Util.GetCppWinRTEventSignature(evt) #>) noexcept { 71 | DispatchTheEvent(eai, sender, args); 72 | }); 73 | } else { 74 | c.<#= evt.GetName() #>(token); 75 | return winrt::event_token{ -1 }; 76 | } 77 | } 78 | return winrt::event_token{0}; 79 | } }, 80 | <# } #> 81 | <# foreach (var evt in SyntheticEvents) { #> 82 | {"<#= evt.Name #>", nullptr /* synthetic event */}, 83 | <# } #> 84 | }; 85 | 86 | static_assert(ARRAYSIZE(EventInfo::xamlEventMap) == <#= Events.Count() + SyntheticEvents.Count() #>); 87 | 88 | void JsEvent(winrt::Microsoft::ReactNative::IJSValueWriter const& constantWriter, std::wstring topName, std::wstring onName) { 89 | constantWriter.WritePropertyName(topName); 90 | constantWriter.WriteObjectBegin(); 91 | WriteProperty(constantWriter, L"registrationName", onName); 92 | constantWriter.WriteObjectEnd(); 93 | } 94 | 95 | #define JS_EVENT(evtName) JsEvent(constantWriter, L"top" L#evtName, L"on" L#evtName) 96 | 97 | ConstantProviderDelegate GetEvents = 98 | [](winrt::Microsoft::ReactNative::IJSValueWriter const& constantWriter) { 99 | for (auto const& e : EventInfo::xamlEventMap) { 100 | auto wideName = std::wstring(winrt::to_hstring(e.name)); 101 | JsEvent(constantWriter, L"top" + wideName, L"on" + wideName); 102 | } 103 | }; 104 | 105 | void XamlMetadata::PopulateNativeEvents(winrt::Windows::Foundation::Collections::IMap& nativeProps) const { 106 | for (const auto& evtInfo : EventInfo::xamlEventMap) { 107 | auto jsEvtName = L"on" + winrt::to_hstring(evtInfo.name); 108 | nativeProps.Insert(jsEvtName, ViewManagerPropertyType::Boolean); 109 | } 110 | } 111 | 112 | -------------------------------------------------------------------------------- /package/Codegen/TypeProperties.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" linePragmas="false" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | #pragma once 7 | #include "pch.h" 8 | #include "XamlMetadata.h" 9 | #include "Crc32Str.h" 10 | 11 | /************************************************************* 12 | THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY 13 | SOURCE WINMDS USED: 14 | <# 15 | foreach (var winmd in WinMDs) { 16 | #> 17 | - <#= winmd #> 18 | <# 19 | } 20 | #> 21 | **************************************************************/ 22 | 23 | <# foreach (var ns in Properties.Select(p => p.DeclaringType.GetNamespace()).Distinct()) { #> 24 | #include .h> 25 | <# } #> 26 | 27 | template 28 | winrt::Windows::Foundation::IInspectable AsType(const winrt::Windows::Foundation::IInspectable& o) { 29 | return o.try_as(); 30 | } 31 | 32 | template 33 | winrt::Windows::Foundation::IInspectable AsUnwrappedType(const winrt::Windows::Foundation::IInspectable& o) { 34 | return Unwrap(o); 35 | } 36 | 37 | /*static*/ const PropInfo xamlPropertyMap[] = { 38 | <# foreach (var p in Properties) { #> 39 | { MAKE_KEY("<#= Util.ToJsName(p) #>"), <#= (Util.DerivesFrom(p.DeclaringType, $"{XamlNames.XamlNamespace}.FrameworkElement") || p.DeclaringType.GetName() == "UIElement") ? "AsType" : "AsUnwrappedType" #><<#= Util.GetCppWinRTType(p.DeclaringType) #>>, []() { return <#= Util.GetCppWinRTType(p.Property != null ? p.Property.DeclaringType : p.DeclaringType) #>::<#= p.SimpleName #>Property(); }, SetPropValue<<#= p.PropertyType != null ? Util.GetCppWinRTType(p.PropertyType) : Util.GetCppWinRTType(p.Property.GetPropertyType()) #>>, ViewManagerPropertyType::<#= Util.GetVMPropertyType(p) #> }, 40 | <# } #> 41 | }; 42 | 43 | <# foreach (var p in FakeProps) { #> 44 | void Set<#= p.GetName() #>_<#= p.DeclaringType.GetName() #>(const xaml::DependencyObject& o, const xaml::DependencyProperty&, const winrt::Microsoft::ReactNative::JSValue& v, const winrt::Microsoft::ReactNative::IReactContext& reactContext); 45 | <# } #> 46 | 47 | <# foreach (var p in SyntheticProps) { #> 48 | void Set<#= p.Name #>_<#= p.DeclaringType.GetName() #>(const xaml::DependencyObject& o, const xaml::DependencyProperty&, const winrt::Microsoft::ReactNative::JSValue& v, const winrt::Microsoft::ReactNative::IReactContext& reactContext); 49 | <# } #> 50 | 51 | /*static*/ const PropInfo fakeProps[] = { 52 | <# foreach (var p in FakeProps) { #> 53 | { MAKE_KEY("<#= Util.ToJsName(p) #>"), AsUnwrappedType<<#= Util.GetCppWinRTType(p.DeclaringType) #>>, nullptr, Set<#= p.GetName() #>_<#= p.DeclaringType.GetName() #>, ViewManagerPropertyType::<#= Util.GetVMPropertyType(p) #> }, 54 | <# } #> 55 | <# foreach (var p in SyntheticProps) { #> 56 | { MAKE_KEY("<#= Util.ToJsName(p.Name) #>"), AsType<<#= Util.GetCppWinRTType(p.DeclaringType) #>>, nullptr, Set<#= p.Name #>_<#= p.DeclaringType.GetName() #>, ViewManagerPropertyType::<#= Util.GetVMPropertyType(p) #> }, 57 | <# } #> 58 | 59 | }; 60 | 61 | #ifdef USE_CRC32 62 | void XamlMetadata::PopulateNativeProps(winrt::Windows::Foundation::Collections::IMap& nativeProps) const { 63 | <# foreach (var p in Properties.Distinct(new NameEqualityComparer())) { #> 64 | nativeProps.Insert(winrt::to_hstring("<#= Util.ToJsName(p) #>"), ViewManagerPropertyType::<#= Util.GetVMPropertyType(p) #>); 65 | <# } #> 66 | } 67 | #else 68 | void XamlMetadata::PopulateNativeProps(winrt::Windows::Foundation::Collections::IMap& nativeProps) const { 69 | for (auto const& entry : xamlPropertyMap) { 70 | nativeProps.Insert(winrt::to_hstring(entry.propName), entry.jsType); 71 | } 72 | for (auto const& entry : fakeProps) { 73 | nativeProps.Insert(winrt::to_hstring(entry.propName), entry.jsType); 74 | } 75 | } 76 | #endif 77 | 78 | 79 | struct XamlCommand { 80 | const char* name; 81 | void (*pfn)(FrameworkElement fe, const winrt::Microsoft::ReactNative::JSValueArray& args, const XamlMetadata& xaml) noexcept; 82 | }; 83 | 84 | <# foreach (var kv in Util.commands) { #> 85 | <# foreach (var command in kv.Value) { #> 86 | void <#= command.Name #>Command(FrameworkElement fe, const winrt::Microsoft::ReactNative::JSValueArray& /* args */, const XamlMetadata& xaml) noexcept; 87 | <# } } #> 88 | 89 | const XamlCommand xamlCommands[] = { 90 | <# foreach (var kv in Util.commands) { #> 91 | <# foreach (var command in kv.Value) { #> 92 | { "<#= command.Name #>", <#= command.Name #>Command}, 93 | <# } #> 94 | <# } #> 95 | }; 96 | 97 | void XamlMetadata::PopulateCommands(const winrt::Windows::Foundation::Collections::IVector& commands) const { 98 | for (auto const& entry : xamlCommands) { 99 | commands.Append(winrt::to_hstring(entry.name)); 100 | } 101 | } 102 | 103 | -------------------------------------------------------------------------------- /package/Codegen/VersionHeader.tt: -------------------------------------------------------------------------------- 1 | <#@ template debug="false" hostspecific="false" language="C#" linePragmas="false" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".h" #> 7 | #pragma once 8 | 9 | /************************************************************* 10 | THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY 11 | SOURCE WINMDS USED: 12 | <# 13 | foreach (var winmd in WinMDs) { 14 | #> 15 | - <#= winmd #> 16 | <# 17 | } 18 | #> 19 | **************************************************************/ 20 | 21 | #define VERSION_MAJOR <#= Version.Major #> 22 | #define VERSION_MINOR <#= Version.Minor #> 23 | #define VERSION_REVISION <#= Version.Revision == -1 ? 0 : Version.Revision #> 24 | #define VERSION_BUILD <#= Version.Build #> 25 | -------------------------------------------------------------------------------- /package/Codegen/Windows.UI.Xaml.json: -------------------------------------------------------------------------------- 1 | { 2 | "baseClasses": [ 3 | "$xaml.UIElement", 4 | "$xaml.Controls.Primitives.FlyoutBase", 5 | "$xaml.Documents.TextElement", 6 | "$xaml.Input.KeyboardAccelerator" 7 | ], 8 | "fakeProps": [ 9 | "$xaml.Controls.Primitives.FlyoutBase.IsOpen", 10 | "$xaml.Documents.Run.Text" 11 | ], 12 | "attachedProps": { 13 | "$xaml.Controls.Grid": "$xaml.UIElement", 14 | "$xaml.Documents.Typography": [ "$xaml.Controls.TextBlock", "$xaml.Controls.RichTextBlock" ], 15 | }, 16 | "syntheticProps": [ 17 | { 18 | "name": "GridLayout", 19 | "declaringType": "$xaml.Controls.Grid", 20 | "fakePropertyType": "GridLayout", 21 | "comment": "An object with a columns and a rows members, each of which is an array of the corresponding dimensions." 22 | }, 23 | { 24 | "name": "Priority", 25 | "declaringType": "$xaml.DependencyObject", 26 | "propertyType": "System.Int32", 27 | "comment": "A hint of where this item should be placed within its parent." 28 | }, 29 | { 30 | "name": "Resources", 31 | "declaringType": "$xaml.UIElement", 32 | "propertyType": "System.Object", 33 | "comment": "An object of key/value pairs used for lightweight styling." 34 | }, 35 | { 36 | "name": "ShowState", 37 | "declaringType": "$xaml.Controls.ContentDialog", 38 | "fakePropertyType": "ContentDialogState", 39 | "comment": "Whether the content dialog should be open, and how." 40 | } 41 | ], 42 | "fakeEnums": [ 43 | { 44 | "name": "NavigationViewPriority", 45 | "values": { 46 | "MenuItem": 0, 47 | "FooterMenuItem": 1, 48 | "Content": 2 49 | } 50 | }, 51 | { 52 | "name": "ExpanderPriority", 53 | "values": { 54 | "Header": 0, 55 | "Content": 1 56 | } 57 | }, 58 | { 59 | "name": "CommandBarPriority", 60 | "values": { 61 | "PrimaryCommand": 0, 62 | "SecondaryCommand": 1 63 | } 64 | }, 65 | { 66 | "name": "SplitViewPriority", 67 | "values": { 68 | "Content": 0, 69 | "Pane": 1 70 | } 71 | }, 72 | { 73 | "name": "MenuFlyoutPriority", 74 | "values": { 75 | "Attached": 0, 76 | "Context": 1 77 | } 78 | }, 79 | { 80 | "name": "ContentDialogState", 81 | "values": { 82 | "Popup": 0, 83 | "InPlace": 1, 84 | "Hidden": 3 85 | } 86 | }, 87 | { 88 | // Windows.UI.Text.FontWeights is a class and we can't statically discover the values of its "enum-like" properties 89 | "name": "FontWeights", 90 | "values": { 91 | "ExtraBlack": 950, 92 | "Black": 900, 93 | "ExtraBold": 800, 94 | "Bold": 700, 95 | "SemiBold": 600, 96 | "Medium": 500, 97 | "Normal": 400, 98 | "SemiLight": 350, 99 | "Light": 300, 100 | "ExtraLight": 200, 101 | "Thin": 100 102 | } 103 | } 104 | ], 105 | "syntheticEvents": { 106 | "$xaml.Controls.ContentDialog.ContentDialogClosed": "$xaml.Controls.ContentDialogResult" 107 | }, 108 | "propNameMapping": { 109 | "$xaml.Input.KeyboardAccelerator.Key": "virtualKey", 110 | "$xaml.Controls.Maps.MapControl.Style": "mapStyle", 111 | "$xaml.FrameworkElement.Style": "styleKey", 112 | "$xaml.FrameworkElement.Margin": "xamlMargin", 113 | "$xaml.Controls.Control.Padding": "xamlPadding", 114 | "$xaml.Controls.Control.TabIndex": "xamlTabIndex", 115 | "$xaml.Documents.ContentLink.TabIndex": "xamlTabIndex", 116 | "$xaml.Documents.Hyperlink.TabIndex": "xamlTabIndex" 117 | }, 118 | "typeMapping": [ 119 | { 120 | "name": "$xaml.Style", 121 | "VM": "String", 122 | "TS": "string" 123 | }, 124 | { 125 | "name": "$xaml.Media.Brush", 126 | "VM": "Color", 127 | "TS": "ColorValue" 128 | }, 129 | { 130 | "name": "$xaml.Media.SolidColorBrush", 131 | "VM": "Color", 132 | "TS": "ColorValue" 133 | }, 134 | { 135 | "name": "$xaml.Media.FontFamily", 136 | "VM": "String", 137 | "TS": "string" 138 | }, 139 | { 140 | "name": "$xaml.Media.ImageSource", 141 | "VM": "String", 142 | "TS": "string" 143 | }, 144 | { 145 | "name": "Windows.Media.Playback.IMediaPlaybackSource", 146 | "VM": "String", 147 | "TS": "string" 148 | }, 149 | { 150 | "name": "$xaml.Thickness", 151 | "VM": "Map", 152 | "TS": "Thickness" 153 | }, 154 | { 155 | "name": "$xaml.CornerRadius", 156 | "VM": "Map", 157 | "TS": "CornerRadius" 158 | }, 159 | { 160 | "name": "$xaml.Media.Geometry", 161 | "VM": "String", 162 | "TS": "string" 163 | }, 164 | { 165 | "name": "GridLayout", 166 | "VM": "Map", 167 | "TS": "{ rows: GridLength[], columns: GridLength[] }" 168 | } 169 | ], 170 | "commands": { 171 | "$xaml.Controls.MenuFlyout": [ 172 | { 173 | "name": "ShowAt", 174 | "args": { 175 | "point": "Point" 176 | } 177 | } 178 | ] 179 | }, 180 | "eventArgsMethods": { 181 | "$xaml.Input.ContextRequestedEventArgs": [ 182 | "TryGetPosition" 183 | ] 184 | } 185 | } -------------------------------------------------------------------------------- /package/Codegen/XamlNames.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | namespace Codegen 5 | { 6 | public static class XamlNames 7 | { 8 | public const string XamlNamespace = "Windows.UI.Xaml"; 9 | public const string TopLevelProjectedType = $"{XamlNamespace}.DependencyObject"; 10 | public const string MuxNamespace = "Microsoft.UI.Xaml"; 11 | public const string WebView2Namespace = "Microsoft.Web.WebView2"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /package/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /package/README.md: -------------------------------------------------------------------------------- 1 | # react-native-xaml 2 | 3 | ## Getting started 4 | 5 | `$ npm install react-native-xaml --save` 6 | 7 | Ensure you're using React Native Windows >= 0.69.0. 8 | 9 | Ensure your app is using WinUI 2.7+. For details about customizing WinUI versions in your React Native for Windows app, see [Customizing SDK versions](https://microsoft.github.io/react-native-windows/docs/customizing-sdk-versions). 10 | 11 | ### Mostly automatic installation 12 | 13 | `$ react-native link react-native-xaml` 14 | 15 | ## Usage 16 | 17 | See the [Usage guide](https://github.com/microsoft/react-native-xaml/blob/main/USAGE.md) for details and lots of examples. 18 | 19 | ```javascript 20 | import { HyperlinkButton, } from 'react-native-xaml'; 21 | 22 | { 26 | alert("clicked!"); 27 | }} /> 28 | ``` 29 | -------------------------------------------------------------------------------- /package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-xaml", 3 | "title": "React Native Xaml", 4 | "version": "0.0.79", 5 | "description": "Allows using XAML directly, inside of a React Native Windows app", 6 | "main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "build": "tsc -b", 10 | "codegen": "dotnet run --project Codegen" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/microsoft/react-native-xaml.git", 15 | "baseUrl": "https://github.com/microsoft/react-native-xaml" 16 | }, 17 | "keywords": [ 18 | "react-native", 19 | "react-native-windows", 20 | "XAML", 21 | "WinUI", 22 | "UWP", 23 | "Fluent", 24 | "Fluent UI", 25 | "Windows" 26 | ], 27 | "author": { 28 | "name": "Alexander Sklar", 29 | "email": "asklar@microsoft.com" 30 | }, 31 | "license": "MIT", 32 | "licenseFilename": "LICENSE", 33 | "readmeFilename": "README.md", 34 | "dependencies": { 35 | "@types/react": "*" 36 | }, 37 | "peerDependencies": { 38 | "react": ">= 18.0.0", 39 | "react-native": ">= 0.71.0", 40 | "react-native-windows": ">= 0.71.0", 41 | "typescript": "^4.1.2" 42 | }, 43 | "devDependencies": { 44 | "@types/jest": "*", 45 | "@types/react": "^18.2.6", 46 | "beachball": "^2.16.0", 47 | "eslint": "^8.19.0", 48 | "react": "18.3.1", 49 | "react-native": "0.77.0", 50 | "react-native-windows": "0.77.2", 51 | "typescript": "5.0.4" 52 | }, 53 | "files": [ 54 | "!*.tgz", 55 | "CodeGen/*.cs*", 56 | "CodeGen/*.json", 57 | "tsconfig.json", 58 | "*.cmd", 59 | "windows/", 60 | "lib/", 61 | "src/", 62 | "!*.ruleset" 63 | ] 64 | } 65 | -------------------------------------------------------------------------------- /package/rebuild_projection.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem run this to rebuild the react-native-xaml projection 3 | dotnet run --project .\Codegen\ %* -------------------------------------------------------------------------------- /package/src/NativeXamlControl.tsx: -------------------------------------------------------------------------------- 1 | // @refresh reset 2 | 3 | import { requireNativeComponent } from "react-native"; 4 | import type { XamlControlProps } from './Props'; 5 | 6 | export const NativeXamlControl = requireNativeComponent("XamlControl"); 7 | -------------------------------------------------------------------------------- /package/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './NativeXamlControl'; 2 | export * from './Types'; 3 | export { XamlControlProps } from './Props'; 4 | export * from './Enums'; -------------------------------------------------------------------------------- /package/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "rootDir": "./src", 5 | "allowUnreachableCode": false, 6 | "allowUnusedLabels": false, 7 | "esModuleInterop": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "jsx": "react", 10 | "lib": ["es6"], 11 | "module": "ESNext", 12 | "declaration": true, 13 | "moduleResolution": "node", 14 | "noFallthroughCasesInSwitch": true, 15 | "noImplicitReturns": true, 16 | "noImplicitUseStrict": false, 17 | "noStrictGenericChecks": false, 18 | "noUnusedLocals": true, 19 | "noUnusedParameters": true, 20 | "resolveJsonModule": true, 21 | "strict": true, 22 | "target": "es6", 23 | "types": ["react"], 24 | "outDir": "lib", 25 | "sourceMap": true 26 | }, 27 | "include": [ "src" ] 28 | } -------------------------------------------------------------------------------- /package/windows/.gitignore: -------------------------------------------------------------------------------- 1 | *AppPackages* 2 | *BundleArtifacts* 3 | 4 | #OS junk files 5 | [Tt]humbs.db 6 | *.DS_Store 7 | 8 | #Visual Studio files 9 | *.[Oo]bj 10 | *.user 11 | *.aps 12 | *.pch 13 | *.vspscc 14 | *.vssscc 15 | *_i.c 16 | *_p.c 17 | *.ncb 18 | *.suo 19 | *.tlb 20 | *.tlh 21 | *.bak 22 | *.[Cc]ache 23 | *.ilk 24 | *.log 25 | *.lib 26 | *.sbr 27 | *.sdf 28 | *.opensdf 29 | *.opendb 30 | *.unsuccessfulbuild 31 | ipch/ 32 | [Oo]bj/ 33 | [Bb]in 34 | **/[Dd]ebug*/ 35 | **/[Rr]elease*/ 36 | Ankh.NoLoad 37 | 38 | # Visual C++ cache files 39 | ipch/ 40 | *.aps 41 | *.ncb 42 | *.opendb 43 | *.opensdf 44 | *.sdf 45 | *.cachefile 46 | *.VC.db 47 | *.VC.VC.opendb 48 | 49 | #MonoDevelop 50 | *.pidb 51 | *.userprefs 52 | 53 | #Tooling 54 | _ReSharper*/ 55 | *.resharper 56 | [Tt]est[Rr]esult* 57 | *.sass-cache 58 | 59 | #Project files 60 | [Bb]uild/ 61 | 62 | #Subversion files 63 | .svn 64 | 65 | # Office Temp Files 66 | ~$* 67 | 68 | # vim Temp Files 69 | *~ 70 | 71 | #NuGet 72 | packages/ 73 | *.nupkg 74 | 75 | #ncrunch 76 | *ncrunch* 77 | *crunch*.local.xml 78 | 79 | # visual studio database projects 80 | *.dbmdl 81 | 82 | #Test files 83 | *.testsettings 84 | 85 | #Other files 86 | *.DotSettings 87 | .vs/ 88 | *project.lock.json 89 | 90 | #Files generated by the VS build 91 | **/Generated Files/** 92 | 93 | -------------------------------------------------------------------------------- /package/windows/ExperimentalFeatures.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | false 7 | true 8 | 9 | 2.8.0 10 | 11 | 12 | 13 | 14 | true 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/Codegen/TypeEnums.g.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /************************************************************* 3 | THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY 4 | SOURCE WINMDS USED: 5 | - %USERPROFILE%\.nuget\packages\microsoft.ui.xaml\2.8.0\lib\uap10.0\Microsoft.UI.Xaml.winmd 6 | **************************************************************/ 7 | 8 | enum class NavigationViewPriority { 9 | MenuItem = 0, 10 | FooterMenuItem = 1, 11 | Content = 2, 12 | }; 13 | 14 | enum class ExpanderPriority { 15 | Header = 0, 16 | Content = 1, 17 | }; 18 | 19 | enum class CommandBarPriority { 20 | PrimaryCommand = 0, 21 | SecondaryCommand = 1, 22 | }; 23 | 24 | enum class SplitViewPriority { 25 | Content = 0, 26 | Pane = 1, 27 | }; 28 | 29 | enum class MenuFlyoutPriority { 30 | Attached = 0, 31 | Context = 1, 32 | }; 33 | 34 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/Codegen/Version.g.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /************************************************************* 4 | THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY 5 | SOURCE WINMDS USED: 6 | - %USERPROFILE%\.nuget\packages\microsoft.ui.xaml\2.8.0\lib\uap10.0\Microsoft.UI.Xaml.winmd 7 | **************************************************************/ 8 | 9 | #define VERSION_MAJOR 0 10 | #define VERSION_MINOR 0 11 | #define VERSION_REVISION 0 12 | #define VERSION_BUILD 79 13 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/Crc32Str.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | // 7 | // static constexpr unsigned int crc_table[256] = { 8 | // 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 9 | // 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 10 | // 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 11 | // 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 12 | // 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 13 | // 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 14 | // 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 15 | // 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 16 | // 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 17 | // 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 18 | // 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 19 | // 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 20 | // 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 21 | // 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 22 | // 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 23 | // 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 24 | // 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 25 | // 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 26 | // 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 27 | // 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 28 | // 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 29 | // 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 30 | // 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 31 | // 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 32 | // 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 33 | // 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 34 | // 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 35 | // 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 36 | // 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 37 | // 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 38 | // 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 39 | // 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 40 | // 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 41 | // 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 42 | // 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 43 | // 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 44 | // 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 45 | // 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 46 | // 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 47 | // 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 48 | // 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 49 | // 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 50 | // 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d 51 | //}; 52 | // 53 | // 54 | // template 55 | // struct MM { 56 | // static constexpr unsigned int crc32(const char* str, unsigned int prev_crc = 0xFFFFFFFF) 57 | // { 58 | // return MM::crc32(str, (prev_crc >> 8) ^ crc_table[(prev_crc ^ str[idx]) & 0xFF]); 59 | // } 60 | //}; 61 | // 62 | //// This is the stop-recursion function 63 | // template 64 | // struct MM { 65 | // static constexpr unsigned int crc32(const char* /*str*/, unsigned int prev_crc = 0xFFFFFFFF) 66 | // { 67 | // return prev_crc ^ 0xFFFFFFFF; 68 | // } 69 | // }; 70 | // 71 | //// This don't take into account the nul char 72 | // #define COMPILE_TIME_CRC32_STR(x) (MM::crc32(x)) 73 | 74 | uint32_t constexpr const_hash(char const *input) { 75 | return *input ? static_cast(*input) + 33 * const_hash(input + 1) : 5381; 76 | } 77 | 78 | #define COMPILE_TIME_CRC32_STR(x) const_hash(x) 79 | 80 | #ifdef USE_CRC32 81 | #define MAKE_KEY(str) COMPILE_TIME_CRC32_STR(str) 82 | using stringKey = uint32_t; 83 | inline bool Equals(const stringKey &a, const stringKey &b) { 84 | return a == b; 85 | } 86 | #else 87 | #define MAKE_KEY(str) str 88 | using stringKey = const char *const; 89 | inline bool Equals(const stringKey &a, const stringKey &b) { 90 | return strcmp(a, b) == 0; 91 | } 92 | 93 | #endif -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/JSValueXaml_local.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #ifndef MICROSOFT_REACTNATIVE_JSVALUEXAML 7 | #define MICROSOFT_REACTNATIVE_JSVALUEXAML 8 | 9 | #include "CppWinRTIncludes.h" 10 | #include "JSValue.h" 11 | 12 | namespace winrt::Microsoft::ReactNative { 13 | 14 | #ifndef CXXUNITTESTS 15 | inline void ReadValue(JSValue const &jsValue, xaml::Media::Brush &value) noexcept { 16 | value = XamlHelper::BrushFrom([&jsValue](IJSValueWriter const &writer) noexcept { jsValue.WriteTo(writer); }); 17 | } 18 | 19 | inline void ReadValue(JSValue const &jsValue, Windows::UI::Color &value) noexcept { 20 | if (jsValue.Type() == JSValueType::Object) { 21 | // try read as a Windows.UI.Color (a,r,g,b) 22 | const auto &obj = jsValue.AsObject(); 23 | value.A = obj["a"].AsInt8(); 24 | value.R = obj["r"].AsInt8(); 25 | value.G = obj["g"].AsInt8(); 26 | value.B = obj["b"].AsInt8(); 27 | } else { 28 | value = XamlHelper::ColorFrom([&jsValue](IJSValueWriter const &writer) noexcept { jsValue.WriteTo(writer); }); 29 | } 30 | } 31 | #endif 32 | 33 | inline void ReadValue(JSValue const &jsValue, xaml::Thickness &value) noexcept { 34 | if (auto array = jsValue.TryGetArray()) { 35 | if (array->size() == 4) { 36 | value = xaml::ThicknessHelper::FromLengths( 37 | (*array)[0].AsDouble(), (*array)[1].AsDouble(), (*array)[2].AsDouble(), (*array)[3].AsDouble()); 38 | return; 39 | } 40 | } else if (auto number = jsValue.TryGetDouble()) { 41 | value = xaml::ThicknessHelper::FromUniformLength(*number); 42 | } else if (auto numberInt = jsValue.TryGetInt64()) { 43 | const auto valueDbl = static_cast(*numberInt); 44 | value = xaml::ThicknessHelper::FromUniformLength(valueDbl); 45 | } else { 46 | const auto &obj = jsValue.AsObject(); 47 | value = xaml::ThicknessHelper::FromLengths( 48 | obj["left"].AsDouble(), obj["top"].AsDouble(), obj["right"].AsDouble(), obj["bottom"].AsDouble()); 49 | return; 50 | } 51 | } 52 | 53 | inline void ReadValue(JSValue const &jsValue, xaml::CornerRadius &value) noexcept { 54 | if (auto array = jsValue.TryGetArray()) { 55 | if (array->size() == 4) { 56 | value = xaml::CornerRadiusHelper::FromRadii( 57 | (*array)[0].AsDouble(), (*array)[1].AsDouble(), (*array)[2].AsDouble(), (*array)[3].AsDouble()); 58 | return; 59 | } 60 | } else if (auto number = jsValue.TryGetDouble()) { 61 | value = xaml::CornerRadiusHelper::FromUniformRadius(*number); 62 | } else if (auto numberInt = jsValue.TryGetInt64()) { 63 | const auto valueDbl = static_cast(*numberInt); 64 | value = xaml::CornerRadiusHelper::FromUniformRadius(valueDbl); 65 | } else { 66 | const auto &obj = jsValue.AsObject(); 67 | value = xaml::CornerRadiusHelper::FromRadii( 68 | obj["topLeft"].AsDouble(), 69 | obj["topRight"].AsDouble(), 70 | obj["bottomRight"].AsDouble(), 71 | obj["bottomLeft"].AsDouble()); 72 | return; 73 | } 74 | } 75 | 76 | inline void ReadValue(JSValue const &jsValue, winrt::Windows::Foundation::Uri &value) noexcept { 77 | value = Uri{winrt::to_hstring(jsValue.AsString())}; 78 | } 79 | 80 | } // namespace winrt::Microsoft::ReactNative 81 | 82 | #endif // MICROSOFT_REACTNATIVE_JSVALUEXAML 83 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/PropertySheet.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/ReactNativeModule.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #include "JSValue.h" 7 | #include "NativeModules.h" 8 | 9 | using namespace winrt::Microsoft::ReactNative; 10 | 11 | namespace winrt::ReactNativeXaml { 12 | 13 | REACT_MODULE(ReactNativeModule, L"ReactNativeXaml") 14 | struct ReactNativeModule { 15 | // See https://microsoft.github.io/react-native-windows/docs/native-modules for details on writing native modules 16 | 17 | REACT_INIT(Initialize) 18 | void Initialize(ReactContext const &reactContext) noexcept { 19 | m_reactContext = reactContext; 20 | } 21 | 22 | REACT_METHOD(sampleMethod) 23 | void 24 | sampleMethod(std::string stringArgument, int numberArgument, std::function &&callback) noexcept { 25 | // TODO: Implement some actually useful functionality 26 | callback("Received numberArgument: " + std::to_string(numberArgument) + " stringArgument: " + stringArgument); 27 | } 28 | 29 | private: 30 | ReactContext m_reactContext{nullptr}; 31 | }; 32 | 33 | } // namespace winrt::ReactNativeXaml 34 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/ReactNativeXaml.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE 3 | DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE 4 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/ReactNativeXaml.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | #include "Version.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | #pragma code_page(1252) 22 | 23 | #ifdef APSTUDIO_INVOKED 24 | ///////////////////////////////////////////////////////////////////////////// 25 | // 26 | // TEXTINCLUDE 27 | // 28 | 29 | 1 TEXTINCLUDE 30 | BEGIN 31 | "resource.h\0" 32 | END 33 | 34 | 2 TEXTINCLUDE 35 | BEGIN 36 | "#include ""winres.h""\r\n" 37 | "\0" 38 | END 39 | 40 | 3 TEXTINCLUDE 41 | BEGIN 42 | "\r\n" 43 | "\0" 44 | END 45 | 46 | #endif // APSTUDIO_INVOKED 47 | 48 | 49 | ///////////////////////////////////////////////////////////////////////////// 50 | // 51 | // Version 52 | // 53 | 54 | VS_VERSION_INFO VERSIONINFO 55 | FILEVERSION VER_FILE_VERSION 56 | PRODUCTVERSION VER_PRODUCT_VERSION 57 | FILEFLAGSMASK 0x3fL 58 | #ifdef _DEBUG 59 | FILEFLAGS 0x1L 60 | #else 61 | FILEFLAGS 0x0L 62 | #endif 63 | FILEOS 0x40004L 64 | FILETYPE 0x2L 65 | FILESUBTYPE 0x0L 66 | BEGIN 67 | BLOCK "StringFileInfo" 68 | BEGIN 69 | BLOCK "040904b0" 70 | BEGIN 71 | VALUE "CompanyName", "Microsoft" 72 | VALUE "FileDescription", VER_FILE_DESCRIPTION_STR 73 | VALUE "FileVersion", VER_FILE_VERSION_STR 74 | VALUE "InternalName", "ReactNativeXaml.dll" 75 | VALUE "LegalCopyright", VER_COPYRIGHT_STR 76 | VALUE "OriginalFilename", VER_ORIGINAL_FILENAME_STR 77 | VALUE "ProductName", VER_PRODUCTNAME_STR 78 | VALUE "ProductVersion", VER_PRODUCT_VERSION_STR 79 | END 80 | END 81 | BLOCK "VarFileInfo" 82 | BEGIN 83 | VALUE "Translation", 0x409, 1200 84 | END 85 | END 86 | 87 | 88 | #endif // English (United States) resources 89 | ///////////////////////////////////////////////////////////////////////////// 90 | 91 | 92 | 93 | #ifndef APSTUDIO_INVOKED 94 | ///////////////////////////////////////////////////////////////////////////// 95 | // 96 | // Generated from the TEXTINCLUDE 3 resource. 97 | // 98 | 99 | 100 | ///////////////////////////////////////////////////////////////////////////// 101 | #endif // not APSTUDIO_INVOKED 102 | 103 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/ReactNativeXaml.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Codegen 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | Codegen 29 | 30 | 31 | Codegen 32 | 33 | 34 | 35 | 36 | 37 | Codegen 38 | 39 | 40 | Codegen 41 | 42 | 43 | 44 | 45 | 46 | Codegen 47 | 48 | 49 | 50 | 51 | 52 | TS 53 | 54 | 55 | TS 56 | 57 | 58 | TS 59 | 60 | 61 | TS 62 | 63 | 64 | 65 | 66 | 67 | TS 68 | 69 | 70 | 71 | 72 | {0ef07389-5c8a-4c8b-9570-1cf9a2153ce5} 73 | 74 | 75 | {5c572e8a-9a91-412d-8a35-4bd65c3cfa2b} 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/ReactPackageProvider.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | #include "pch.h" 5 | #include "ReactPackageProvider.h" 6 | #if __has_include("ReactPackageProvider.g.cpp") 7 | #include "ReactPackageProvider.g.cpp" 8 | #endif 9 | 10 | #include "ReactNativeModule.h" 11 | #include "XamlViewManager.h" 12 | 13 | using namespace winrt::Microsoft::ReactNative; 14 | 15 | namespace winrt::ReactNativeXaml::implementation { 16 | 17 | void ReactPackageProvider::CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept { 18 | AddAttributedModules(packageBuilder); 19 | packageBuilder.AddViewManager(L"XamlControl", []() { 20 | auto vm = winrt::make(); 21 | return vm; 22 | }); 23 | } 24 | 25 | } // namespace winrt::ReactNativeXaml::implementation 26 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/ReactPackageProvider.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | #include "ReactPackageProvider.g.h" 6 | 7 | using namespace winrt::Microsoft::ReactNative; 8 | 9 | namespace winrt::ReactNativeXaml::implementation { 10 | struct ReactPackageProvider : ReactPackageProviderT { 11 | ReactPackageProvider() = default; 12 | 13 | void CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept; 14 | }; 15 | } // namespace winrt::ReactNativeXaml::implementation 16 | 17 | namespace winrt::ReactNativeXaml::factory_implementation { 18 | 19 | struct ReactPackageProvider : ReactPackageProviderT {}; 20 | 21 | } // namespace winrt::ReactNativeXaml::factory_implementation 22 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/ReactPackageProvider.idl: -------------------------------------------------------------------------------- 1 | namespace ReactNativeXaml 2 | { 3 | [webhosthidden] 4 | [default_interface] 5 | runtimeclass ReactPackageProvider : Microsoft.ReactNative.IReactPackageProvider 6 | { 7 | ReactPackageProvider(); 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/Serialize.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | #include "pch.h" 5 | #include "Serialize.h" 6 | #include "XamlMetadata.h" 7 | 8 | std::vector VectorToIndices( 9 | const winrt::IVector &vector, 10 | const xaml::Controls::ItemCollection &coll) { 11 | std::vector vec; 12 | for (const auto &item : vector) { 13 | uint32_t index; 14 | if (coll.IndexOf(item, index)) { 15 | vec.push_back(index); 16 | } 17 | } 18 | return vec; 19 | } 20 | 21 | namespace winrt::Microsoft::ReactNative { 22 | 23 | bool TryWriteScalar(const winrt::Microsoft::ReactNative::IJSValueWriter &writer, const winrt::IInspectable &item) { 24 | if (auto str = item.try_as>()) { 25 | writer.WriteString(str.GetString()); 26 | return true; 27 | } else if (auto i32 = item.try_as>()) { 28 | writer.WriteInt64(i32.GetInt32()); 29 | return true; 30 | } else if (auto fw = item.try_as>()) { 31 | writer.WriteInt64(fw.GetInt32()); 32 | return true; 33 | } 34 | 35 | return false; 36 | } 37 | 38 | void WriteValue(const winrt::Microsoft::ReactNative::IJSValueWriter &writer, const Point &p) noexcept { 39 | writer.WriteObjectBegin(); 40 | WriteProperty(writer, "x", p.X); 41 | WriteProperty(writer, "y", p.Y); 42 | writer.WriteObjectEnd(); 43 | } 44 | 45 | void WriteIInspectable(winrt::Microsoft::ReactNative::IJSValueWriter const &writer, const winrt::IInspectable &item) { 46 | if (TryWriteScalar(writer, item)) { 47 | return; 48 | } else if (auto cc = item.try_as()) { 49 | WriteIInspectable(writer, cc.Content()); 50 | } else if (auto mfi = item.try_as()) { 51 | writer.WriteObjectBegin(); 52 | WriteProperty(writer, L"text", mfi.Text()); 53 | writer.WriteObjectEnd(); 54 | } else if (auto trEventArgs = item.try_as()) { 55 | writer.WriteObjectBegin(); 56 | if (auto ui = item.try_as()) { 57 | WriteProperty(writer, L"position", trEventArgs.GetPosition(ui)); 58 | } 59 | WriteProperty(writer, L"pointerDeviceType", (int)trEventArgs.PointerDeviceType()); 60 | writer.WriteObjectEnd(); 61 | } else { 62 | if (item) { 63 | auto cn = winrt::get_class_name(item); 64 | OutputDebugStringW(L"Don't yet know how to marshal this type: "); 65 | OutputDebugStringW(cn.c_str()); 66 | OutputDebugStringW(L"\n"); 67 | // assert(false); 68 | } 69 | writer.WriteNull(); 70 | } 71 | } 72 | void WriteValue(winrt::Microsoft::ReactNative::IJSValueWriter const &writer, const winrt::IInspectable &item) { 73 | if (item == nullptr) { 74 | return writer.WriteNull(); 75 | } 76 | 77 | if (TryWriteScalar(writer, item)) 78 | return; 79 | 80 | auto cn = winrt::get_class_name(item); 81 | writer.WriteObjectBegin(); 82 | WriteProperty(writer, L"type", cn); 83 | if (auto fe = item.try_as()) { 84 | auto const tag = XamlMetadata::TagFromElement(item.as()); 85 | if (tag != InvalidTag) { 86 | WriteProperty(writer, L"tag", tag); 87 | } 88 | auto name = fe.Name(); 89 | if (!name.empty()) { 90 | WriteProperty(writer, L"name", name); 91 | } 92 | } 93 | writer.WritePropertyName(L"value"); 94 | WriteIInspectable(writer, item); 95 | writer.WriteObjectEnd(); 96 | } 97 | } // namespace winrt::Microsoft::ReactNative 98 | 99 | template <> 100 | void Serialize( 101 | winrt::Microsoft::ReactNative::IJSValueWriter const &writer, 102 | const winrt::IInspectable &sender, 103 | const xaml::RoutedEventArgs &args) { 104 | writer.WriteObjectBegin(); 105 | if (auto originalSource = args.OriginalSource()) { 106 | WriteProperty(writer, L"originalSource", originalSource); 107 | } 108 | writer.WriteObjectEnd(); 109 | } 110 | 111 | template <> 112 | void Serialize( 113 | winrt::Microsoft::ReactNative::IJSValueWriter const &writer, 114 | const winrt::IInspectable &sender, 115 | const xaml::Controls::SelectionChangedEventArgs &args) { 116 | auto sel = sender.as(); 117 | const auto &items = sel.Items(); 118 | auto added = VectorToIndices(args.AddedItems(), items); 119 | auto removed = VectorToIndices(args.RemovedItems(), items); 120 | 121 | writer.WriteObjectBegin(); 122 | WriteProperty(writer, L"addedIndices", added); 123 | WriteProperty(writer, L"removedIndices", removed); 124 | WriteProperty(writer, L"addedItems", args.AddedItems()); 125 | WriteProperty(writer, L"removedItems", args.RemovedItems()); 126 | WriteProperty(writer, L"selectedIndex", sel.SelectedIndex()); 127 | WriteProperty(writer, L"selectedItem", sel.SelectedItem()); 128 | WriteProperty(writer, L"selectedValue", sel.SelectedValue()); 129 | writer.WriteObjectEnd(); 130 | } 131 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/Styling.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | #include 5 | #include "Styling.h" 6 | 7 | /// from RNW ValueUtils.cpp 8 | #pragma region Copied from RNW ValueUtils.cpp 9 | namespace ColorUtils { 10 | 11 | inline winrt::Windows::UI::Color FromArgb(uint8_t a, uint8_t r, uint8_t g, uint8_t b) { 12 | return winrt::Windows::UI::Color{a, r, g, b}; 13 | } 14 | 15 | struct ColorComp { 16 | bool operator()(const winrt::Windows::UI::Color &lhs, const winrt::Windows::UI::Color &rhs) const { 17 | return ( 18 | lhs.A < rhs.A || 19 | lhs.A == rhs.A && (lhs.R < rhs.R || lhs.R == rhs.R && (lhs.G < rhs.G || lhs.G == rhs.G && lhs.B < rhs.B))); 20 | } 21 | }; 22 | 23 | xaml::Media::SolidColorBrush SolidBrushFromColor(winrt::Windows::UI::Color color) { 24 | thread_local static std::map, ColorComp> 25 | solidColorBrushCache; 26 | 27 | if (solidColorBrushCache.count(color) != 0) { 28 | if (auto brush = solidColorBrushCache[color].get()) { 29 | return brush; 30 | } 31 | } 32 | 33 | xaml::Media::SolidColorBrush brush(color); 34 | solidColorBrushCache[color] = winrt::make_weak(brush); 35 | return brush; 36 | } 37 | 38 | inline BYTE GetAFromArgb(DWORD v) { 39 | return ((BYTE)((v & 0xFF000000) >> 24)); 40 | } 41 | inline BYTE GetRFromArgb(DWORD v) { 42 | return ((BYTE)((v & 0x00FF0000) >> 16)); 43 | } 44 | inline BYTE GetGFromArgb(DWORD v) { 45 | return ((BYTE)((v & 0x0000FF00) >> 8)); 46 | } 47 | inline BYTE GetBFromArgb(DWORD v) { 48 | return ((BYTE)((v & 0x000000FF))); 49 | } 50 | 51 | winrt::Windows::UI::Color ColorFromNumber(DWORD argb) { 52 | return FromArgb(GetAFromArgb(argb), GetRFromArgb(argb), GetGFromArgb(argb), GetBFromArgb(argb)); 53 | } 54 | 55 | winrt::Windows::UI::Color ColorFrom(const winrt::Microsoft::ReactNative::JSValue &v) { 56 | if (v.Type() != winrt::Microsoft::ReactNative::JSValueType::Int64 && 57 | v.Type() != winrt::Microsoft::ReactNative::JSValueType::Double) 58 | return winrt::Windows::UI::Colors::Transparent(); 59 | return ColorFromNumber(v.AsUInt32()); 60 | } 61 | 62 | xaml::Media::Brush GetBrushFromThemeResource(winrt::hstring resourceName) { 63 | winrt::hstring xamlString = 64 | L"" 67 | L" " 74 | L""; 75 | 76 | auto dictionary{winrt::unbox_value(xaml::Markup::XamlReader::Load(xamlString))}; 77 | 78 | auto brush{winrt::unbox_value(dictionary.TryLookup(winrt::box_value(resourceName)))}; 79 | return brush; 80 | } 81 | 82 | xaml::Media::Brush BrushFromColorObject(winrt::hstring resourceName) { 83 | thread_local static std::map> accentColorMap = { 84 | {L"SystemAccentColor", {nullptr}}, 85 | {L"SystemAccentColorLight1", {nullptr}}, 86 | {L"SystemAccentColorLight2", {nullptr}}, 87 | {L"SystemAccentColorLight3", {nullptr}}, 88 | {L"SystemAccentColorDark1", {nullptr}}, 89 | {L"SystemAccentColorDark2", {nullptr}}, 90 | {L"SystemAccentColorDark3", {nullptr}}, 91 | {L"SystemListAccentLowColor", {nullptr}}, 92 | {L"SystemListAccentMediumColor", {nullptr}}, 93 | {L"SystemListAccentHighColor", {nullptr}}}; 94 | xaml::Media::Brush brush{nullptr}; 95 | 96 | if (accentColorMap.find(resourceName) != accentColorMap.end()) { 97 | if (brush = accentColorMap.at(resourceName).get()) { 98 | return brush; 99 | } 100 | try { 101 | brush = GetBrushFromThemeResource(resourceName); 102 | } catch (...) { 103 | } 104 | } 105 | 106 | if (!brush) { 107 | try { 108 | auto color = winrt::unbox_value(xaml::Markup::XamlBindingHelper::ConvertValue( 109 | winrt::xaml_typename(), winrt::box_value(resourceName))); 110 | brush = SolidBrushFromColor(color); 111 | } catch (...) { 112 | } 113 | } 114 | if (!brush) { 115 | winrt::IInspectable resource{xaml::Application::Current().Resources().TryLookup(winrt::box_value(resourceName))}; 116 | brush = winrt::unbox_value(resource); 117 | } 118 | 119 | if (brush) { 120 | accentColorMap[resourceName] = winrt::make_weak(brush); 121 | } 122 | 123 | return brush; 124 | } 125 | 126 | xaml::Media::Brush BrushFrom(const winrt::Microsoft::ReactNative::JSValue &v) { 127 | if (v.Type() == winrt::Microsoft::ReactNative::JSValueType::String) { 128 | return BrushFromColorObject(winrt::to_hstring(v.AsString())); 129 | } 130 | 131 | return SolidBrushFromColor(ColorFrom(v)); 132 | } 133 | } // namespace ColorUtils 134 | #pragma endregion 135 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/Styling.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace ColorUtils { 9 | xaml::Media::Brush BrushFrom(const winrt::Microsoft::ReactNative::JSValue &v); 10 | } -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/Version.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/react-native-xaml/7d98a7301a8be4e55f0ad0278558e7eda7eb7327/package/windows/ReactNativeXaml/Version.h -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/Wrapper.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | #include "pch.h" 5 | #include "Wrapper.h" 6 | #if __has_include("Wrapper.g.cpp") 7 | #include "Wrapper.g.cpp" 8 | #endif 9 | 10 | namespace winrt::ReactNativeXaml::implementation { 11 | IInspectable Wrapper::WrappedObject() { 12 | return m_value; 13 | } 14 | 15 | void Wrapper::WrappedObject(IInspectable value) { 16 | m_value = value; 17 | } 18 | } // namespace winrt::ReactNativeXaml::implementation 19 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/Wrapper.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #include "Wrapper.g.h" 7 | 8 | namespace winrt::ReactNativeXaml::implementation { 9 | struct Wrapper : WrapperT { 10 | Wrapper() = default; 11 | 12 | IInspectable WrappedObject(); 13 | void WrappedObject(IInspectable value); 14 | 15 | private: 16 | IInspectable m_value{nullptr}; 17 | }; 18 | } // namespace winrt::ReactNativeXaml::implementation 19 | 20 | namespace winrt::ReactNativeXaml::factory_implementation { 21 | struct Wrapper : WrapperT {}; 22 | } // namespace winrt::ReactNativeXaml::factory_implementation 23 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/Wrapper.idl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace ReactNativeXaml 4 | { 5 | [default_interface] 6 | runtimeclass Wrapper : XAML_NAMESPACE.FrameworkElement 7 | { 8 | Wrapper(); 9 | IInspectable WrappedObject; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/XamlObject.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #include "pch.h" 7 | #include 8 | #include 9 | #include "JSI/JsiApiContext.h" 10 | #include "XamlMetadata.h" 11 | 12 | struct XamlMetadata; 13 | 14 | struct XamlObject : std::enable_shared_from_this, facebook::jsi::HostObject { 15 | facebook::jsi::Value get(facebook::jsi::Runtime &rt, const facebook::jsi::PropNameID &nameId) noexcept override; 16 | void set( 17 | facebook::jsi::Runtime &rt, 18 | const facebook::jsi::PropNameID &name, 19 | const facebook::jsi::Value &value) noexcept override; 20 | std::vector getPropertyNames(facebook::jsi::Runtime &rt) noexcept override; 21 | 22 | XamlObject() = default; 23 | XamlObject(winrt::Windows::Foundation::IInspectable obj, std::shared_ptr metadata) 24 | : m_obj(obj), m_metadata(metadata) {} 25 | XamlObject(const XamlObject &) = default; 26 | template 27 | T try_as() const { 28 | return m_obj.try_as(); 29 | } 30 | 31 | facebook::jsi::Value IInspectableToValue( 32 | facebook::jsi::Runtime &rt, 33 | const winrt::Windows::Foundation::IInspectable &inspectable) const; 34 | 35 | template >::value, int> = 0> 36 | auto RunOnUIThread(const TLambda &code) const; 37 | 38 | template >::value, int> = 0> 39 | void RunOnUIThread(const TLambda &code) const; 40 | 41 | std::shared_ptr m_metadata; 42 | 43 | private: 44 | winrt::Windows::Foundation::IInspectable m_obj; 45 | }; -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/XamlViewManager.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #include "pch.h" 7 | #include "CppWinRTIncludes.h" 8 | #include "JSI/JsiApiContext.h" 9 | #include "XamlMetadata.h" 10 | #include "winrt/Microsoft.ReactNative.h" 11 | 12 | namespace winrt::ReactNativeXaml { 13 | 14 | struct XamlViewManager : winrt::implements< 15 | XamlViewManager, 16 | winrt::Microsoft::ReactNative::IViewManager, 17 | winrt::Microsoft::ReactNative::IViewManagerWithNativeProperties, 18 | winrt::Microsoft::ReactNative::IViewManagerWithCommands, 19 | winrt::Microsoft::ReactNative::IViewManagerWithExportedEventTypeConstants, 20 | winrt::Microsoft::ReactNative::IViewManagerWithReactContext, 21 | winrt::Microsoft::ReactNative::IViewManagerWithChildren, 22 | winrt::Microsoft::ReactNative::IViewManagerCreateWithProperties, 23 | winrt::Microsoft::ReactNative::IViewManagerRequiresNativeLayout> { 24 | public: 25 | XamlViewManager() = default; 26 | 27 | // IViewManager 28 | winrt::hstring Name() noexcept; 29 | 30 | xaml::FrameworkElement CreateView() noexcept; 31 | 32 | // IViewManagerCreateWithProperties 33 | winrt::IInspectable CreateViewWithProperties( 34 | winrt::Microsoft::ReactNative::IJSValueReader const &propertyMapReader) noexcept; 35 | 36 | // IViewManagerWithNativeProperties 37 | winrt::Windows::Foundation::Collections:: 38 | IMapView 39 | NativeProps() noexcept; 40 | 41 | void UpdateProperties( 42 | winrt::Windows::UI::Xaml::FrameworkElement const &view, 43 | winrt::Microsoft::ReactNative::IJSValueReader const &propertyMapReader) noexcept; 44 | 45 | // IViewManagerWithCommands 46 | winrt::Windows::Foundation::Collections::IVectorView Commands() noexcept; 47 | 48 | void DispatchCommand( 49 | winrt::Windows::UI::Xaml::FrameworkElement const &view, 50 | winrt::hstring const &commandId, 51 | winrt::Microsoft::ReactNative::IJSValueReader const &commandArgsReader) noexcept; 52 | 53 | winrt::Microsoft::ReactNative::ConstantProviderDelegate ExportedCustomBubblingEventTypeConstants() noexcept; 54 | 55 | winrt::Microsoft::ReactNative::ConstantProviderDelegate ExportedCustomDirectEventTypeConstants() noexcept; 56 | 57 | // IViewManagerWithReactContext 58 | winrt::Microsoft::ReactNative::IReactContext ReactContext() noexcept; 59 | 60 | void ReactContext(winrt::Microsoft::ReactNative::IReactContext reactContext) noexcept; 61 | 62 | // IViewManagerRequiresNativeLayout 63 | bool RequiresNativeLayout() noexcept; 64 | 65 | // IViewManagerWithChildren 66 | void AddView(xaml::FrameworkElement parent, xaml::UIElement child, int64_t index); 67 | void RemoveAllChildren(xaml::FrameworkElement parent); 68 | void RemoveChildAt(xaml::FrameworkElement parent, int64_t index); 69 | void ReplaceChild(xaml::FrameworkElement parent, xaml::UIElement oldChild, xaml::UIElement newChild); 70 | 71 | static winrt::Microsoft::ReactNative::ReactPropertyId XamlViewManagerProperty() { 72 | return {L"ReactNativeXaml", L"ViewManager"}; 73 | } 74 | 75 | const std::shared_ptr &Metadata() const { 76 | return m_xamlMetadata; 77 | } 78 | 79 | private: 80 | winrt::Microsoft::ReactNative::IReactContext m_reactContext{nullptr}; 81 | std::shared_ptr m_xamlMetadata; 82 | }; 83 | 84 | } // namespace winrt::ReactNativeXaml 85 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/packages.lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "dependencies": { 4 | "native,Version=v0.0": { 5 | "CDebug": { 6 | "type": "Direct", 7 | "requested": "[0.0.3, )", 8 | "resolved": "0.0.3", 9 | "contentHash": "C6pojNJ2rdJuOdhe0xhJ/FedNLRJkpCVLEEHsfgoU5d5kkOOVKK+7xlGWYgttB51nDB5dLDu/O8j03jSxu81oA==" 10 | }, 11 | "Microsoft.UI.Xaml": { 12 | "type": "Direct", 13 | "requested": "[2.8.0, )", 14 | "resolved": "2.8.0", 15 | "contentHash": "vxdHxTr63s5KVtNddMFpgvjBjUH50z7seq/5jLWmmSuf8poxg+sXrywkofUdE8ZstbpO9y3FL/IXXUcPYbeesA==", 16 | "dependencies": { 17 | "Microsoft.Web.WebView2": "1.0.1264.42" 18 | } 19 | }, 20 | "Microsoft.Windows.CppWinRT": { 21 | "type": "Direct", 22 | "requested": "[2.0.230706.1, )", 23 | "resolved": "2.0.230706.1", 24 | "contentHash": "l0D7oCw/5X+xIKHqZTi62TtV+1qeSz7KVluNFdrJ9hXsst4ghvqQ/Yhura7JqRdZWBXAuDS0G0KwALptdoxweQ==" 25 | }, 26 | "boost": { 27 | "type": "Transitive", 28 | "resolved": "1.83.0", 29 | "contentHash": "cy53VNMzysEMvhBixDe8ujPk67Fcj3v6FPHQnH91NYJNLHpc6jxa2xq9ruCaaJjE4M3YrGSHDi4uUSTGBWw6EQ==" 30 | }, 31 | "Microsoft.JavaScript.Hermes": { 32 | "type": "Transitive", 33 | "resolved": "0.1.23", 34 | "contentHash": "cA9t1GjY4Yo0JD1AfA//e1lOwk48hLANfuX6GXrikmEBNZVr2TIX5ONJt5tqCnpZyLz6xGiPDgTfFNKbSfb21g==" 35 | }, 36 | "Microsoft.Web.WebView2": { 37 | "type": "Transitive", 38 | "resolved": "1.0.1264.42", 39 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 40 | }, 41 | "common": { 42 | "type": "Project", 43 | "dependencies": { 44 | "boost": "1.83.0" 45 | } 46 | }, 47 | "fmt": { 48 | "type": "Project" 49 | }, 50 | "folly": { 51 | "type": "Project", 52 | "dependencies": { 53 | "boost": "1.83.0", 54 | "fmt": "1.0.0" 55 | } 56 | }, 57 | "microsoft.reactnative": { 58 | "type": "Project", 59 | "dependencies": { 60 | "Common": "1.0.0", 61 | "Folly": "1.0.0", 62 | "Microsoft.JavaScript.Hermes": "0.1.23", 63 | "Microsoft.UI.Xaml": "2.8.0", 64 | "ReactCommon": "1.0.0", 65 | "boost": "1.83.0" 66 | } 67 | }, 68 | "reactcommon": { 69 | "type": "Project", 70 | "dependencies": { 71 | "Folly": "1.0.0", 72 | "boost": "1.83.0" 73 | } 74 | } 75 | }, 76 | "native,Version=v0.0/win10-arm": { 77 | "Microsoft.Web.WebView2": { 78 | "type": "Transitive", 79 | "resolved": "1.0.1264.42", 80 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 81 | } 82 | }, 83 | "native,Version=v0.0/win10-arm-aot": { 84 | "Microsoft.Web.WebView2": { 85 | "type": "Transitive", 86 | "resolved": "1.0.1264.42", 87 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 88 | } 89 | }, 90 | "native,Version=v0.0/win10-arm64-aot": { 91 | "Microsoft.Web.WebView2": { 92 | "type": "Transitive", 93 | "resolved": "1.0.1264.42", 94 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 95 | } 96 | }, 97 | "native,Version=v0.0/win10-x64": { 98 | "Microsoft.Web.WebView2": { 99 | "type": "Transitive", 100 | "resolved": "1.0.1264.42", 101 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 102 | } 103 | }, 104 | "native,Version=v0.0/win10-x64-aot": { 105 | "Microsoft.Web.WebView2": { 106 | "type": "Transitive", 107 | "resolved": "1.0.1264.42", 108 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 109 | } 110 | }, 111 | "native,Version=v0.0/win10-x86": { 112 | "Microsoft.Web.WebView2": { 113 | "type": "Transitive", 114 | "resolved": "1.0.1264.42", 115 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 116 | } 117 | }, 118 | "native,Version=v0.0/win10-x86-aot": { 119 | "Microsoft.Web.WebView2": { 120 | "type": "Transitive", 121 | "resolved": "1.0.1264.42", 122 | "contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA==" 123 | } 124 | } 125 | } 126 | } -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/pch.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | #include "pch.h" 5 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/pch.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #define NOMINMAX 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | using namespace winrt::Windows::Foundation; 27 | #include "CppWinRTIncludes.h" 28 | -------------------------------------------------------------------------------- /package/windows/ReactNativeXaml/resource.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | //{{NO_DEPENDENCIES}} 5 | // Microsoft Visual C++ generated include file. 6 | // Used by ReactNativeXaml.rc 7 | 8 | // Next default values for new objects 9 | // 10 | #ifdef APSTUDIO_INVOKED 11 | #ifndef APSTUDIO_READONLY_SYMBOLS 12 | #define _APS_NEXT_RESOURCE_VALUE 101 13 | #define _APS_NEXT_COMMAND_VALUE 40001 14 | #define _APS_NEXT_CONTROL_VALUE 1001 15 | #define _APS_NEXT_SYMED_VALUE 101 16 | #endif 17 | #endif 18 | --------------------------------------------------------------------------------