quickwin 2.3.1 → 3.0.0

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.
Files changed (97) hide show
  1. package/README.en.md +1 -2
  2. package/README.md +1 -2
  3. package/constants.ts +15 -0
  4. package/enum_map.d.ts +3 -0
  5. package/examples/PdfCanvas.js +1 -1
  6. package/examples/PdfCanvas.tsx +2 -2
  7. package/examples/execd/main.js +334 -188
  8. package/examples/pdf_preview2.js +76 -67
  9. package/examples/pdf_preview2.ts +84 -64
  10. package/examples/pdf_viewer.js +4932 -1029
  11. package/examples/pdf_viewer.tsx +11 -22
  12. package/examples/test_gallery.js +308 -143
  13. package/examples/test_gallery.tsx +12 -7
  14. package/examples/test_react_lazy.js +295 -133
  15. package/examples/test_react_lazy.tsx +4 -3
  16. package/examples/test_react_listbox.js +293 -132
  17. package/examples/test_react_listbox.tsx +3 -2
  18. package/examples/test_root_window.js +283 -126
  19. package/examples/test_tab.js +295 -133
  20. package/examples/test_tab.tsx +4 -3
  21. package/examples/tray_demo.js +37 -30
  22. package/examples/tray_demo.tsx +39 -32
  23. package/lib/bitmap.js +40 -0
  24. package/lib/bitmap.ts +39 -0
  25. package/lib/certs.js +31 -3
  26. package/lib/certs.ts +32 -3
  27. package/lib/dpi.js +30 -0
  28. package/lib/dpi.ts +31 -0
  29. package/lib/dumpRects.js +14 -7
  30. package/lib/dumpRects.ts +14 -6
  31. package/lib/ffi/bind.js +5 -4
  32. package/lib/ffi/bind.ts +9 -8
  33. package/lib/react-qw/components/DateTimePicker.js +6 -7
  34. package/lib/react-qw/components/Input.js +5 -1
  35. package/lib/react-qw/components/ListView.js +8 -6
  36. package/lib/react-qw/components/ScrollView.js +28 -22
  37. package/lib/react-qw/index.js +7 -5
  38. package/lib/react-qw/index.ts +5 -5
  39. package/lib/react-qw/props.js +3 -3
  40. package/lib/react-qw/props.ts +3 -3
  41. package/lib/react-qw/reconciler.js +12 -17
  42. package/lib/react-qw/reconciler.ts +12 -16
  43. package/lib/text-measure.js +9 -6
  44. package/lib/text-measure.ts +9 -6
  45. package/lib/windows/comctl32.js +3 -2
  46. package/lib/windows/comctl32.ts +3 -2
  47. package/lib/windows/gdi32.js +28 -6
  48. package/lib/windows/gdi32.ts +30 -6
  49. package/lib/windows/kernel32.js +9 -0
  50. package/lib/windows/kernel32.ts +9 -0
  51. package/lib/windows/shell32.js +11 -2
  52. package/lib/windows/shell32.ts +13 -2
  53. package/lib/windows/structs.js +51 -0
  54. package/lib/windows/structs.ts +55 -0
  55. package/lib/windows/user32.js +6 -5
  56. package/lib/windows/user32.ts +6 -5
  57. package/main.js +13 -5
  58. package/package.json +2 -2
  59. package/quickwin.d.ts +13 -115
  60. package/qwin-nowasm-x86.exe +0 -0
  61. package/qwin-nowasm.exe +0 -0
  62. package/qwin-x86.exe +0 -0
  63. package/qwin.exe +0 -0
  64. package/test/bench_ffi_callraw.js +3 -4
  65. package/test/bench_ffi_callraw.ts +3 -4
  66. package/test/debug/mupdf_debug.js +4 -22
  67. package/test/debug/wasm_export_debug.js +2 -12
  68. package/test/debug/wasm_names.js +3 -13
  69. package/test/example.pdf +0 -0
  70. package/test/mupdf-cdn.js +40 -0
  71. package/test/mupdf-cdn.ts +43 -0
  72. package/test/test_ffi.js +8 -9
  73. package/test/test_ffi.ts +8 -9
  74. package/test/test_ffi_abi.js +6 -6
  75. package/test/test_ffi_abi.ts +8 -8
  76. package/test/test_ffi_windows.js +82 -11
  77. package/test/test_ffi_windows.ts +85 -11
  78. package/test/test_gdi_draw.js +3 -3
  79. package/test/test_gdi_draw.ts +4 -4
  80. package/test/test_mupdf_render.js +4 -22
  81. package/test/test_mupdf_render.ts +4 -23
  82. package/test/test_mupdf_twice.js +4 -19
  83. package/test/test_mupdf_twice.ts +4 -20
  84. package/test/test_mupdf_wasm.js +10 -4
  85. package/test/test_mupdf_wasm.ts +6 -4
  86. package/test/test_react_complex.js +316 -140
  87. package/test/test_react_counter.js +295 -133
  88. package/test/test_react_flex.js +297 -138
  89. package/test/test_react_hidden.js +296 -134
  90. package/test/test_react_listview_link.js +288 -131
  91. package/test/test_react_notify.js +290 -133
  92. package/test/test_react_render.js +295 -133
  93. package/vendor/mupdf-wasm/mupdf-wasm.d.ts +0 -571
  94. package/vendor/mupdf-wasm/mupdf-wasm.js +0 -2749
  95. package/vendor/mupdf-wasm/mupdf-wasm.wasm +0 -0
  96. package/vendor/mupdf-wasm/mupdf.d.ts +0 -939
  97. package/vendor/mupdf-wasm/mupdf.js +0 -3317
@@ -1,31 +1,13 @@
1
1
  import * as std from 'std';
2
2
  import '../lib/polyfill.js';
3
- function loadWasmBytes(path) {
4
- const fp = std.open(path, 'rb');
5
- if (!fp)
6
- throw new Error('Cannot open: ' + path);
7
- fp.seek(0, 2);
8
- const size = fp.tell();
9
- fp.seek(0, 0);
10
- const buffer = new ArrayBuffer(size);
11
- fp.read(buffer, 0, size);
12
- fp.close();
13
- return buffer;
14
- }
15
- function setupMupdfModule(wasmPath) {
16
- const wasmBinary = loadWasmBytes(wasmPath);
17
- globalThis["$libmupdf_wasm_Module"] = {
18
- wasmBinary,
19
- locateFile: (p) => p
20
- };
21
- }
3
+ import { MUPDF_JS_URL, preloadMupdfWasm } from './mupdf-cdn.js';
22
4
  export const suite = {
23
5
  name: 'mupdf-render',
24
6
  run: async (t) => {
25
7
  try {
26
- setupMupdfModule('./vendor/mupdf-wasm/mupdf-wasm.wasm');
27
- const mupdf = await import('../vendor/mupdf-wasm/mupdf.js');
28
- const fp = std.open('./example.pdf', 'rb');
8
+ await preloadMupdfWasm();
9
+ const mupdf = await import(MUPDF_JS_URL);
10
+ const fp = std.open('./test/example.pdf', 'rb');
29
11
  if (!fp) {
30
12
  console.log('SKIP: no example.pdf');
31
13
  return;
@@ -1,36 +1,17 @@
1
1
  import * as std from 'std'
2
2
  import { Tester } from './test_helper.js'
3
3
  import '../lib/polyfill.js'
4
-
5
- function loadWasmBytes(path: string): ArrayBuffer {
6
- const fp = std.open(path, 'rb')
7
- if (!fp) throw new Error('Cannot open: ' + path)
8
- fp.seek(0, 2)
9
- const size = fp.tell()
10
- fp.seek(0, 0)
11
- const buffer = new ArrayBuffer(size)
12
- fp.read(buffer, 0, size)
13
- fp.close()
14
- return buffer
15
- }
16
-
17
- function setupMupdfModule(wasmPath: string) {
18
- const wasmBinary = loadWasmBytes(wasmPath)
19
- ;(globalThis as any)["$libmupdf_wasm_Module"] = {
20
- wasmBinary,
21
- locateFile: (p: string) => p
22
- }
23
- }
4
+ import { MUPDF_JS_URL, preloadMupdfWasm } from './mupdf-cdn.js'
24
5
 
25
6
  export const suite = {
26
7
  name: 'mupdf-render',
27
8
  run: async (t: Tester): Promise<void> => {
28
9
  try {
29
- setupMupdfModule('./vendor/mupdf-wasm/mupdf-wasm.wasm')
10
+ await preloadMupdfWasm()
30
11
 
31
- const mupdf: typeof import('../vendor/mupdf-wasm/mupdf.js') = await import('../vendor/mupdf-wasm/mupdf.js')
12
+ const mupdf: typeof import('@quickwinlabs/mupdf-wasm') = await import(MUPDF_JS_URL)
32
13
 
33
- const fp = std.open('./example.pdf', 'rb')
14
+ const fp = std.open('./test/example.pdf', 'rb')
34
15
  if (!fp) { console.log('SKIP: no example.pdf'); return }
35
16
  fp.seek(0, 2)
36
17
  const size = fp.tell()
@@ -1,32 +1,17 @@
1
1
  import '../lib/polyfill.js';
2
2
  import * as std from 'std';
3
- function loadWasmBytes(path) {
4
- const fp = std.open(path, 'rb');
5
- if (!fp)
6
- throw new Error('Cannot open: ' + path);
7
- fp.seek(0, 2);
8
- const size = fp.tell();
9
- fp.seek(0, 0);
10
- const buffer = new ArrayBuffer(size);
11
- fp.read(buffer, 0, size);
12
- fp.close();
13
- return buffer;
14
- }
3
+ import { MUPDF_JS_URL, preloadMupdfWasm } from './mupdf-cdn.js';
15
4
  export const suite = {
16
5
  name: 'mupdf-twice',
17
6
  run: async (t) => {
18
7
  try {
19
8
  console.log(' Loading WASM binary...');
20
- const wasmBinary = loadWasmBytes('./vendor/mupdf-wasm/mupdf-wasm.wasm');
9
+ const wasmBinary = await preloadMupdfWasm();
21
10
  console.log(' WASM binary loaded, size:', wasmBinary.byteLength);
22
- globalThis["$libmupdf_wasm_Module"] = {
23
- wasmBinary,
24
- locateFile: (p) => p
25
- };
26
11
  console.log(' Importing mupdf module...');
27
- const mupdf = await import('../vendor/mupdf-wasm/mupdf.js');
12
+ const mupdf = await import(MUPDF_JS_URL);
28
13
  console.log(' mupdf module imported ok');
29
- const fp = std.open('./example.pdf', 'rb');
14
+ const fp = std.open('./test/example.pdf', 'rb');
30
15
  if (!fp) {
31
16
  console.log('SKIP: no example.pdf');
32
17
  return;
@@ -1,37 +1,21 @@
1
1
  import '../lib/polyfill.js'
2
2
  import * as std from 'std'
3
3
  import { Tester } from './test_helper.js'
4
-
5
- function loadWasmBytes(path: string): ArrayBuffer {
6
- const fp = std.open(path, 'rb')
7
- if (!fp) throw new Error('Cannot open: ' + path)
8
- fp.seek(0, 2)
9
- const size = fp.tell()
10
- fp.seek(0, 0)
11
- const buffer = new ArrayBuffer(size)
12
- fp.read(buffer, 0, size)
13
- fp.close()
14
- return buffer
15
- }
4
+ import { MUPDF_JS_URL, preloadMupdfWasm } from './mupdf-cdn.js'
16
5
 
17
6
  export const suite = {
18
7
  name: 'mupdf-twice',
19
8
  run: async (t: Tester): Promise<void> => {
20
9
  try {
21
10
  console.log(' Loading WASM binary...')
22
- const wasmBinary = loadWasmBytes('./vendor/mupdf-wasm/mupdf-wasm.wasm')
11
+ const wasmBinary = await preloadMupdfWasm()
23
12
  console.log(' WASM binary loaded, size:', wasmBinary.byteLength)
24
13
 
25
- ;(globalThis as any)["$libmupdf_wasm_Module"] = {
26
- wasmBinary,
27
- locateFile: (p: string) => p
28
- }
29
-
30
14
  console.log(' Importing mupdf module...')
31
- const mupdf: typeof import('../vendor/mupdf-wasm/mupdf.js') = await import('../vendor/mupdf-wasm/mupdf.js')
15
+ const mupdf: typeof import('@quickwinlabs/mupdf-wasm') = await import(MUPDF_JS_URL)
32
16
  console.log(' mupdf module imported ok')
33
17
 
34
- const fp = std.open('./example.pdf', 'rb')
18
+ const fp = std.open('./test/example.pdf', 'rb')
35
19
  if (!fp) { console.log('SKIP: no example.pdf'); return }
36
20
  fp.seek(0, 2)
37
21
  const size = fp.tell()
@@ -1,9 +1,15 @@
1
- import { readWasmFile } from './test_helper.js';
1
+ import { fetchMupdfWasm } from './mupdf-cdn.js';
2
2
  export const suite = {
3
- name: 'vendor/mupdf-wasm',
4
- run: (t) => {
3
+ name: 'mupdf-wasm',
4
+ run: async (t) => {
5
5
  t.section('validate binary');
6
- const buf = readWasmFile('../vendor/mupdf-wasm/mupdf-wasm.wasm');
6
+ let buf = null;
7
+ try {
8
+ buf = await fetchMupdfWasm();
9
+ }
10
+ catch (e) {
11
+ console.log('mupdf wasm fetch failed: ' + String(e));
12
+ }
7
13
  if (!buf) {
8
14
  t.fail++;
9
15
  return;
@@ -1,10 +1,12 @@
1
- import { Tester, readWasmFile } from './test_helper.js'
1
+ import { Tester } from './test_helper.js'
2
+ import { fetchMupdfWasm } from './mupdf-cdn.js'
2
3
 
3
4
  export const suite = {
4
- name: 'vendor/mupdf-wasm',
5
- run: (t: Tester) => {
5
+ name: 'mupdf-wasm',
6
+ run: async (t: Tester) => {
6
7
  t.section('validate binary')
7
- const buf = readWasmFile('../vendor/mupdf-wasm/mupdf-wasm.wasm')
8
+ let buf: ArrayBuffer | null = null
9
+ try { buf = await fetchMupdfWasm() } catch (e) { console.log('mupdf wasm fetch failed: ' + String(e)) }
8
10
  if (!buf) { t.fail++; return }
9
11
  t.check('file size > 0', true, buf.byteLength > 0)
10
12
  const header = new Uint8Array(buf)