quickwin 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +3 -0
- package/README.md +2 -0
- package/package.json +1 -3
- package/qwin-nowasm-x86.exe +0 -0
- package/qwin-nowasm.exe +0 -0
- package/qwin-x86.exe +0 -0
- package/qwin.exe +0 -0
- package/examples/PdfCanvas.js +0 -38
- package/examples/PdfCanvas.tsx +0 -54
- package/examples/execd/main.js +0 -23379
- package/examples/execd/tray.js +0 -192
- package/examples/execd/worker.js +0 -122
- package/examples/pdf_preview2.js +0 -398
- package/examples/pdf_preview2.ts +0 -353
- package/examples/pdf_viewer.js +0 -22515
- package/examples/pdf_viewer.tsx +0 -228
- package/examples/test_gallery.js +0 -18692
- package/examples/test_gallery.tsx +0 -291
- package/examples/test_react_lazy.js +0 -18560
- package/examples/test_react_lazy.tsx +0 -65
- package/examples/test_react_listbox.js +0 -18562
- package/examples/test_react_listbox.tsx +0 -73
- package/examples/test_root_window.js +0 -18532
- package/examples/test_root_window.tsx +0 -41
- package/examples/test_tab.js +0 -18563
- package/examples/test_tab.tsx +0 -77
- package/examples/tray_demo.js +0 -86
- package/examples/tray_demo.tsx +0 -89
- package/test/add.wasm +0 -0
- package/test/bench_ffi_callraw.js +0 -235
- package/test/bench_ffi_callraw.ts +0 -235
- package/test/bench_ffi_overhead.js +0 -139
- package/test/bench_ffi_overhead.ts +0 -141
- package/test/bench_sendmessage.js +0 -104
- package/test/bench_sendmessage.ts +0 -100
- package/test/bench_sendmessage_nonnull.js +0 -187
- package/test/bench_sendmessage_nonnull.ts +0 -188
- package/test/complex.wasm +0 -0
- package/test/complex_imports.wasm +0 -0
- package/test/debug/http_server_e2e.js +0 -31
- package/test/debug/minwasm.js +0 -52
- package/test/debug/mupdf_debug.js +0 -86
- package/test/debug/wasm.js +0 -122
- package/test/debug/wasm_export_debug.js +0 -54
- package/test/debug/wasm_names.js +0 -36
- package/test/example.pdf +0 -0
- package/test/global_imports.wasm +0 -0
- package/test/import_func.wasm +0 -0
- package/test/imports.wasm +0 -0
- package/test/mupdf-cdn.js +0 -40
- package/test/mupdf-cdn.ts +0 -43
- package/test/run.js +0 -111
- package/test/run.ts +0 -116
- package/test/sjlj.wasm +0 -0
- package/test/test_basic.js +0 -7
- package/test/test_basic.ts +0 -9
- package/test/test_basic_fetch.js +0 -63
- package/test/test_basic_fetch.ts +0 -59
- package/test/test_brotli.js +0 -48
- package/test/test_brotli.ts +0 -52
- package/test/test_fetch_cache.js +0 -169
- package/test/test_fetch_cache.ts +0 -187
- package/test/test_ffi.js +0 -157
- package/test/test_ffi.ts +0 -170
- package/test/test_ffi_abi.js +0 -290
- package/test/test_ffi_abi.ts +0 -274
- package/test/test_ffi_array.js +0 -116
- package/test/test_ffi_array.ts +0 -141
- package/test/test_ffi_bind.js +0 -656
- package/test/test_ffi_bind.ts +0 -670
- package/test/test_ffi_struct.js +0 -779
- package/test/test_ffi_struct.ts +0 -828
- package/test/test_ffi_struct_layout.js +0 -495
- package/test/test_ffi_struct_layout.ts +0 -543
- package/test/test_ffi_user32.js +0 -103
- package/test/test_ffi_user32.ts +0 -113
- package/test/test_ffi_windows.js +0 -172
- package/test/test_ffi_windows.ts +0 -187
- package/test/test_files.js +0 -102
- package/test/test_files.ts +0 -121
- package/test/test_frame_encoding.js +0 -128
- package/test/test_frame_encoding.ts +0 -132
- package/test/test_gdi_draw.js +0 -681
- package/test/test_gdi_draw.ts +0 -725
- package/test/test_helper.js +0 -91
- package/test/test_helper.ts +0 -88
- package/test/test_http_import.js +0 -96
- package/test/test_http_import.ts +0 -93
- package/test/test_http_server.js +0 -214
- package/test/test_http_server.ts +0 -211
- package/test/test_import_dir.js +0 -4
- package/test/test_import_dir.ts +0 -5
- package/test/test_ipv6.js +0 -134
- package/test/test_ipv6.ts +0 -130
- package/test/test_jsx.js +0 -1314
- package/test/test_meta_url.js +0 -3
- package/test/test_meta_url.ts +0 -4
- package/test/test_mupdf_render.js +0 -51
- package/test/test_mupdf_render.ts +0 -55
- package/test/test_mupdf_twice.js +0 -62
- package/test/test_mupdf_twice.ts +0 -65
- package/test/test_mupdf_wasm.js +0 -39
- package/test/test_mupdf_wasm.ts +0 -32
- package/test/test_net_event.js +0 -57
- package/test/test_net_event.ts +0 -56
- package/test/test_net_fetch.js +0 -384
- package/test/test_net_fetch.ts +0 -373
- package/test/test_net_websocket.js +0 -180
- package/test/test_net_websocket.ts +0 -164
- package/test/test_polyfill.js +0 -144
- package/test/test_polyfill.ts +0 -159
- package/test/test_printer.js +0 -137
- package/test/test_printer.ts +0 -148
- package/test/test_proc.js +0 -141
- package/test/test_proc.ts +0 -163
- package/test/test_react_complex.js +0 -18678
- package/test/test_react_counter.js +0 -18555
- package/test/test_react_flex.js +0 -18871
- package/test/test_react_hidden.js +0 -18560
- package/test/test_react_listview_link.js +0 -18590
- package/test/test_react_notify.js +0 -18797
- package/test/test_react_render.js +0 -18550
- package/test/test_registry.js +0 -74
- package/test/test_registry.ts +0 -95
- package/test/test_sysinfo.js +0 -122
- package/test/test_sysinfo.ts +0 -141
- package/test/test_url.js +0 -173
- package/test/test_url.ts +0 -183
- package/test/test_wasm_basic.js +0 -85
- package/test/test_wasm_basic.ts +0 -73
- package/test/test_wasm_import_global.js +0 -41
- package/test/test_wasm_import_global.ts +0 -45
- package/test/test_wasm_sjlj.js +0 -145
- package/test/test_wasm_sjlj.ts +0 -125
- package/test/test_wasm_types.js +0 -97
- package/test/test_wasm_types.ts +0 -124
- package/test/test_wolfssl_read.js +0 -203
- package/test/test_wolfssl_read.ts +0 -184
- package/test/test_worker.js +0 -21
- package/test/test_worker.ts +0 -24
- package/test/test_worker_concurrent.js +0 -45
- package/test/test_worker_concurrent.ts +0 -56
- package/test/test_worker_data_url.js +0 -46
- package/test/test_worker_data_url.ts +0 -51
- package/test/test_worker_fetch.js +0 -26
- package/test/test_worker_fetch.ts +0 -27
- package/test/test_worker_net.js +0 -69
- package/test/test_worker_net.ts +0 -66
- package/test/test_worker_wasm_concurrent.js +0 -44
- package/test/test_worker_wasm_concurrent.ts +0 -45
- package/test/types.wasm +0 -0
- package/test/worker_fetch.js +0 -13
- package/test/worker_fetch.ts +0 -13
- package/test/worker_helper.js +0 -1
- package/test/worker_helper.ts +0 -1
- package/test/worker_http.js +0 -18
- package/test/worker_http.ts +0 -20
- package/test/worker_import_lib.js +0 -12
- package/test/worker_import_lib.ts +0 -13
- package/test/worker_module.js +0 -16
- package/test/worker_module.ts +0 -17
- package/test/worker_wasm_concurrent.js +0 -22
- package/test/worker_wasm_concurrent.ts +0 -22
package/test/test_meta_url.js
DELETED
package/test/test_meta_url.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import * as std from 'std';
|
|
2
|
-
import '../lib/polyfill.js';
|
|
3
|
-
import { MUPDF_JS_URL, preloadMupdfWasm } from './mupdf-cdn.js';
|
|
4
|
-
export const suite = {
|
|
5
|
-
name: 'mupdf-render',
|
|
6
|
-
run: async (t) => {
|
|
7
|
-
try {
|
|
8
|
-
await preloadMupdfWasm();
|
|
9
|
-
const mupdf = await import(MUPDF_JS_URL);
|
|
10
|
-
const fp = std.open('./test/example.pdf', 'rb');
|
|
11
|
-
if (!fp) {
|
|
12
|
-
console.log('SKIP: no example.pdf');
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
fp.seek(0, 2);
|
|
16
|
-
const size = fp.tell();
|
|
17
|
-
fp.seek(0, 0);
|
|
18
|
-
const buf = new ArrayBuffer(size);
|
|
19
|
-
fp.read(buf, 0, size);
|
|
20
|
-
fp.close();
|
|
21
|
-
console.log('pdf size:', size);
|
|
22
|
-
const doc = mupdf.Document.openDocument(new Uint8Array(buf), "application/pdf");
|
|
23
|
-
console.log('pages:', doc.countPages());
|
|
24
|
-
const page = doc.loadPage(0);
|
|
25
|
-
const bounds = page.getBounds();
|
|
26
|
-
if (bounds && bounds.length === 4)
|
|
27
|
-
console.log('page size:', bounds[2] - bounds[0], 'x', bounds[3] - bounds[1]);
|
|
28
|
-
const pixmap = page.toPixmap(mupdf.Matrix.scale(2, 2), mupdf.ColorSpace.DeviceRGB, false);
|
|
29
|
-
if (pixmap) {
|
|
30
|
-
console.log('pixmap:', pixmap.getWidth(), 'x', pixmap.getHeight());
|
|
31
|
-
const png = pixmap.asPNG();
|
|
32
|
-
console.log('png size:', png.byteLength);
|
|
33
|
-
const out = std.open('./output.png', 'wb');
|
|
34
|
-
if (out) {
|
|
35
|
-
const pngBuf = new ArrayBuffer(png.byteLength);
|
|
36
|
-
new Uint8Array(pngBuf).set(png);
|
|
37
|
-
out.write(pngBuf, 0, png.byteLength);
|
|
38
|
-
out.close();
|
|
39
|
-
}
|
|
40
|
-
console.log('saved to output.png');
|
|
41
|
-
}
|
|
42
|
-
doc.destroy();
|
|
43
|
-
console.log('done');
|
|
44
|
-
t.ok++;
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
console.log('ERROR:', error);
|
|
48
|
-
t.fail++;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import * as std from 'std'
|
|
2
|
-
import { Tester } from './test_helper.js'
|
|
3
|
-
import '../lib/polyfill.js'
|
|
4
|
-
import { MUPDF_JS_URL, preloadMupdfWasm } from './mupdf-cdn.js'
|
|
5
|
-
|
|
6
|
-
export const suite = {
|
|
7
|
-
name: 'mupdf-render',
|
|
8
|
-
run: async (t: Tester): Promise<void> => {
|
|
9
|
-
try {
|
|
10
|
-
await preloadMupdfWasm()
|
|
11
|
-
|
|
12
|
-
const mupdf: typeof import('@quickwinlabs/mupdf-wasm') = await import(MUPDF_JS_URL)
|
|
13
|
-
|
|
14
|
-
const fp = std.open('./test/example.pdf', 'rb')
|
|
15
|
-
if (!fp) { console.log('SKIP: no example.pdf'); return }
|
|
16
|
-
fp.seek(0, 2)
|
|
17
|
-
const size = fp.tell()
|
|
18
|
-
fp.seek(0, 0)
|
|
19
|
-
const buf = new ArrayBuffer(size)
|
|
20
|
-
fp.read(buf, 0, size)
|
|
21
|
-
fp.close()
|
|
22
|
-
console.log('pdf size:', size)
|
|
23
|
-
|
|
24
|
-
const doc = mupdf.Document.openDocument(new Uint8Array(buf), "application/pdf")
|
|
25
|
-
console.log('pages:', doc.countPages())
|
|
26
|
-
|
|
27
|
-
const page = doc.loadPage(0)
|
|
28
|
-
const bounds = page.getBounds()
|
|
29
|
-
if (bounds && bounds.length === 4)
|
|
30
|
-
console.log('page size:', bounds[2] - bounds[0], 'x', bounds[3] - bounds[1])
|
|
31
|
-
|
|
32
|
-
const pixmap = page.toPixmap(mupdf.Matrix.scale(2, 2), mupdf.ColorSpace.DeviceRGB, false)
|
|
33
|
-
if (pixmap) {
|
|
34
|
-
console.log('pixmap:', pixmap.getWidth(), 'x', pixmap.getHeight())
|
|
35
|
-
const png = pixmap.asPNG()
|
|
36
|
-
console.log('png size:', png.byteLength)
|
|
37
|
-
const out = std.open('./output.png', 'wb')
|
|
38
|
-
if (out) {
|
|
39
|
-
const pngBuf = new ArrayBuffer(png.byteLength)
|
|
40
|
-
new Uint8Array(pngBuf).set(png)
|
|
41
|
-
out.write(pngBuf, 0, png.byteLength)
|
|
42
|
-
out.close()
|
|
43
|
-
}
|
|
44
|
-
console.log('saved to output.png')
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
doc.destroy()
|
|
48
|
-
console.log('done')
|
|
49
|
-
t.ok++
|
|
50
|
-
} catch (error) {
|
|
51
|
-
console.log('ERROR:', error)
|
|
52
|
-
t.fail++
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
package/test/test_mupdf_twice.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import '../lib/polyfill.js';
|
|
2
|
-
import * as std from 'std';
|
|
3
|
-
import { MUPDF_JS_URL, preloadMupdfWasm } from './mupdf-cdn.js';
|
|
4
|
-
export const suite = {
|
|
5
|
-
name: 'mupdf-twice',
|
|
6
|
-
run: async (t) => {
|
|
7
|
-
try {
|
|
8
|
-
console.log(' Loading WASM binary...');
|
|
9
|
-
const wasmBinary = await preloadMupdfWasm();
|
|
10
|
-
console.log(' WASM binary loaded, size:', wasmBinary.byteLength);
|
|
11
|
-
console.log(' Importing mupdf module...');
|
|
12
|
-
const mupdf = await import(MUPDF_JS_URL);
|
|
13
|
-
console.log(' mupdf module imported ok');
|
|
14
|
-
const fp = std.open('./test/example.pdf', 'rb');
|
|
15
|
-
if (!fp) {
|
|
16
|
-
console.log('SKIP: no example.pdf');
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
fp.seek(0, 2);
|
|
20
|
-
const size = fp.tell();
|
|
21
|
-
fp.seek(0, 0);
|
|
22
|
-
const pdfBuf = new ArrayBuffer(size);
|
|
23
|
-
fp.read(pdfBuf, 0, size);
|
|
24
|
-
fp.close();
|
|
25
|
-
console.log(' PDF loaded, size:', size);
|
|
26
|
-
t.section('Test 1: two toPixmap on same page (no destroy)');
|
|
27
|
-
try {
|
|
28
|
-
const doc = mupdf.Document.openDocument(new Uint8Array(pdfBuf), "application/pdf");
|
|
29
|
-
const page = doc.loadPage(0);
|
|
30
|
-
console.log(' 1: toPixmap #1...');
|
|
31
|
-
const pm1 = page.toPixmap(mupdf.Matrix.scale(1, 1), mupdf.ColorSpace.DeviceRGB, false);
|
|
32
|
-
console.log(' 1: toPixmap #1 done:', pm1.getWidth(), 'x', pm1.getHeight());
|
|
33
|
-
t.check('toPixmap #1 ok', true, pm1 !== null);
|
|
34
|
-
console.log(' 1: toPixmap #2...');
|
|
35
|
-
const pm2 = page.toPixmap(mupdf.Matrix.scale(1, 1), mupdf.ColorSpace.DeviceRGB, false);
|
|
36
|
-
console.log(' 1: toPixmap #2 done:', pm2.getWidth(), 'x', pm2.getHeight());
|
|
37
|
-
t.check('toPixmap #2 ok', true, pm2 !== null);
|
|
38
|
-
}
|
|
39
|
-
catch (e) {
|
|
40
|
-
console.log(' 1: ERROR:', e instanceof Error ? e.message : String(e));
|
|
41
|
-
}
|
|
42
|
-
t.section('Test 2: second openDocument + toPixmap (no destroy of first)');
|
|
43
|
-
try {
|
|
44
|
-
console.log(' 2: openDocument #2...');
|
|
45
|
-
const doc2 = mupdf.Document.openDocument(new Uint8Array(pdfBuf), "application/pdf");
|
|
46
|
-
console.log(' 2: loadPage #2...');
|
|
47
|
-
const page2 = doc2.loadPage(0);
|
|
48
|
-
console.log(' 2: toPixmap #3...');
|
|
49
|
-
const pm3 = page2.toPixmap(mupdf.Matrix.scale(1, 1), mupdf.ColorSpace.DeviceRGB, false);
|
|
50
|
-
console.log(' 2: toPixmap #3 done:', pm3.getWidth(), 'x', pm3.getHeight());
|
|
51
|
-
t.check('toPixmap #3 ok', true, pm3 !== null);
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
console.log(' 2: ERROR:', e instanceof Error ? e.message : String(e));
|
|
55
|
-
}
|
|
56
|
-
console.log('All mupdf-twice tests done');
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
console.log('TOP-LEVEL ERROR:', e instanceof Error ? e.message : String(e));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
package/test/test_mupdf_twice.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import '../lib/polyfill.js'
|
|
2
|
-
import * as std from 'std'
|
|
3
|
-
import { Tester } from './test_helper.js'
|
|
4
|
-
import { MUPDF_JS_URL, preloadMupdfWasm } from './mupdf-cdn.js'
|
|
5
|
-
|
|
6
|
-
export const suite = {
|
|
7
|
-
name: 'mupdf-twice',
|
|
8
|
-
run: async (t: Tester): Promise<void> => {
|
|
9
|
-
try {
|
|
10
|
-
console.log(' Loading WASM binary...')
|
|
11
|
-
const wasmBinary = await preloadMupdfWasm()
|
|
12
|
-
console.log(' WASM binary loaded, size:', wasmBinary.byteLength)
|
|
13
|
-
|
|
14
|
-
console.log(' Importing mupdf module...')
|
|
15
|
-
const mupdf: typeof import('@quickwinlabs/mupdf-wasm') = await import(MUPDF_JS_URL)
|
|
16
|
-
console.log(' mupdf module imported ok')
|
|
17
|
-
|
|
18
|
-
const fp = std.open('./test/example.pdf', 'rb')
|
|
19
|
-
if (!fp) { console.log('SKIP: no example.pdf'); return }
|
|
20
|
-
fp.seek(0, 2)
|
|
21
|
-
const size = fp.tell()
|
|
22
|
-
fp.seek(0, 0)
|
|
23
|
-
const pdfBuf = new ArrayBuffer(size)
|
|
24
|
-
fp.read(pdfBuf, 0, size)
|
|
25
|
-
fp.close()
|
|
26
|
-
console.log(' PDF loaded, size:', size)
|
|
27
|
-
|
|
28
|
-
t.section('Test 1: two toPixmap on same page (no destroy)')
|
|
29
|
-
try {
|
|
30
|
-
const doc = mupdf.Document.openDocument(new Uint8Array(pdfBuf), "application/pdf")
|
|
31
|
-
const page = doc.loadPage(0)
|
|
32
|
-
|
|
33
|
-
console.log(' 1: toPixmap #1...')
|
|
34
|
-
const pm1 = page.toPixmap(mupdf.Matrix.scale(1, 1), mupdf.ColorSpace.DeviceRGB, false)
|
|
35
|
-
console.log(' 1: toPixmap #1 done:', pm1.getWidth(), 'x', pm1.getHeight())
|
|
36
|
-
t.check('toPixmap #1 ok', true, pm1 !== null)
|
|
37
|
-
|
|
38
|
-
console.log(' 1: toPixmap #2...')
|
|
39
|
-
const pm2 = page.toPixmap(mupdf.Matrix.scale(1, 1), mupdf.ColorSpace.DeviceRGB, false)
|
|
40
|
-
console.log(' 1: toPixmap #2 done:', pm2.getWidth(), 'x', pm2.getHeight())
|
|
41
|
-
t.check('toPixmap #2 ok', true, pm2 !== null)
|
|
42
|
-
} catch (e: unknown) {
|
|
43
|
-
console.log(' 1: ERROR:', e instanceof Error ? e.message : String(e))
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
t.section('Test 2: second openDocument + toPixmap (no destroy of first)')
|
|
47
|
-
try {
|
|
48
|
-
console.log(' 2: openDocument #2...')
|
|
49
|
-
const doc2 = mupdf.Document.openDocument(new Uint8Array(pdfBuf), "application/pdf")
|
|
50
|
-
console.log(' 2: loadPage #2...')
|
|
51
|
-
const page2 = doc2.loadPage(0)
|
|
52
|
-
console.log(' 2: toPixmap #3...')
|
|
53
|
-
const pm3 = page2.toPixmap(mupdf.Matrix.scale(1, 1), mupdf.ColorSpace.DeviceRGB, false)
|
|
54
|
-
console.log(' 2: toPixmap #3 done:', pm3.getWidth(), 'x', pm3.getHeight())
|
|
55
|
-
t.check('toPixmap #3 ok', true, pm3 !== null)
|
|
56
|
-
} catch (e: unknown) {
|
|
57
|
-
console.log(' 2: ERROR:', e instanceof Error ? e.message : String(e))
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
console.log('All mupdf-twice tests done')
|
|
61
|
-
} catch (e: unknown) {
|
|
62
|
-
console.log('TOP-LEVEL ERROR:', e instanceof Error ? e.message : String(e))
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
package/test/test_mupdf_wasm.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { fetchMupdfWasm } from './mupdf-cdn.js';
|
|
2
|
-
export const suite = {
|
|
3
|
-
name: 'mupdf-wasm',
|
|
4
|
-
run: async (t) => {
|
|
5
|
-
t.section('validate binary');
|
|
6
|
-
let buf = null;
|
|
7
|
-
try {
|
|
8
|
-
buf = await fetchMupdfWasm();
|
|
9
|
-
}
|
|
10
|
-
catch (e) {
|
|
11
|
-
console.log('mupdf wasm fetch failed: ' + String(e));
|
|
12
|
-
}
|
|
13
|
-
if (!buf) {
|
|
14
|
-
t.fail++;
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
t.check('file size > 0', true, buf.byteLength > 0);
|
|
18
|
-
const header = new Uint8Array(buf);
|
|
19
|
-
t.check('magic', true, header[0] === 0x00 && header[1] === 0x61 && header[2] === 0x73 && header[3] === 0x6d);
|
|
20
|
-
t.check('version 1', true, header[4] === 0x01 && header[5] === 0x00 && header[6] === 0x00 && header[7] === 0x00);
|
|
21
|
-
t.check('WebAssembly.validate', true, WebAssembly.validate(buf));
|
|
22
|
-
t.section('Module');
|
|
23
|
-
var mod = null;
|
|
24
|
-
try {
|
|
25
|
-
mod = new WebAssembly.Module(buf);
|
|
26
|
-
t.ok++;
|
|
27
|
-
}
|
|
28
|
-
catch (e) {
|
|
29
|
-
t.fail++;
|
|
30
|
-
}
|
|
31
|
-
t.section('imports/exports');
|
|
32
|
-
if (mod) {
|
|
33
|
-
const exps = WebAssembly.Module.exports(mod);
|
|
34
|
-
t.check('exports > 0', true, exps.length > 0);
|
|
35
|
-
const imps = WebAssembly.Module.imports(mod);
|
|
36
|
-
t.check('imports', imps.length, imps.length);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
package/test/test_mupdf_wasm.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Tester } from './test_helper.js'
|
|
2
|
-
import { fetchMupdfWasm } from './mupdf-cdn.js'
|
|
3
|
-
|
|
4
|
-
export const suite = {
|
|
5
|
-
name: 'mupdf-wasm',
|
|
6
|
-
run: async (t: Tester) => {
|
|
7
|
-
t.section('validate binary')
|
|
8
|
-
let buf: ArrayBuffer | null = null
|
|
9
|
-
try { buf = await fetchMupdfWasm() } catch (e) { console.log('mupdf wasm fetch failed: ' + String(e)) }
|
|
10
|
-
if (!buf) { t.fail++; return }
|
|
11
|
-
t.check('file size > 0', true, buf.byteLength > 0)
|
|
12
|
-
const header = new Uint8Array(buf)
|
|
13
|
-
t.check('magic', true, header[0] === 0x00 && header[1] === 0x61 && header[2] === 0x73 && header[3] === 0x6d)
|
|
14
|
-
t.check('version 1', true, header[4] === 0x01 && header[5] === 0x00 && header[6] === 0x00 && header[7] === 0x00)
|
|
15
|
-
t.check('WebAssembly.validate', true, WebAssembly.validate(buf))
|
|
16
|
-
|
|
17
|
-
t.section('Module')
|
|
18
|
-
var mod: WebAssembly.Module | null = null
|
|
19
|
-
try {
|
|
20
|
-
mod = new WebAssembly.Module(buf)
|
|
21
|
-
t.ok++
|
|
22
|
-
} catch (e) { t.fail++ }
|
|
23
|
-
|
|
24
|
-
t.section('imports/exports')
|
|
25
|
-
if (mod) {
|
|
26
|
-
const exps = WebAssembly.Module.exports(mod)
|
|
27
|
-
t.check('exports > 0', true, exps.length > 0)
|
|
28
|
-
const imps = WebAssembly.Module.imports(mod)
|
|
29
|
-
t.check('imports', imps.length, imps.length)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
package/test/test_net_event.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import * as sock from "sock";
|
|
2
|
-
import * as os from "os";
|
|
3
|
-
export const suite = {
|
|
4
|
-
name: 'net-event',
|
|
5
|
-
run: async (t) => {
|
|
6
|
-
await new Promise((resolve, reject) => {
|
|
7
|
-
const s = sock.socket();
|
|
8
|
-
if (s === null || s < 0) {
|
|
9
|
-
t.fail++;
|
|
10
|
-
reject(new Error('socket() failed'));
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
var connected = false, gotData = false;
|
|
14
|
-
const timeoutId = os.setTimeout(() => {
|
|
15
|
-
if (!connected) {
|
|
16
|
-
sock.closesocket(s);
|
|
17
|
-
reject(new Error('connect timeout'));
|
|
18
|
-
}
|
|
19
|
-
}, 5000);
|
|
20
|
-
sock.set_on_event(s, (event) => {
|
|
21
|
-
if (event.lNetworkEvents & 16 /* FdEvent.FD_CONNECT */) {
|
|
22
|
-
if (event.iErrorCode[0] === 0) {
|
|
23
|
-
connected = true;
|
|
24
|
-
t.ok++;
|
|
25
|
-
os.clearTimeout(timeoutId);
|
|
26
|
-
const req = "GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n";
|
|
27
|
-
const buf = new ArrayBuffer(req.length);
|
|
28
|
-
const v = new Uint8Array(buf);
|
|
29
|
-
for (let i = 0; i < req.length; i++)
|
|
30
|
-
v[i] = req.charCodeAt(i);
|
|
31
|
-
sock.send(s, buf);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
sock.closesocket(s);
|
|
35
|
-
reject(new Error('connect error: ' + event.iErrorCode[0]));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (event.lNetworkEvents & 1 /* FdEvent.FD_READ */ && connected && !gotData) {
|
|
39
|
-
const data = sock.recv(s, 4096);
|
|
40
|
-
if (data && data.byteLength > 0) {
|
|
41
|
-
gotData = true;
|
|
42
|
-
t.ok++;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (event.lNetworkEvents & 32 /* FdEvent.FD_CLOSE */) {
|
|
46
|
-
os.clearTimeout(timeoutId);
|
|
47
|
-
sock.closesocket(s);
|
|
48
|
-
if (gotData && connected)
|
|
49
|
-
resolve();
|
|
50
|
-
else
|
|
51
|
-
reject(new Error('test incomplete'));
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
sock.connect(s, '127.0.0.1', 18923);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
};
|
package/test/test_net_event.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import * as sock from "sock"
|
|
2
|
-
import * as os from "os"
|
|
3
|
-
import { Tester } from './test_helper.js'
|
|
4
|
-
import { FdEvent } from '../constants'
|
|
5
|
-
|
|
6
|
-
interface WSAEvent {
|
|
7
|
-
lNetworkEvents: number;
|
|
8
|
-
iErrorCode: number[];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const suite = {
|
|
12
|
-
name: 'net-event',
|
|
13
|
-
run: async (t: Tester): Promise<void> => {
|
|
14
|
-
await new Promise<void>((resolve, reject) => {
|
|
15
|
-
const s = sock.socket()
|
|
16
|
-
if (s === null || s < 0) { t.fail++; reject(new Error('socket() failed')); return }
|
|
17
|
-
|
|
18
|
-
var connected = false, gotData = false
|
|
19
|
-
|
|
20
|
-
const timeoutId = os.setTimeout(() => {
|
|
21
|
-
if (!connected) {
|
|
22
|
-
sock.closesocket(s)
|
|
23
|
-
reject(new Error('connect timeout'))
|
|
24
|
-
}
|
|
25
|
-
}, 5000)
|
|
26
|
-
|
|
27
|
-
sock.set_on_event(s, (event: WSAEvent) => {
|
|
28
|
-
if (event.lNetworkEvents & FdEvent.FD_CONNECT) {
|
|
29
|
-
if (event.iErrorCode[0] === 0) {
|
|
30
|
-
connected = true; t.ok++
|
|
31
|
-
os.clearTimeout(timeoutId)
|
|
32
|
-
const req = "GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n"
|
|
33
|
-
const buf = new ArrayBuffer(req.length)
|
|
34
|
-
const v = new Uint8Array(buf)
|
|
35
|
-
for (let i = 0; i < req.length; i++) v[i] = req.charCodeAt(i)
|
|
36
|
-
sock.send(s, buf)
|
|
37
|
-
} else {
|
|
38
|
-
sock.closesocket(s)
|
|
39
|
-
reject(new Error('connect error: ' + event.iErrorCode[0]))
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (event.lNetworkEvents & FdEvent.FD_READ && connected && !gotData) {
|
|
43
|
-
const data = sock.recv(s, 4096)
|
|
44
|
-
if (data && data.byteLength > 0) { gotData = true; t.ok++ }
|
|
45
|
-
}
|
|
46
|
-
if (event.lNetworkEvents & FdEvent.FD_CLOSE) {
|
|
47
|
-
os.clearTimeout(timeoutId)
|
|
48
|
-
sock.closesocket(s)
|
|
49
|
-
if (gotData && connected) resolve()
|
|
50
|
-
else reject(new Error('test incomplete'))
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
sock.connect(s, '127.0.0.1', 18923)
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
}
|