Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update README.md #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 99 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,99 @@
# WebView

WebView is a WPF control that wraps [CefSharp](https://github.com/cefsharp/CefSharp) web view control. Provides the following additional features:
- Strongly-typed javascript evaluation: results of javascript evaluation returns the appropriate type
- Scripts are aggregated and executed in bulk for improved performance
- Synchronous javascript evaluation
- Javascript error handling with stack information
- Events to intercept and respond to resource load
- Events to track file download progress
- Ability to load embedded resources using a custom protocol
- Ability to disable history navigation
- Error handling
- Proxy configuration support
- Runs under AnyCPU configuration (works both on x64 and x86 configurations)

# Build pre-requisites
- NodeJS

# TODO
- Improve documentation
# dotNetron

Build cross platform desktop apps with React.js and .Net.

dotNetron is a framework that provides a shell for wrapping desktop apps built with web-technologies (such as react.js, javascript and css). Via the dotNetron Javascript interop bridge it is possible to invoke APIs from .Net and vice-versa.
Powered by [.Net Core](https://dotnet.microsoft.com/download), [React.js](https://reactjs.org/), [CefGlue](https://gitlab.com/joaompneves/cefglue) and [Avalonia](https://avaloniaui.net/), dotNetron apps can run on Windows, Linux and Mac using the same code base.

This framework is inspired on the [Electron](https://github.com/electron/electron) concept. Similarly to Electron, this framework provides a native shell with a browser (CefGlue) with the react.js library embedded, out-of-the-box.

Contrary to [Electron.Net](https://github.com/ElectronNET/Electron.NET), dotNetron does not use an embedded ASP.Net core server. Instead, .Net code runs all on the same process, and all the UI resources are fetched automatically by the browser and served directly from the application bundle. This approach improves the performance of the apps, while leveraging the web-techonologies capabilities for building UIs.

## Features

dotNetron provides tooling and libraries for building web-based UIs that can easily interop with .Net APIs, in the same process.
With dotNetron you can
- build react.js UIs
- use typescript (which enables the companion tooling to generate strongly-typed APIs)
- style with SASS
- call .Net APIs from javascript in an asynchronous fashion
- call javascript APIs in a strongly-typed fashion
- SASS support
- pass information (simple or more complex types) from .Net to javascript and vice-versa (the js interop bridge takes care of the data serialization)
- seamly use images and other UI resources on the react.js UIs

## Usage

### Bootstrap
You start by creating a .Net Core project. Then add the dotNetron Nuget packages.

// TODO

### Configuration

Change the ts2lang.json file on the root of your project to match your needs:

{
"tasks": [
{
"input": Path where the declaration of the UI (typescript) files live,
"output": Path where the generated C# class files will be written to,
"template": Leave empty,
"parameters": {
"namespace": Namespace to be used in the generated C# classes,
"baseComponentClass": Name of the base class of the UI component. Use this if you need to inherit from a base component other than the default,
"javascriptDistPath": Place where the typescript compiler will place the compiled js files
}
}
]
}

### Hello World

Create the entry typescript (.tsx) module that will host your application UI. Check out the following simple example.

import * as React from "react";
import "styles.sass";

export interface IHelloWorldProperties {
click(arg: string): void;
}

export interface IHelloWorldBehaviors {
sayHello(): void;
}

export default class HelloWorld extends React.Component<IHelloWorldProperties, {}> implements IHelloWorldBehaviors {

sayHello(): void {
alert("Hello World");
}

render() {
return <button onClick={() => this.props.click("hello from js")}>Click me!</button>
}
}

#### Properties and Behaviors

The Hello World example contains 2 interfaces: IHelloWorldProperties and IHelloWorldBehaviors.
These interfaces are special, in way that enables the dotNetron tooling to generate the .Net APIs for the interop between javascript and .Net.
The Properties interface defines the .Net APIs that will be available to javascript, while the Behaviors interface defines the methods javascript methods that can be called from .Net.
The properties and behaviors interfaces must follow the following naming conventions: start with I and end with Properties or Behaviors suffix.
You can use other types in these interfaces, as long as they are declared in the same module. All types must be exported in order for its C# APIs be generated.
Methods in the Properties interface must either be void or Promise.
Methods in the Behaviors interface cannot return any values ie. their return type must be void.

#### React component

The component is a standard react component that should implement the Properties interface. The Behaviors interface is optional.
Don't forget to export default your component.

### Generated C# code

TODO

### Wrapping all

TODO