TDLib

TDLib WebAssembly 构建指南

使用 Emscripten 构建 TDLib 浏览器版本,准备 OpenSSL 并生成 tdweb 包。

GetTGAPI 编辑团队更新于
TDLib 文档核对日期

来源版本 a94b83d67ab4 · TDLib contributors · BSL-1.0

依据官方资料整理,由 GetTGAPI 独立维护。 文档目录与术语表 →

本页内容
  1. 开始之前
  2. TDLib Web 示例
  3. 构建 tdweb NPM 包
  4. 使用 tdweb NPM 包

开始之前

这里说明如何从源码构建 tdweb;如何在网页中使用它另见 tdweb 接入文档。emsdk 3.1.1 是上游说明中的已验证版本,不代表本次已经在所有新环境重新构建通过。

TDLib Web 示例

本示例使用 Emscripten 为浏览器构建 TDLib。 这些脚本会构建 TDLib,并创建名为 tdweb 的 NPM 包。 运行提供的脚本需要 Unix shell,以及 sed、tar 和 wget 工具。

构建 tdweb NPM 包

  • 安装已知可用的 3.1.1 版 emsdk。不要使用系统提供的 emscripten 包,原文说明其 emsdk 版本过旧。
  • 安装 构建说明 中列出的所有 TDLib 构建依赖,以及 sed、tar 和 wget 工具。
  • 在 emsdk 目录运行 source ./emsdk_env.sh,设置正确的构建环境。
  • 在 macOS 上,安装 Homebrew 的 coreutils 包,并将脚本中的 realpath 替换为 grealpath:
brew install coreutils
sed -i.bak 's/[(]realpath/(grealpath/g' build-tdlib.sh
  • 按以下顺序运行构建脚本:
cd <path to TDLib sources>/example/web
./build-openssl.sh
./build-tdlib.sh
./copy-tdlib.sh
./build-tdweb.sh
  • 构建好的包位于 tdweb 目录。

使用 tdweb NPM 包

包的文档见 tdweb 或 README.md。

继续阅读 TDLib 总览与构建。需要应用凭证时,可参考 API ID 与 Hash 申请流程;申请遇到 ERROR,可通过 GetTGAPI 客服 沟通。

原文许可与归属 · BSL-1.0

TDLib contributors · 完整许可文件

Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.