Skip to content

Commit f7c575d

Browse files
committed
L:: fix error messages from the worker
Remove debug code that broke them. Update comments and README. V:: fix typo in Spanish translation
1 parent d0182b0 commit f7c575d

File tree

5 files changed

+37
-20
lines changed

5 files changed

+37
-20
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
## About / О проекте
44

55
**DjVu.js** is a program library for working with `.djvu` online. It's written
6-
in JavaScript and can be run in the web browsers without any connection with the
6+
in JavaScript and can be run in a web browser without any connection with a
77
server. DjVu.js can be used for splitting (and concatenation) of `.djvu` files,
88
rendering pages of a `.djvu` document, converting (and compressing) images
99
into `.djvu` documents and for analyzing of metadata of `.djvu` documents.
1010

11-
**DjVu.js Viewer** is an app which uses DjVu.js in order to render DjVu
11+
**DjVu.js Viewer** is an app which uses DjVu.js to render DjVu
1212
documents. The app may be easily included into any html page. You can look at it
1313
and try it out on the official website (the link is below).
1414

15-
**DjVu.js Viewer browser extension**. By and large it's a copy of the viewer,
15+
**DjVu.js Viewer browser extension**. By and large, it's a copy of the viewer,
1616
but also it allows opening links to `.djvu` files right in the browser without
17-
explicit downloading of a file. The links to the extension are below.
17+
downloading them explicitly. The links to the extension are below.
1818

1919
<hr>
2020

@@ -32,7 +32,7 @@ html-страницу. Данное приложение служит для п
3232

3333
**Расширение для браузера DjVu.js Viewer**. По большей части это копия
3434
приложения DjVu.js Viewer, однако также расширение позволяет открывать ссылки
35-
на `.djvu` файлы прямо в браузере, не скачивая файл явно. Ссылки на расширение
35+
на `.djvu` файлы прямо в браузере, не скачивая их явно. Ссылки на расширение
3636
доступны ниже.
3737

3838
## Translation (localization)
@@ -42,32 +42,32 @@ how to do it.
4242

4343
## How to build it
4444

45-
If you have Node.js (10.x or higher) installed, after you cloned the repository,
46-
run
45+
You need to have Node.js 16+ and npm 8+ installed.
46+
Clone the repo and run:
4747

4848
```
4949
npm run install
5050
npm run build
5151
````
5252
5353
in the root folder of the repository. The command will install all dependencies
54-
and create bundles of the library and of the viewer (the build folder should
54+
and create bundles of the library and viewer (the `build` folder should
5555
appear).
5656
57-
Also there is another way to do the same operations:
57+
Also, there is another way to do the same operations:
5858
5959
```
6060
npm run make
6161
```
6262
6363
The command will clean all git-ignored files, install all the dependencies and
64-
build the library and the viewer. However, you should have `git` installed of
65-
course and the repository should have the `.git` folder (there is no one in the
64+
build the library and viewer. However, you should have `git` installed
65+
and the repository should have the `.git` folder (there is no one in the
6666
source code uploaded to the browser extensions websites).
6767
6868
## How to start the viewer in the dev mode
6969
70-
You have to build the library once. You can archive it via `npm run make`. Then
70+
You have to build the library once. You can achieve it via `npm run make`. Then
7171
you can start the viewer:
7272
7373
```
@@ -96,7 +96,7 @@ web-ext build
9696
and the packed version of the extension will appear in the extension folder.
9797
9898
If you have some problems, read the technical documentation or create an issue.
99-
Also you can download the library from the official website. (All links are
99+
Also, you can download the library from the official website. (All links are
100100
below).
101101
102102
## Links

library/src/DjVuWorker.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* @typedef {{
3+
* command: string,
4+
* data?: {funcs: string[], args: any[][]}[]
5+
* } & Partial<Record<string, any>>} CommandObject
6+
*/
7+
18
/**
29
* DjVuScript is a function containing the whole library.
310
* It's a wrapper added in the build process. Look at the build config file.
@@ -85,8 +92,8 @@ export default class DjVuWorker {
8592
}
8693

8794
/**
88-
* @param {Array<Transferable>} transferList - the list of objects to transfer
89-
* ownership of the the Web Worker (like ArrayBuffer).
95+
* @param {CommandObject} commandObj
96+
* @param {Array<Transferable>} transferList
9097
*/
9198
createNewPromise(commandObj, transferList = undefined) {
9299
var callbacks;
@@ -98,6 +105,12 @@ export default class DjVuWorker {
98105
return promise;
99106
}
100107

108+
/**
109+
* Replaces functions with special "hyper callback" objects - it allows invoking callbacks from the web worker
110+
* (asynchronously of course, but it's mostly used to track progress)
111+
* @param {CommandObject} commandObj
112+
* @returns {CommandObject}
113+
*/
101114
prepareCommandObject(commandObj) {
102115
if (!(commandObj.data instanceof Array)) return commandObj;
103116

@@ -238,7 +251,7 @@ export default class DjVuWorker {
238251
return value;
239252
}
240253

241-
/** @param {Array<DjVuWorkerTask} tasks */
254+
/** @param {DjVuWorkerTask} tasks */
242255
run(...tasks) {
243256
const data = tasks.map(task => task._);
244257
return this.createNewPromise({
@@ -308,9 +321,14 @@ export default class DjVuWorker {
308321
}
309322

310323
class DjVuWorkerTask {
324+
/**
325+
* @property {{funcs: string[], args: any[][]}} _
326+
*/
311327

312328
/**
313329
* @param {DjVuWorker} worker
330+
* @param {string[]} funcs
331+
* @param {any[][]} args
314332
*/
315333
static instance(worker, funcs = [], args = []) {
316334
var proxy = new Proxy(DjVuWorkerTask.emptyFunc, {

library/src/DjVuWorkerScript.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export default function initWorker() {
4949
postMessage({
5050
command: 'Error',
5151
error: errorObj,
52-
a: () => {},
5352
...(obj.sendBackData ? { sendBackData: obj.sendBackData } : null),
5453
});
5554
}

viewer/src/locales/Spanish.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,5 +263,5 @@ export default {
263263
"Full page mode":
264264
"Modo de página completa",
265265
"Fullscreen mode":
266-
"Modo de oantalla completa",
267-
};
266+
"Modo de pantalla completa",
267+
};

viewer/syncLocales.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* A script for automatic synchronization of the Russian dictionary with others.
3-
* It automatically generate English.js from Russian.js, adds missing phrases with null values
3+
* It automatically generates English.js from Russian.js, adds missing phrases with null values
44
* to other dictionaries, and also can generate a template file for a new translation
55
* if the name of a new language is provided as the first command-line argument.
66
*/

0 commit comments

Comments
 (0)