wpd-codec 0.0.0 → 1.0.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/LICENSE +21 -0
- package/README.md +182 -0
- package/dist/bytes/view.cjs +23 -0
- package/dist/bytes/view.d.cts +7 -0
- package/dist/bytes/view.d.ts +7 -0
- package/dist/bytes/view.js +19 -0
- package/dist/codec.cjs +23 -0
- package/dist/codec.d.cts +8 -0
- package/dist/codec.d.ts +8 -0
- package/dist/codec.js +21 -0
- package/dist/container/container.cjs +53 -0
- package/dist/container/container.d.cts +16 -0
- package/dist/container/container.d.ts +16 -0
- package/dist/container/container.js +50 -0
- package/dist/container/header.cjs +49 -0
- package/dist/container/header.d.cts +16 -0
- package/dist/container/header.d.ts +16 -0
- package/dist/container/header.js +45 -0
- package/dist/container/prefix.cjs +66 -0
- package/dist/container/prefix.d.cts +18 -0
- package/dist/container/prefix.d.ts +18 -0
- package/dist/container/prefix.js +61 -0
- package/dist/diagnostics-Cp0HKphg.d.cts +15 -0
- package/dist/diagnostics-Cp0HKphg.d.ts +15 -0
- package/dist/diagnostics.cjs +12 -0
- package/dist/diagnostics.d.cts +2 -0
- package/dist/diagnostics.d.ts +2 -0
- package/dist/diagnostics.js +10 -0
- package/dist/errors.cjs +31 -0
- package/dist/errors.d.cts +15 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.js +27 -0
- package/dist/format.cjs +7 -0
- package/dist/format.d.cts +5 -0
- package/dist/format.d.ts +5 -0
- package/dist/format.js +5 -0
- package/dist/index.cjs +58 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +13 -0
- package/dist/read.cjs +296 -0
- package/dist/read.d.cts +10 -0
- package/dist/read.d.ts +10 -0
- package/dist/read.js +294 -0
- package/dist/stream/attributes.cjs +46 -0
- package/dist/stream/attributes.d.cts +37 -0
- package/dist/stream/attributes.d.ts +37 -0
- package/dist/stream/attributes.js +41 -0
- package/dist/stream/characters.cjs +205 -0
- package/dist/stream/characters.d.cts +12 -0
- package/dist/stream/characters.d.ts +12 -0
- package/dist/stream/characters.js +199 -0
- package/dist/stream/eol.cjs +52 -0
- package/dist/stream/eol.d.cts +10 -0
- package/dist/stream/eol.d.ts +10 -0
- package/dist/stream/eol.js +46 -0
- package/dist/stream/tokenise.cjs +125 -0
- package/dist/stream/tokenise.d.cts +30 -0
- package/dist/stream/tokenise.d.ts +30 -0
- package/dist/stream/tokenise.js +121 -0
- package/package.json +96 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/stream/attributes.d.ts
|
|
2
|
+
declare const ATTRIBUTE_ON = 242;
|
|
3
|
+
declare const ATTRIBUTE_OFF = 243;
|
|
4
|
+
declare const WpdAttribute: {
|
|
5
|
+
readonly ExtraLarge: 0;
|
|
6
|
+
readonly VeryLarge: 1;
|
|
7
|
+
readonly Large: 2;
|
|
8
|
+
readonly SmallPrint: 3;
|
|
9
|
+
readonly FinePrint: 4;
|
|
10
|
+
readonly Superscript: 5;
|
|
11
|
+
readonly Subscript: 6;
|
|
12
|
+
readonly Outline: 7;
|
|
13
|
+
readonly Italics: 8;
|
|
14
|
+
readonly Shadow: 9;
|
|
15
|
+
readonly Redline: 10;
|
|
16
|
+
readonly DoubleUnderline: 11;
|
|
17
|
+
readonly Bold: 12;
|
|
18
|
+
readonly Strikeout: 13;
|
|
19
|
+
readonly Underline: 14;
|
|
20
|
+
readonly SmallCaps: 15;
|
|
21
|
+
readonly Blink: 16;
|
|
22
|
+
readonly ReverseVideo: 17;
|
|
23
|
+
};
|
|
24
|
+
interface WpdAttributeCode {
|
|
25
|
+
readonly attribute: number;
|
|
26
|
+
readonly ignore: boolean;
|
|
27
|
+
}
|
|
28
|
+
declare function decodeAttributeByte(payload: number): WpdAttributeCode;
|
|
29
|
+
interface WpdRunAttributes {
|
|
30
|
+
readonly bold: boolean;
|
|
31
|
+
readonly italic: boolean;
|
|
32
|
+
readonly underline: boolean;
|
|
33
|
+
readonly strike: boolean;
|
|
34
|
+
}
|
|
35
|
+
declare function runAttributesFrom(active: ReadonlySet<number>): WpdRunAttributes;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { ATTRIBUTE_OFF, ATTRIBUTE_ON, WpdAttribute, WpdAttributeCode, WpdRunAttributes, decodeAttributeByte, runAttributesFrom };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/stream/attributes.ts
|
|
2
|
+
const ATTRIBUTE_ON = 242;
|
|
3
|
+
const ATTRIBUTE_OFF = 243;
|
|
4
|
+
const ATTRIBUTE_IGNORE_BIT = 128;
|
|
5
|
+
const ATTRIBUTE_NUMBER_MASK = 63;
|
|
6
|
+
const WpdAttribute = {
|
|
7
|
+
ExtraLarge: 0,
|
|
8
|
+
VeryLarge: 1,
|
|
9
|
+
Large: 2,
|
|
10
|
+
SmallPrint: 3,
|
|
11
|
+
FinePrint: 4,
|
|
12
|
+
Superscript: 5,
|
|
13
|
+
Subscript: 6,
|
|
14
|
+
Outline: 7,
|
|
15
|
+
Italics: 8,
|
|
16
|
+
Shadow: 9,
|
|
17
|
+
Redline: 10,
|
|
18
|
+
DoubleUnderline: 11,
|
|
19
|
+
Bold: 12,
|
|
20
|
+
Strikeout: 13,
|
|
21
|
+
Underline: 14,
|
|
22
|
+
SmallCaps: 15,
|
|
23
|
+
Blink: 16,
|
|
24
|
+
ReverseVideo: 17
|
|
25
|
+
};
|
|
26
|
+
function decodeAttributeByte(payload) {
|
|
27
|
+
return {
|
|
28
|
+
attribute: payload & ATTRIBUTE_NUMBER_MASK,
|
|
29
|
+
ignore: (payload & ATTRIBUTE_IGNORE_BIT) !== 0
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function runAttributesFrom(active) {
|
|
33
|
+
return {
|
|
34
|
+
bold: active.has(WpdAttribute.Bold),
|
|
35
|
+
italic: active.has(WpdAttribute.Italics),
|
|
36
|
+
underline: active.has(WpdAttribute.Underline) || active.has(WpdAttribute.DoubleUnderline),
|
|
37
|
+
strike: active.has(WpdAttribute.Strikeout)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { ATTRIBUTE_OFF, ATTRIBUTE_ON, WpdAttribute, decodeAttributeByte, runAttributesFrom };
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/stream/characters.ts
|
|
3
|
+
const DEFAULT_EXTENDED_INTERNATIONAL = [
|
|
4
|
+
[
|
|
5
|
+
1,
|
|
6
|
+
35,
|
|
7
|
+
"å"
|
|
8
|
+
],
|
|
9
|
+
[
|
|
10
|
+
2,
|
|
11
|
+
34,
|
|
12
|
+
"Å"
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
3,
|
|
16
|
+
37,
|
|
17
|
+
"æ"
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
4,
|
|
21
|
+
36,
|
|
22
|
+
"Æ"
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
5,
|
|
26
|
+
31,
|
|
27
|
+
"ä"
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
6,
|
|
31
|
+
30,
|
|
32
|
+
"Ä"
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
7,
|
|
36
|
+
27,
|
|
37
|
+
"á"
|
|
38
|
+
],
|
|
39
|
+
[
|
|
40
|
+
8,
|
|
41
|
+
33,
|
|
42
|
+
"à"
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
9,
|
|
46
|
+
29,
|
|
47
|
+
"â"
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
10,
|
|
51
|
+
77,
|
|
52
|
+
"ã"
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
11,
|
|
56
|
+
76,
|
|
57
|
+
"Ã"
|
|
58
|
+
],
|
|
59
|
+
[
|
|
60
|
+
12,
|
|
61
|
+
39,
|
|
62
|
+
"ç"
|
|
63
|
+
],
|
|
64
|
+
[
|
|
65
|
+
13,
|
|
66
|
+
38,
|
|
67
|
+
"Ç"
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
14,
|
|
71
|
+
45,
|
|
72
|
+
"ë"
|
|
73
|
+
],
|
|
74
|
+
[
|
|
75
|
+
15,
|
|
76
|
+
41,
|
|
77
|
+
"é"
|
|
78
|
+
],
|
|
79
|
+
[
|
|
80
|
+
16,
|
|
81
|
+
40,
|
|
82
|
+
"É"
|
|
83
|
+
],
|
|
84
|
+
[
|
|
85
|
+
17,
|
|
86
|
+
47,
|
|
87
|
+
"è"
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
18,
|
|
91
|
+
43,
|
|
92
|
+
"ê"
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
19,
|
|
96
|
+
49,
|
|
97
|
+
"í"
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
20,
|
|
101
|
+
57,
|
|
102
|
+
"ñ"
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
21,
|
|
106
|
+
56,
|
|
107
|
+
"Ñ"
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
22,
|
|
111
|
+
81,
|
|
112
|
+
"ø"
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
23,
|
|
116
|
+
80,
|
|
117
|
+
"Ø"
|
|
118
|
+
],
|
|
119
|
+
[
|
|
120
|
+
24,
|
|
121
|
+
83,
|
|
122
|
+
"õ"
|
|
123
|
+
],
|
|
124
|
+
[
|
|
125
|
+
25,
|
|
126
|
+
82,
|
|
127
|
+
"Õ"
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
26,
|
|
131
|
+
63,
|
|
132
|
+
"ö"
|
|
133
|
+
],
|
|
134
|
+
[
|
|
135
|
+
27,
|
|
136
|
+
62,
|
|
137
|
+
"Ö"
|
|
138
|
+
],
|
|
139
|
+
[
|
|
140
|
+
28,
|
|
141
|
+
71,
|
|
142
|
+
"ü"
|
|
143
|
+
],
|
|
144
|
+
[
|
|
145
|
+
29,
|
|
146
|
+
70,
|
|
147
|
+
"Ü"
|
|
148
|
+
],
|
|
149
|
+
[
|
|
150
|
+
30,
|
|
151
|
+
67,
|
|
152
|
+
"ú"
|
|
153
|
+
],
|
|
154
|
+
[
|
|
155
|
+
31,
|
|
156
|
+
73,
|
|
157
|
+
"ù"
|
|
158
|
+
],
|
|
159
|
+
[
|
|
160
|
+
32,
|
|
161
|
+
23,
|
|
162
|
+
"ß"
|
|
163
|
+
]
|
|
164
|
+
];
|
|
165
|
+
const SINGLE_BYTE_SHORTHAND = new Map(DEFAULT_EXTENDED_INTERNATIONAL.map(([byteValue, , glyph]) => [byteValue, glyph]));
|
|
166
|
+
const CHARACTER_SET_MULTINATIONAL_1 = new Map(DEFAULT_EXTENDED_INTERNATIONAL.map(([, characterNumber, glyph]) => [characterNumber, glyph]));
|
|
167
|
+
const FIRST_ASCII_CHARACTER = 33;
|
|
168
|
+
const LAST_CHARACTER = 127;
|
|
169
|
+
const UNMAPPED_CHARACTER = "�";
|
|
170
|
+
function decodeAsciiSet(characterNumber) {
|
|
171
|
+
if (characterNumber < 32 || characterNumber > 127) return;
|
|
172
|
+
return String.fromCharCode(characterNumber);
|
|
173
|
+
}
|
|
174
|
+
function decodeWpCharacter(characterSet, characterNumber) {
|
|
175
|
+
if (characterSet === 0) return decodeAsciiSet(characterNumber);
|
|
176
|
+
if (characterSet === 1) return CHARACTER_SET_MULTINATIONAL_1.get(characterNumber);
|
|
177
|
+
}
|
|
178
|
+
function decodeSingleByteCharacter(byte) {
|
|
179
|
+
const shorthand = SINGLE_BYTE_SHORTHAND.get(byte);
|
|
180
|
+
if (shorthand !== void 0) return shorthand;
|
|
181
|
+
if (byte >= 33 && byte <= 127) return String.fromCharCode(byte);
|
|
182
|
+
}
|
|
183
|
+
function decodeWordString(bytes, offset, maxWords) {
|
|
184
|
+
let text = "";
|
|
185
|
+
let wordsRead = 0;
|
|
186
|
+
while (wordsRead < maxWords) {
|
|
187
|
+
const low = bytes[offset + wordsRead * 2];
|
|
188
|
+
const high = bytes[offset + wordsRead * 2 + 1];
|
|
189
|
+
if (low === void 0 || high === void 0) break;
|
|
190
|
+
wordsRead += 1;
|
|
191
|
+
if (low === 0 && high === 0) break;
|
|
192
|
+
text += decodeWpCharacter(high, low) ?? "�";
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
text,
|
|
196
|
+
wordsRead
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
//#endregion
|
|
200
|
+
exports.FIRST_ASCII_CHARACTER = FIRST_ASCII_CHARACTER;
|
|
201
|
+
exports.LAST_CHARACTER = LAST_CHARACTER;
|
|
202
|
+
exports.UNMAPPED_CHARACTER = UNMAPPED_CHARACTER;
|
|
203
|
+
exports.decodeSingleByteCharacter = decodeSingleByteCharacter;
|
|
204
|
+
exports.decodeWordString = decodeWordString;
|
|
205
|
+
exports.decodeWpCharacter = decodeWpCharacter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/stream/characters.d.ts
|
|
2
|
+
declare const FIRST_ASCII_CHARACTER = 33;
|
|
3
|
+
declare const LAST_CHARACTER = 127;
|
|
4
|
+
declare const UNMAPPED_CHARACTER = "�";
|
|
5
|
+
declare function decodeWpCharacter(characterSet: number, characterNumber: number): string | undefined;
|
|
6
|
+
declare function decodeSingleByteCharacter(byte: number): string | undefined;
|
|
7
|
+
declare function decodeWordString(bytes: Uint8Array, offset: number, maxWords: number): {
|
|
8
|
+
text: string;
|
|
9
|
+
wordsRead: number;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { FIRST_ASCII_CHARACTER, LAST_CHARACTER, UNMAPPED_CHARACTER, decodeSingleByteCharacter, decodeWordString, decodeWpCharacter };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/stream/characters.d.ts
|
|
2
|
+
declare const FIRST_ASCII_CHARACTER = 33;
|
|
3
|
+
declare const LAST_CHARACTER = 127;
|
|
4
|
+
declare const UNMAPPED_CHARACTER = "�";
|
|
5
|
+
declare function decodeWpCharacter(characterSet: number, characterNumber: number): string | undefined;
|
|
6
|
+
declare function decodeSingleByteCharacter(byte: number): string | undefined;
|
|
7
|
+
declare function decodeWordString(bytes: Uint8Array, offset: number, maxWords: number): {
|
|
8
|
+
text: string;
|
|
9
|
+
wordsRead: number;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { FIRST_ASCII_CHARACTER, LAST_CHARACTER, UNMAPPED_CHARACTER, decodeSingleByteCharacter, decodeWordString, decodeWpCharacter };
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
//#region src/stream/characters.ts
|
|
2
|
+
const DEFAULT_EXTENDED_INTERNATIONAL = [
|
|
3
|
+
[
|
|
4
|
+
1,
|
|
5
|
+
35,
|
|
6
|
+
"å"
|
|
7
|
+
],
|
|
8
|
+
[
|
|
9
|
+
2,
|
|
10
|
+
34,
|
|
11
|
+
"Å"
|
|
12
|
+
],
|
|
13
|
+
[
|
|
14
|
+
3,
|
|
15
|
+
37,
|
|
16
|
+
"æ"
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
4,
|
|
20
|
+
36,
|
|
21
|
+
"Æ"
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
5,
|
|
25
|
+
31,
|
|
26
|
+
"ä"
|
|
27
|
+
],
|
|
28
|
+
[
|
|
29
|
+
6,
|
|
30
|
+
30,
|
|
31
|
+
"Ä"
|
|
32
|
+
],
|
|
33
|
+
[
|
|
34
|
+
7,
|
|
35
|
+
27,
|
|
36
|
+
"á"
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
8,
|
|
40
|
+
33,
|
|
41
|
+
"à"
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
9,
|
|
45
|
+
29,
|
|
46
|
+
"â"
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
10,
|
|
50
|
+
77,
|
|
51
|
+
"ã"
|
|
52
|
+
],
|
|
53
|
+
[
|
|
54
|
+
11,
|
|
55
|
+
76,
|
|
56
|
+
"Ã"
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
12,
|
|
60
|
+
39,
|
|
61
|
+
"ç"
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
13,
|
|
65
|
+
38,
|
|
66
|
+
"Ç"
|
|
67
|
+
],
|
|
68
|
+
[
|
|
69
|
+
14,
|
|
70
|
+
45,
|
|
71
|
+
"ë"
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
15,
|
|
75
|
+
41,
|
|
76
|
+
"é"
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
16,
|
|
80
|
+
40,
|
|
81
|
+
"É"
|
|
82
|
+
],
|
|
83
|
+
[
|
|
84
|
+
17,
|
|
85
|
+
47,
|
|
86
|
+
"è"
|
|
87
|
+
],
|
|
88
|
+
[
|
|
89
|
+
18,
|
|
90
|
+
43,
|
|
91
|
+
"ê"
|
|
92
|
+
],
|
|
93
|
+
[
|
|
94
|
+
19,
|
|
95
|
+
49,
|
|
96
|
+
"í"
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
20,
|
|
100
|
+
57,
|
|
101
|
+
"ñ"
|
|
102
|
+
],
|
|
103
|
+
[
|
|
104
|
+
21,
|
|
105
|
+
56,
|
|
106
|
+
"Ñ"
|
|
107
|
+
],
|
|
108
|
+
[
|
|
109
|
+
22,
|
|
110
|
+
81,
|
|
111
|
+
"ø"
|
|
112
|
+
],
|
|
113
|
+
[
|
|
114
|
+
23,
|
|
115
|
+
80,
|
|
116
|
+
"Ø"
|
|
117
|
+
],
|
|
118
|
+
[
|
|
119
|
+
24,
|
|
120
|
+
83,
|
|
121
|
+
"õ"
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
25,
|
|
125
|
+
82,
|
|
126
|
+
"Õ"
|
|
127
|
+
],
|
|
128
|
+
[
|
|
129
|
+
26,
|
|
130
|
+
63,
|
|
131
|
+
"ö"
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
27,
|
|
135
|
+
62,
|
|
136
|
+
"Ö"
|
|
137
|
+
],
|
|
138
|
+
[
|
|
139
|
+
28,
|
|
140
|
+
71,
|
|
141
|
+
"ü"
|
|
142
|
+
],
|
|
143
|
+
[
|
|
144
|
+
29,
|
|
145
|
+
70,
|
|
146
|
+
"Ü"
|
|
147
|
+
],
|
|
148
|
+
[
|
|
149
|
+
30,
|
|
150
|
+
67,
|
|
151
|
+
"ú"
|
|
152
|
+
],
|
|
153
|
+
[
|
|
154
|
+
31,
|
|
155
|
+
73,
|
|
156
|
+
"ù"
|
|
157
|
+
],
|
|
158
|
+
[
|
|
159
|
+
32,
|
|
160
|
+
23,
|
|
161
|
+
"ß"
|
|
162
|
+
]
|
|
163
|
+
];
|
|
164
|
+
const SINGLE_BYTE_SHORTHAND = new Map(DEFAULT_EXTENDED_INTERNATIONAL.map(([byteValue, , glyph]) => [byteValue, glyph]));
|
|
165
|
+
const CHARACTER_SET_MULTINATIONAL_1 = new Map(DEFAULT_EXTENDED_INTERNATIONAL.map(([, characterNumber, glyph]) => [characterNumber, glyph]));
|
|
166
|
+
const FIRST_ASCII_CHARACTER = 33;
|
|
167
|
+
const LAST_CHARACTER = 127;
|
|
168
|
+
const UNMAPPED_CHARACTER = "�";
|
|
169
|
+
function decodeAsciiSet(characterNumber) {
|
|
170
|
+
if (characterNumber < 32 || characterNumber > 127) return;
|
|
171
|
+
return String.fromCharCode(characterNumber);
|
|
172
|
+
}
|
|
173
|
+
function decodeWpCharacter(characterSet, characterNumber) {
|
|
174
|
+
if (characterSet === 0) return decodeAsciiSet(characterNumber);
|
|
175
|
+
if (characterSet === 1) return CHARACTER_SET_MULTINATIONAL_1.get(characterNumber);
|
|
176
|
+
}
|
|
177
|
+
function decodeSingleByteCharacter(byte) {
|
|
178
|
+
const shorthand = SINGLE_BYTE_SHORTHAND.get(byte);
|
|
179
|
+
if (shorthand !== void 0) return shorthand;
|
|
180
|
+
if (byte >= 33 && byte <= 127) return String.fromCharCode(byte);
|
|
181
|
+
}
|
|
182
|
+
function decodeWordString(bytes, offset, maxWords) {
|
|
183
|
+
let text = "";
|
|
184
|
+
let wordsRead = 0;
|
|
185
|
+
while (wordsRead < maxWords) {
|
|
186
|
+
const low = bytes[offset + wordsRead * 2];
|
|
187
|
+
const high = bytes[offset + wordsRead * 2 + 1];
|
|
188
|
+
if (low === void 0 || high === void 0) break;
|
|
189
|
+
wordsRead += 1;
|
|
190
|
+
if (low === 0 && high === 0) break;
|
|
191
|
+
text += decodeWpCharacter(high, low) ?? "�";
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
text,
|
|
195
|
+
wordsRead
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
export { FIRST_ASCII_CHARACTER, LAST_CHARACTER, UNMAPPED_CHARACTER, decodeSingleByteCharacter, decodeWordString, decodeWpCharacter };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/stream/eol.ts
|
|
3
|
+
const EOL_MAPPINGS = [
|
|
4
|
+
"ignore",
|
|
5
|
+
"space",
|
|
6
|
+
"space",
|
|
7
|
+
"space",
|
|
8
|
+
"hardReturn",
|
|
9
|
+
"hardReturn",
|
|
10
|
+
"hardReturn",
|
|
11
|
+
"hardEndOfColumn",
|
|
12
|
+
"hardEndOfColumn",
|
|
13
|
+
"hardEndOfPage",
|
|
14
|
+
"tableCell",
|
|
15
|
+
"tableRow",
|
|
16
|
+
"tableRow",
|
|
17
|
+
"tableRow",
|
|
18
|
+
"hardTableRow",
|
|
19
|
+
"hardTableRow",
|
|
20
|
+
"hardTableRow",
|
|
21
|
+
"tableOff",
|
|
22
|
+
"tableOff",
|
|
23
|
+
"tableOff",
|
|
24
|
+
"space",
|
|
25
|
+
"space",
|
|
26
|
+
"space",
|
|
27
|
+
"hardReturn",
|
|
28
|
+
"hardReturn",
|
|
29
|
+
"hardReturn",
|
|
30
|
+
"hardEndOfColumn",
|
|
31
|
+
"hardEndOfColumn",
|
|
32
|
+
"hardEndOfPage"
|
|
33
|
+
];
|
|
34
|
+
const EOL_GROUP = 208;
|
|
35
|
+
const FIRST_SINGLE_BYTE_EOL = 180;
|
|
36
|
+
const LAST_SINGLE_BYTE_EOL = 207;
|
|
37
|
+
function eolMappingForSubfunction(subfunction) {
|
|
38
|
+
return EOL_MAPPINGS[subfunction];
|
|
39
|
+
}
|
|
40
|
+
function subfunctionForSingleByteEol(code) {
|
|
41
|
+
return 208 - code;
|
|
42
|
+
}
|
|
43
|
+
function isSingleByteEol(code) {
|
|
44
|
+
return code >= 180 && code <= 207;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
exports.EOL_GROUP = EOL_GROUP;
|
|
48
|
+
exports.FIRST_SINGLE_BYTE_EOL = FIRST_SINGLE_BYTE_EOL;
|
|
49
|
+
exports.LAST_SINGLE_BYTE_EOL = LAST_SINGLE_BYTE_EOL;
|
|
50
|
+
exports.eolMappingForSubfunction = eolMappingForSubfunction;
|
|
51
|
+
exports.isSingleByteEol = isSingleByteEol;
|
|
52
|
+
exports.subfunctionForSingleByteEol = subfunctionForSingleByteEol;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/stream/eol.d.ts
|
|
2
|
+
type WpdEolMapping = "ignore" | "space" | "hardReturn" | "hardEndOfColumn" | "hardEndOfPage" | "tableCell" | "tableRow" | "hardTableRow" | "tableOff";
|
|
3
|
+
declare const EOL_GROUP = 208;
|
|
4
|
+
declare const FIRST_SINGLE_BYTE_EOL = 180;
|
|
5
|
+
declare const LAST_SINGLE_BYTE_EOL = 207;
|
|
6
|
+
declare function eolMappingForSubfunction(subfunction: number): WpdEolMapping | undefined;
|
|
7
|
+
declare function subfunctionForSingleByteEol(code: number): number;
|
|
8
|
+
declare function isSingleByteEol(code: number): boolean;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { EOL_GROUP, FIRST_SINGLE_BYTE_EOL, LAST_SINGLE_BYTE_EOL, WpdEolMapping, eolMappingForSubfunction, isSingleByteEol, subfunctionForSingleByteEol };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/stream/eol.d.ts
|
|
2
|
+
type WpdEolMapping = "ignore" | "space" | "hardReturn" | "hardEndOfColumn" | "hardEndOfPage" | "tableCell" | "tableRow" | "hardTableRow" | "tableOff";
|
|
3
|
+
declare const EOL_GROUP = 208;
|
|
4
|
+
declare const FIRST_SINGLE_BYTE_EOL = 180;
|
|
5
|
+
declare const LAST_SINGLE_BYTE_EOL = 207;
|
|
6
|
+
declare function eolMappingForSubfunction(subfunction: number): WpdEolMapping | undefined;
|
|
7
|
+
declare function subfunctionForSingleByteEol(code: number): number;
|
|
8
|
+
declare function isSingleByteEol(code: number): boolean;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { EOL_GROUP, FIRST_SINGLE_BYTE_EOL, LAST_SINGLE_BYTE_EOL, WpdEolMapping, eolMappingForSubfunction, isSingleByteEol, subfunctionForSingleByteEol };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/stream/eol.ts
|
|
2
|
+
const EOL_MAPPINGS = [
|
|
3
|
+
"ignore",
|
|
4
|
+
"space",
|
|
5
|
+
"space",
|
|
6
|
+
"space",
|
|
7
|
+
"hardReturn",
|
|
8
|
+
"hardReturn",
|
|
9
|
+
"hardReturn",
|
|
10
|
+
"hardEndOfColumn",
|
|
11
|
+
"hardEndOfColumn",
|
|
12
|
+
"hardEndOfPage",
|
|
13
|
+
"tableCell",
|
|
14
|
+
"tableRow",
|
|
15
|
+
"tableRow",
|
|
16
|
+
"tableRow",
|
|
17
|
+
"hardTableRow",
|
|
18
|
+
"hardTableRow",
|
|
19
|
+
"hardTableRow",
|
|
20
|
+
"tableOff",
|
|
21
|
+
"tableOff",
|
|
22
|
+
"tableOff",
|
|
23
|
+
"space",
|
|
24
|
+
"space",
|
|
25
|
+
"space",
|
|
26
|
+
"hardReturn",
|
|
27
|
+
"hardReturn",
|
|
28
|
+
"hardReturn",
|
|
29
|
+
"hardEndOfColumn",
|
|
30
|
+
"hardEndOfColumn",
|
|
31
|
+
"hardEndOfPage"
|
|
32
|
+
];
|
|
33
|
+
const EOL_GROUP = 208;
|
|
34
|
+
const FIRST_SINGLE_BYTE_EOL = 180;
|
|
35
|
+
const LAST_SINGLE_BYTE_EOL = 207;
|
|
36
|
+
function eolMappingForSubfunction(subfunction) {
|
|
37
|
+
return EOL_MAPPINGS[subfunction];
|
|
38
|
+
}
|
|
39
|
+
function subfunctionForSingleByteEol(code) {
|
|
40
|
+
return 208 - code;
|
|
41
|
+
}
|
|
42
|
+
function isSingleByteEol(code) {
|
|
43
|
+
return code >= 180 && code <= 207;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { EOL_GROUP, FIRST_SINGLE_BYTE_EOL, LAST_SINGLE_BYTE_EOL, eolMappingForSubfunction, isSingleByteEol, subfunctionForSingleByteEol };
|