Devmachinist.Xavier 7.0.5

dotnet add package Devmachinist.Xavier --version 7.0.5
NuGet\Install-Package Devmachinist.Xavier -Version 7.0.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Devmachinist.Xavier" Version="7.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Devmachinist.Xavier --version 7.0.5
#r "nuget: Devmachinist.Xavier, 7.0.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Devmachinist.Xavier as a Cake Addin
#addin nuget:?package=Devmachinist.Xavier&version=7.0.5

// Install Devmachinist.Xavier as a Cake Tool
#tool nuget:?package=Devmachinist.Xavier&version=7.0.5

Xavier Framework

The Xavier Framework is a powerful framework designed to facilitate the development of web applications by providing support for multiple programming languages, including C#, Python, and JavaScript. It allows you to define and process template strings in both C# and JavaScript, ensuring seamless integration and efficient development. Xavier also offers server-side rendering capabilities, enabling full-page rendering for enhanced performance and SEO.

Table of Contents

Installation

To use Xavier, follow these steps using the cli:

  • dotnet add package Devmachinist.Xavier
  • or dotnet add package Devmachinist.Xavier.AOT

Usage

Template Syntax

The Xavier Framework recognizes three types of languages:

  • x{ ... }x - This syntax denotes a C# execution. Any code within these tags will be interpreted as C# code.
  • {{ ... }} - This syntax represents as JavaScript in a script tag. Code within these tags will be interpreted as JavaScript code.
  • py{ ... }py - This syntax represents as python 3.4 IronPython. Code within these tags will be interpreted as python code.

Creating a Component

To create a component using the Xavier Framework, follow these steps:

  1. Create a new file with the .xavier extension (e.g., MyComponent.xavier).
  2. Define your component within the .xavier file using the appropriate afformentioned syntax.
  3. Implement the code behind for the component in a separate file with the same name as the component and a .xavier.cs extension (e.g., MyComponent.xavier.cs). Use the base class provided by Xavier Framework and match it with the component's code behind file.

Server-Side Rendering

Xavier Framework supports server-side rendering, which provides benefits like improved performance and search engine optimization (SEO). To enable server-side rendering for Xavier pages, follow these steps:

  1. Configure your web application to use Xavier Framework.
  2. Use the app.MapXavierNodes method in your application's configuration to map the Xavier nodes to specific routes. This method specifies the URL pattern and the destination directory for Xavier pages.
  3. Set the static fallback for Xavier:
<<<<<<< HEAD
memory.StaticFallback("c:/fallback/index.html");

//app build
app.MapXavierNodes("{controller=Home}/{action=Index}/{id?}", Environment.CurrentDirectory + "/Pages", memory);

=======
Xavier.Memory.StaticFallback("c:/fallback/index.html");
app.MapXavierNodes("{controller=Home}/{action=Index}/{id?}", Environment.CurrentDirectory + "/Pages", memory);


>>>>>>> 77bcdb0bd50646e5000d11855349045f0efcf2f8

Initialization

To initialize Xavier in a .NET app, follow these steps:

  1. Import the required namespace:
using Xavier;
//and
using Xavier.AOT;

Call the Init method to initialize Xavier with the desired parameters. This method builds your assembly into the specified destination. The last part of the destination path should have a .js extension.

<<<<<<< HEAD
var memory = new Xavier.Memory();

=======
var memory = new Memory();
>>>>>>> 77bcdb0bd50646e5000d11855349045f0efcf2f8
await memory.Init(root, destination, assembly);

Or with AOT, pass in your memory object without calling memory.Init()...

<<<<<<< HEAD
Parallel.Invoke(async () =>
    {
     await aot.Init(
                    memory,
                    Environment.CurrentDirectory,
                    Environment.CurrentDirectory + "/Live/Xavier",
                    null,
                    typeof(Program).Assembly
                    );
     });
=======
var memory = new Memory();
var aot = new XAOT();
await aot.Init(memory,root,destination,assembly);
>>>>>>> 77bcdb0bd50646e5000d11855349045f0efcf2f8

Examples

Here's an example of a .xavier file that demonstrates the usage of template strings in C# and JavaScript within the Xavier Framework:



<div id="${this.target}auth">
</div>

{{
let username = "";
var target = '${this.target}'


<<<<<<< HEAD

}}

x{ 
// C# Code here

    var Items = new[]{"item1","item2","item3"};
    @foreach( var k in items){
        <div>
        @k
        </div>
    }
}x

=======

// More JavaScript code here
}}

// C# code here

x{
    var items = new[]{"item1","item2","item3"};
    @foreach( var k in items){
      <div>
        @k
      </div>
    }
}x
>>>>>>> 77bcdb0bd50646e5000d11855349045f0efcf2f8

Here is the code behind required for each component.

//this file should be named MyComponent.xavier.cs
using Xavier;

namespace MyNamespace{
    public partial class MyComponent : XavierNode
    {
        new public bool? ShouldRender = true;
<<<<<<< HEAD

=======
>>>>>>> 77bcdb0bd50646e5000d11855349045f0efcf2f8
        public MyComponent(XavierNode xavier) : base(xavier){
        }
        public MyComponent(){
        }
    }
}

Information

  • Xavier is experimental and should be treated as such. <<<<<<< HEAD =======
  • Known to cause thread pool starvation while using Devmachinist.Xavier.AOT . Simply stop the app when done testing and use the memory.Init(root,destination,assembly) for production.

77bcdb0bd50646e5000d11855349045f0efcf2f8

Contributing

We welcome contributions from the community to enhance the Xavier Framework. If you find any issues, have suggestions for improvements, or would like to add new features, please submit a pull request.

License

The Xavier Framework is released under the MIT License. Feel free to use, modify, and distribute it according to the terms of this license.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Devmachinist.Xavier:

Package Downloads
Devmachinist.Xavier.AOT

Package Description

Devmachinist.Xavier.AspNetCore

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
7.0.5 56 4/14/2024
7.0.4 59 4/14/2024
7.0.3 237 9/11/2023
7.0.1 86 6/5/2023
7.0.0 252 6/3/2023
1.0.2 299 3/26/2023
1.0.1 103 3/26/2023
1.0.0 296 3/24/2023