Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

GIT for nodejs and the browser usinghttps://libgit2.org compiled to WebAssembly withhttps://emscripten.org

License

NotificationsYou must be signed in to change notification settings

petersalomonsen/wasm-git

Repository files navigation

(Wasm should be pronounced likeawesome starting with aW ).

GIT for nodejs and the browser usinglibgit2 compiled to WebAssembly withEmscripten.

The main purpose of bringing git to the browser, is to enable storage of web application data locally in the users web browser, with the option to synchronize with a remote server.

Demo in the browser

A simple demo in the browser can be found at:

https://wasm-git.petersalomonsen.com/

Please do not abuse, this is open for you to test and see the proof of concept

The sources for the demo can be found in thegithttpserver project. It shows basic operations like cloning, edit files, add and commit, push and pull.

Demo videos

Videos showing example applications using wasm-git can bee seen inthis playlist. Wasm-git is used for local and offline storage of web application data, and for syncing with a remote server.

Examples

Wasm-git packages are built in two variants: Synchronuous and Asynchronuous. To run the sync version in the browser, awebworker is needed. This is because of the use of synchronous http requests and long running operations that would block if running on the main thread. The sync version has the smallest binary, but need extra client code to communicate with the web worker. When using the sync version in nodejsworker_threads are used, withAtomics to exchange data between threads.

The async version useEmscripten Asyncify, which allows calling the Wasm-git functions withasync /await. It can also run from the main thread in the browser. Asyncify increase the binary size because of instrumentation to unwind and rewind WebAssembly state, but makes it possible to have simple client code without exchanging data with worker threads like in the sync version.

Examples of using Wasm-git can be found in the tests:

The examples shows importing thelg2.js /lg2-async.js modules from the local build, but you may also access these from releases available at public CDNs.

Building and developing

TheGithub actions test pipeline shows all the commands needed to install dependencies, build the packages and run the tests.

Another option is loading the repository into a github codespace, where the configuration in.devcontainer folder will be used to install dependencies and set up a full development environment.

Emscripten fixes that were needed for making Wasm-git work

As part of being able to compile libgit2 to WebAssembly and run it in a Javascript environment, some fixes toEmscripten were needed.

Here are the Pull Requests that resolved the issues identified when the first version was developed:

for using withNODEFS you'll also needemscripten-core/emscripten#10669

All of these pull requests are merged to emscripten master as of 2020-03-29.

Releases

No releases published

Sponsor this project

 

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp