janus-parse 2.1.0 → 2.2.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.
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ A lightweight, high-performance, isomorphic HTML text extractor and sanitizer bu
|
|
|
12
12
|
|
|
13
13
|
Here is exactly what it handles:
|
|
14
14
|
|
|
15
|
-
1. **Completely removes blocked tags**: If a tag is blacklisted (like `script` or `style`), it doesn't just empty the content
|
|
15
|
+
1. **Completely removes blocked tags**: If a tag is blacklisted (like `script` or `style`), it doesn't just empty the content, it deletes the entire element so no empty HTML tags are left behind in your final string.
|
|
16
16
|
2. **Keeps specific HTML intact**: You can pass tags into `tagsToPreserve` (like `<code>` or `<iframe>`). It will keep their full HTML layout exactly as it is while stripping out generic structural tags like `<div>` or `<span>`.
|
|
17
17
|
3. **Cleans up messy whitespace**: It automatically strips out layout code indentations, tabs, and random line breaks, squashing them down into uniform, single spaces.
|
|
18
18
|
|
|
@@ -118,7 +118,7 @@ type JanusServerStreamConfig = {
|
|
|
118
118
|
config?: Config;
|
|
119
119
|
encoding?: BufferEncoding;
|
|
120
120
|
fetchOptions?: RequestInit;
|
|
121
|
-
|
|
121
|
+
filePath?: string;
|
|
122
122
|
};
|
|
123
123
|
```
|
|
124
124
|
|
|
@@ -133,9 +133,9 @@ type JanusServerStreamConfig = {
|
|
|
133
133
|
|
|
134
134
|
This package is split into targeted modules. Modern bundlers will only bundle the exact module you import, keeping your builds incredibly lightweight.
|
|
135
135
|
|
|
136
|
-
| Import Path | Target Environment | Size (
|
|
137
|
-
| :-------------------------- | :----------------- |
|
|
138
|
-
| `janus-parse/server` | Node.js | **~47.6 KB**
|
|
139
|
-
| `janus-parse/server:stream` | Node.js | **~49 KB**
|
|
140
|
-
| `janus-parse/client` | Browser | **~700 B**
|
|
141
|
-
| `janus-parse/client:stream` | Browser | **~1 KB**
|
|
136
|
+
| Import Path | Target Environment | Size (Gzipped) |
|
|
137
|
+
| :-------------------------- | :----------------- | :------------- |
|
|
138
|
+
| `janus-parse/server` | Node.js | **~47.6 KB** |
|
|
139
|
+
| `janus-parse/server:stream` | Node.js | **~49 KB** |
|
|
140
|
+
| `janus-parse/client` | Browser | **~700 B** |
|
|
141
|
+
| `janus-parse/client:stream` | Browser | **~1 KB** |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../lib/client/stream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../lib/client/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,KAAK,uBAAuB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,YAAY,CAAC,EAAE,WAAW,CAAC;CAC5B,CAAC;AAEF,wBAAsB,iBAAiB,CAAC,EACtC,GAAG,EACH,MAAM,EACN,QAAQ,EACR,YAAY,GACb,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAS3C"}
|
package/dist/client/stream.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { janusClient } from "./client.js";
|
|
2
1
|
export async function janusClientStream({ url, config, encoding, fetchOptions, }) {
|
|
3
2
|
const response = await fetch(url, fetchOptions);
|
|
4
3
|
if (!response.ok || !response.body) {
|
|
@@ -22,5 +21,6 @@ async function _janusClient(inputStream, config, encoding = "utf8") {
|
|
|
22
21
|
finally {
|
|
23
22
|
reader.releaseLock();
|
|
24
23
|
}
|
|
24
|
+
const { janusClient } = await import("./client.js");
|
|
25
25
|
return janusClient(text, config);
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../lib/server/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../lib/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAa7C,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,MAAsB,mBAU/B"}
|
package/dist/server/server.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { parse } from "node-html-parser";
|
|
2
1
|
import { validateText, getTags, normalizeWhitespace, serialize, } from "../utils/index.js";
|
|
3
2
|
const defaultConfig = {
|
|
4
3
|
tagsToRemove: [],
|
|
@@ -6,6 +5,7 @@ const defaultConfig = {
|
|
|
6
5
|
};
|
|
7
6
|
export async function janusServer(text, config = defaultConfig) {
|
|
8
7
|
validateText(text);
|
|
8
|
+
const { parse } = await import("node-html-parser");
|
|
9
9
|
const root = parse(text);
|
|
10
10
|
const { removedTags, preservedTags } = getTags(config);
|
|
11
11
|
return normalizeWhitespace(serialize({ node: root, removedTags, preservedTags }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../lib/server/stream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../lib/server/stream.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,KAAK,aAAa,GAAG;IACnB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAMF,KAAK,eAAe,GAAG,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG;IAC3D,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AACF,KAAK,uBAAuB,GAAG,aAAa,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/D,wBAAsB,iBAAiB,CAAC,EACtC,MAAM,EACN,QAAQ,EACR,QAAQ,GACT,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACrC,wBAAsB,iBAAiB,CAAC,EACtC,GAAG,EACH,QAAQ,EACR,YAAY,EACZ,MAAM,GACP,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/server/stream.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { open } from "node:fs/promises";
|
|
2
2
|
import { Readable } from "node:stream";
|
|
3
3
|
import { buffer } from "node:stream/consumers";
|
|
4
|
-
import { janusServer } from "./server.js";
|
|
5
4
|
export async function janusServerStream({ encoding = "utf8", filePath = "", fetchOptions = {}, config = {}, url = "", }) {
|
|
6
5
|
if (url.trim().length > 0) {
|
|
7
6
|
const response = await fetch(url, fetchOptions);
|
|
@@ -28,5 +27,6 @@ async function _janusServer(inputStream, config, encoding = "utf8") {
|
|
|
28
27
|
const bytesBuffer = await buffer(inputStream);
|
|
29
28
|
const decoder = new TextDecoder(encoding);
|
|
30
29
|
const text = decoder.decode(bytesBuffer);
|
|
30
|
+
const { janusServer } = await import("./server.js");
|
|
31
31
|
return await janusServer(text, config);
|
|
32
32
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "janus-parse",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "2.1
|
|
5
|
-
"packageManager": "pnpm@
|
|
4
|
+
"version": "2.2.1",
|
|
5
|
+
"packageManager": "pnpm@12.16.1",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"html-parser",
|
|
8
8
|
"text-extractor",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
],
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
|
-
"types": "./dist/
|
|
21
|
-
"import": "./dist/
|
|
20
|
+
"types": "./dist/client/client.d.js",
|
|
21
|
+
"import": "./dist/client/client.js"
|
|
22
22
|
},
|
|
23
23
|
"./server/stream": {
|
|
24
24
|
"types": "./dist/server/stream.d.ts",
|
|
@@ -73,27 +73,27 @@
|
|
|
73
73
|
"bundle:size": "tsx scripts/bundle-size.ts"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"node-html-parser": "9.0.
|
|
76
|
+
"node-html-parser": "9.0.6"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@eslint/js": "^10.0.1",
|
|
80
80
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
81
|
-
"@semantic-release/github": "
|
|
82
|
-
"@semantic-release/npm": "
|
|
81
|
+
"@semantic-release/github": "12.0.10",
|
|
82
|
+
"@semantic-release/npm": "13.2.0",
|
|
83
83
|
"@semantic-release/release-notes-generator": "^14.1.1",
|
|
84
|
-
"@types/node": "
|
|
85
|
-
"
|
|
86
|
-
"
|
|
84
|
+
"@types/node": "26.6.6",
|
|
85
|
+
"eslint": "10.14.0",
|
|
86
|
+
"esbuild": "^0.28.2",
|
|
87
87
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
88
88
|
"eslint-plugin-import-x": "^4.17.1",
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"prettier": "
|
|
89
|
+
"happy-dom": "21.0.4",
|
|
90
|
+
"eslint-plugin-unicorn": "79.0.0",
|
|
91
|
+
"prettier": "3.9.10",
|
|
92
92
|
"semantic-release": "^25.0.8",
|
|
93
|
-
"tsx": "4.23.
|
|
93
|
+
"tsx": "4.23.15",
|
|
94
94
|
"typescript": "6.0.3",
|
|
95
|
-
"typescript-eslint": "
|
|
96
|
-
"vitest": "
|
|
95
|
+
"typescript-eslint": "8.72.1",
|
|
96
|
+
"vitest": "5.0.5"
|
|
97
97
|
},
|
|
98
98
|
"prettier": {},
|
|
99
99
|
"--Typescript V 7--": "cannot use TS v7 until typescript-eslint adds support"
|