equoter 0.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/LICENSE +24 -0
- package/README.md +157 -0
- package/dist/enums.d.ts +5 -0
- package/dist/enums.d.ts.map +1 -0
- package/dist/html.d.ts +45 -0
- package/dist/html.d.ts.map +1 -0
- package/dist/index.cjs +918 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +913 -0
- package/dist/internal.d.ts +46 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/patterns.d.ts +23 -0
- package/dist/patterns.d.ts.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Position } from "./enums.js";
|
|
2
|
+
export type UnwrapType = "forward" | "reply" | "headers" | "quoted" | "quote";
|
|
3
|
+
export type RangeTuple = [number | null, number | null];
|
|
4
|
+
export type UnwrapResult = [
|
|
5
|
+
type: string,
|
|
6
|
+
topRange: RangeTuple,
|
|
7
|
+
headers: Record<string, string> | null,
|
|
8
|
+
mainRange: RangeTuple | null,
|
|
9
|
+
bottomRange: RangeTuple | null,
|
|
10
|
+
needsUnindent: boolean
|
|
11
|
+
];
|
|
12
|
+
/**
|
|
13
|
+
* Find a forward/reply pattern within the given lines on the given
|
|
14
|
+
* line number. Returns [lineNumber, type] or null.
|
|
15
|
+
*/
|
|
16
|
+
export declare function findPatternOnLine(lines: string[], n: number, maxWrapLines: number, position: Position): [number, string] | null;
|
|
17
|
+
/**
|
|
18
|
+
* Return the beginning or ending line number of a quoting pattern.
|
|
19
|
+
*/
|
|
20
|
+
export declare function findQuotePosition(lines: string[], maxWrapLines: number, limit?: number | null, position?: Position): number | null;
|
|
21
|
+
/**
|
|
22
|
+
* Join one or multiple lines that wrapped.
|
|
23
|
+
*/
|
|
24
|
+
export declare function joinWrappedLines(lines: string[]): string;
|
|
25
|
+
/**
|
|
26
|
+
* Extract email headers from the given lines. Returns [headers, linesProcessed].
|
|
27
|
+
*/
|
|
28
|
+
export declare function extractHeaders(lines: string[], maxWrapLines: number): [Record<string, string>, number];
|
|
29
|
+
/**
|
|
30
|
+
* Parse a reply line ("On DATE, USER wrote:") and return { date, from } or null.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseReply(line: string): Record<string, string> | null;
|
|
33
|
+
/**
|
|
34
|
+
* Find the starting point of a wrapped email.
|
|
35
|
+
* Returns [startLine, endLine, type] or null.
|
|
36
|
+
*/
|
|
37
|
+
export declare function findUnwrapStart(lines: string[], maxWrapLines: number, minHeaderLines: number, minQuotedLines: number): [number, number, string] | null;
|
|
38
|
+
/**
|
|
39
|
+
* Unindent lines by stripping leading "> " or ">".
|
|
40
|
+
*/
|
|
41
|
+
export declare function unindentLines(lines: string[]): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Core unwrap function. Returns the unwrap result tuple or null.
|
|
44
|
+
*/
|
|
45
|
+
export declare function unwrap(lines: string[], maxWrapLines: number, minHeaderLines: number, minQuotedLines: number): UnwrapResult | null;
|
|
46
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE9E,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;AAExD,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IACtC,SAAS,EAAE,UAAU,GAAG,IAAI;IAC5B,WAAW,EAAE,UAAU,GAAG,IAAI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}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const REPLY_PATTERNS: RegExp[];
|
|
2
|
+
export declare const REPLY_DATE_SPLIT_REGEX: RegExp;
|
|
3
|
+
export declare const FORWARD_MESSAGES: string[];
|
|
4
|
+
export declare const FORWARD_LINE = "________________________________";
|
|
5
|
+
export declare const FORWARD_PATTERNS: RegExp[];
|
|
6
|
+
export declare const FORWARD_STYLES: RegExp[];
|
|
7
|
+
export declare const HEADER_RE: RegExp;
|
|
8
|
+
export declare const HEADER_MAP: Record<string, string>;
|
|
9
|
+
export declare const COMPILED_PATTERN_MAP: Record<string, RegExp[]>;
|
|
10
|
+
export declare const MULTIPLE_WHITESPACE_RE: RegExp;
|
|
11
|
+
/** Amount of lines to join to check for potential wrapped patterns in plain text messages. */
|
|
12
|
+
export declare const MAX_WRAP_LINES = 2;
|
|
13
|
+
/** Minimum number of headers that we recognize. */
|
|
14
|
+
export declare const MIN_HEADER_LINES = 2;
|
|
15
|
+
/** Minimum number of lines to recognize a quoted block. */
|
|
16
|
+
export declare const MIN_QUOTED_LINES = 3;
|
|
17
|
+
/**
|
|
18
|
+
* Characters at the end of line where we join lines without adding a space.
|
|
19
|
+
* For example, "John <\njohn@example>" becomes "John <john@example>", but
|
|
20
|
+
* "John\nDoe" becomes "John Doe".
|
|
21
|
+
*/
|
|
22
|
+
export declare const STRIP_SPACE_CHARS = "<([{\"'";
|
|
23
|
+
//# sourceMappingURL=patterns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../src/patterns.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,UAY1B,CAAC;AAEF,eAAO,MAAM,sBAAsB,QACa,CAAC;AAEjD,eAAO,MAAM,gBAAgB,UAqB5B,CAAC;AAEF,eAAO,MAAM,YAAY,qCAAqC,CAAC;AAE/D,eAAO,MAAM,gBAAgB,UAI5B,CAAC;AAEF,eAAO,MAAM,cAAc,UAK1B,CAAC;AAEF,eAAO,MAAM,SAAS,QAAqC,CAAC;AAE5D,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA2C7C,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAGzD,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C,8FAA8F;AAC9F,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC,mDAAmD;AACnD,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,2DAA2D;AAC3D,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,YAAY,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "equoter",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Identify quoted text in email messages (TypeScript port of quotequail)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"prepare": "rolldown -c && tsc --emitDeclarationOnly",
|
|
21
|
+
"build": "rolldown -c && tsc --emitDeclarationOnly",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest",
|
|
24
|
+
"typecheck": "tsc --noEmit"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"email",
|
|
28
|
+
"quote",
|
|
29
|
+
"reply",
|
|
30
|
+
"forward",
|
|
31
|
+
"quoted-text"
|
|
32
|
+
],
|
|
33
|
+
"author": "Wicher Heldring",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/pyroxymat/equoter.git"
|
|
37
|
+
},
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"packageManager": "pnpm@10.32.1",
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"linkedom": "^0.18.9"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^25.5.0",
|
|
45
|
+
"rolldown": "1.0.0-rc.12",
|
|
46
|
+
"typescript": "^6.0.2",
|
|
47
|
+
"vitest": "^4.1.0"
|
|
48
|
+
}
|
|
49
|
+
}
|