2018-12-24 03:02:53 +01:00
# TDLib Web example
This is an example of building `TDLib` for browsers using [Emscripten ](https://github.com/kripken/emscripten ).
2019-04-30 17:02:08 +02:00
These scripts build `TDLib` and create an [NPM ](https://www.npmjs.com/ ) package [tdweb ](https://www.npmjs.com/package/tdweb ).
2019-04-29 19:06:18 +02:00
You need a Unix shell with `sed` , `tar` and `wget` utilities to run the provided scripts.
2018-12-24 03:02:53 +01:00
2019-04-23 23:06:39 +02:00
## Building tdweb NPM package
2018-12-24 03:02:53 +01:00
2022-01-25 13:59:50 +01:00
* Install the 3.1.1 [emsdk ](https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html ), which is known to work. Do not use the system-provided `emscripten` package, because it contains a too old emsdk version.
2021-12-26 22:34:14 +01:00
* Install all `TDLib` build dependencies described in [Building ](https://github.com/tdlib/td#building ) and `sed` , `tar` and `wget` utilities.
2019-04-29 19:06:18 +02:00
* Run `source ./emsdk_env.sh` from `emsdk` directory to set up the correct build environment.
* On `macOS` , install the `coreutils` [Homebrew ](https://brew.sh ) package and replace `realpath` in scripts with `grealpath` :
2018-12-24 03:02:53 +01:00
```
brew install coreutils
sed -i.bak 's/[(]realpath/(grealpath/g' build-tdlib.sh
```
* Run build scripts in the following order:
```
cd < path to TDLib sources > /example/web
./build-openssl.sh
./build-tdlib.sh
./copy-tdlib.sh
./build-tdweb.sh
```
2019-04-29 19:06:18 +02:00
* The built package is now located in the `tdweb` directory.
2019-04-28 01:38:43 +02:00
## Using tdweb NPM package
2023-10-08 16:59:20 +02:00
See [tdweb ](https://www.npmjs.com/package/tdweb ) or [README.md ](https://github.com/tdlight-team/tdlight/tree/master/example/web/tdweb/README.md ) for package documentation.