parse5-parser-stream 8.0.0 → 8.1.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.
package/dist/index.d.ts CHANGED
@@ -33,6 +33,26 @@ export declare class ParserStream<T extends TreeAdapterTypeMap = DefaultTreeAdap
33
33
  /** The resulting document node. */
34
34
  get document(): T['document'];
35
35
  getFragment(): T['documentFragment'];
36
+ /**
37
+ * Synchronously delivers buffered character tokens to the tree builder without ending the input stream.
38
+ * Incomplete tags and character references are retained for subsequent writes. This does not resume a
39
+ * suspended script or process queued writes, and must not be called from a parser callback.
40
+ *
41
+ * Flushing splits character-token runs. Their source locations do not extend through subsequently
42
+ * ignored input, such as CDATA delimiters or the leading newline in a `pre` element, so text-node
43
+ * source ranges can differ from parsing without flushing.
44
+ *
45
+ * @example
46
+ *
47
+ * ```js
48
+ * const stream = new ParserStream();
49
+ * stream.write('<p>hello');
50
+ * stream.flushCharacters();
51
+ * // The paragraph's text is now available in `stream.document`.
52
+ * stream.end(' world</p>');
53
+ * ```
54
+ */
55
+ flushCharacters(): void;
36
56
  /**
37
57
  * @param options Parsing options.
38
58
  */
package/dist/index.js CHANGED
@@ -37,6 +37,28 @@ export class ParserStream extends Writable {
37
37
  getFragment() {
38
38
  return this.parser.getFragment();
39
39
  }
40
+ /**
41
+ * Synchronously delivers buffered character tokens to the tree builder without ending the input stream.
42
+ * Incomplete tags and character references are retained for subsequent writes. This does not resume a
43
+ * suspended script or process queued writes, and must not be called from a parser callback.
44
+ *
45
+ * Flushing splits character-token runs. Their source locations do not extend through subsequently
46
+ * ignored input, such as CDATA delimiters or the leading newline in a `pre` element, so text-node
47
+ * source ranges can differ from parsing without flushing.
48
+ *
49
+ * @example
50
+ *
51
+ * ```js
52
+ * const stream = new ParserStream();
53
+ * stream.write('<p>hello');
54
+ * stream.flushCharacters();
55
+ * // The paragraph's text is now available in `stream.document`.
56
+ * stream.end(' world</p>');
57
+ * ```
58
+ */
59
+ flushCharacters() {
60
+ this.parser.tokenizer.flushCharacters();
61
+ }
40
62
  /**
41
63
  * @param options Parsing options.
42
64
  */
package/package.json CHANGED
@@ -2,9 +2,14 @@
2
2
  "name": "parse5-parser-stream",
3
3
  "type": "module",
4
4
  "description": "Streaming HTML parser with scripting support.",
5
- "version": "8.0.0",
5
+ "version": "8.1.0",
6
6
  "author": "Ivan Nikulin <ifaaan@gmail.com> (https://github.com/inikulin)",
7
- "contributors": "https://github.com/inikulin/parse5/graphs/contributors",
7
+ "contributors": [
8
+ "James Garbutt (https://github.com/43081j)",
9
+ "Felix Boehm (https://github.com/fb55)",
10
+ "Ivan Nikulin (https://github.com/inikulin)",
11
+ "Titus (https://github.com/wooorm)"
12
+ ],
8
13
  "homepage": "https://parse5.js.org",
9
14
  "funding": "https://github.com/inikulin/parse5?sponsor=1",
10
15
  "keywords": [
@@ -33,5 +38,8 @@
33
38
  "files": [
34
39
  "dist/**/*.js",
35
40
  "dist/**/*.d.ts"
36
- ]
41
+ ],
42
+ "devDependencies": {
43
+ "parse5-test-utils": "1.0.0"
44
+ }
37
45
  }