tdweb: update dependencies
GitOrigin-RevId: fd26c28c878ac4b74f8beca25958ce54d4a428b0
This commit is contained in:
parent
5cc40abeba
commit
7312a624c5
@ -3,12 +3,16 @@
|
||||
"version": "0.2.43",
|
||||
"description": "Javascript interface for TDLib (telegram library)",
|
||||
"main": "dist/tdweb.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tdlib/td.git",
|
||||
"directory": "example/web/tdweb"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"precommit": "lint-staged",
|
||||
"build": "webpack",
|
||||
"build": "webpack --mode production",
|
||||
"start": "webpack-dev-server --open"
|
||||
},
|
||||
"keywords": [
|
||||
@ -17,34 +21,38 @@
|
||||
"author": "Arseny Smirnov",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-eslint": "^7.2.3",
|
||||
"babel-loader": "^7.1.5",
|
||||
"babel-plugin-syntax-dynamic-import": "^6.18.0",
|
||||
"babel-plugin-transform-runtime": "^6.23.0",
|
||||
"babel-preset-env": "^1.7.0",
|
||||
"clean-webpack-plugin": "^0.1.19",
|
||||
"eslint": "^4.19.1",
|
||||
"eslint-config-react-app": "^2.1.0",
|
||||
"eslint-loader": "^1.9.0",
|
||||
"eslint-plugin-flowtype": "^2.50.1",
|
||||
"eslint-plugin-import": "^2.14.0",
|
||||
"eslint-plugin-jsx-a11y": "^5.1.1",
|
||||
"eslint-plugin-react": "^7.11.1",
|
||||
"exports-loader": "^0.6.4",
|
||||
"file-loader": "^1.1.11",
|
||||
"html-webpack-plugin": "^2.30.1",
|
||||
"husky": "^0.14.3",
|
||||
"lint-staged": "^4.3.0",
|
||||
"prettier": "^1.14.2",
|
||||
"script-loader": "^0.7.2",
|
||||
"uglifyjs-webpack-plugin": "^1.3.0",
|
||||
"webpack": "^3.12.0",
|
||||
"webpack-dev-server": "^2.11.3",
|
||||
"worker-loader": "^1.1.1"
|
||||
"@babel/core": "^7.4.3",
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
||||
"@babel/plugin-transform-runtime": "^7.4.3",
|
||||
"@babel/preset-env": "^7.4.3",
|
||||
"@typescript-eslint/eslint-plugin": "^1.7.0",
|
||||
"acorn": "^6.1.1",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babel-loader": "^8.0.5",
|
||||
"clean-webpack-plugin": "^2.0.1",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-config-react-app": "^4.0.0",
|
||||
"eslint-loader": "^2.1.2",
|
||||
"eslint-plugin-flowtype": "^2.0.0",
|
||||
"eslint-plugin-import": "^2.17.2",
|
||||
"eslint-plugin-jsx-a11y": "^6.2.1",
|
||||
"eslint-plugin-react": "^7.12.4",
|
||||
"eslint-plugin-react-hooks": "^1.6.0",
|
||||
"file-loader": "^3.0.1",
|
||||
"husky": "^1.3.1",
|
||||
"lint-staged": "^8.1.5",
|
||||
"prettier": "^1.17.0",
|
||||
"typescript": "^3.4.5",
|
||||
"webpack": "4.28.2",
|
||||
"webpack-cli": "^3.3.1",
|
||||
"worker-loader": "^2.0.0"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"gitDir": "../../../",
|
||||
"linters": {
|
||||
"webpack.config.json": [
|
||||
"prettier --single-quote --write",
|
||||
@ -61,18 +69,17 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-runtime": "^6.26.0",
|
||||
"detect-browser": "^2.5.1",
|
||||
"localforage": "^1.7.2",
|
||||
"@babel/runtime": "^7.4.3",
|
||||
"localforage": "^1.7.3",
|
||||
"uuid": "^3.3.2"
|
||||
},
|
||||
"babel": {
|
||||
"presets": [
|
||||
"env"
|
||||
"@babel/env"
|
||||
],
|
||||
"plugins": [
|
||||
"syntax-dynamic-import",
|
||||
"transform-runtime"
|
||||
"@babel/syntax-dynamic-import",
|
||||
"@babel/transform-runtime"
|
||||
]
|
||||
},
|
||||
"eslintConfig": {
|
||||
@ -84,6 +91,11 @@
|
||||
},
|
||||
"globals": {
|
||||
"WebAssembly": true
|
||||
},
|
||||
"settings": {
|
||||
"react": {
|
||||
"version": "999.999.999"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
import localforage from 'localforage';
|
||||
import log from './logger.js';
|
||||
import {
|
||||
instantiateAny
|
||||
} from './wasm-utils.js';
|
||||
import { instantiateAny } from './wasm-utils.js';
|
||||
|
||||
import td_wasm_release from './prebuilt/release/td_wasm.wasm';
|
||||
|
||||
@ -10,7 +8,11 @@ import td_wasm_release from './prebuilt/release/td_wasm.wasm';
|
||||
import td_asmjs_mem_release from './prebuilt/release/td_asmjs.js.mem';
|
||||
|
||||
const tdlibVersion = 6;
|
||||
const localForageDrivers = [localforage.INDEXEDDB, localforage.LOCALSTORAGE, 'memoryDriver'];
|
||||
const localForageDrivers = [
|
||||
localforage.INDEXEDDB,
|
||||
localforage.LOCALSTORAGE,
|
||||
'memoryDriver'
|
||||
];
|
||||
|
||||
async function initLocalForage() {
|
||||
// Implement the driver here.
|
||||
@ -31,14 +33,14 @@ async function initLocalForage() {
|
||||
},
|
||||
getItem: async function(key) {
|
||||
let value = this._map.get(key);
|
||||
console.log("getItem", this._map, key, value);
|
||||
console.log('getItem', this._map, key, value);
|
||||
return value;
|
||||
},
|
||||
iterate: async function(iteratorCallback) {
|
||||
log.error("iterate is not supported");
|
||||
log.error('iterate is not supported');
|
||||
},
|
||||
key: async function(n) {
|
||||
log.error("key n is not supported");
|
||||
log.error('key n is not supported');
|
||||
},
|
||||
keys: async function() {
|
||||
return this._map.keys();
|
||||
@ -47,15 +49,15 @@ async function initLocalForage() {
|
||||
return this._map.size();
|
||||
},
|
||||
removeItem: async function(key) {
|
||||
this._map.delete(key)
|
||||
this._map.delete(key);
|
||||
},
|
||||
setItem: async function(key, value) {
|
||||
let originalValue = this._map.get(key);
|
||||
console.log("setItem", this._map, key, value);
|
||||
console.log('setItem', this._map, key, value);
|
||||
this._map.set(key, value);
|
||||
return originalValue;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Add the driver to localForage.
|
||||
localforage.defineDriver(memoryDriver);
|
||||
@ -66,7 +68,7 @@ async function loadTdLibWasm(onFS) {
|
||||
let Module = await import('./prebuilt/release/td_wasm.js');
|
||||
log.info('got td_wasm.js');
|
||||
let td_wasm = td_wasm_release;
|
||||
let module = Module({
|
||||
let module = Module.default({
|
||||
onRuntimeInitialized: () => {
|
||||
log.info('runtime intialized');
|
||||
},
|
||||
@ -126,18 +128,23 @@ async function loadTdLibAsmjs(onFS) {
|
||||
async function loadTdLib(mode, onFS) {
|
||||
const wasmSupported = (() => {
|
||||
try {
|
||||
if (typeof WebAssembly === "object"
|
||||
&& typeof WebAssembly.instantiate === "function") {
|
||||
const module = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
|
||||
if (
|
||||
typeof WebAssembly === 'object' &&
|
||||
typeof WebAssembly.instantiate === 'function'
|
||||
) {
|
||||
const module = new WebAssembly.Module(
|
||||
Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00)
|
||||
);
|
||||
if (module instanceof WebAssembly.Module)
|
||||
return new WebAssembly.Instance(module) instanceof WebAssembly.Instance;
|
||||
}
|
||||
} catch (e) {
|
||||
return (
|
||||
new WebAssembly.Instance(module) instanceof WebAssembly.Instance
|
||||
);
|
||||
}
|
||||
} catch (e) {}
|
||||
return false;
|
||||
})();
|
||||
if (!wasmSupported) {
|
||||
log.warning("WebAssembly is not supported, trying to use asmjs");
|
||||
log.warning('WebAssembly is not supported, trying to use asmjs');
|
||||
mode = 'asmjs';
|
||||
}
|
||||
|
||||
@ -212,7 +219,9 @@ class InboundFileSystem {
|
||||
log.debug('InboundFileSystem::create::keys start');
|
||||
let keys = await this.store.keys();
|
||||
let keys_time = (performance.now() - keys_start) / 1000;
|
||||
log.debug('InboundFileSystem::create::keys ' + keys_time + ' ' + keys.length);
|
||||
log.debug(
|
||||
'InboundFileSystem::create::keys ' + keys_time + ' ' + keys.length
|
||||
);
|
||||
this.pids = new Set(keys);
|
||||
}
|
||||
|
||||
@ -262,23 +271,23 @@ class DbFileSystem {
|
||||
});
|
||||
});
|
||||
|
||||
let rmrf = (path) => {
|
||||
log.debug("rmrf " , path);
|
||||
let rmrf = path => {
|
||||
log.debug('rmrf ', path);
|
||||
var info;
|
||||
try {
|
||||
info = FS.lookupPath(path);
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
log.debug("rmrf " , path, info);
|
||||
log.debug('rmrf ', path, info);
|
||||
if (info.node.isFolder) {
|
||||
for (var key in info.node.contents) {
|
||||
rmrf(info.path + '/' + info.node.contents[key].name);
|
||||
}
|
||||
log.debug("rmdir " , path);
|
||||
log.debug('rmdir ', path);
|
||||
FS.rmdir(path);
|
||||
} else {
|
||||
log.debug("unlink " , path);
|
||||
log.debug('unlink ', path);
|
||||
FS.unlink(path);
|
||||
}
|
||||
};
|
||||
@ -287,15 +296,15 @@ class DbFileSystem {
|
||||
let root_dir = FS.lookupPath(root);
|
||||
for (var key in root_dir.node.contents) {
|
||||
let value = root_dir.node.contents[key];
|
||||
log.debug("node " , key, value);
|
||||
log.debug('node ', key, value);
|
||||
if (!value.isFolder) {
|
||||
continue;
|
||||
}
|
||||
dirs.push(root_dir.path + '/' + value.name)
|
||||
dirs.push(root_dir.path + '/' + value.name);
|
||||
}
|
||||
for (let i in dirs) {
|
||||
let dir = dirs[i];
|
||||
rmrf(dir)
|
||||
rmrf(dir);
|
||||
//FS.mkdir(dir);
|
||||
//FS.mount(FS.filesystems.MEMFS, {}, dir);
|
||||
}
|
||||
@ -336,18 +345,18 @@ class DbFileSystem {
|
||||
this.FS.unmount(this.root);
|
||||
var req = indexedDB.deleteDatabase(this.root);
|
||||
await new Promise((resolve, reject) => {
|
||||
req.onsuccess = function (e) {
|
||||
req.onsuccess = function(e) {
|
||||
log.info('SUCCESS');
|
||||
resolve(e.result);
|
||||
};
|
||||
req.onerror = function(e) {
|
||||
log.info('ONERROR');
|
||||
reject(e.error);
|
||||
}
|
||||
};
|
||||
req.onblocked = function(e) {
|
||||
log.info('ONBLOCKED');
|
||||
reject('blocked');
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -372,7 +381,11 @@ class TdFileSystem {
|
||||
);
|
||||
|
||||
//IDBFS. MEMFS which is flushed to IDB from time to time
|
||||
let dbFileSystem = DbFileSystem.create(prefix + '/dbfs', FS_promise, readOnly);
|
||||
let dbFileSystem = DbFileSystem.create(
|
||||
prefix + '/dbfs',
|
||||
FS_promise,
|
||||
readOnly
|
||||
);
|
||||
|
||||
let FS = await FS_promise;
|
||||
tdfs.FS = FS;
|
||||
@ -414,20 +427,20 @@ class TdClient {
|
||||
localForageDrivers
|
||||
];
|
||||
for (const driverName of DRIVERS) {
|
||||
console.log("Test ", driverName);
|
||||
console.log('Test ', driverName);
|
||||
try {
|
||||
await localforage.setDriver(driverName);
|
||||
console.log("A");
|
||||
console.log('A');
|
||||
await localforage.setItem('hello', 'world');
|
||||
console.log("B");
|
||||
console.log('B');
|
||||
let x = await localforage.getItem('hello');
|
||||
console.log("got ", x);
|
||||
console.log('got ', x);
|
||||
await localforage.clear();
|
||||
console.log("C");
|
||||
console.log('C');
|
||||
} catch (error) {
|
||||
console.log("Error", error);
|
||||
console.log('Error', error);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async init(options) {
|
||||
@ -573,7 +586,8 @@ class TdClient {
|
||||
query.parameters.use_secret_chats = useDb;
|
||||
}
|
||||
if (query['@type'] === 'getLanguagePackString') {
|
||||
query.language_pack_database_path = this.tdfs.dbFileSystem.root + '/language';
|
||||
query.language_pack_database_path =
|
||||
this.tdfs.dbFileSystem.root + '/language';
|
||||
}
|
||||
return this.prepareQueryRecursive(query);
|
||||
}
|
||||
@ -591,16 +605,24 @@ class TdClient {
|
||||
var buf = new Uint8Array(query.size);
|
||||
this.FS.read(stream, buf, 0, query.size, query.offset);
|
||||
this.FS.close(stream);
|
||||
res = buf
|
||||
res = buf;
|
||||
} catch (e) {
|
||||
this.callback({'@type':'error', '@extra': query['@extra'], code: 400, message: e});
|
||||
this.callback({
|
||||
'@type': 'error',
|
||||
'@extra': query['@extra'],
|
||||
code: 400,
|
||||
message: e
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.callback({
|
||||
this.callback(
|
||||
{
|
||||
'@type': 'FilePart',
|
||||
'@extra': query['@extra'],
|
||||
'data': res
|
||||
}, [res.buffer]);
|
||||
data: res
|
||||
},
|
||||
[res.buffer]
|
||||
);
|
||||
}
|
||||
|
||||
send(query) {
|
||||
@ -609,7 +631,7 @@ class TdClient {
|
||||
}
|
||||
if (this.wasFatalError) {
|
||||
if (query['@type'] === 'destroy') {
|
||||
this.destroy({'@type': 'Ok', '@extra': query['@extra']});
|
||||
this.destroy({ '@type': 'Ok', '@extra': query['@extra'] });
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -630,11 +652,13 @@ class TdClient {
|
||||
this.pendingQueries.push(query);
|
||||
return;
|
||||
}
|
||||
if (query['@type'] === 'setLogVerbosityLevel' ||
|
||||
if (
|
||||
query['@type'] === 'setLogVerbosityLevel' ||
|
||||
query['@type'] === 'getLogVerbosityLevel' ||
|
||||
query['@type'] === 'setLogTagVerbosityLevel' ||
|
||||
query['@type'] === 'getLogTagVerbosityLevel' ||
|
||||
query['@type'] === 'getLogTags') {
|
||||
query['@type'] === 'getLogTags'
|
||||
) {
|
||||
this.execute(query);
|
||||
return;
|
||||
}
|
||||
@ -744,8 +768,7 @@ class TdClient {
|
||||
authorization_state: {
|
||||
'@type': 'authorizationStateClosed'
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async asyncOnFatalError(error) {
|
||||
|
@ -1,7 +1,5 @@
|
||||
const path = require('path');
|
||||
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
||||
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
|
||||
module.exports = {
|
||||
entry: ['./src/index.js'],
|
||||
@ -10,16 +8,20 @@ module.exports = {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
library: 'tdweb',
|
||||
libraryTarget: 'umd',
|
||||
umdNamedDefine: true
|
||||
umdNamedDefine: true,
|
||||
globalObject: 'this'
|
||||
},
|
||||
devServer: {
|
||||
contentBase: './dist'
|
||||
},
|
||||
plugins: [
|
||||
// new HtmlWebpackPlugin(),
|
||||
new CleanWebpackPlugin(['dist'], {})
|
||||
new CleanWebpackPlugin({})
|
||||
//, new UglifyJSPlugin()
|
||||
],
|
||||
optimization:{
|
||||
minimize: false, // <---- disables uglify.
|
||||
},
|
||||
module: {
|
||||
noParse: /td_asmjs\.js$/,
|
||||
rules: [
|
||||
@ -56,6 +58,7 @@ module.exports = {
|
||||
{
|
||||
test: /\.(wasm|mem)$/,
|
||||
include: [path.resolve(__dirname, 'src')],
|
||||
type: "javascript/auto",
|
||||
use: [
|
||||
{
|
||||
loader: require.resolve('file-loader')
|
||||
|
Loading…
Reference in New Issue
Block a user