@procedures/browser 0.55.1 → 0.56.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.
@@ -0,0 +1,121 @@
1
+ /**
2
+ * The profiles of the Chromium browsers on the disk: Google Chrome, Microsoft Edge and Chromium.
3
+ * This file finds the folders of the user data of each browser. Then it finds the bookmarks files of
4
+ * each profile in them, with the names of the profiles, and reads a file. The parse is in `bookmarks.ts`.
5
+ * This file uses Node.js, so only the root entry exports it.
6
+ */
7
+ import { readFile, readdir, stat } from "node:fs/promises";
8
+ import { join, posix, win32 } from "node:path";
9
+ import { BOOKMARK_FILES, MAX_BOOKMARKS_BYTES, parseChromeBookmarks, profileNames, } from "./bookmarks.js";
10
+ /**
11
+ * The file operations on the disk. `list` gives no names for each error, not only for a missing
12
+ * folder: also for a folder that it cannot read (`EACCES`). `size` gives `undefined` for each error
13
+ * and for a path that is not a file. `read` throws the error of the disk.
14
+ */
15
+ export const diskFileAccess = {
16
+ list: async (folder) => {
17
+ try {
18
+ return await readdir(folder);
19
+ }
20
+ catch {
21
+ return [];
22
+ }
23
+ },
24
+ size: async (file) => {
25
+ try {
26
+ const found = await stat(file);
27
+ return found.isFile() ? found.size : undefined;
28
+ }
29
+ catch {
30
+ return undefined;
31
+ }
32
+ },
33
+ read: (file) => readFile(file, "utf8"),
34
+ };
35
+ /** The browsers of `browserDataFolders`, in the order of its result. */
36
+ export const PROFILE_BROWSERS = ["chrome", "edge", "chromium"];
37
+ /** The parts of the path of the user data of each browser, on each platform. */
38
+ const DATA_PATHS = {
39
+ chrome: { windows: ["Google", "Chrome", "User Data"], mac: ["Google", "Chrome"], linux: "google-chrome" },
40
+ edge: { windows: ["Microsoft", "Edge", "User Data"], mac: ["Microsoft Edge"], linux: "microsoft-edge" },
41
+ chromium: { windows: ["Chromium", "User Data"], mac: ["Chromium"], linux: "chromium" },
42
+ };
43
+ /**
44
+ * This function gives the folders of the user data of the browsers for a platform. Windows uses
45
+ * `LOCALAPPDATA`, macOS uses `~/Library/Application Support`, and Linux uses `XDG_CONFIG_HOME` or `~/.config`.
46
+ * The function reads no file, so a folder in the result can be absent.
47
+ */
48
+ export function browserDataFolders(platform, env, home, browsers = PROFILE_BROWSERS) {
49
+ if (platform === "win32") {
50
+ const local = env["LOCALAPPDATA"] ?? win32.join(home, "AppData", "Local");
51
+ return browsers.map((browser) => ({ browser, folder: win32.join(local, ...DATA_PATHS[browser].windows) }));
52
+ }
53
+ if (platform === "darwin") {
54
+ const support = posix.join(home, "Library", "Application Support");
55
+ return browsers.map((browser) => ({ browser, folder: posix.join(support, ...DATA_PATHS[browser].mac) }));
56
+ }
57
+ const config = env["XDG_CONFIG_HOME"] ?? posix.join(home, ".config");
58
+ return browsers.map((browser) => ({ browser, folder: posix.join(config, DATA_PATHS[browser].linux) }));
59
+ }
60
+ /** A profile folder has the name `Default` or `Profile <n>`. The guest and system profiles have no bookmarks. */
61
+ const PROFILE = /^(Default|Profile \d+)$/;
62
+ /** This function gives the order of two profile folders: `Default` first, then `Profile <n>` by the number. */
63
+ function profileOrder(a, b) {
64
+ const number = (name) => (name === "Default" ? 0 : Number(name.slice("Profile ".length)));
65
+ return number(a) - number(b);
66
+ }
67
+ /**
68
+ * This function finds the bookmarks files of the profiles in the folders of the user data, in the
69
+ * order of the folders. In a folder, it gives `Default` first, then `Profile <n>` by the number. The
70
+ * file `Local State` gives the names of the profiles. Without it, a profile has the name of its folder.
71
+ * The id of a file starts with the key of its browser, so the files of two browsers have different ids.
72
+ */
73
+ export async function findBookmarkFiles(folders, files = diskFileAccess) {
74
+ const found = [];
75
+ for (const { browser, folder } of folders) {
76
+ let names = new Map();
77
+ try {
78
+ names = profileNames(JSON.parse(await files.read(join(folder, "Local State"))));
79
+ }
80
+ catch {
81
+ // A missing or broken file Local State gives the names of the folders
82
+ }
83
+ const profiles = new Set([...names.keys(), ...(await files.list(folder))].filter((name) => PROFILE.test(name)));
84
+ for (const profile of [...profiles].sort(profileOrder)) {
85
+ for (const [file, kind] of Object.entries(BOOKMARK_FILES)) {
86
+ const path = join(folder, profile, file);
87
+ const size = await files.size(path);
88
+ if (size === undefined)
89
+ continue;
90
+ found.push({ id: `${browser}:${profile}:${file}`, name: names.get(profile) ?? profile, kind, browser, profile, path, size });
91
+ }
92
+ }
93
+ }
94
+ return found;
95
+ }
96
+ /**
97
+ * This function reads and parses a bookmarks file that `findBookmarkFiles` found. It reads the size
98
+ * again, because the file can change after the search. It refuses a file over `MAX_BOOKMARKS_BYTES`
99
+ * before the read. The default prefix of the keys is the id of the file and a colon, so the keys of
100
+ * two files are different.
101
+ *
102
+ * @throws Error when the file is not there, is too large, is not JSON or has no roots
103
+ */
104
+ export async function readBookmarkFile(file, files = diskFileAccess, options = {}) {
105
+ const size = await files.size(file.path);
106
+ if (size === undefined)
107
+ throw new Error(`The file ${file.path} is not there now.`);
108
+ if (size > MAX_BOOKMARKS_BYTES) {
109
+ throw new Error(`The file ${file.path} has ${size} bytes. A bookmarks file has ${MAX_BOOKMARKS_BYTES} bytes at most.`);
110
+ }
111
+ const text = await files.read(file.path);
112
+ let value;
113
+ try {
114
+ value = JSON.parse(text);
115
+ }
116
+ catch (error) {
117
+ throw new Error(`The file ${file.path} is not JSON, so it is not a bookmarks file.`, { cause: error });
118
+ }
119
+ return parseChromeBookmarks(value, { prefix: options.prefix ?? `${file.id}:` });
120
+ }
121
+ //# sourceMappingURL=profiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiles.js","sourceRoot":"","sources":["../src/profiles.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,GAIb,MAAM,gBAAgB,CAAC;AAYxB;;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,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,CAAC,IAAI,8CAA8C,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACzG,CAAC;IACD,OAAO,oBAAoB,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;AAClF,CAAC"}
package/dist/run.d.ts CHANGED
@@ -5,7 +5,12 @@
5
5
  *
6
6
  * The browser starts through `runCommand` of `@procedures/shell`, not through a shell. A time limit
7
7
  * and the signal of the call stop its process tree.
8
+ *
9
+ * With the option `hostPolicy`, the run starts a policy proxy of `@procedures/http`. The browser
10
+ * sends each request through the proxy, and the proxy applies the host policy to each request.
11
+ * When the page is an `http:` or `https:` URL and the proxy gets no request, the run fails.
8
12
  */
13
+ import { type HostPolicy, type ProxyRefusal } from "@procedures/http";
9
14
  import { type CommandOptions, type CommandResult } from "@procedures/shell/command";
10
15
  import { type FindBrowserOptions } from "./browser.js";
11
16
  /** The default time limit of one render, in milliseconds. */
@@ -24,7 +29,30 @@ export interface HeadlessOptions extends FindBrowserOptions {
24
29
  readonly signal?: AbortSignal | undefined;
25
30
  /** The function that runs the browser (default: `runCommand`). The tests give their own. */
26
31
  readonly runner?: CommandRunner | undefined;
32
+ /**
33
+ * The host policy of each request of the browser. With it, each request goes through a policy
34
+ * proxy, also each redirect and each resource of the page. The proxy gives the status 403 to
35
+ * each host that the policy refuses.
36
+ */
37
+ readonly hostPolicy?: HostPolicy | undefined;
38
+ /** This function gets each request that the host policy refused. It needs `hostPolicy`. */
39
+ readonly onHostRefusal?: ((refusal: ProxyRefusal) => void) | undefined;
27
40
  }
41
+ /**
42
+ * This function gives the flags that send each request of the browser through the proxy at
43
+ * `proxyUrl`, and that close the paths around the proxy.
44
+ *
45
+ * - `--proxy-server` sends each `http:`, `https:`, `ws:` and `wss:` request to the proxy. The proxy
46
+ * resolves each name, not the browser.
47
+ * - `--proxy-bypass-list=<-loopback>` removes the default bypass of `localhost`, of the loopback
48
+ * addresses and of the link-local addresses. Thus these requests also go to the proxy.
49
+ * - `--disable-quic` stops the QUIC protocol, so no request goes over UDP around the proxy.
50
+ * - `--force-webrtc-ip-handling-policy=disable_non_proxied_udp` stops the UDP of WebRTC, and shows no
51
+ * local address.
52
+ * - `--host-resolver-rules` stops each DNS look-up of the browser. The only exception is the address
53
+ * of the proxy.
54
+ */
55
+ export declare function policyProxyArgs(proxyUrl: string): string[];
28
56
  /** The result of a render. */
29
57
  export interface RenderResult {
30
58
  /** The absolute path of the output file. */
@@ -57,13 +85,25 @@ export interface HeadlessRender {
57
85
  }
58
86
  /** This function gives the first bytes of a file, at most `count` bytes. */
59
87
  export declare function readHead(path: string, count: number): Buffer;
88
+ /**
89
+ * This function makes a new temporary folder, gives its path to `use`, and then removes the folder,
90
+ * also when `use` throws. The name of the folder starts with `prefix`. The folder is in `folder`,
91
+ * else in the temporary folder of the system. Each temporary folder of this package uses this function.
92
+ */
93
+ export declare function withTemporaryFolder<T>(prefix: string, folder: string | undefined, use: (path: string) => Promise<T>): Promise<T>;
60
94
  /**
61
95
  * This function starts the browser one time for a render, and gives the path and the size of the
62
96
  * file. It throws when it finds no browser, at the time limit and after a cancel. It also throws
63
97
  * when the file is missing, empty or not of the kind of the render.
64
98
  *
65
99
  * An existing output file changes only after the check of the new file. Thus a failed render keeps
66
- * an old output file.
100
+ * an old output file. Without the option `output`, the file goes in a new temporary folder. This
101
+ * folder stays after a success, and goes after a failure.
102
+ *
103
+ * With the option `hostPolicy`, the browser gets the flags of `policyProxyArgs` before the flags of
104
+ * `args`. The proxy stops at the end of the run, also after an error. When the page is an `http:`
105
+ * or `https:` URL and the proxy gets no request, the render fails. Then the requests of the page
106
+ * did not go through the policy.
67
107
  */
68
108
  export declare function headlessRender(render: HeadlessRender, source: PageSource, options: HeadlessOptions): Promise<RenderResult>;
69
109
  //# sourceMappingURL=run.d.ts.map
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CAAE,CAAC;AAE1G,qFAAqF;AACrF,MAAM,WAAW,cAAc;IAC7B,oFAAoF;IACpF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oGAAoG;IACpG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8FAA8F;IAC9F,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IACxF,qFAAqF;IACrF,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAChC;AAED,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAS5D;AA2BD;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAOtI;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC,CAchI"}
package/dist/run.js CHANGED
@@ -5,15 +5,85 @@
5
5
  *
6
6
  * The browser starts through `runCommand` of `@procedures/shell`, not through a shell. A time limit
7
7
  * and the signal of the call stop its process tree.
8
+ *
9
+ * With the option `hostPolicy`, the run starts a policy proxy of `@procedures/http`. The browser
10
+ * sends each request through the proxy, and the proxy applies the host policy to each request.
11
+ * When the page is an `http:` or `https:` URL and the proxy gets no request, the run fails.
8
12
  */
9
13
  import { closeSync, copyFileSync, mkdirSync, mkdtempSync, openSync, readSync, rmSync, statSync, writeFileSync } from "node:fs";
10
14
  import { tmpdir } from "node:os";
11
15
  import { dirname, join, resolve } from "node:path";
12
16
  import { pathToFileURL } from "node:url";
17
+ import { startPolicyProxy } from "@procedures/http";
13
18
  import { runCommand } from "@procedures/shell/command";
14
19
  import { BROWSER_ENV, findBrowser } from "./browser.js";
15
20
  /** The default time limit of one render, in milliseconds. */
16
21
  export const DEFAULT_TIMEOUT_MS = 60_000;
22
+ /**
23
+ * The switches that the flags of the policy proxy set, and the switches that can undo these flags.
24
+ * With a host policy, the run refuses each of them in `args`.
25
+ */
26
+ const POLICY_SWITCHES = new Set([
27
+ "proxy-server",
28
+ "proxy-bypass-list",
29
+ "no-proxy-server",
30
+ "proxy-pac-url",
31
+ "proxy-auto-detect",
32
+ "use-system-proxy-resolver",
33
+ "winhttp-proxy-resolver",
34
+ "enable-quic",
35
+ "origin-to-force-quic-on",
36
+ "force-webrtc-ip-handling-policy",
37
+ "host-resolver-rules",
38
+ "host-rules",
39
+ ]);
40
+ /**
41
+ * This function gives the flags that send each request of the browser through the proxy at
42
+ * `proxyUrl`, and that close the paths around the proxy.
43
+ *
44
+ * - `--proxy-server` sends each `http:`, `https:`, `ws:` and `wss:` request to the proxy. The proxy
45
+ * resolves each name, not the browser.
46
+ * - `--proxy-bypass-list=<-loopback>` removes the default bypass of `localhost`, of the loopback
47
+ * addresses and of the link-local addresses. Thus these requests also go to the proxy.
48
+ * - `--disable-quic` stops the QUIC protocol, so no request goes over UDP around the proxy.
49
+ * - `--force-webrtc-ip-handling-policy=disable_non_proxied_udp` stops the UDP of WebRTC, and shows no
50
+ * local address.
51
+ * - `--host-resolver-rules` stops each DNS look-up of the browser. The only exception is the address
52
+ * of the proxy.
53
+ */
54
+ export function policyProxyArgs(proxyUrl) {
55
+ const { hostname } = new URL(proxyUrl);
56
+ return [
57
+ `--proxy-server=${proxyUrl}`,
58
+ "--proxy-bypass-list=<-loopback>",
59
+ "--disable-quic",
60
+ "--force-webrtc-ip-handling-policy=disable_non_proxied_udp",
61
+ `--host-resolver-rules=MAP * ~NOTFOUND , EXCLUDE ${hostname}`,
62
+ ];
63
+ }
64
+ /**
65
+ * This function gives the name of the switch of a flag, or undefined for a value that is not a
66
+ * switch. The browser takes the prefixes `--`, `-` and, on Windows, `/`. Windows ignores the case of
67
+ * the name. Thus the function takes each prefix, and gives the name in lower case.
68
+ */
69
+ function switchName(arg) {
70
+ const match = /^(?:--|-|\/)([^=]+)/.exec(arg);
71
+ return match?.[1]?.toLowerCase();
72
+ }
73
+ /** This function throws when the options of the host policy do not agree with the other options. */
74
+ function checkPolicyOptions(options) {
75
+ if (options.hostPolicy === undefined) {
76
+ if (options.onHostRefusal !== undefined)
77
+ throw new Error("The option onHostRefusal needs the option hostPolicy");
78
+ return;
79
+ }
80
+ for (const arg of options.args ?? []) {
81
+ const name = switchName(arg);
82
+ if (name !== undefined && POLICY_SWITCHES.has(name)) {
83
+ throw new Error(`The option hostPolicy sets the proxy flags of the browser, so args cannot have the flag --${name}`);
84
+ }
85
+ }
86
+ }
17
87
  /** This function gives the first bytes of a file, at most `count` bytes. */
18
88
  export function readHead(path, count) {
19
89
  const fd = openSync(path, "r");
@@ -37,26 +107,70 @@ function fileSize(path) {
37
107
  function lastLines(text, count = 5) {
38
108
  return text.trim().split(/\r?\n/).slice(-count).join("\n");
39
109
  }
110
+ /**
111
+ * This function removes a folder and its content. It tries again 3 times, 100 ms apart, because
112
+ * Windows can hold a file for a short time after the browser stops. A removal that fails leaves the
113
+ * folder and does not throw. Thus it does not hide the result or the error of the caller.
114
+ */
115
+ function removeFolder(path) {
116
+ try {
117
+ rmSync(path, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
118
+ }
119
+ catch {
120
+ // The folder stays in the temporary folder of the system
121
+ }
122
+ }
123
+ /**
124
+ * This function makes a new temporary folder, gives its path to `use`, and then removes the folder,
125
+ * also when `use` throws. The name of the folder starts with `prefix`. The folder is in `folder`,
126
+ * else in the temporary folder of the system. Each temporary folder of this package uses this function.
127
+ */
128
+ export async function withTemporaryFolder(prefix, folder, use) {
129
+ const path = mkdtempSync(join(folder ?? tmpdir(), prefix));
130
+ try {
131
+ return await use(path);
132
+ }
133
+ finally {
134
+ removeFolder(path);
135
+ }
136
+ }
40
137
  /**
41
138
  * This function starts the browser one time for a render, and gives the path and the size of the
42
139
  * file. It throws when it finds no browser, at the time limit and after a cancel. It also throws
43
140
  * when the file is missing, empty or not of the kind of the render.
44
141
  *
45
142
  * An existing output file changes only after the check of the new file. Thus a failed render keeps
46
- * an old output file.
143
+ * an old output file. Without the option `output`, the file goes in a new temporary folder. This
144
+ * folder stays after a success, and goes after a failure.
145
+ *
146
+ * With the option `hostPolicy`, the browser gets the flags of `policyProxyArgs` before the flags of
147
+ * `args`. The proxy stops at the end of the run, also after an error. When the page is an `http:`
148
+ * or `https:` URL and the proxy gets no request, the render fails. Then the requests of the page
149
+ * did not go through the policy.
47
150
  */
48
151
  export async function headlessRender(render, source, options) {
152
+ checkPolicyOptions(options);
49
153
  const browser = findBrowser(options);
50
154
  if (browser === undefined) {
51
155
  throw new Error(`No browser found. Install Microsoft Edge, Google Chrome or Chromium, or set ${BROWSER_ENV} to the browser program.`);
52
156
  }
53
- const work = mkdtempSync(join(tmpdir(), render.prefix));
54
- const profile = join(work, "profile");
55
- const htmlFile = join(work, "page.html");
56
- const output = resolve(options.output ?? join(work, render.file));
57
- const written = join(work, render.file);
58
- let made = false;
157
+ if (options.output !== undefined)
158
+ return renderOnce(render, source, options, browser, resolve(options.output));
159
+ const kept = mkdtempSync(join(tmpdir(), render.prefix));
59
160
  try {
161
+ return await renderOnce(render, source, options, browser, join(kept, render.file));
162
+ }
163
+ catch (error) {
164
+ removeFolder(kept);
165
+ throw error;
166
+ }
167
+ }
168
+ /** This function starts the browser in a temporary folder that always goes, and copies the checked file to `output`. */
169
+ function renderOnce(render, source, options, browser, output) {
170
+ return withTemporaryFolder(render.prefix, undefined, async (work) => {
171
+ const profile = join(work, "profile");
172
+ const htmlFile = join(work, "page.html");
173
+ const written = join(work, render.file);
60
174
  let page;
61
175
  if ("html" in source) {
62
176
  writeFileSync(htmlFile, source.html, "utf8");
@@ -71,13 +185,22 @@ export async function headlessRender(render, source, options) {
71
185
  mkdirSync(dirname(output), { recursive: true });
72
186
  const run = options.runner ?? runCommand;
73
187
  const timeout = options.timeout ?? DEFAULT_TIMEOUT_MS;
74
- const result = await run(browser, {
75
- args: render.argv(page, written, profile, options.args ?? []),
76
- timeout,
77
- signal: options.signal,
78
- maxOutputBytes: 64 * 1024,
79
- keep: "tail",
80
- });
188
+ const proxy = options.hostPolicy === undefined ? undefined : await startPolicyProxy({ policy: options.hostPolicy, onRefusal: options.onHostRefusal });
189
+ let result;
190
+ try {
191
+ // The flags of the proxy come before the extra flags. A "--" in the extra flags ends the switches of the browser
192
+ const extra = proxy === undefined ? (options.args ?? []) : [...policyProxyArgs(proxy.url), ...(options.args ?? [])];
193
+ result = await run(browser, {
194
+ args: render.argv(page, written, profile, extra),
195
+ timeout,
196
+ signal: options.signal,
197
+ maxOutputBytes: 64 * 1024,
198
+ keep: "tail",
199
+ });
200
+ }
201
+ finally {
202
+ await proxy?.close();
203
+ }
81
204
  if (result.error !== undefined)
82
205
  throw new Error(`The browser did not start: ${result.error}`);
83
206
  if (result.timedOut === true)
@@ -89,23 +212,16 @@ export async function headlessRender(render, source, options) {
89
212
  const detail = lastLines(result.stderr || result.stdout);
90
213
  throw new Error(`The browser made no ${render.noun} (exit code ${result.exitCode})${detail ? `: ${detail}` : ""}`);
91
214
  }
215
+ // A Chrome or Edge policy (ProxySettings or ProxyMode) replaces the flag --proxy-server, and the browser gives no error.
216
+ // A web page sends at least one request, so a run with no request through the proxy is not a pass
217
+ if (proxy !== undefined && /^https?:/i.test(page) && proxy.requests === 0) {
218
+ throw new Error("The browser sent no request through the policy proxy, so the host policy did not apply. A Chrome or Edge policy (ProxySettings or ProxyMode) can replace the flag --proxy-server.");
219
+ }
92
220
  if (!render.isValid(written))
93
221
  throw new Error(`The file ${output} is not a ${render.noun}`);
94
- // The temporary folder goes in `finally`, so a copy is enough, also across two drives
95
- if (written !== output)
96
- copyFileSync(written, output);
97
- made = true;
222
+ // The temporary folder goes after this function, so a copy is enough, also across two drives
223
+ copyFileSync(written, output);
98
224
  return { path: output, bytes, browser };
99
- }
100
- finally {
101
- // The temporary page and profile go. A default output stays in its folder after a success.
102
- if (made && options.output === undefined) {
103
- rmSync(profile, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
104
- rmSync(htmlFile, { force: true });
105
- }
106
- else {
107
- rmSync(work, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
108
- }
109
- }
225
+ });
110
226
  }
111
227
  //# sourceMappingURL=run.js.map
package/dist/run.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/H,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAA2C,MAAM,2BAA2B,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,WAAW,EAA2B,MAAM,cAAc,CAAC;AAEjF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AA8CzC,4EAA4E;AAC5E,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,KAAa;IAClD,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC/B,IAAI,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EAAE,CAAC,CAAC;QAC5F,6FAA6F;QAC7F,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -60,4 +60,25 @@ export declare function isImageFile(path: string, format: ScreenshotFormat): boo
60
60
  * own.
61
61
  */
62
62
  export declare function renderScreenshot(options: RenderScreenshotOptions): Promise<RenderScreenshotResult>;
63
+ /** The options of `renderScreenshotBytes`: the options of `renderScreenshot`, with no `output`. */
64
+ export interface RenderScreenshotBytesOptions extends Omit<RenderScreenshotOptions, "output"> {
65
+ /** The folder that gets the temporary folder of the picture. The default is the temporary folder of the system. */
66
+ readonly folder?: string | undefined;
67
+ }
68
+ /** The result of `renderScreenshotBytes`: the picture, its format and the browser program. */
69
+ export interface RenderScreenshotBytesResult {
70
+ /** The bytes of the picture. In Node.js, the value is a `Buffer`. */
71
+ readonly data: Uint8Array;
72
+ readonly format: ScreenshotFormat;
73
+ /** The browser program that made the picture. */
74
+ readonly browser: string;
75
+ }
76
+ /**
77
+ * This function loads a page in a headless browser, and gives the picture of the window as bytes.
78
+ * It has the options and the errors of `renderScreenshot`, with no `output`.
79
+ *
80
+ * The function writes the picture to a new temporary folder, and reads it. Then it removes the
81
+ * folder, also after an error. A folder that the system does not let it remove stays, and gives no error.
82
+ */
83
+ export declare function renderScreenshotBytes(options: RenderScreenshotBytesOptions): Promise<RenderScreenshotBytesResult>;
63
84
  //# sourceMappingURL=screenshot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../src/screenshot.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAA4B,KAAK,eAAe,EAAwC,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAEnI,kGAAkG;AAClG,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,MAAM,G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,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAOvH"}
@@ -3,8 +3,9 @@
3
3
  * uses the headless run of `run.ts`. The browser loads the page in a window of the given size, and
4
4
  * writes a PNG, JPEG or WebP picture of the window.
5
5
  */
6
- import { extname } from "node:path";
7
- import { headlessRender, readHead } from "./run.js";
6
+ import { readFileSync } from "node:fs";
7
+ import { extname, join } from "node:path";
8
+ import { headlessRender, readHead, withTemporaryFolder } from "./run.js";
8
9
  /** The default size of the window: a common size of a desktop screen. */
9
10
  export const DEFAULT_SCREENSHOT_SIZE = { width: 1280, height: 800 };
10
11
  /** The largest side of the window, in CSS pixels. */
@@ -105,4 +106,19 @@ export async function renderScreenshot(options) {
105
106
  };
106
107
  return { ...(await headlessRender(render, source, options)), format };
107
108
  }
109
+ /**
110
+ * This function loads a page in a headless browser, and gives the picture of the window as bytes.
111
+ * It has the options and the errors of `renderScreenshot`, with no `output`.
112
+ *
113
+ * The function writes the picture to a new temporary folder, and reads it. Then it removes the
114
+ * folder, also after an error. A folder that the system does not let it remove stays, and gives no error.
115
+ */
116
+ export async function renderScreenshotBytes(options) {
117
+ const { folder, ...rest } = options;
118
+ const format = rest.format ?? "png";
119
+ return withTemporaryFolder("procedures-screenshot-bytes-", folder, async (work) => {
120
+ const { path, browser } = await renderScreenshot({ ...rest, format, output: join(work, `picture${SCREENSHOT_EXTENSIONS[format]}`) });
121
+ return { data: readFileSync(path), format, browser };
122
+ });
123
+ }
108
124
  //# sourceMappingURL=screenshot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../src/screenshot.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAiF,MAAM,UAAU,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AE,GAAG,MAAM,gBAAgB,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACrI,OAAO,EAAE,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@procedures/browser",
4
- "version": "0.55.1",
5
- "description": "Find a Chromium browser that is already installed (Edge, Chrome or Chromium), and render a page with it: a PDF file or a screenshot, with no browser download.",
4
+ "version": "0.56.0",
5
+ "description": "Find a Chromium browser that is already installed (Edge, Chrome or Chromium), and render a page with it: a PDF file or a screenshot, with no browser download. Find and read the bookmarks files of the profiles of Chrome, Edge and Chromium.",
6
6
  "keywords": [
7
7
  "browser",
8
8
  "headless",
@@ -10,6 +10,7 @@
10
10
  "edge",
11
11
  "pdf",
12
12
  "screenshot",
13
+ "bookmarks",
13
14
  "procedures"
14
15
  ],
15
16
  "homepage": "https://mark1russell7.github.io/client/",
@@ -29,7 +30,13 @@
29
30
  "exports": {
30
31
  ".": {
31
32
  "types": "./dist/index.d.ts",
32
- "import": "./dist/index.js"
33
+ "import": "./dist/index.js",
34
+ "default": "./dist/index.js"
35
+ },
36
+ "./bookmarks": {
37
+ "types": "./dist/bookmarks.d.ts",
38
+ "import": "./dist/bookmarks.js",
39
+ "default": "./dist/bookmarks.js"
33
40
  }
34
41
  },
35
42
  "files": [
@@ -50,15 +57,21 @@
50
57
  "provenance": true
51
58
  },
52
59
  "dependencies": {
53
- "@procedures/shell": "0.55.1"
60
+ "@procedures/http": "0.56.0",
61
+ "@procedures/shell": "0.56.0"
54
62
  },
55
63
  "devDependencies": {
56
64
  "typescript": "^7.0.2",
57
65
  "@types/node": "^22.0.0",
58
66
  "@mark1russell7/cue": "^2.1.1",
59
- "vitest": "^5.0.3"
67
+ "vitest": "^5.0.3",
68
+ "fast-check": "^4.10.2"
69
+ },
70
+ "client": {
71
+ "browser": [
72
+ "./bookmarks"
73
+ ]
60
74
  },
61
- "client": null,
62
75
  "scripts": {
63
76
  "build": "tsc -b",
64
77
  "typecheck": "tsc --noEmit && tsc -p tsconfig.test.json",