archive-codec 1.2.0 → 1.4.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/README.md +71 -11
- package/dist/cfb/write.cjs +297 -0
- package/dist/cfb/write.d.cts +11 -0
- package/dist/cfb/write.d.ts +11 -0
- package/dist/cfb/write.js +295 -0
- package/dist/index.cjs +17 -0
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +6 -1
- package/dist/oleps/layout-metadata.cjs +30 -0
- package/dist/oleps/layout-metadata.d.cts +9 -0
- package/dist/oleps/layout-metadata.d.ts +9 -0
- package/dist/oleps/layout-metadata.js +27 -0
- package/dist/oleps/read.cjs +132 -0
- package/dist/oleps/read.d.cts +8 -0
- package/dist/oleps/read.d.ts +8 -0
- package/dist/oleps/read.js +130 -0
- package/dist/oleps/summary-information.cjs +94 -0
- package/dist/oleps/summary-information.d.cts +16 -0
- package/dist/oleps/summary-information.d.ts +16 -0
- package/dist/oleps/summary-information.js +91 -0
- package/dist/oleps/wire.cjs +70 -0
- package/dist/oleps/wire.d.cts +45 -0
- package/dist/oleps/wire.d.ts +45 -0
- package/dist/oleps/wire.js +51 -0
- package/dist/oleps/write.cjs +103 -0
- package/dist/oleps/write.d.cts +8 -0
- package/dist/oleps/write.d.ts +8 -0
- package/dist/oleps/write.js +101 -0
- package/package.json +3 -2
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { WINDOWS_1252_CODEPAGE, filetimeToDate, readGuid } from "./wire.js";
|
|
2
|
+
//#region src/oleps/read.ts
|
|
3
|
+
var PropertySetFormatError = class extends Error {
|
|
4
|
+
constructor(message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "PropertySetFormatError";
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
function requireBytes(byteLength, offset, length, what) {
|
|
10
|
+
if (offset < 0 || length < 0 || offset + length > byteLength) throw new PropertySetFormatError(`property set stream ends before ${what} (needs ${length} bytes at offset ${offset}, stream is ${byteLength} bytes)`);
|
|
11
|
+
}
|
|
12
|
+
const ANSI_DECODER = new TextDecoder("windows-1252");
|
|
13
|
+
const UTF16_DECODER = new TextDecoder("utf-16le");
|
|
14
|
+
function decodeAnsi(bytes, codepage) {
|
|
15
|
+
if (codepage !== 1252) return;
|
|
16
|
+
return ANSI_DECODER.decode(bytes);
|
|
17
|
+
}
|
|
18
|
+
function truncateAtNull(value) {
|
|
19
|
+
const index = value.indexOf("\0");
|
|
20
|
+
return index === -1 ? value : value.slice(0, index);
|
|
21
|
+
}
|
|
22
|
+
function readCodePageString(bytes, view, offset, codepage) {
|
|
23
|
+
requireBytes(bytes.length, offset, 4, "a CodePageString's Size field");
|
|
24
|
+
const size = view.getUint32(offset, true);
|
|
25
|
+
requireBytes(bytes.length, offset + 4, size, "a CodePageString's Characters field");
|
|
26
|
+
const raw = bytes.subarray(offset + 4, offset + 4 + size);
|
|
27
|
+
if (codepage === 1200) return truncateAtNull(UTF16_DECODER.decode(raw));
|
|
28
|
+
const decoded = decodeAnsi(raw, codepage);
|
|
29
|
+
return decoded === void 0 ? void 0 : truncateAtNull(decoded);
|
|
30
|
+
}
|
|
31
|
+
function readUnicodeString(bytes, view, offset) {
|
|
32
|
+
requireBytes(bytes.length, offset, 4, "a UnicodeString's Length field");
|
|
33
|
+
const byteLength = view.getUint32(offset, true) * 2;
|
|
34
|
+
requireBytes(bytes.length, offset + 4, byteLength, "a UnicodeString's Characters field");
|
|
35
|
+
const raw = bytes.subarray(offset + 4, offset + 4 + byteLength);
|
|
36
|
+
return truncateAtNull(UTF16_DECODER.decode(raw));
|
|
37
|
+
}
|
|
38
|
+
function readPropertySetStream(bytes) {
|
|
39
|
+
requireBytes(bytes.length, 0, 48, "the PropertySetStream header");
|
|
40
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
41
|
+
const byteOrder = view.getUint16(0, true);
|
|
42
|
+
if (byteOrder !== 65534) throw new PropertySetFormatError(`property set stream's ByteOrder field is 0x${byteOrder.toString(16)}, not the mandated 0xFFFE`);
|
|
43
|
+
const numPropertySets = view.getUint32(24, true);
|
|
44
|
+
if (numPropertySets !== 1) throw new PropertySetFormatError(`property set stream declares ${numPropertySets} property sets; this reader only handles the single-property-set form every "\\x05SummaryInformation" stream uses (the two-property-set DocumentSummaryInformation/UserDefinedProperties spelling is out of scope, see the package README)`);
|
|
45
|
+
const formatId = readGuid(view, 28);
|
|
46
|
+
const offset0 = view.getUint32(44, true);
|
|
47
|
+
requireBytes(bytes.length, offset0, 8, "the PropertySet packet header");
|
|
48
|
+
const size = view.getUint32(offset0, true);
|
|
49
|
+
requireBytes(bytes.length, offset0, size, "the PropertySet packet's own declared Size");
|
|
50
|
+
const numProperties = view.getUint32(offset0 + 4, true);
|
|
51
|
+
const tableStart = offset0 + 8;
|
|
52
|
+
requireBytes(bytes.length, tableStart, numProperties * 8, "the PropertyIdentifierAndOffset dictionary");
|
|
53
|
+
const entries = [];
|
|
54
|
+
for (let i = 0; i < numProperties; i++) {
|
|
55
|
+
const entryOffset = tableStart + i * 8;
|
|
56
|
+
const pid = view.getUint32(entryOffset, true);
|
|
57
|
+
if (pid === 0) throw new PropertySetFormatError("property set carries a Dictionary property (PID 0), which names string-keyed properties this reader does not support -- no \"\\x05SummaryInformation\" stream should carry one");
|
|
58
|
+
entries.push({
|
|
59
|
+
pid,
|
|
60
|
+
relativeOffset: view.getUint32(entryOffset + 4, true)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
let codepage = WINDOWS_1252_CODEPAGE;
|
|
64
|
+
for (const entry of entries) {
|
|
65
|
+
if (entry.pid !== 1) continue;
|
|
66
|
+
const abs = offset0 + entry.relativeOffset;
|
|
67
|
+
requireBytes(bytes.length, abs, 8, "the CodePage property's TypedPropertyValue");
|
|
68
|
+
const type = view.getUint16(abs, true);
|
|
69
|
+
if (type !== 2) throw new PropertySetFormatError(`CodePage property (PID 1) has type 0x${type.toString(16)}, not VT_I2 as [MS-OLEPS] requires`);
|
|
70
|
+
const raw = view.getInt16(abs + 4, true);
|
|
71
|
+
codepage = raw < 0 ? raw + 65536 : raw;
|
|
72
|
+
}
|
|
73
|
+
const properties = /* @__PURE__ */ new Map();
|
|
74
|
+
for (const entry of entries) {
|
|
75
|
+
const abs = offset0 + entry.relativeOffset;
|
|
76
|
+
requireBytes(bytes.length, abs, 4, "a property's TypedPropertyValue header");
|
|
77
|
+
const type = view.getUint16(abs, true);
|
|
78
|
+
const padding = view.getUint16(abs + 2, true);
|
|
79
|
+
if (padding !== 0) throw new PropertySetFormatError(`property ${entry.pid}'s TypedPropertyValue padding is 0x${padding.toString(16)}, not zero as [MS-OLEPS] requires`);
|
|
80
|
+
const valueOffset = abs + 4;
|
|
81
|
+
switch (type) {
|
|
82
|
+
case 2:
|
|
83
|
+
requireBytes(bytes.length, valueOffset, 4, `property ${entry.pid}'s VT_I2 value`);
|
|
84
|
+
properties.set(entry.pid, {
|
|
85
|
+
type: "VT_I2",
|
|
86
|
+
value: view.getInt16(valueOffset, true)
|
|
87
|
+
});
|
|
88
|
+
break;
|
|
89
|
+
case 3:
|
|
90
|
+
requireBytes(bytes.length, valueOffset, 4, `property ${entry.pid}'s VT_I4 value`);
|
|
91
|
+
properties.set(entry.pid, {
|
|
92
|
+
type: "VT_I4",
|
|
93
|
+
value: view.getInt32(valueOffset, true)
|
|
94
|
+
});
|
|
95
|
+
break;
|
|
96
|
+
case 30: {
|
|
97
|
+
const value = readCodePageString(bytes, view, valueOffset, codepage);
|
|
98
|
+
if (value !== void 0) properties.set(entry.pid, {
|
|
99
|
+
type: "VT_LPSTR",
|
|
100
|
+
value
|
|
101
|
+
});
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
case 31: {
|
|
105
|
+
const value = readUnicodeString(bytes, view, valueOffset);
|
|
106
|
+
properties.set(entry.pid, {
|
|
107
|
+
type: "VT_LPWSTR",
|
|
108
|
+
value
|
|
109
|
+
});
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case 64: {
|
|
113
|
+
requireBytes(bytes.length, valueOffset, 8, `property ${entry.pid}'s VT_FILETIME value`);
|
|
114
|
+
const low = view.getUint32(valueOffset, true);
|
|
115
|
+
const high = view.getUint32(valueOffset + 4, true);
|
|
116
|
+
properties.set(entry.pid, {
|
|
117
|
+
type: "VT_FILETIME",
|
|
118
|
+
value: filetimeToDate(low, high)
|
|
119
|
+
});
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
formatId,
|
|
126
|
+
properties
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
export { PropertySetFormatError, readPropertySetStream };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_oleps_wire = require("./wire.cjs");
|
|
3
|
+
const require_oleps_read = require("./read.cjs");
|
|
4
|
+
const require_oleps_write = require("./write.cjs");
|
|
5
|
+
//#region src/oleps/summary-information.ts
|
|
6
|
+
const FMTID_SUMMARY_INFORMATION = "{F29F85E0-4FF9-1068-AB91-08002B27B3D9}";
|
|
7
|
+
const PID_TITLE = 2;
|
|
8
|
+
const PID_SUBJECT = 3;
|
|
9
|
+
const PID_AUTHOR = 4;
|
|
10
|
+
const PID_KEYWORDS = 5;
|
|
11
|
+
const PID_COMMENTS = 6;
|
|
12
|
+
const PID_LASTPRINTED = 11;
|
|
13
|
+
const PID_CREATE_DTM = 12;
|
|
14
|
+
const PID_LASTSAVE_DTM = 13;
|
|
15
|
+
const KEYWORDS_DELIMITER = ", ";
|
|
16
|
+
function splitKeywords(value) {
|
|
17
|
+
const parts = value.split(",").map((part) => part.trim()).filter((part) => part.length > 0);
|
|
18
|
+
return parts.length > 0 ? parts : void 0;
|
|
19
|
+
}
|
|
20
|
+
function stringValue(value, pid) {
|
|
21
|
+
if (value === void 0) return void 0;
|
|
22
|
+
if (value.type !== "VT_LPSTR" && value.type !== "VT_LPWSTR") throw new require_oleps_read.PropertySetFormatError(`SummaryInformation property ${pid} has type ${value.type}, not a string type as [MS-OLEPS]'s SummaryInformation Property Set defines`);
|
|
23
|
+
return value.value.length > 0 ? value.value : void 0;
|
|
24
|
+
}
|
|
25
|
+
const FILETIME_UNSET_ISO = "1601-01-01T00:00:00.000Z";
|
|
26
|
+
function dateIsoValue(value, pid) {
|
|
27
|
+
if (value === void 0) return void 0;
|
|
28
|
+
if (value.type !== "VT_FILETIME") throw new require_oleps_read.PropertySetFormatError(`SummaryInformation property ${pid} has type ${value.type}, not VT_FILETIME as [MS-OLEPS]'s SummaryInformation Property Set defines`);
|
|
29
|
+
const iso = value.value.toISOString();
|
|
30
|
+
return iso === FILETIME_UNSET_ISO ? void 0 : iso;
|
|
31
|
+
}
|
|
32
|
+
function readSummaryInformation(bytes) {
|
|
33
|
+
const propertySet = require_oleps_read.readPropertySetStream(bytes);
|
|
34
|
+
if (propertySet.formatId !== "{F29F85E0-4FF9-1068-AB91-08002B27B3D9}") throw new require_oleps_read.PropertySetFormatError(`property set stream declares FMTID ${propertySet.formatId}, not FMTID_SummaryInformation (${FMTID_SUMMARY_INFORMATION}); this is not a "\\x05SummaryInformation" stream`);
|
|
35
|
+
const { properties } = propertySet;
|
|
36
|
+
const keywords = stringValue(properties.get(PID_KEYWORDS), PID_KEYWORDS);
|
|
37
|
+
return {
|
|
38
|
+
title: stringValue(properties.get(PID_TITLE), PID_TITLE),
|
|
39
|
+
subject: stringValue(properties.get(PID_SUBJECT), PID_SUBJECT),
|
|
40
|
+
author: stringValue(properties.get(PID_AUTHOR), PID_AUTHOR),
|
|
41
|
+
keywords: keywords === void 0 ? void 0 : splitKeywords(keywords),
|
|
42
|
+
comments: stringValue(properties.get(PID_COMMENTS), PID_COMMENTS),
|
|
43
|
+
createdIso: dateIsoValue(properties.get(PID_CREATE_DTM), PID_CREATE_DTM),
|
|
44
|
+
lastSavedIso: dateIsoValue(properties.get(PID_LASTSAVE_DTM), PID_LASTSAVE_DTM),
|
|
45
|
+
lastPrintedIso: dateIsoValue(properties.get(PID_LASTPRINTED), PID_LASTPRINTED)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function writeSummaryInformationStream(properties) {
|
|
49
|
+
const entries = /* @__PURE__ */ new Map();
|
|
50
|
+
entries.set(1, {
|
|
51
|
+
type: "VT_I2",
|
|
52
|
+
value: require_oleps_wire.CP_WINUNICODE
|
|
53
|
+
});
|
|
54
|
+
if (properties.title !== void 0) entries.set(PID_TITLE, {
|
|
55
|
+
type: "VT_LPWSTR",
|
|
56
|
+
value: properties.title
|
|
57
|
+
});
|
|
58
|
+
if (properties.subject !== void 0) entries.set(PID_SUBJECT, {
|
|
59
|
+
type: "VT_LPWSTR",
|
|
60
|
+
value: properties.subject
|
|
61
|
+
});
|
|
62
|
+
if (properties.author !== void 0) entries.set(PID_AUTHOR, {
|
|
63
|
+
type: "VT_LPWSTR",
|
|
64
|
+
value: properties.author
|
|
65
|
+
});
|
|
66
|
+
if (properties.keywords !== void 0 && properties.keywords.length > 0) entries.set(PID_KEYWORDS, {
|
|
67
|
+
type: "VT_LPWSTR",
|
|
68
|
+
value: properties.keywords.join(KEYWORDS_DELIMITER)
|
|
69
|
+
});
|
|
70
|
+
if (properties.comments !== void 0) entries.set(PID_COMMENTS, {
|
|
71
|
+
type: "VT_LPWSTR",
|
|
72
|
+
value: properties.comments
|
|
73
|
+
});
|
|
74
|
+
if (properties.createdIso !== void 0) entries.set(PID_CREATE_DTM, {
|
|
75
|
+
type: "VT_FILETIME",
|
|
76
|
+
value: new Date(properties.createdIso)
|
|
77
|
+
});
|
|
78
|
+
if (properties.lastSavedIso !== void 0) entries.set(PID_LASTSAVE_DTM, {
|
|
79
|
+
type: "VT_FILETIME",
|
|
80
|
+
value: new Date(properties.lastSavedIso)
|
|
81
|
+
});
|
|
82
|
+
if (properties.lastPrintedIso !== void 0) entries.set(PID_LASTPRINTED, {
|
|
83
|
+
type: "VT_FILETIME",
|
|
84
|
+
value: new Date(properties.lastPrintedIso)
|
|
85
|
+
});
|
|
86
|
+
return require_oleps_write.writePropertySetStream({
|
|
87
|
+
formatId: FMTID_SUMMARY_INFORMATION,
|
|
88
|
+
properties: entries
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
exports.FMTID_SUMMARY_INFORMATION = FMTID_SUMMARY_INFORMATION;
|
|
93
|
+
exports.readSummaryInformation = readSummaryInformation;
|
|
94
|
+
exports.writeSummaryInformationStream = writeSummaryInformationStream;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/oleps/summary-information.d.ts
|
|
2
|
+
declare const FMTID_SUMMARY_INFORMATION = "{F29F85E0-4FF9-1068-AB91-08002B27B3D9}";
|
|
3
|
+
interface SummaryInformationProperties {
|
|
4
|
+
readonly title?: string;
|
|
5
|
+
readonly subject?: string;
|
|
6
|
+
readonly author?: string;
|
|
7
|
+
readonly keywords?: readonly string[];
|
|
8
|
+
readonly comments?: string;
|
|
9
|
+
readonly createdIso?: string;
|
|
10
|
+
readonly lastSavedIso?: string;
|
|
11
|
+
readonly lastPrintedIso?: string;
|
|
12
|
+
}
|
|
13
|
+
declare function readSummaryInformation(bytes: Uint8Array<ArrayBuffer>): SummaryInformationProperties;
|
|
14
|
+
declare function writeSummaryInformationStream(properties: SummaryInformationProperties): Uint8Array<ArrayBuffer>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { FMTID_SUMMARY_INFORMATION, SummaryInformationProperties, readSummaryInformation, writeSummaryInformationStream };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/oleps/summary-information.d.ts
|
|
2
|
+
declare const FMTID_SUMMARY_INFORMATION = "{F29F85E0-4FF9-1068-AB91-08002B27B3D9}";
|
|
3
|
+
interface SummaryInformationProperties {
|
|
4
|
+
readonly title?: string;
|
|
5
|
+
readonly subject?: string;
|
|
6
|
+
readonly author?: string;
|
|
7
|
+
readonly keywords?: readonly string[];
|
|
8
|
+
readonly comments?: string;
|
|
9
|
+
readonly createdIso?: string;
|
|
10
|
+
readonly lastSavedIso?: string;
|
|
11
|
+
readonly lastPrintedIso?: string;
|
|
12
|
+
}
|
|
13
|
+
declare function readSummaryInformation(bytes: Uint8Array<ArrayBuffer>): SummaryInformationProperties;
|
|
14
|
+
declare function writeSummaryInformationStream(properties: SummaryInformationProperties): Uint8Array<ArrayBuffer>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { FMTID_SUMMARY_INFORMATION, SummaryInformationProperties, readSummaryInformation, writeSummaryInformationStream };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { CP_WINUNICODE } from "./wire.js";
|
|
2
|
+
import { PropertySetFormatError, readPropertySetStream } from "./read.js";
|
|
3
|
+
import { writePropertySetStream } from "./write.js";
|
|
4
|
+
//#region src/oleps/summary-information.ts
|
|
5
|
+
const FMTID_SUMMARY_INFORMATION = "{F29F85E0-4FF9-1068-AB91-08002B27B3D9}";
|
|
6
|
+
const PID_TITLE = 2;
|
|
7
|
+
const PID_SUBJECT = 3;
|
|
8
|
+
const PID_AUTHOR = 4;
|
|
9
|
+
const PID_KEYWORDS = 5;
|
|
10
|
+
const PID_COMMENTS = 6;
|
|
11
|
+
const PID_LASTPRINTED = 11;
|
|
12
|
+
const PID_CREATE_DTM = 12;
|
|
13
|
+
const PID_LASTSAVE_DTM = 13;
|
|
14
|
+
const KEYWORDS_DELIMITER = ", ";
|
|
15
|
+
function splitKeywords(value) {
|
|
16
|
+
const parts = value.split(",").map((part) => part.trim()).filter((part) => part.length > 0);
|
|
17
|
+
return parts.length > 0 ? parts : void 0;
|
|
18
|
+
}
|
|
19
|
+
function stringValue(value, pid) {
|
|
20
|
+
if (value === void 0) return void 0;
|
|
21
|
+
if (value.type !== "VT_LPSTR" && value.type !== "VT_LPWSTR") throw new PropertySetFormatError(`SummaryInformation property ${pid} has type ${value.type}, not a string type as [MS-OLEPS]'s SummaryInformation Property Set defines`);
|
|
22
|
+
return value.value.length > 0 ? value.value : void 0;
|
|
23
|
+
}
|
|
24
|
+
const FILETIME_UNSET_ISO = "1601-01-01T00:00:00.000Z";
|
|
25
|
+
function dateIsoValue(value, pid) {
|
|
26
|
+
if (value === void 0) return void 0;
|
|
27
|
+
if (value.type !== "VT_FILETIME") throw new PropertySetFormatError(`SummaryInformation property ${pid} has type ${value.type}, not VT_FILETIME as [MS-OLEPS]'s SummaryInformation Property Set defines`);
|
|
28
|
+
const iso = value.value.toISOString();
|
|
29
|
+
return iso === FILETIME_UNSET_ISO ? void 0 : iso;
|
|
30
|
+
}
|
|
31
|
+
function readSummaryInformation(bytes) {
|
|
32
|
+
const propertySet = readPropertySetStream(bytes);
|
|
33
|
+
if (propertySet.formatId !== "{F29F85E0-4FF9-1068-AB91-08002B27B3D9}") throw new PropertySetFormatError(`property set stream declares FMTID ${propertySet.formatId}, not FMTID_SummaryInformation (${FMTID_SUMMARY_INFORMATION}); this is not a "\\x05SummaryInformation" stream`);
|
|
34
|
+
const { properties } = propertySet;
|
|
35
|
+
const keywords = stringValue(properties.get(PID_KEYWORDS), PID_KEYWORDS);
|
|
36
|
+
return {
|
|
37
|
+
title: stringValue(properties.get(PID_TITLE), PID_TITLE),
|
|
38
|
+
subject: stringValue(properties.get(PID_SUBJECT), PID_SUBJECT),
|
|
39
|
+
author: stringValue(properties.get(PID_AUTHOR), PID_AUTHOR),
|
|
40
|
+
keywords: keywords === void 0 ? void 0 : splitKeywords(keywords),
|
|
41
|
+
comments: stringValue(properties.get(PID_COMMENTS), PID_COMMENTS),
|
|
42
|
+
createdIso: dateIsoValue(properties.get(PID_CREATE_DTM), PID_CREATE_DTM),
|
|
43
|
+
lastSavedIso: dateIsoValue(properties.get(PID_LASTSAVE_DTM), PID_LASTSAVE_DTM),
|
|
44
|
+
lastPrintedIso: dateIsoValue(properties.get(PID_LASTPRINTED), PID_LASTPRINTED)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function writeSummaryInformationStream(properties) {
|
|
48
|
+
const entries = /* @__PURE__ */ new Map();
|
|
49
|
+
entries.set(1, {
|
|
50
|
+
type: "VT_I2",
|
|
51
|
+
value: CP_WINUNICODE
|
|
52
|
+
});
|
|
53
|
+
if (properties.title !== void 0) entries.set(PID_TITLE, {
|
|
54
|
+
type: "VT_LPWSTR",
|
|
55
|
+
value: properties.title
|
|
56
|
+
});
|
|
57
|
+
if (properties.subject !== void 0) entries.set(PID_SUBJECT, {
|
|
58
|
+
type: "VT_LPWSTR",
|
|
59
|
+
value: properties.subject
|
|
60
|
+
});
|
|
61
|
+
if (properties.author !== void 0) entries.set(PID_AUTHOR, {
|
|
62
|
+
type: "VT_LPWSTR",
|
|
63
|
+
value: properties.author
|
|
64
|
+
});
|
|
65
|
+
if (properties.keywords !== void 0 && properties.keywords.length > 0) entries.set(PID_KEYWORDS, {
|
|
66
|
+
type: "VT_LPWSTR",
|
|
67
|
+
value: properties.keywords.join(KEYWORDS_DELIMITER)
|
|
68
|
+
});
|
|
69
|
+
if (properties.comments !== void 0) entries.set(PID_COMMENTS, {
|
|
70
|
+
type: "VT_LPWSTR",
|
|
71
|
+
value: properties.comments
|
|
72
|
+
});
|
|
73
|
+
if (properties.createdIso !== void 0) entries.set(PID_CREATE_DTM, {
|
|
74
|
+
type: "VT_FILETIME",
|
|
75
|
+
value: new Date(properties.createdIso)
|
|
76
|
+
});
|
|
77
|
+
if (properties.lastSavedIso !== void 0) entries.set(PID_LASTSAVE_DTM, {
|
|
78
|
+
type: "VT_FILETIME",
|
|
79
|
+
value: new Date(properties.lastSavedIso)
|
|
80
|
+
});
|
|
81
|
+
if (properties.lastPrintedIso !== void 0) entries.set(PID_LASTPRINTED, {
|
|
82
|
+
type: "VT_FILETIME",
|
|
83
|
+
value: new Date(properties.lastPrintedIso)
|
|
84
|
+
});
|
|
85
|
+
return writePropertySetStream({
|
|
86
|
+
formatId: FMTID_SUMMARY_INFORMATION,
|
|
87
|
+
properties: entries
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { FMTID_SUMMARY_INFORMATION, readSummaryInformation, writeSummaryInformationStream };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/oleps/wire.ts
|
|
3
|
+
const BYTE_ORDER_MARK = 65534;
|
|
4
|
+
const HEADER_SIZE = 48;
|
|
5
|
+
const PROPERTY_SET_HEADER_SIZE = 8;
|
|
6
|
+
const IDENTIFIER_AND_OFFSET_SIZE = 8;
|
|
7
|
+
const TYPED_VALUE_HEADER_SIZE = 4;
|
|
8
|
+
const VT_I2 = 2;
|
|
9
|
+
const VT_I4 = 3;
|
|
10
|
+
const VT_LPSTR = 30;
|
|
11
|
+
const VT_LPWSTR = 31;
|
|
12
|
+
const VT_FILETIME = 64;
|
|
13
|
+
const PID_DICTIONARY = 0;
|
|
14
|
+
const PID_CODEPAGE = 1;
|
|
15
|
+
const CP_WINUNICODE = 1200;
|
|
16
|
+
const WINDOWS_1252_CODEPAGE = 1252;
|
|
17
|
+
const GUID_NULL = "{00000000-0000-0000-0000-000000000000}";
|
|
18
|
+
function hex(n, width) {
|
|
19
|
+
return n.toString(16).padStart(width, "0");
|
|
20
|
+
}
|
|
21
|
+
function readGuid(view, offset) {
|
|
22
|
+
const data1 = hex(view.getUint32(offset, true), 8);
|
|
23
|
+
const data2 = hex(view.getUint16(offset + 4, true), 4);
|
|
24
|
+
const data3 = hex(view.getUint16(offset + 6, true), 4);
|
|
25
|
+
let data4a = "";
|
|
26
|
+
for (let i = 0; i < 2; i++) data4a += hex(view.getUint8(offset + 8 + i), 2);
|
|
27
|
+
let data4b = "";
|
|
28
|
+
for (let i = 2; i < 8; i++) data4b += hex(view.getUint8(offset + 8 + i), 2);
|
|
29
|
+
return `{${data1}-${data2}-${data3}-${data4a}-${data4b}}`.toUpperCase();
|
|
30
|
+
}
|
|
31
|
+
function writeGuid(view, offset, guid) {
|
|
32
|
+
const digits = guid.replace(/[{}-]/g, "");
|
|
33
|
+
view.setUint32(offset, Number.parseInt(digits.slice(0, 8), 16), true);
|
|
34
|
+
view.setUint16(offset + 4, Number.parseInt(digits.slice(8, 12), 16), true);
|
|
35
|
+
view.setUint16(offset + 6, Number.parseInt(digits.slice(12, 16), 16), true);
|
|
36
|
+
for (let i = 0; i < 8; i++) view.setUint8(offset + 8 + i, Number.parseInt(digits.slice(16 + i * 2, 18 + i * 2), 16));
|
|
37
|
+
}
|
|
38
|
+
const FILETIME_EPOCH_OFFSET_100NS = 116444736000000000n;
|
|
39
|
+
const HUNDRED_NS_PER_MS = 10000n;
|
|
40
|
+
function filetimeToDate(low, high) {
|
|
41
|
+
const ms = ((BigInt(high) << 32n | BigInt(low)) - FILETIME_EPOCH_OFFSET_100NS) / HUNDRED_NS_PER_MS;
|
|
42
|
+
return new Date(Number(ms));
|
|
43
|
+
}
|
|
44
|
+
function dateToFiletime(date) {
|
|
45
|
+
const ticks = BigInt(date.getTime()) * HUNDRED_NS_PER_MS + FILETIME_EPOCH_OFFSET_100NS;
|
|
46
|
+
return {
|
|
47
|
+
low: Number(ticks & 4294967295n),
|
|
48
|
+
high: Number(ticks >> 32n & 4294967295n)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
exports.BYTE_ORDER_MARK = BYTE_ORDER_MARK;
|
|
53
|
+
exports.CP_WINUNICODE = CP_WINUNICODE;
|
|
54
|
+
exports.GUID_NULL = GUID_NULL;
|
|
55
|
+
exports.HEADER_SIZE = HEADER_SIZE;
|
|
56
|
+
exports.IDENTIFIER_AND_OFFSET_SIZE = IDENTIFIER_AND_OFFSET_SIZE;
|
|
57
|
+
exports.PID_CODEPAGE = PID_CODEPAGE;
|
|
58
|
+
exports.PID_DICTIONARY = PID_DICTIONARY;
|
|
59
|
+
exports.PROPERTY_SET_HEADER_SIZE = PROPERTY_SET_HEADER_SIZE;
|
|
60
|
+
exports.TYPED_VALUE_HEADER_SIZE = TYPED_VALUE_HEADER_SIZE;
|
|
61
|
+
exports.VT_FILETIME = VT_FILETIME;
|
|
62
|
+
exports.VT_I2 = VT_I2;
|
|
63
|
+
exports.VT_I4 = VT_I4;
|
|
64
|
+
exports.VT_LPSTR = VT_LPSTR;
|
|
65
|
+
exports.VT_LPWSTR = VT_LPWSTR;
|
|
66
|
+
exports.WINDOWS_1252_CODEPAGE = WINDOWS_1252_CODEPAGE;
|
|
67
|
+
exports.dateToFiletime = dateToFiletime;
|
|
68
|
+
exports.filetimeToDate = filetimeToDate;
|
|
69
|
+
exports.readGuid = readGuid;
|
|
70
|
+
exports.writeGuid = writeGuid;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/oleps/wire.d.ts
|
|
2
|
+
declare const BYTE_ORDER_MARK = 65534;
|
|
3
|
+
declare const HEADER_SIZE = 48;
|
|
4
|
+
declare const PROPERTY_SET_HEADER_SIZE = 8;
|
|
5
|
+
declare const IDENTIFIER_AND_OFFSET_SIZE = 8;
|
|
6
|
+
declare const TYPED_VALUE_HEADER_SIZE = 4;
|
|
7
|
+
declare const VT_I2 = 2;
|
|
8
|
+
declare const VT_I4 = 3;
|
|
9
|
+
declare const VT_LPSTR = 30;
|
|
10
|
+
declare const VT_LPWSTR = 31;
|
|
11
|
+
declare const VT_FILETIME = 64;
|
|
12
|
+
declare const PID_DICTIONARY = 0;
|
|
13
|
+
declare const PID_CODEPAGE = 1;
|
|
14
|
+
declare const CP_WINUNICODE = 1200;
|
|
15
|
+
declare const WINDOWS_1252_CODEPAGE = 1252;
|
|
16
|
+
declare const GUID_NULL = "{00000000-0000-0000-0000-000000000000}";
|
|
17
|
+
declare function readGuid(view: DataView, offset: number): string;
|
|
18
|
+
declare function writeGuid(view: DataView, offset: number, guid: string): void;
|
|
19
|
+
declare function filetimeToDate(low: number, high: number): Date;
|
|
20
|
+
declare function dateToFiletime(date: Date): {
|
|
21
|
+
readonly low: number;
|
|
22
|
+
readonly high: number;
|
|
23
|
+
};
|
|
24
|
+
type PropertyValue = {
|
|
25
|
+
readonly type: "VT_I2";
|
|
26
|
+
readonly value: number;
|
|
27
|
+
} | {
|
|
28
|
+
readonly type: "VT_I4";
|
|
29
|
+
readonly value: number;
|
|
30
|
+
} | {
|
|
31
|
+
readonly type: "VT_LPSTR";
|
|
32
|
+
readonly value: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly type: "VT_LPWSTR";
|
|
35
|
+
readonly value: string;
|
|
36
|
+
} | {
|
|
37
|
+
readonly type: "VT_FILETIME";
|
|
38
|
+
readonly value: Date;
|
|
39
|
+
};
|
|
40
|
+
interface PropertySet {
|
|
41
|
+
readonly formatId: string;
|
|
42
|
+
readonly properties: ReadonlyMap<number, PropertyValue>;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { BYTE_ORDER_MARK, CP_WINUNICODE, GUID_NULL, HEADER_SIZE, IDENTIFIER_AND_OFFSET_SIZE, PID_CODEPAGE, PID_DICTIONARY, PROPERTY_SET_HEADER_SIZE, PropertySet, PropertyValue, TYPED_VALUE_HEADER_SIZE, VT_FILETIME, VT_I2, VT_I4, VT_LPSTR, VT_LPWSTR, WINDOWS_1252_CODEPAGE, dateToFiletime, filetimeToDate, readGuid, writeGuid };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/oleps/wire.d.ts
|
|
2
|
+
declare const BYTE_ORDER_MARK = 65534;
|
|
3
|
+
declare const HEADER_SIZE = 48;
|
|
4
|
+
declare const PROPERTY_SET_HEADER_SIZE = 8;
|
|
5
|
+
declare const IDENTIFIER_AND_OFFSET_SIZE = 8;
|
|
6
|
+
declare const TYPED_VALUE_HEADER_SIZE = 4;
|
|
7
|
+
declare const VT_I2 = 2;
|
|
8
|
+
declare const VT_I4 = 3;
|
|
9
|
+
declare const VT_LPSTR = 30;
|
|
10
|
+
declare const VT_LPWSTR = 31;
|
|
11
|
+
declare const VT_FILETIME = 64;
|
|
12
|
+
declare const PID_DICTIONARY = 0;
|
|
13
|
+
declare const PID_CODEPAGE = 1;
|
|
14
|
+
declare const CP_WINUNICODE = 1200;
|
|
15
|
+
declare const WINDOWS_1252_CODEPAGE = 1252;
|
|
16
|
+
declare const GUID_NULL = "{00000000-0000-0000-0000-000000000000}";
|
|
17
|
+
declare function readGuid(view: DataView, offset: number): string;
|
|
18
|
+
declare function writeGuid(view: DataView, offset: number, guid: string): void;
|
|
19
|
+
declare function filetimeToDate(low: number, high: number): Date;
|
|
20
|
+
declare function dateToFiletime(date: Date): {
|
|
21
|
+
readonly low: number;
|
|
22
|
+
readonly high: number;
|
|
23
|
+
};
|
|
24
|
+
type PropertyValue = {
|
|
25
|
+
readonly type: "VT_I2";
|
|
26
|
+
readonly value: number;
|
|
27
|
+
} | {
|
|
28
|
+
readonly type: "VT_I4";
|
|
29
|
+
readonly value: number;
|
|
30
|
+
} | {
|
|
31
|
+
readonly type: "VT_LPSTR";
|
|
32
|
+
readonly value: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly type: "VT_LPWSTR";
|
|
35
|
+
readonly value: string;
|
|
36
|
+
} | {
|
|
37
|
+
readonly type: "VT_FILETIME";
|
|
38
|
+
readonly value: Date;
|
|
39
|
+
};
|
|
40
|
+
interface PropertySet {
|
|
41
|
+
readonly formatId: string;
|
|
42
|
+
readonly properties: ReadonlyMap<number, PropertyValue>;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { BYTE_ORDER_MARK, CP_WINUNICODE, GUID_NULL, HEADER_SIZE, IDENTIFIER_AND_OFFSET_SIZE, PID_CODEPAGE, PID_DICTIONARY, PROPERTY_SET_HEADER_SIZE, PropertySet, PropertyValue, TYPED_VALUE_HEADER_SIZE, VT_FILETIME, VT_I2, VT_I4, VT_LPSTR, VT_LPWSTR, WINDOWS_1252_CODEPAGE, dateToFiletime, filetimeToDate, readGuid, writeGuid };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region src/oleps/wire.ts
|
|
2
|
+
const BYTE_ORDER_MARK = 65534;
|
|
3
|
+
const HEADER_SIZE = 48;
|
|
4
|
+
const PROPERTY_SET_HEADER_SIZE = 8;
|
|
5
|
+
const IDENTIFIER_AND_OFFSET_SIZE = 8;
|
|
6
|
+
const TYPED_VALUE_HEADER_SIZE = 4;
|
|
7
|
+
const VT_I2 = 2;
|
|
8
|
+
const VT_I4 = 3;
|
|
9
|
+
const VT_LPSTR = 30;
|
|
10
|
+
const VT_LPWSTR = 31;
|
|
11
|
+
const VT_FILETIME = 64;
|
|
12
|
+
const PID_DICTIONARY = 0;
|
|
13
|
+
const PID_CODEPAGE = 1;
|
|
14
|
+
const CP_WINUNICODE = 1200;
|
|
15
|
+
const WINDOWS_1252_CODEPAGE = 1252;
|
|
16
|
+
const GUID_NULL = "{00000000-0000-0000-0000-000000000000}";
|
|
17
|
+
function hex(n, width) {
|
|
18
|
+
return n.toString(16).padStart(width, "0");
|
|
19
|
+
}
|
|
20
|
+
function readGuid(view, offset) {
|
|
21
|
+
const data1 = hex(view.getUint32(offset, true), 8);
|
|
22
|
+
const data2 = hex(view.getUint16(offset + 4, true), 4);
|
|
23
|
+
const data3 = hex(view.getUint16(offset + 6, true), 4);
|
|
24
|
+
let data4a = "";
|
|
25
|
+
for (let i = 0; i < 2; i++) data4a += hex(view.getUint8(offset + 8 + i), 2);
|
|
26
|
+
let data4b = "";
|
|
27
|
+
for (let i = 2; i < 8; i++) data4b += hex(view.getUint8(offset + 8 + i), 2);
|
|
28
|
+
return `{${data1}-${data2}-${data3}-${data4a}-${data4b}}`.toUpperCase();
|
|
29
|
+
}
|
|
30
|
+
function writeGuid(view, offset, guid) {
|
|
31
|
+
const digits = guid.replace(/[{}-]/g, "");
|
|
32
|
+
view.setUint32(offset, Number.parseInt(digits.slice(0, 8), 16), true);
|
|
33
|
+
view.setUint16(offset + 4, Number.parseInt(digits.slice(8, 12), 16), true);
|
|
34
|
+
view.setUint16(offset + 6, Number.parseInt(digits.slice(12, 16), 16), true);
|
|
35
|
+
for (let i = 0; i < 8; i++) view.setUint8(offset + 8 + i, Number.parseInt(digits.slice(16 + i * 2, 18 + i * 2), 16));
|
|
36
|
+
}
|
|
37
|
+
const FILETIME_EPOCH_OFFSET_100NS = 116444736000000000n;
|
|
38
|
+
const HUNDRED_NS_PER_MS = 10000n;
|
|
39
|
+
function filetimeToDate(low, high) {
|
|
40
|
+
const ms = ((BigInt(high) << 32n | BigInt(low)) - FILETIME_EPOCH_OFFSET_100NS) / HUNDRED_NS_PER_MS;
|
|
41
|
+
return new Date(Number(ms));
|
|
42
|
+
}
|
|
43
|
+
function dateToFiletime(date) {
|
|
44
|
+
const ticks = BigInt(date.getTime()) * HUNDRED_NS_PER_MS + FILETIME_EPOCH_OFFSET_100NS;
|
|
45
|
+
return {
|
|
46
|
+
low: Number(ticks & 4294967295n),
|
|
47
|
+
high: Number(ticks >> 32n & 4294967295n)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { BYTE_ORDER_MARK, CP_WINUNICODE, GUID_NULL, HEADER_SIZE, IDENTIFIER_AND_OFFSET_SIZE, PID_CODEPAGE, PID_DICTIONARY, PROPERTY_SET_HEADER_SIZE, TYPED_VALUE_HEADER_SIZE, VT_FILETIME, VT_I2, VT_I4, VT_LPSTR, VT_LPWSTR, WINDOWS_1252_CODEPAGE, dateToFiletime, filetimeToDate, readGuid, writeGuid };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_oleps_wire = require("./wire.cjs");
|
|
3
|
+
//#region src/oleps/write.ts
|
|
4
|
+
var PropertySetWriteError = class extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "PropertySetWriteError";
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
function encodeUnicodeStringValue(value) {
|
|
11
|
+
const characterBytes = new Uint8Array((value.length + 1) * 2);
|
|
12
|
+
const charView = new DataView(characterBytes.buffer);
|
|
13
|
+
for (let i = 0; i < value.length; i++) charView.setUint16(i * 2, value.charCodeAt(i), true);
|
|
14
|
+
charView.setUint16(value.length * 2, 0, true);
|
|
15
|
+
return characterBytes;
|
|
16
|
+
}
|
|
17
|
+
function padTo4(length) {
|
|
18
|
+
return Math.ceil(length / 4) * 4;
|
|
19
|
+
}
|
|
20
|
+
function encodeTypedPropertyValue(value) {
|
|
21
|
+
switch (value.type) {
|
|
22
|
+
case "VT_I2": {
|
|
23
|
+
const bytes = /* @__PURE__ */ new Uint8Array(8);
|
|
24
|
+
const view = new DataView(bytes.buffer);
|
|
25
|
+
view.setUint16(0, 2, true);
|
|
26
|
+
view.setUint16(2, 0, true);
|
|
27
|
+
view.setInt16(4, value.value, true);
|
|
28
|
+
view.setUint16(6, 0, true);
|
|
29
|
+
return bytes;
|
|
30
|
+
}
|
|
31
|
+
case "VT_I4": {
|
|
32
|
+
const bytes = /* @__PURE__ */ new Uint8Array(8);
|
|
33
|
+
const view = new DataView(bytes.buffer);
|
|
34
|
+
view.setUint16(0, 3, true);
|
|
35
|
+
view.setUint16(2, 0, true);
|
|
36
|
+
view.setInt32(4, value.value, true);
|
|
37
|
+
return bytes;
|
|
38
|
+
}
|
|
39
|
+
case "VT_FILETIME": {
|
|
40
|
+
const { low, high } = require_oleps_wire.dateToFiletime(value.value);
|
|
41
|
+
const bytes = /* @__PURE__ */ new Uint8Array(12);
|
|
42
|
+
const view = new DataView(bytes.buffer);
|
|
43
|
+
view.setUint16(0, 64, true);
|
|
44
|
+
view.setUint16(2, 0, true);
|
|
45
|
+
view.setUint32(4, low, true);
|
|
46
|
+
view.setUint32(8, high, true);
|
|
47
|
+
return bytes;
|
|
48
|
+
}
|
|
49
|
+
case "VT_LPWSTR": {
|
|
50
|
+
const characters = encodeUnicodeStringValue(value.value);
|
|
51
|
+
const paddedLength = padTo4(characters.length);
|
|
52
|
+
const bytes = new Uint8Array(8 + paddedLength);
|
|
53
|
+
const view = new DataView(bytes.buffer);
|
|
54
|
+
view.setUint16(0, 31, true);
|
|
55
|
+
view.setUint16(2, 0, true);
|
|
56
|
+
view.setUint32(4, characters.length / 2, true);
|
|
57
|
+
bytes.set(characters, 8);
|
|
58
|
+
return bytes;
|
|
59
|
+
}
|
|
60
|
+
case "VT_LPSTR": throw new PropertySetWriteError("writePropertySetStream cannot write a VT_LPSTR property: this writer emits Unicode (VT_LPWSTR) strings only, since encoding to an arbitrary ANSI codepage is out of scope -- see the package README's OLEPS scope note");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function writePropertySetStream(propertySet) {
|
|
64
|
+
const entries = [...propertySet.properties.entries()].sort(([a], [b]) => a - b);
|
|
65
|
+
const dictionaryBytes = new Uint8Array(entries.length * 8);
|
|
66
|
+
const dictionaryView = new DataView(dictionaryBytes.buffer);
|
|
67
|
+
const valueChunks = [];
|
|
68
|
+
let valueOffset = 8 + dictionaryBytes.length;
|
|
69
|
+
let index = 0;
|
|
70
|
+
for (const [pid, value] of entries) {
|
|
71
|
+
const encoded = encodeTypedPropertyValue(value);
|
|
72
|
+
dictionaryView.setUint32(index * 8, pid, true);
|
|
73
|
+
dictionaryView.setUint32(index * 8 + 4, valueOffset, true);
|
|
74
|
+
valueChunks.push(encoded);
|
|
75
|
+
valueOffset += encoded.length;
|
|
76
|
+
index += 1;
|
|
77
|
+
}
|
|
78
|
+
const propertySetSize = valueOffset;
|
|
79
|
+
const propertySetBytes = new Uint8Array(propertySetSize);
|
|
80
|
+
const propertySetView = new DataView(propertySetBytes.buffer);
|
|
81
|
+
propertySetView.setUint32(0, propertySetSize, true);
|
|
82
|
+
propertySetView.setUint32(4, entries.length, true);
|
|
83
|
+
propertySetBytes.set(dictionaryBytes, 8);
|
|
84
|
+
let cursor = 8 + dictionaryBytes.length;
|
|
85
|
+
for (const chunk of valueChunks) {
|
|
86
|
+
propertySetBytes.set(chunk, cursor);
|
|
87
|
+
cursor += chunk.length;
|
|
88
|
+
}
|
|
89
|
+
const streamBytes = new Uint8Array(48 + propertySetBytes.length);
|
|
90
|
+
const view = new DataView(streamBytes.buffer);
|
|
91
|
+
view.setUint16(0, require_oleps_wire.BYTE_ORDER_MARK, true);
|
|
92
|
+
view.setUint16(2, 0, true);
|
|
93
|
+
view.setUint32(4, 0, true);
|
|
94
|
+
require_oleps_wire.writeGuid(view, 8, require_oleps_wire.GUID_NULL);
|
|
95
|
+
view.setUint32(24, 1, true);
|
|
96
|
+
require_oleps_wire.writeGuid(view, 28, propertySet.formatId);
|
|
97
|
+
view.setUint32(44, 48, true);
|
|
98
|
+
streamBytes.set(propertySetBytes, 48);
|
|
99
|
+
return streamBytes;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
exports.PropertySetWriteError = PropertySetWriteError;
|
|
103
|
+
exports.writePropertySetStream = writePropertySetStream;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PropertySet } from "./wire.cjs";
|
|
2
|
+
//#region src/oleps/write.d.ts
|
|
3
|
+
declare class PropertySetWriteError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
declare function writePropertySetStream(propertySet: PropertySet): Uint8Array<ArrayBuffer>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { PropertySetWriteError, writePropertySetStream };
|