@pagepocket/lib 0.4.0 → 0.4.1

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 (2) hide show
  1. package/README.md +45 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # @pagepocket/lib
2
+
3
+ Library for rewriting captured HTML into an offline-ready snapshot. It downloads
4
+ assets, rewrites HTML/CSS/JS references to local URLs, and injects replay/preload
5
+ scripts.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @pagepocket/lib
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```ts
16
+ import { PagePocket } from "@pagepocket/lib";
17
+
18
+ const pagepocket = new PagePocket(htmlString, requestsJSON, {
19
+ assetsDirName: "example_files",
20
+ baseUrl: "https://example.com",
21
+ requestsPath: "example.requests.json"
22
+ });
23
+
24
+ const html = await pagepocket.put();
25
+ ```
26
+
27
+ ## API
28
+
29
+ ```ts
30
+ type PagePocketOptions = {
31
+ assetsDirName?: string;
32
+ baseUrl?: string;
33
+ requestsPath?: string;
34
+ };
35
+ ```
36
+
37
+ - `assetsDirName`: folder name for downloaded assets.
38
+ - `baseUrl`: used to resolve relative URLs.
39
+ - `requestsPath`: path to the `*.requests.json` file referenced by replay.
40
+
41
+ `put()` returns the rewritten HTML string.
42
+
43
+ ## Notes
44
+
45
+ - Uses `@pagepocket/uni-fs` for file IO so it works in Node and OPFS contexts.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pagepocket/lib",
3
- "version": "0.4.0",
4
- "description": "",
3
+ "version": "0.4.1",
4
+ "description": "Library for rewriting HTML snapshots and inlining local resources.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [
@@ -12,7 +12,7 @@
12
12
  "license": "ISC",
13
13
  "dependencies": {
14
14
  "cheerio": "^1.0.0-rc.12",
15
- "uni-fs": "npm:@pagepocket/uni-fs@0.4.0"
15
+ "uni-fs": "npm:@pagepocket/uni-fs@0.4.1"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/node": "^20.11.30",