@link-assistant/web-capture 1.11.2 → 2.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 (61) hide show
  1. package/.changeset/config.json +1 -1
  2. package/.dockerignore +6 -0
  3. package/.jscpd.json +4 -5
  4. package/CHANGELOG.md +12 -0
  5. package/Dockerfile +13 -11
  6. package/README.md +23 -4
  7. package/bin/web-capture.js +3 -2
  8. package/examples/js/capture_cache.js +12 -0
  9. package/examples/js/playwright_example.js +1 -1
  10. package/examples/python/capture_client.py +20 -0
  11. package/examples/python/html_download.py +2 -14
  12. package/examples/python/image_download.py +3 -7
  13. package/examples/python/markdown_download.py +2 -14
  14. package/examples/python/playwright_example.py +6 -6
  15. package/jest.config.mjs +1 -4
  16. package/package.json +54 -39
  17. package/src/archive.js +1 -1
  18. package/src/binary-download.js +14 -0
  19. package/src/cache.js +313 -0
  20. package/src/docx.js +1 -1
  21. package/src/fetch.js +1 -1
  22. package/src/figures.js +2 -12
  23. package/src/gdocs-model-wait.js +2 -4
  24. package/src/gdocs.js +1 -1
  25. package/src/index.js +7 -0
  26. package/src/lib.js +2 -2
  27. package/src/localize-images.js +2 -12
  28. package/src/search.js +1 -1
  29. package/src/shared-dialog.js +1 -1
  30. package/src/transport.js +2 -2
  31. package/tests/ci/dependency-freshness.test.js +74 -0
  32. package/tests/ci/detect-code-changes.test.js +36 -23
  33. package/tests/ci/docker-install.test.js +31 -0
  34. package/tests/ci/workflow-policy.test.js +18 -2
  35. package/tests/e2e/process.test.js +2 -1
  36. package/tests/helpers/nock.js +10 -0
  37. package/tests/helpers/screenshot.js +10 -0
  38. package/tests/helpers/search-fixture.cjs +1 -1
  39. package/tests/helpers/temporary-directory.js +12 -0
  40. package/tests/integration/api-endpoints.test.js +1 -1
  41. package/tests/integration/browser-engines.test.js +4 -52
  42. package/tests/integration/browser-packaged-path.test.js +45 -0
  43. package/tests/integration/deepwiki-rendered-page.mock.test.js +1 -1
  44. package/tests/integration/formalai-contract.test.js +1 -1
  45. package/tests/integration/github-readme.test.js +2 -6
  46. package/tests/integration/google-drive-image.test.js +1 -1
  47. package/tests/integration/search-endpoint.test.js +1 -1
  48. package/tests/integration/wikipedia-download.test.js +3 -11
  49. package/tests/mock/index.test.js +1 -1
  50. package/tests/unit/browser-launch-options.test.js +42 -0
  51. package/tests/unit/cache.test.js +182 -0
  52. package/tests/unit/fetch-html.test.js +1 -1
  53. package/tests/unit/gdocs-export-headers.test.js +1 -1
  54. package/tests/unit/gdocs.test.js +1 -1
  55. package/tests/unit/github.test.js +1 -1
  56. package/tests/unit/publish-verification.test.js +13 -16
  57. package/tests/unit/stream.test.js +8 -10
  58. package/tests/xpaste/xpaste-screenshot-markdown.mock.test.js +1 -1
  59. package/tests/xpaste/xpaste.e2e.test.js +1 -1
  60. package/tests/xpaste/xpaste.mock.test.js +1 -1
  61. package/babel.config.cjs +0 -13
@@ -17,10 +17,7 @@ describe('streamHandler', () => {
17
17
  });
18
18
 
19
19
  try {
20
- const res = await request(testApp())
21
- .get('/stream')
22
- .query({ url })
23
- .expect(200);
20
+ const res = await streamFrom(url);
24
21
 
25
22
  expect(upstreamHeaders['accept-encoding']).toBe('identity');
26
23
  expect(res.headers['content-type']).toBe('text/html; charset=utf-8');
@@ -39,15 +36,12 @@ describe('streamHandler', () => {
39
36
  res.writeHead(200, {
40
37
  'Content-Type': 'text/html; charset=utf-8',
41
38
  });
42
- res.write(body);
43
- res.socket.end();
39
+ // Wait until the body reaches the socket before deliberately truncating it.
40
+ res.write(body, () => res.socket.end());
44
41
  });
45
42
 
46
43
  try {
47
- const res = await request(testApp())
48
- .get('/stream')
49
- .query({ url })
50
- .expect(200);
44
+ const res = await streamFrom(url);
51
45
 
52
46
  expect(res.text).toContain('Example Domain');
53
47
  } finally {
@@ -83,3 +77,7 @@ async function closeServer(server) {
83
77
  });
84
78
  });
85
79
  }
80
+
81
+ function streamFrom(url) {
82
+ return request(testApp()).get('/stream').query({ url }).expect(200);
83
+ }
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import request from 'supertest';
9
- import nock from 'nock';
9
+ import nock from '../helpers/nock.js';
10
10
  import fs from 'fs';
11
11
  import path from 'path';
12
12
  import { fileURLToPath } from 'url';
@@ -1,5 +1,5 @@
1
1
  import getPort from 'get-port';
2
- import nock from 'nock';
2
+ import nock from '../helpers/nock.js';
3
3
  import { app } from '../../src/index.js';
4
4
 
5
5
  describe('xpaste.pro HTTP e2e', () => {
@@ -1,5 +1,5 @@
1
1
  import request from 'supertest';
2
- import nock from 'nock';
2
+ import nock from '../helpers/nock.js';
3
3
  import { jest } from '@jest/globals';
4
4
  import unzipper from 'unzipper';
5
5
 
package/babel.config.cjs DELETED
@@ -1,13 +0,0 @@
1
- module.exports = {
2
- presets: [
3
- [
4
- '@babel/preset-env',
5
- {
6
- targets: {
7
- node: 'current',
8
- },
9
- modules: false,
10
- },
11
- ],
12
- ],
13
- };