Add README.md

This commit is contained in:
Wu Yu Wei
2023-06-01 15:05:02 +08:00
parent 21e84c4c84
commit cbb6fd3208
6 changed files with 292 additions and 5 deletions

134
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,134 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[contact@tauri.app](mailto:contact@tauri.app).
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series of
actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within the
community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
[https://www.contributor-covenant.org/translations][translations].
[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations

37
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,37 @@
# Contributing Guide
Hi! We, the maintainers, are really excited that you are interested in contributing to this project. Before submitting your contribution though, please make sure to take a moment and read through the [Code of Conduct](CODE_OF_CONDUCT.md), as well as the appropriate section for the contribution you intend to make:
- [Issue Reporting Guidelines](#issue-reporting-guidelines)
- [Pull Request Guidelines](#pull-request-guidelines)
- [Development Guide](#development-guide)
## Issue Reporting Guidelines
- The issue list of this repo is **exclusively** for bug reports and feature requests of this project only. General cef issues should go to [CEF issue list](https://github.com/chromiumembedded/cef/issues).
- If you have any question, please visit [CEF Forum](https://magpcss.org/ceforum/index.php) for answers.
- Issue must follow the issue template format. If it's a bug report, reproduce steps must be provided. Otherwise, the issue will be closed.
## Pull Request Guidelines
- The title and commits should follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0-beta.4/).
- Add changes in CHANGELOG.md. It should be the same as the title.
- It's OK to have multiple small commits as you work on the PR - we will let GitHub automatically squash it before merging.
## Development Guide
### Architecture
Like many FFI crates, there are two crates in this repo: `cef-rs` in root and `cef-sys` in sys directory. `cef-sys` contains C APIs generated by `bindgen.sh`. You shouldn't edit the code directly in this crate. `cef-rs` is where type safe bindings land. Most features and implementation should go here.
### Types
There are a few types we recommend you learn first before adding any implementation. This could help you understand the interface of CEF better. We also welcome everyone who can add tests for these types:
- `CefString`
- `rc` module

55
README.md Normal file
View File

@@ -0,0 +1,55 @@
# cef-rs
Use CEF in Rust.
## Supported Targets
| Target | Linux | macOS | Windows |
| ------ | ----- | ----- | ------- |
| x86_64 | ✅ | ❎ | ❎ |
| ARM64 | ❎ | ❎ | ❎ |
## Usage
### Linux
- Install flatpak runtime & sdk:
```
TODO
```
- Setup cargo project for flatpak. See [flatpak-builder-tools](https://github.com/flatpak/flatpak-builder-tools/blob/master/cargo/README.md) for more details. Here are files you will need to have at leaset:
- flatpak-cargo-generator.py
- flatpak manifest file (ie. app.tauri.demo)
- Build the flatpak application and run:
```
cargo b --example demo
python3 ./flatpak-cargo-generator.py ./quickstart/Cargo.lock -o cargo-sources.json
touch run.sh
flatpak-builder --user --install --force-clean target app.tauri.demo.yml
flatpak run app.tauri.demo
```
## Contributing
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
## Roadmap
Welcome to open feature requests if the feature you look for isn't listed below. But please understand that some requests might result into not planned.
### Planned
- Find out the best approach to use CEF in the target we support.
- [ ] Add Linux ARM64 target
- [ ] Add macOS ARM64 target
- [ ] Add Windows x86_64 target
### Not Planned
- Other package formats on Linux.
- Add all possible ergonomic interfaces (ie. builder types for attributes and settings.)
- Provide tools to bundle and distribute application.

View File

@@ -1,13 +1,17 @@
pub mod app;
mod app;
pub mod args;
pub mod browser;
pub mod client;
pub mod command_line;
mod command_line;
pub mod rc;
pub mod settings;
mod settings;
pub mod string;
pub mod window;
pub use app::{execute_process, initialize, App};
pub use command_line::CommandLine;
pub use settings::Settings;
pub type LogSeverity = cef_sys::cef_log_severity_t;
pub type Rect = cef_sys::cef_rect_t;
pub type State = cef_sys::cef_state_t;

View File

@@ -1,3 +1,47 @@
//! Reference counted module
//!
//! Many cef types are reference counted, this module is the building block to create them. Users
//! typically don't need to uses these types, but anyone who want to add feaures and
//! implementations to this crate will need to understand them.
//!
//! In order to create a new Rust type for a raw cef type, simply create a module for it first. And
//! then work on the implementations based on following conditions:
//!
//! ## If raw cef type is a simple struct with basic fields
//! For example like [`cef_settings_t`], just create a struct like [`Settings`] and define a method
//! `into_raw` that can convert to raw cef type.
//!
//! ## If raw cef type has [`cef_base_ref_counted_t`]
//! For example like [`cef_app_t`], it should implement [`Rc`] trait.
//! There's a private macro `impl_rc` in this module for you to implement it. And for the Rust
//! type...
//!
//! ### if it's a type we should create in Rust and pass to C API
//!
//! Define a trait with [`Clone`] trait bound like [`App`] for it.
//! We need [`Clone`] trait because users will define a reference counted type based on it.
//! Each field of this kind of cef type usually is a callback like `Option<unsafe extern "C" fn(...)>`.
//! We define a trampoline function with the same signature, and then define a trait method like
//! [`App::on_before_command_line_processing`]. Finally, define a trait method [`to_raw`] that can
//! create raw cef type with reference counted. In the implementation of [`to_raw`], create the raw
//! cef type by `unsafe { std::mem::zeroed }` first. And then fill each field by adding the
//! trampoline function. Return the value by calling [`RcImpl::new`]. This is the wrapper to add
//! [`cef_base_ref_counted_t`] to the type, so the trampoline function can call [`RcImpl::get`] to
//! retreive rust type and use it.
//!
//! ### if it's type we sould get from C API
//!
//! Define a new type like [`CommandLine`] to wrap the raw type with [`RefGuard`], and then define
//! a method called `from_raw`.
//!
//! [`cef_settings_t`]: cef_sys::cef_settings_t
//! [`cef_app_t`]: cef_sys::cef_app_t
//! [`Settings`]: crate::Settings
//! [`App`]: crate::App
//! [`App::on_before_command_line_processing`]: crate::App::on_before_command_line_processing
//! [`to_raw`]: crate::App::to_raw
//! [`CommandLine`]: crate::CommandLine
use std::{
ops::Deref,
sync::atomic::{fence, AtomicUsize, Ordering},
@@ -5,7 +49,7 @@ use std::{
use cef_sys::cef_base_ref_counted_t;
/// Reference counted trait for types has `cef_base_ref_counted_t`.
/// Reference counted trait for types has [`cef_base_ref_counted_t`].
pub trait Rc {
fn add_ref(&self);
fn has_one_ref(&self) -> bool;

View File

@@ -1,3 +1,16 @@
//! String module
//!
//!
//! cef-rs defines its own type [`CefString`] which is a new
//! type of [`widestring::U16CString`] to handle everything around strings.
//! Including converting from/to raw [`cef_string_utf16_t`],
//! converting from/to Rust string types. Every cef-rs types should also use [`CefString`] as
//! interface in most of the cases. Raw cef string [`cef_string_utf16_t`] is a UTF-16 C String,
//! but it also has a version [`cef_string_userfree_utf16_t`] that users are responsible
//! for free it manually.
//!
//! There's also [`str_to_cef`] function to convert rust string to cef string directly.
use cef_sys::{
cef_string_list_t, cef_string_map_t, cef_string_userfree_utf16_t, cef_string_utf16_t,
};
@@ -5,7 +18,7 @@ use std::collections::HashMap;
use std::ptr::null_mut;
use widestring::U16CString;
/// Helper type to deal with Cef string. It's essentially an Utf-16 C string.
/// Helper type to deal with Cef string. It's essentially an UTF-16 C string.
#[derive(Debug, Default, Clone)]
pub struct CefString(pub U16CString);