@pagepocket/write-down-unit 0.8.6 → 0.9.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.
@@ -4,8 +4,9 @@ export type WriteDownOptions = {
4
4
  outputPath: string;
5
5
  overwrite: boolean;
6
6
  };
7
+ type EntryInfo = import("@pagepocket/lib").EntryInfo;
7
8
  export declare const writeDown: (input: {
8
- entry: unknown;
9
+ entry: EntryInfo;
9
10
  html: {
10
11
  htmlString: string;
11
12
  baseUrl: string;
@@ -16,3 +17,4 @@ export declare const writeDown: (input: {
16
17
  outputPath: string;
17
18
  overwrite: boolean;
18
19
  }) => Promise<import("@pagepocket/lib").PagePocketCaptureResult>;
20
+ export {};
@@ -37,6 +37,9 @@ const pathExists = async (p) => {
37
37
  const removeExistingPath = async (p) => {
38
38
  await rm(p, { force: true, recursive: true });
39
39
  };
40
+ const isUrlEntry = (entry) => {
41
+ return entry.kind === "url";
42
+ };
40
43
  const withUniquePath = async (desiredPath, options) => {
41
44
  if (!(await pathExists(desiredPath))) {
42
45
  return desiredPath;
@@ -58,9 +61,7 @@ const withUniquePath = async (desiredPath, options) => {
58
61
  };
59
62
  const resolveSnapshotBaseName = (entry, html) => {
60
63
  const titleFromHtml = extractHtmlTitle(html.htmlString);
61
- const entryUrl = entry && typeof entry === "object" && "kind" in entry && entry.kind === "url"
62
- ? entry.url
63
- : undefined;
64
+ const entryUrl = isUrlEntry(entry) ? entry.url : undefined;
64
65
  const fallbackHostname = tryHostname(entryUrl) ?? tryHostname(html.url ?? html.baseUrl);
65
66
  return safeFilename(titleFromHtml ?? fallbackHostname ?? "snapshot");
66
67
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagepocket/write-down-unit",
3
- "version": "0.8.6",
3
+ "version": "0.9.0",
4
4
  "description": "PagePocket plugin: write snapshot output to fs (raw or zip)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -11,11 +11,12 @@
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
13
  "fflate": "^0.8.2",
14
- "@pagepocket/lib": "0.8.6",
15
- "@pagepocket/contracts": "0.8.6",
16
- "@pagepocket/uni-fs": "0.8.6"
14
+ "@pagepocket/lib": "0.9.0",
15
+ "@pagepocket/contracts": "0.9.0",
16
+ "@pagepocket/uni-fs": "0.9.0"
17
17
  },
18
18
  "devDependencies": {
19
+ "@types/node": "^20.17.12",
19
20
  "typescript": "^5.4.5"
20
21
  },
21
22
  "scripts": {