ppt-codec 1.0.2 → 1.1.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.
Files changed (100) hide show
  1. package/README.md +142 -38
  2. package/dist/content-write.cjs +114 -0
  3. package/dist/content-write.d.cts +11 -0
  4. package/dist/content-write.d.ts +11 -0
  5. package/dist/content-write.js +112 -0
  6. package/dist/content.cjs +22 -2
  7. package/dist/content.js +22 -2
  8. package/dist/document/color-scheme-write.cjs +57 -0
  9. package/dist/document/color-scheme-write.d.cts +4 -0
  10. package/dist/document/color-scheme-write.d.ts +4 -0
  11. package/dist/document/color-scheme-write.js +56 -0
  12. package/dist/document/document-atom-write.cjs +12 -0
  13. package/dist/document/document-atom-write.d.cts +5 -0
  14. package/dist/document/document-atom-write.d.ts +5 -0
  15. package/dist/document/document-atom-write.js +11 -0
  16. package/dist/document/fonts-write.cjs +17 -0
  17. package/dist/document/fonts-write.d.cts +4 -0
  18. package/dist/document/fonts-write.d.ts +4 -0
  19. package/dist/document/fonts-write.js +16 -0
  20. package/dist/document/master-write.cjs +128 -0
  21. package/dist/document/master-write.d.cts +15 -0
  22. package/dist/document/master-write.d.ts +15 -0
  23. package/dist/document/master-write.js +123 -0
  24. package/dist/document/notes-list-write.cjs +12 -0
  25. package/dist/document/notes-list-write.d.cts +5 -0
  26. package/dist/document/notes-list-write.d.ts +5 -0
  27. package/dist/document/notes-list-write.js +11 -0
  28. package/dist/document/notes-list.cjs +22 -0
  29. package/dist/document/notes-list.d.cts +9 -0
  30. package/dist/document/notes-list.d.ts +9 -0
  31. package/dist/document/notes-list.js +21 -0
  32. package/dist/document/notes-write.cjs +43 -0
  33. package/dist/document/notes-write.d.cts +6 -0
  34. package/dist/document/notes-write.d.ts +6 -0
  35. package/dist/document/notes-write.js +41 -0
  36. package/dist/document/notes.cjs +41 -0
  37. package/dist/document/notes.d.cts +12 -0
  38. package/dist/document/notes.d.ts +12 -0
  39. package/dist/document/notes.js +37 -0
  40. package/dist/document/slide-list-write.cjs +12 -0
  41. package/dist/document/slide-list-write.d.cts +8 -0
  42. package/dist/document/slide-list-write.d.ts +8 -0
  43. package/dist/document/slide-list-write.js +11 -0
  44. package/dist/drawing/shapes-write.cjs +60 -0
  45. package/dist/drawing/shapes-write.d.cts +10 -0
  46. package/dist/drawing/shapes-write.d.ts +10 -0
  47. package/dist/drawing/shapes-write.js +58 -0
  48. package/dist/errors.cjs +7 -0
  49. package/dist/errors.d.cts +4 -1
  50. package/dist/errors.d.ts +4 -1
  51. package/dist/errors.js +7 -1
  52. package/dist/index.cjs +112 -3
  53. package/dist/index.d.cts +24 -7
  54. package/dist/index.d.ts +24 -7
  55. package/dist/index.js +25 -8
  56. package/dist/metadata.cjs +14 -0
  57. package/dist/metadata.d.cts +6 -0
  58. package/dist/metadata.d.ts +6 -0
  59. package/dist/metadata.js +13 -0
  60. package/dist/read.cjs +33 -8
  61. package/dist/read.d.cts +5 -1
  62. package/dist/read.d.ts +5 -1
  63. package/dist/read.js +32 -10
  64. package/dist/record/types.cjs +8 -0
  65. package/dist/record/types.d.cts +5 -1
  66. package/dist/record/types.d.ts +5 -1
  67. package/dist/record/types.js +5 -1
  68. package/dist/record/write.cjs +75 -0
  69. package/dist/record/write.d.cts +17 -0
  70. package/dist/record/write.d.ts +17 -0
  71. package/dist/record/write.js +65 -0
  72. package/dist/stream/current-user-write.cjs +13 -0
  73. package/dist/stream/current-user-write.d.cts +4 -0
  74. package/dist/stream/current-user-write.d.ts +4 -0
  75. package/dist/stream/current-user-write.js +12 -0
  76. package/dist/stream/current-user.cjs +7 -5
  77. package/dist/stream/current-user.d.cts +3 -1
  78. package/dist/stream/current-user.d.ts +3 -1
  79. package/dist/stream/current-user.js +6 -6
  80. package/dist/stream/persist-write.cjs +14 -0
  81. package/dist/stream/persist-write.d.cts +16 -0
  82. package/dist/stream/persist-write.d.ts +16 -0
  83. package/dist/stream/persist-write.js +12 -0
  84. package/dist/text/style-write.cjs +79 -0
  85. package/dist/text/style-write.d.cts +5 -0
  86. package/dist/text/style-write.d.ts +5 -0
  87. package/dist/text/style-write.js +78 -0
  88. package/dist/text/style.cjs +85 -30
  89. package/dist/text/style.d.cts +50 -1
  90. package/dist/text/style.d.ts +50 -1
  91. package/dist/text/style.js +44 -31
  92. package/dist/units.cjs +4 -0
  93. package/dist/units.d.cts +2 -1
  94. package/dist/units.d.ts +2 -1
  95. package/dist/units.js +4 -1
  96. package/dist/write.cjs +145 -0
  97. package/dist/write.d.cts +11 -0
  98. package/dist/write.d.ts +11 -0
  99. package/dist/write.js +142 -0
  100. package/package.json +4 -4
package/dist/read.js CHANGED
@@ -1,21 +1,25 @@
1
1
  import { PptEncryptedError, PptFormatError } from "./errors.js";
2
2
  import { childRecords, findChild } from "./record/tree.js";
3
3
  import { RT_Document, RT_DocumentAtom, RT_Drawing, RT_Environment, RT_OutlineTextRefAtom, RT_Slide, RT_StyleTextPropAtom } from "./record/types.js";
4
- import { characterCountOf, readTextBody } from "./text/atoms.js";
5
4
  import { readStyleTextPropAtom } from "./text/style.js";
5
+ import { characterCountOf, readTextBody } from "./text/atoms.js";
6
+ import { masterUnitsToPoints } from "./units.js";
6
7
  import { buildParagraphs } from "./content.js";
7
8
  import { readDocumentAtom } from "./document/document-atom.js";
8
9
  import { readFontNames } from "./document/fonts.js";
9
- import { readSlideListWithText } from "./document/slide-list.js";
10
+ import { readNotesListWithText } from "./document/notes-list.js";
10
11
  import { readDrawingShapes } from "./drawing/shapes.js";
12
+ import { readNotesContainerAtom, readNotesText } from "./document/notes.js";
13
+ import { readSlideListWithText } from "./document/slide-list.js";
11
14
  import { readCurrentUserAtom } from "./stream/current-user.js";
12
15
  import { buildPersistDirectory, resolvePersistObject } from "./stream/persist.js";
13
- import { masterUnitsToPoints } from "./units.js";
14
- import { readCompoundFile } from "archive-codec";
16
+ import { readCompoundFile, readSummaryInformation, summaryInformationToLayoutMetadata } from "archive-codec";
15
17
  import { assembleTree } from "document-schema.js";
16
18
  //#region src/read.ts
17
19
  const CURRENT_USER_STREAM = "Current User";
18
20
  const POWERPOINT_DOCUMENT_STREAM = "PowerPoint Document";
21
+ /** The [MS-OLEPS] Property Set Stream a .ppt's title/author/dates live in when present ([MS-OSHARED] 2.3.3.2.2) -- a genuinely optional stream, unlike the two above, since a valid PowerPoint binary document need not carry document properties at all. */
22
+ const SUMMARY_INFORMATION_STREAM = "SummaryInformation";
19
23
  const DEFAULT_INSET_LEFT_RIGHT_PT = 7.2;
20
24
  const DEFAULT_INSET_TOP_BOTTOM_PT = 3.6;
21
25
  const NO_STYLE = {
@@ -46,7 +50,16 @@ function blocksFor(clientTextbox, persist, fontNames) {
46
50
  const style = styleRecord === void 0 ? NO_STYLE : readStyleTextPropAtom(styleRecord, characterCountOf(text));
47
51
  return buildParagraphs(text, style, fontNames);
48
52
  }
49
- function readSlide(streamBytes, directory, persist, size, fontNames) {
53
+ function readNotesBySlideId(streamBytes, directory, notesList) {
54
+ const notes = /* @__PURE__ */ new Map();
55
+ if (notesList === void 0) return notes;
56
+ for (const persist of readNotesListWithText(notesList)) {
57
+ const notesContainer = resolvePersistObject(streamBytes, directory, persist.persistIdRef, `NotesPersistAtom for notes slide ${persist.notesId}`);
58
+ notes.set(readNotesContainerAtom(notesContainer).slideIdRef, readNotesText(notesContainer));
59
+ }
60
+ return notes;
61
+ }
62
+ function readSlide(streamBytes, directory, persist, size, fontNames, notes) {
50
63
  const slideContainer = resolvePersistObject(streamBytes, directory, persist.persistIdRef, `SlidePersistAtom for slide ${persist.slideId}`);
51
64
  if (slideContainer.header.recType !== 1006) throw new PptFormatError(`persist object ${persist.persistIdRef} is record type 0x${slideContainer.header.recType.toString(16)}, not the RT_Slide (0x${RT_Slide.toString(16)}) its SlidePersistAtom promised`);
52
65
  const drawing = findChild(childRecords(slideContainer), RT_Drawing);
@@ -72,7 +85,7 @@ function readSlide(streamBytes, directory, persist, size, fontNames) {
72
85
  return {
73
86
  size,
74
87
  shapes,
75
- notes: ""
88
+ notes
76
89
  };
77
90
  }
78
91
  function readPptStreams(currentUserStream, powerPointDocumentStream) {
@@ -91,15 +104,24 @@ function readPptStreams(currentUserStream, powerPointDocumentStream) {
91
104
  };
92
105
  const environment = findChild(children, RT_Environment);
93
106
  const fontNames = environment === void 0 ? [] : readFontNames(environment);
94
- const slideList = children.find((record) => record.header.recType === 4080 && record.header.recInstance === 0);
107
+ const listWithInstance = (instance) => children.find((record) => record.header.recType === 4080 && record.header.recInstance === instance);
108
+ const slideList = listWithInstance(0);
109
+ const persists = slideList === void 0 ? [] : readSlideListWithText(slideList);
110
+ const notesBySlideId = readNotesBySlideId(powerPointDocumentStream, directory, listWithInstance(2));
95
111
  return {
96
112
  metadata: {},
97
- slides: (slideList === void 0 ? [] : readSlideListWithText(slideList)).map((persist) => readSlide(powerPointDocumentStream, directory, persist, size, fontNames))
113
+ slides: persists.map((persist) => readSlide(powerPointDocumentStream, directory, persist, size, fontNames, notesBySlideId.get(persist.slideId) ?? ""))
98
114
  };
99
115
  }
100
116
  function readPptContent(bytes) {
101
117
  const streams = readCompoundFile(bytes);
102
- return readPptStreams(requireStream(streams, CURRENT_USER_STREAM), requireStream(streams, POWERPOINT_DOCUMENT_STREAM));
118
+ const document = readPptStreams(requireStream(streams, CURRENT_USER_STREAM), requireStream(streams, POWERPOINT_DOCUMENT_STREAM));
119
+ const metadataStream = streams.find((stream) => stream.path === SUMMARY_INFORMATION_STREAM);
120
+ if (metadataStream === void 0) return document;
121
+ return {
122
+ ...document,
123
+ metadata: summaryInformationToLayoutMetadata(readSummaryInformation(metadataStream.bytes))
124
+ };
103
125
  }
104
126
  function readPpt(bytes) {
105
127
  const { metadata, slides } = readPptContent(bytes);
@@ -111,4 +133,4 @@ function readPpt(bytes) {
111
133
  return assembleTree(document);
112
134
  }
113
135
  //#endregion
114
- export { CURRENT_USER_STREAM, POWERPOINT_DOCUMENT_STREAM, readPpt, readPptContent, readPptStreams };
136
+ export { CURRENT_USER_STREAM, DEFAULT_INSET_LEFT_RIGHT_PT, DEFAULT_INSET_TOP_BOTTOM_PT, POWERPOINT_DOCUMENT_STREAM, SUMMARY_INFORMATION_STREAM, readPpt, readPptContent, readPptStreams };
@@ -5,6 +5,7 @@ const RT_DocumentAtom = 1001;
5
5
  const RT_Slide = 1006;
6
6
  const RT_SlideAtom = 1007;
7
7
  const RT_Notes = 1008;
8
+ const RT_NotesAtom = 1009;
8
9
  const RT_Environment = 1010;
9
10
  const RT_SlidePersistAtom = 1011;
10
11
  const RT_MainMaster = 1016;
@@ -13,6 +14,8 @@ const RT_DrawingGroup = 1035;
13
14
  const RT_Drawing = 1036;
14
15
  const RT_List = 2e3;
15
16
  const RT_FontCollection = 2005;
17
+ const RT_ColorSchemeAtom = 2032;
18
+ const RT_PlaceholderAtom = 3011;
16
19
  const RT_OutlineTextRefAtom = 3998;
17
20
  const RT_TextHeaderAtom = 3999;
18
21
  const RT_TextCharsAtom = 4e3;
@@ -42,9 +45,11 @@ const OfficeArtFOPT = 61451;
42
45
  const OfficeArtClientTextbox = 61453;
43
46
  const OfficeArtChildAnchor = 61455;
44
47
  const OfficeArtClientAnchor = 61456;
48
+ const OfficeArtClientData = 61457;
45
49
  //#endregion
46
50
  exports.OfficeArtChildAnchor = OfficeArtChildAnchor;
47
51
  exports.OfficeArtClientAnchor = OfficeArtClientAnchor;
52
+ exports.OfficeArtClientData = OfficeArtClientData;
48
53
  exports.OfficeArtClientTextbox = OfficeArtClientTextbox;
49
54
  exports.OfficeArtDgContainer = OfficeArtDgContainer;
50
55
  exports.OfficeArtFOPT = OfficeArtFOPT;
@@ -53,6 +58,7 @@ exports.OfficeArtFSPGR = OfficeArtFSPGR;
53
58
  exports.OfficeArtSpContainer = OfficeArtSpContainer;
54
59
  exports.OfficeArtSpgrContainer = OfficeArtSpgrContainer;
55
60
  exports.RT_CString = RT_CString;
61
+ exports.RT_ColorSchemeAtom = RT_ColorSchemeAtom;
56
62
  exports.RT_CryptSession10Container = RT_CryptSession10Container;
57
63
  exports.RT_CurrentUserAtom = RT_CurrentUserAtom;
58
64
  exports.RT_Document = RT_Document;
@@ -67,8 +73,10 @@ exports.RT_List = RT_List;
67
73
  exports.RT_MainMaster = RT_MainMaster;
68
74
  exports.RT_MasterTextPropAtom = RT_MasterTextPropAtom;
69
75
  exports.RT_Notes = RT_Notes;
76
+ exports.RT_NotesAtom = RT_NotesAtom;
70
77
  exports.RT_OutlineTextRefAtom = RT_OutlineTextRefAtom;
71
78
  exports.RT_PersistDirectoryAtom = RT_PersistDirectoryAtom;
79
+ exports.RT_PlaceholderAtom = RT_PlaceholderAtom;
72
80
  exports.RT_Slide = RT_Slide;
73
81
  exports.RT_SlideAtom = RT_SlideAtom;
74
82
  exports.RT_SlideListWithText = RT_SlideListWithText;
@@ -4,6 +4,7 @@ declare const RT_DocumentAtom = 1001;
4
4
  declare const RT_Slide = 1006;
5
5
  declare const RT_SlideAtom = 1007;
6
6
  declare const RT_Notes = 1008;
7
+ declare const RT_NotesAtom = 1009;
7
8
  declare const RT_Environment = 1010;
8
9
  declare const RT_SlidePersistAtom = 1011;
9
10
  declare const RT_MainMaster = 1016;
@@ -12,6 +13,8 @@ declare const RT_DrawingGroup = 1035;
12
13
  declare const RT_Drawing = 1036;
13
14
  declare const RT_List = 2000;
14
15
  declare const RT_FontCollection = 2005;
16
+ declare const RT_ColorSchemeAtom = 2032;
17
+ declare const RT_PlaceholderAtom = 3011;
15
18
  declare const RT_OutlineTextRefAtom = 3998;
16
19
  declare const RT_TextHeaderAtom = 3999;
17
20
  declare const RT_TextCharsAtom = 4000;
@@ -41,5 +44,6 @@ declare const OfficeArtFOPT = 61451;
41
44
  declare const OfficeArtClientTextbox = 61453;
42
45
  declare const OfficeArtChildAnchor = 61455;
43
46
  declare const OfficeArtClientAnchor = 61456;
47
+ declare const OfficeArtClientData = 61457;
44
48
  //#endregion
45
- export { OfficeArtChildAnchor, OfficeArtClientAnchor, OfficeArtClientTextbox, OfficeArtDgContainer, OfficeArtFOPT, OfficeArtFSP, OfficeArtFSPGR, OfficeArtSpContainer, OfficeArtSpgrContainer, RT_CString, RT_CryptSession10Container, RT_CurrentUserAtom, RT_Document, RT_DocumentAtom, RT_Drawing, RT_DrawingGroup, RT_Environment, RT_ExternalObjectList, RT_FontCollection, RT_FontEntityAtom, RT_List, RT_MainMaster, RT_MasterTextPropAtom, RT_Notes, RT_OutlineTextRefAtom, RT_PersistDirectoryAtom, RT_Slide, RT_SlideAtom, RT_SlideListWithText, RT_SlidePersistAtom, RT_StyleTextPropAtom, RT_TextBytesAtom, RT_TextCharsAtom, RT_TextHeaderAtom, RT_TextMasterStyleAtom, RT_TextRulerAtom, RT_TextSpecialInfoAtom, RT_TextSpecialInfoDefaultAtom, RT_UserEditAtom, SLIDE_LIST_INSTANCE_MASTERS, SLIDE_LIST_INSTANCE_NOTES, SLIDE_LIST_INSTANCE_SLIDES };
49
+ export { OfficeArtChildAnchor, OfficeArtClientAnchor, OfficeArtClientData, OfficeArtClientTextbox, OfficeArtDgContainer, OfficeArtFOPT, OfficeArtFSP, OfficeArtFSPGR, OfficeArtSpContainer, OfficeArtSpgrContainer, RT_CString, RT_ColorSchemeAtom, RT_CryptSession10Container, RT_CurrentUserAtom, RT_Document, RT_DocumentAtom, RT_Drawing, RT_DrawingGroup, RT_Environment, RT_ExternalObjectList, RT_FontCollection, RT_FontEntityAtom, RT_List, RT_MainMaster, RT_MasterTextPropAtom, RT_Notes, RT_NotesAtom, RT_OutlineTextRefAtom, RT_PersistDirectoryAtom, RT_PlaceholderAtom, RT_Slide, RT_SlideAtom, RT_SlideListWithText, RT_SlidePersistAtom, RT_StyleTextPropAtom, RT_TextBytesAtom, RT_TextCharsAtom, RT_TextHeaderAtom, RT_TextMasterStyleAtom, RT_TextRulerAtom, RT_TextSpecialInfoAtom, RT_TextSpecialInfoDefaultAtom, RT_UserEditAtom, SLIDE_LIST_INSTANCE_MASTERS, SLIDE_LIST_INSTANCE_NOTES, SLIDE_LIST_INSTANCE_SLIDES };
@@ -4,6 +4,7 @@ declare const RT_DocumentAtom = 1001;
4
4
  declare const RT_Slide = 1006;
5
5
  declare const RT_SlideAtom = 1007;
6
6
  declare const RT_Notes = 1008;
7
+ declare const RT_NotesAtom = 1009;
7
8
  declare const RT_Environment = 1010;
8
9
  declare const RT_SlidePersistAtom = 1011;
9
10
  declare const RT_MainMaster = 1016;
@@ -12,6 +13,8 @@ declare const RT_DrawingGroup = 1035;
12
13
  declare const RT_Drawing = 1036;
13
14
  declare const RT_List = 2000;
14
15
  declare const RT_FontCollection = 2005;
16
+ declare const RT_ColorSchemeAtom = 2032;
17
+ declare const RT_PlaceholderAtom = 3011;
15
18
  declare const RT_OutlineTextRefAtom = 3998;
16
19
  declare const RT_TextHeaderAtom = 3999;
17
20
  declare const RT_TextCharsAtom = 4000;
@@ -41,5 +44,6 @@ declare const OfficeArtFOPT = 61451;
41
44
  declare const OfficeArtClientTextbox = 61453;
42
45
  declare const OfficeArtChildAnchor = 61455;
43
46
  declare const OfficeArtClientAnchor = 61456;
47
+ declare const OfficeArtClientData = 61457;
44
48
  //#endregion
45
- export { OfficeArtChildAnchor, OfficeArtClientAnchor, OfficeArtClientTextbox, OfficeArtDgContainer, OfficeArtFOPT, OfficeArtFSP, OfficeArtFSPGR, OfficeArtSpContainer, OfficeArtSpgrContainer, RT_CString, RT_CryptSession10Container, RT_CurrentUserAtom, RT_Document, RT_DocumentAtom, RT_Drawing, RT_DrawingGroup, RT_Environment, RT_ExternalObjectList, RT_FontCollection, RT_FontEntityAtom, RT_List, RT_MainMaster, RT_MasterTextPropAtom, RT_Notes, RT_OutlineTextRefAtom, RT_PersistDirectoryAtom, RT_Slide, RT_SlideAtom, RT_SlideListWithText, RT_SlidePersistAtom, RT_StyleTextPropAtom, RT_TextBytesAtom, RT_TextCharsAtom, RT_TextHeaderAtom, RT_TextMasterStyleAtom, RT_TextRulerAtom, RT_TextSpecialInfoAtom, RT_TextSpecialInfoDefaultAtom, RT_UserEditAtom, SLIDE_LIST_INSTANCE_MASTERS, SLIDE_LIST_INSTANCE_NOTES, SLIDE_LIST_INSTANCE_SLIDES };
49
+ export { OfficeArtChildAnchor, OfficeArtClientAnchor, OfficeArtClientData, OfficeArtClientTextbox, OfficeArtDgContainer, OfficeArtFOPT, OfficeArtFSP, OfficeArtFSPGR, OfficeArtSpContainer, OfficeArtSpgrContainer, RT_CString, RT_ColorSchemeAtom, RT_CryptSession10Container, RT_CurrentUserAtom, RT_Document, RT_DocumentAtom, RT_Drawing, RT_DrawingGroup, RT_Environment, RT_ExternalObjectList, RT_FontCollection, RT_FontEntityAtom, RT_List, RT_MainMaster, RT_MasterTextPropAtom, RT_Notes, RT_NotesAtom, RT_OutlineTextRefAtom, RT_PersistDirectoryAtom, RT_PlaceholderAtom, RT_Slide, RT_SlideAtom, RT_SlideListWithText, RT_SlidePersistAtom, RT_StyleTextPropAtom, RT_TextBytesAtom, RT_TextCharsAtom, RT_TextHeaderAtom, RT_TextMasterStyleAtom, RT_TextRulerAtom, RT_TextSpecialInfoAtom, RT_TextSpecialInfoDefaultAtom, RT_UserEditAtom, SLIDE_LIST_INSTANCE_MASTERS, SLIDE_LIST_INSTANCE_NOTES, SLIDE_LIST_INSTANCE_SLIDES };
@@ -4,6 +4,7 @@ const RT_DocumentAtom = 1001;
4
4
  const RT_Slide = 1006;
5
5
  const RT_SlideAtom = 1007;
6
6
  const RT_Notes = 1008;
7
+ const RT_NotesAtom = 1009;
7
8
  const RT_Environment = 1010;
8
9
  const RT_SlidePersistAtom = 1011;
9
10
  const RT_MainMaster = 1016;
@@ -12,6 +13,8 @@ const RT_DrawingGroup = 1035;
12
13
  const RT_Drawing = 1036;
13
14
  const RT_List = 2e3;
14
15
  const RT_FontCollection = 2005;
16
+ const RT_ColorSchemeAtom = 2032;
17
+ const RT_PlaceholderAtom = 3011;
15
18
  const RT_OutlineTextRefAtom = 3998;
16
19
  const RT_TextHeaderAtom = 3999;
17
20
  const RT_TextCharsAtom = 4e3;
@@ -41,5 +44,6 @@ const OfficeArtFOPT = 61451;
41
44
  const OfficeArtClientTextbox = 61453;
42
45
  const OfficeArtChildAnchor = 61455;
43
46
  const OfficeArtClientAnchor = 61456;
47
+ const OfficeArtClientData = 61457;
44
48
  //#endregion
45
- export { OfficeArtChildAnchor, OfficeArtClientAnchor, OfficeArtClientTextbox, OfficeArtDgContainer, OfficeArtFOPT, OfficeArtFSP, OfficeArtFSPGR, OfficeArtSpContainer, OfficeArtSpgrContainer, RT_CString, RT_CryptSession10Container, RT_CurrentUserAtom, RT_Document, RT_DocumentAtom, RT_Drawing, RT_DrawingGroup, RT_Environment, RT_ExternalObjectList, RT_FontCollection, RT_FontEntityAtom, RT_List, RT_MainMaster, RT_MasterTextPropAtom, RT_Notes, RT_OutlineTextRefAtom, RT_PersistDirectoryAtom, RT_Slide, RT_SlideAtom, RT_SlideListWithText, RT_SlidePersistAtom, RT_StyleTextPropAtom, RT_TextBytesAtom, RT_TextCharsAtom, RT_TextHeaderAtom, RT_TextMasterStyleAtom, RT_TextRulerAtom, RT_TextSpecialInfoAtom, RT_TextSpecialInfoDefaultAtom, RT_UserEditAtom, SLIDE_LIST_INSTANCE_MASTERS, SLIDE_LIST_INSTANCE_NOTES, SLIDE_LIST_INSTANCE_SLIDES };
49
+ export { OfficeArtChildAnchor, OfficeArtClientAnchor, OfficeArtClientData, OfficeArtClientTextbox, OfficeArtDgContainer, OfficeArtFOPT, OfficeArtFSP, OfficeArtFSPGR, OfficeArtSpContainer, OfficeArtSpgrContainer, RT_CString, RT_ColorSchemeAtom, RT_CryptSession10Container, RT_CurrentUserAtom, RT_Document, RT_DocumentAtom, RT_Drawing, RT_DrawingGroup, RT_Environment, RT_ExternalObjectList, RT_FontCollection, RT_FontEntityAtom, RT_List, RT_MainMaster, RT_MasterTextPropAtom, RT_Notes, RT_NotesAtom, RT_OutlineTextRefAtom, RT_PersistDirectoryAtom, RT_PlaceholderAtom, RT_Slide, RT_SlideAtom, RT_SlideListWithText, RT_SlidePersistAtom, RT_StyleTextPropAtom, RT_TextBytesAtom, RT_TextCharsAtom, RT_TextHeaderAtom, RT_TextMasterStyleAtom, RT_TextRulerAtom, RT_TextSpecialInfoAtom, RT_TextSpecialInfoDefaultAtom, RT_UserEditAtom, SLIDE_LIST_INSTANCE_MASTERS, SLIDE_LIST_INSTANCE_NOTES, SLIDE_LIST_INSTANCE_SLIDES };
@@ -0,0 +1,75 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("./header.cjs");
3
+ //#region src/record/write.ts
4
+ function concatBytes(...parts) {
5
+ const total = parts.reduce((sum, part) => sum + part.length, 0);
6
+ const out = new Uint8Array(total);
7
+ let at = 0;
8
+ for (const part of parts) {
9
+ out.set(part, at);
10
+ at += part.length;
11
+ }
12
+ return out;
13
+ }
14
+ function u8(value) {
15
+ return new Uint8Array([value & 255]);
16
+ }
17
+ function u16le(value) {
18
+ const bytes = /* @__PURE__ */ new Uint8Array(2);
19
+ new DataView(bytes.buffer).setUint16(0, value, true);
20
+ return bytes;
21
+ }
22
+ function i16le(value) {
23
+ const bytes = /* @__PURE__ */ new Uint8Array(2);
24
+ new DataView(bytes.buffer).setInt16(0, value, true);
25
+ return bytes;
26
+ }
27
+ function u32le(value) {
28
+ const bytes = /* @__PURE__ */ new Uint8Array(4);
29
+ new DataView(bytes.buffer).setUint32(0, value, true);
30
+ return bytes;
31
+ }
32
+ function i32le(value) {
33
+ const bytes = /* @__PURE__ */ new Uint8Array(4);
34
+ new DataView(bytes.buffer).setInt32(0, value, true);
35
+ return bytes;
36
+ }
37
+ function asciiBytes(text) {
38
+ const bytes = new Uint8Array(text.length);
39
+ for (let i = 0; i < text.length; i++) bytes[i] = text.charCodeAt(i);
40
+ return bytes;
41
+ }
42
+ function utf16le(text) {
43
+ const bytes = new Uint8Array(text.length * 2);
44
+ const view = new DataView(bytes.buffer);
45
+ for (let i = 0; i < text.length; i++) view.setUint16(i * 2, text.charCodeAt(i), true);
46
+ return bytes;
47
+ }
48
+ function recordHeaderBytes(recVer, recInstance, recType, recLen) {
49
+ const bytes = /* @__PURE__ */ new Uint8Array(8);
50
+ const view = new DataView(bytes.buffer);
51
+ view.setUint16(0, recVer & 15 | (recInstance & 4095) << 4, true);
52
+ view.setUint16(2, recType, true);
53
+ view.setUint32(4, recLen, true);
54
+ return bytes;
55
+ }
56
+ function writeAtom(recType, data, options = {}) {
57
+ const { recVer = 0, recInstance = 0 } = options;
58
+ return concatBytes(recordHeaderBytes(recVer, recInstance, recType, data.length), data);
59
+ }
60
+ function writeContainer(recType, children, options = {}) {
61
+ const { recInstance = 0 } = options;
62
+ const body = concatBytes(...children);
63
+ return concatBytes(recordHeaderBytes(15, recInstance, recType, body.length), body);
64
+ }
65
+ //#endregion
66
+ exports.asciiBytes = asciiBytes;
67
+ exports.concatBytes = concatBytes;
68
+ exports.i16le = i16le;
69
+ exports.i32le = i32le;
70
+ exports.u16le = u16le;
71
+ exports.u32le = u32le;
72
+ exports.u8 = u8;
73
+ exports.utf16le = utf16le;
74
+ exports.writeAtom = writeAtom;
75
+ exports.writeContainer = writeContainer;
@@ -0,0 +1,17 @@
1
+ //#region src/record/write.d.ts
2
+ declare function concatBytes(...parts: readonly Uint8Array<ArrayBuffer>[]): Uint8Array<ArrayBuffer>;
3
+ declare function u8(value: number): Uint8Array<ArrayBuffer>;
4
+ declare function u16le(value: number): Uint8Array<ArrayBuffer>;
5
+ declare function i16le(value: number): Uint8Array<ArrayBuffer>;
6
+ declare function u32le(value: number): Uint8Array<ArrayBuffer>;
7
+ declare function i32le(value: number): Uint8Array<ArrayBuffer>;
8
+ declare function asciiBytes(text: string): Uint8Array<ArrayBuffer>;
9
+ declare function utf16le(text: string): Uint8Array<ArrayBuffer>;
10
+ interface RecordWriteOptions {
11
+ readonly recVer?: number;
12
+ readonly recInstance?: number;
13
+ }
14
+ declare function writeAtom(recType: number, data: Uint8Array<ArrayBuffer>, options?: RecordWriteOptions): Uint8Array<ArrayBuffer>;
15
+ declare function writeContainer(recType: number, children: readonly Uint8Array<ArrayBuffer>[], options?: Omit<RecordWriteOptions, "recVer">): Uint8Array<ArrayBuffer>;
16
+ //#endregion
17
+ export { RecordWriteOptions, asciiBytes, concatBytes, i16le, i32le, u16le, u32le, u8, utf16le, writeAtom, writeContainer };
@@ -0,0 +1,17 @@
1
+ //#region src/record/write.d.ts
2
+ declare function concatBytes(...parts: readonly Uint8Array<ArrayBuffer>[]): Uint8Array<ArrayBuffer>;
3
+ declare function u8(value: number): Uint8Array<ArrayBuffer>;
4
+ declare function u16le(value: number): Uint8Array<ArrayBuffer>;
5
+ declare function i16le(value: number): Uint8Array<ArrayBuffer>;
6
+ declare function u32le(value: number): Uint8Array<ArrayBuffer>;
7
+ declare function i32le(value: number): Uint8Array<ArrayBuffer>;
8
+ declare function asciiBytes(text: string): Uint8Array<ArrayBuffer>;
9
+ declare function utf16le(text: string): Uint8Array<ArrayBuffer>;
10
+ interface RecordWriteOptions {
11
+ readonly recVer?: number;
12
+ readonly recInstance?: number;
13
+ }
14
+ declare function writeAtom(recType: number, data: Uint8Array<ArrayBuffer>, options?: RecordWriteOptions): Uint8Array<ArrayBuffer>;
15
+ declare function writeContainer(recType: number, children: readonly Uint8Array<ArrayBuffer>[], options?: Omit<RecordWriteOptions, "recVer">): Uint8Array<ArrayBuffer>;
16
+ //#endregion
17
+ export { RecordWriteOptions, asciiBytes, concatBytes, i16le, i32le, u16le, u32le, u8, utf16le, writeAtom, writeContainer };
@@ -0,0 +1,65 @@
1
+ import "./header.js";
2
+ //#region src/record/write.ts
3
+ function concatBytes(...parts) {
4
+ const total = parts.reduce((sum, part) => sum + part.length, 0);
5
+ const out = new Uint8Array(total);
6
+ let at = 0;
7
+ for (const part of parts) {
8
+ out.set(part, at);
9
+ at += part.length;
10
+ }
11
+ return out;
12
+ }
13
+ function u8(value) {
14
+ return new Uint8Array([value & 255]);
15
+ }
16
+ function u16le(value) {
17
+ const bytes = /* @__PURE__ */ new Uint8Array(2);
18
+ new DataView(bytes.buffer).setUint16(0, value, true);
19
+ return bytes;
20
+ }
21
+ function i16le(value) {
22
+ const bytes = /* @__PURE__ */ new Uint8Array(2);
23
+ new DataView(bytes.buffer).setInt16(0, value, true);
24
+ return bytes;
25
+ }
26
+ function u32le(value) {
27
+ const bytes = /* @__PURE__ */ new Uint8Array(4);
28
+ new DataView(bytes.buffer).setUint32(0, value, true);
29
+ return bytes;
30
+ }
31
+ function i32le(value) {
32
+ const bytes = /* @__PURE__ */ new Uint8Array(4);
33
+ new DataView(bytes.buffer).setInt32(0, value, true);
34
+ return bytes;
35
+ }
36
+ function asciiBytes(text) {
37
+ const bytes = new Uint8Array(text.length);
38
+ for (let i = 0; i < text.length; i++) bytes[i] = text.charCodeAt(i);
39
+ return bytes;
40
+ }
41
+ function utf16le(text) {
42
+ const bytes = new Uint8Array(text.length * 2);
43
+ const view = new DataView(bytes.buffer);
44
+ for (let i = 0; i < text.length; i++) view.setUint16(i * 2, text.charCodeAt(i), true);
45
+ return bytes;
46
+ }
47
+ function recordHeaderBytes(recVer, recInstance, recType, recLen) {
48
+ const bytes = /* @__PURE__ */ new Uint8Array(8);
49
+ const view = new DataView(bytes.buffer);
50
+ view.setUint16(0, recVer & 15 | (recInstance & 4095) << 4, true);
51
+ view.setUint16(2, recType, true);
52
+ view.setUint32(4, recLen, true);
53
+ return bytes;
54
+ }
55
+ function writeAtom(recType, data, options = {}) {
56
+ const { recVer = 0, recInstance = 0 } = options;
57
+ return concatBytes(recordHeaderBytes(recVer, recInstance, recType, data.length), data);
58
+ }
59
+ function writeContainer(recType, children, options = {}) {
60
+ const { recInstance = 0 } = options;
61
+ const body = concatBytes(...children);
62
+ return concatBytes(recordHeaderBytes(15, recInstance, recType, body.length), body);
63
+ }
64
+ //#endregion
65
+ export { asciiBytes, concatBytes, i16le, i32le, u16le, u32le, u8, utf16le, writeAtom, writeContainer };
@@ -0,0 +1,13 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_record_types = require("../record/types.cjs");
3
+ const require_record_write = require("../record/write.cjs");
4
+ const require_stream_current_user = require("./current-user.cjs");
5
+ //#region src/stream/current-user-write.ts
6
+ const PRODUCER_USER_NAME = "documents.js";
7
+ const REL_VERSION = 8;
8
+ function writeCurrentUserAtom(offsetToCurrentEdit) {
9
+ const ansiUserName = require_record_write.asciiBytes(PRODUCER_USER_NAME);
10
+ return require_record_write.writeAtom(require_record_types.RT_CurrentUserAtom, require_record_write.concatBytes(require_record_write.u32le(20), require_record_write.u32le(require_stream_current_user.CURRENT_USER_HEADER_TOKEN_PLAIN), require_record_write.u32le(offsetToCurrentEdit), require_record_write.u16le(ansiUserName.length), require_record_write.u16le(require_stream_current_user.CURRENT_USER_DOC_FILE_VERSION), require_record_write.u8(3), require_record_write.u8(0), require_record_write.u16le(0), ansiUserName, require_record_write.u32le(REL_VERSION), require_record_write.utf16le(PRODUCER_USER_NAME)));
11
+ }
12
+ //#endregion
13
+ exports.writeCurrentUserAtom = writeCurrentUserAtom;
@@ -0,0 +1,4 @@
1
+ //#region src/stream/current-user-write.d.ts
2
+ declare function writeCurrentUserAtom(offsetToCurrentEdit: number): Uint8Array<ArrayBuffer>;
3
+ //#endregion
4
+ export { writeCurrentUserAtom };
@@ -0,0 +1,4 @@
1
+ //#region src/stream/current-user-write.d.ts
2
+ declare function writeCurrentUserAtom(offsetToCurrentEdit: number): Uint8Array<ArrayBuffer>;
3
+ //#endregion
4
+ export { writeCurrentUserAtom };
@@ -0,0 +1,12 @@
1
+ import { RT_CurrentUserAtom } from "../record/types.js";
2
+ import { asciiBytes, concatBytes, u16le, u32le, u8, utf16le, writeAtom } from "../record/write.js";
3
+ import { CURRENT_USER_DOC_FILE_VERSION, CURRENT_USER_HEADER_TOKEN_PLAIN } from "./current-user.js";
4
+ //#region src/stream/current-user-write.ts
5
+ const PRODUCER_USER_NAME = "documents.js";
6
+ const REL_VERSION = 8;
7
+ function writeCurrentUserAtom(offsetToCurrentEdit) {
8
+ const ansiUserName = asciiBytes(PRODUCER_USER_NAME);
9
+ return writeAtom(RT_CurrentUserAtom, concatBytes(u32le(20), u32le(CURRENT_USER_HEADER_TOKEN_PLAIN), u32le(offsetToCurrentEdit), u16le(ansiUserName.length), u16le(CURRENT_USER_DOC_FILE_VERSION), u8(3), u8(0), u16le(0), ansiUserName, u32le(REL_VERSION), utf16le(PRODUCER_USER_NAME)));
10
+ }
11
+ //#endregion
12
+ export { writeCurrentUserAtom };
@@ -22,21 +22,21 @@ function readCurrentUserAtom(streamBytes) {
22
22
  const record = require_record_tree.readRecordAt(streamBytes, 0);
23
23
  if (record.header.recType !== 4086) throw new require_errors.PptFormatError(`Current User stream begins with record type 0x${record.header.recType.toString(16)}, not RT_CurrentUserAtom (0x${require_record_types.RT_CurrentUserAtom.toString(16)})`);
24
24
  const { data } = record;
25
- if (data.length < CURRENT_USER_FIXED_SIZE) throw new require_errors.PptFormatError(`CurrentUserAtom carries ${data.length} bytes of data, fewer than the ${CURRENT_USER_FIXED_SIZE}-byte fixed portion the record requires`);
25
+ if (data.length < 20) throw new require_errors.PptFormatError(`CurrentUserAtom carries ${data.length} bytes of data, fewer than the 20-byte fixed portion the record requires`);
26
26
  const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
27
27
  const size = view.getUint32(0, true);
28
- if (size !== CURRENT_USER_FIXED_SIZE) throw new require_errors.PptFormatError(`CurrentUserAtom size field is 0x${size.toString(16)}, not the mandated 0x${CURRENT_USER_FIXED_SIZE.toString(16)}`);
28
+ if (size !== 20) throw new require_errors.PptFormatError(`CurrentUserAtom size field is 0x${size.toString(16)}, not the mandated 0x${20 .toString(16)}`);
29
29
  const headerToken = view.getUint32(4, true);
30
30
  if (headerToken !== 3817979999 && headerToken !== 4090610911) throw new require_errors.PptFormatError(`CurrentUserAtom headerToken is 0x${headerToken.toString(16)}, neither the plaintext 0x${CURRENT_USER_HEADER_TOKEN_PLAIN.toString(16)} nor the encrypted 0x${CURRENT_USER_HEADER_TOKEN_ENCRYPTED.toString(16)}`);
31
31
  const offsetToCurrentEdit = view.getUint32(8, true);
32
32
  const lenUserName = view.getUint16(12, true);
33
33
  const docFileVersion = view.getUint16(14, true);
34
- if (docFileVersion !== CURRENT_USER_DOC_FILE_VERSION) throw new require_errors.PptFormatError(`CurrentUserAtom docFileVersion is 0x${docFileVersion.toString(16)}, not the mandated 0x${CURRENT_USER_DOC_FILE_VERSION.toString(16)}`);
35
- const ansiEnd = CURRENT_USER_FIXED_SIZE + lenUserName;
34
+ if (docFileVersion !== 1012) throw new require_errors.PptFormatError(`CurrentUserAtom docFileVersion is 0x${docFileVersion.toString(16)}, not the mandated 0x${CURRENT_USER_DOC_FILE_VERSION.toString(16)}`);
35
+ const ansiEnd = 20 + lenUserName;
36
36
  if (ansiEnd > data.length) throw new require_errors.PptFormatError(`CurrentUserAtom declares a ${lenUserName}-byte ansiUserName that runs past the record's ${data.length} bytes`);
37
37
  const unicodeStart = ansiEnd + 4;
38
38
  const unicodeEnd = unicodeStart + lenUserName * 2;
39
- const userName = unicodeEnd <= data.length && lenUserName > 0 ? decodeUtf16Le(data.subarray(unicodeStart, unicodeEnd)) : decodeAnsi(data.subarray(CURRENT_USER_FIXED_SIZE, ansiEnd));
39
+ const userName = unicodeEnd <= data.length && lenUserName > 0 ? decodeUtf16Le(data.subarray(unicodeStart, unicodeEnd)) : decodeAnsi(data.subarray(20, ansiEnd));
40
40
  return {
41
41
  offsetToCurrentEdit,
42
42
  encrypted: headerToken === CURRENT_USER_HEADER_TOKEN_ENCRYPTED,
@@ -44,6 +44,8 @@ function readCurrentUserAtom(streamBytes) {
44
44
  };
45
45
  }
46
46
  //#endregion
47
+ exports.CURRENT_USER_DOC_FILE_VERSION = CURRENT_USER_DOC_FILE_VERSION;
48
+ exports.CURRENT_USER_FIXED_SIZE = CURRENT_USER_FIXED_SIZE;
47
49
  exports.CURRENT_USER_HEADER_TOKEN_ENCRYPTED = CURRENT_USER_HEADER_TOKEN_ENCRYPTED;
48
50
  exports.CURRENT_USER_HEADER_TOKEN_PLAIN = CURRENT_USER_HEADER_TOKEN_PLAIN;
49
51
  exports.readCurrentUserAtom = readCurrentUserAtom;
@@ -1,6 +1,8 @@
1
1
  //#region src/stream/current-user.d.ts
2
2
  declare const CURRENT_USER_HEADER_TOKEN_PLAIN = 3817979999;
3
3
  declare const CURRENT_USER_HEADER_TOKEN_ENCRYPTED = 4090610911;
4
+ declare const CURRENT_USER_FIXED_SIZE = 20;
5
+ declare const CURRENT_USER_DOC_FILE_VERSION = 1012;
4
6
  interface CurrentUser {
5
7
  readonly offsetToCurrentEdit: number;
6
8
  readonly encrypted: boolean;
@@ -8,4 +10,4 @@ interface CurrentUser {
8
10
  }
9
11
  declare function readCurrentUserAtom(streamBytes: Uint8Array<ArrayBuffer>): CurrentUser;
10
12
  //#endregion
11
- export { CURRENT_USER_HEADER_TOKEN_ENCRYPTED, CURRENT_USER_HEADER_TOKEN_PLAIN, CurrentUser, readCurrentUserAtom };
13
+ export { CURRENT_USER_DOC_FILE_VERSION, CURRENT_USER_FIXED_SIZE, CURRENT_USER_HEADER_TOKEN_ENCRYPTED, CURRENT_USER_HEADER_TOKEN_PLAIN, CurrentUser, readCurrentUserAtom };
@@ -1,6 +1,8 @@
1
1
  //#region src/stream/current-user.d.ts
2
2
  declare const CURRENT_USER_HEADER_TOKEN_PLAIN = 3817979999;
3
3
  declare const CURRENT_USER_HEADER_TOKEN_ENCRYPTED = 4090610911;
4
+ declare const CURRENT_USER_FIXED_SIZE = 20;
5
+ declare const CURRENT_USER_DOC_FILE_VERSION = 1012;
4
6
  interface CurrentUser {
5
7
  readonly offsetToCurrentEdit: number;
6
8
  readonly encrypted: boolean;
@@ -8,4 +10,4 @@ interface CurrentUser {
8
10
  }
9
11
  declare function readCurrentUserAtom(streamBytes: Uint8Array<ArrayBuffer>): CurrentUser;
10
12
  //#endregion
11
- export { CURRENT_USER_HEADER_TOKEN_ENCRYPTED, CURRENT_USER_HEADER_TOKEN_PLAIN, CurrentUser, readCurrentUserAtom };
13
+ export { CURRENT_USER_DOC_FILE_VERSION, CURRENT_USER_FIXED_SIZE, CURRENT_USER_HEADER_TOKEN_ENCRYPTED, CURRENT_USER_HEADER_TOKEN_PLAIN, CurrentUser, readCurrentUserAtom };
@@ -21,21 +21,21 @@ function readCurrentUserAtom(streamBytes) {
21
21
  const record = readRecordAt(streamBytes, 0);
22
22
  if (record.header.recType !== 4086) throw new PptFormatError(`Current User stream begins with record type 0x${record.header.recType.toString(16)}, not RT_CurrentUserAtom (0x${RT_CurrentUserAtom.toString(16)})`);
23
23
  const { data } = record;
24
- if (data.length < CURRENT_USER_FIXED_SIZE) throw new PptFormatError(`CurrentUserAtom carries ${data.length} bytes of data, fewer than the ${CURRENT_USER_FIXED_SIZE}-byte fixed portion the record requires`);
24
+ if (data.length < 20) throw new PptFormatError(`CurrentUserAtom carries ${data.length} bytes of data, fewer than the 20-byte fixed portion the record requires`);
25
25
  const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
26
26
  const size = view.getUint32(0, true);
27
- if (size !== CURRENT_USER_FIXED_SIZE) throw new PptFormatError(`CurrentUserAtom size field is 0x${size.toString(16)}, not the mandated 0x${CURRENT_USER_FIXED_SIZE.toString(16)}`);
27
+ if (size !== 20) throw new PptFormatError(`CurrentUserAtom size field is 0x${size.toString(16)}, not the mandated 0x${20 .toString(16)}`);
28
28
  const headerToken = view.getUint32(4, true);
29
29
  if (headerToken !== 3817979999 && headerToken !== 4090610911) throw new PptFormatError(`CurrentUserAtom headerToken is 0x${headerToken.toString(16)}, neither the plaintext 0x${CURRENT_USER_HEADER_TOKEN_PLAIN.toString(16)} nor the encrypted 0x${CURRENT_USER_HEADER_TOKEN_ENCRYPTED.toString(16)}`);
30
30
  const offsetToCurrentEdit = view.getUint32(8, true);
31
31
  const lenUserName = view.getUint16(12, true);
32
32
  const docFileVersion = view.getUint16(14, true);
33
- if (docFileVersion !== CURRENT_USER_DOC_FILE_VERSION) throw new PptFormatError(`CurrentUserAtom docFileVersion is 0x${docFileVersion.toString(16)}, not the mandated 0x${CURRENT_USER_DOC_FILE_VERSION.toString(16)}`);
34
- const ansiEnd = CURRENT_USER_FIXED_SIZE + lenUserName;
33
+ if (docFileVersion !== 1012) throw new PptFormatError(`CurrentUserAtom docFileVersion is 0x${docFileVersion.toString(16)}, not the mandated 0x${CURRENT_USER_DOC_FILE_VERSION.toString(16)}`);
34
+ const ansiEnd = 20 + lenUserName;
35
35
  if (ansiEnd > data.length) throw new PptFormatError(`CurrentUserAtom declares a ${lenUserName}-byte ansiUserName that runs past the record's ${data.length} bytes`);
36
36
  const unicodeStart = ansiEnd + 4;
37
37
  const unicodeEnd = unicodeStart + lenUserName * 2;
38
- const userName = unicodeEnd <= data.length && lenUserName > 0 ? decodeUtf16Le(data.subarray(unicodeStart, unicodeEnd)) : decodeAnsi(data.subarray(CURRENT_USER_FIXED_SIZE, ansiEnd));
38
+ const userName = unicodeEnd <= data.length && lenUserName > 0 ? decodeUtf16Le(data.subarray(unicodeStart, unicodeEnd)) : decodeAnsi(data.subarray(20, ansiEnd));
39
39
  return {
40
40
  offsetToCurrentEdit,
41
41
  encrypted: headerToken === CURRENT_USER_HEADER_TOKEN_ENCRYPTED,
@@ -43,4 +43,4 @@ function readCurrentUserAtom(streamBytes) {
43
43
  };
44
44
  }
45
45
  //#endregion
46
- export { CURRENT_USER_HEADER_TOKEN_ENCRYPTED, CURRENT_USER_HEADER_TOKEN_PLAIN, readCurrentUserAtom };
46
+ export { CURRENT_USER_DOC_FILE_VERSION, CURRENT_USER_FIXED_SIZE, CURRENT_USER_HEADER_TOKEN_ENCRYPTED, CURRENT_USER_HEADER_TOKEN_PLAIN, readCurrentUserAtom };
@@ -0,0 +1,14 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_record_types = require("../record/types.cjs");
3
+ const require_record_write = require("../record/write.cjs");
4
+ //#region src/stream/persist-write.ts
5
+ function writePersistDirectoryAtom(entries) {
6
+ const data = require_record_write.concatBytes(...entries.map((entry) => require_record_write.concatBytes(require_record_write.u32le(entry.persistId & 1048575 | 1 << 20), require_record_write.u32le(entry.offset))));
7
+ return require_record_write.writeAtom(require_record_types.RT_PersistDirectoryAtom, data);
8
+ }
9
+ function writeUserEditAtom(fields) {
10
+ return require_record_write.writeAtom(require_record_types.RT_UserEditAtom, require_record_write.concatBytes(require_record_write.u32le(fields.lastSlideIdRef), require_record_write.u16le(0), require_record_write.u8(0), require_record_write.u8(3), require_record_write.u32le(fields.offsetLastEdit), require_record_write.u32le(fields.offsetPersistDirectory), require_record_write.u32le(fields.docPersistIdRef), require_record_write.u32le(fields.persistIdSeed), require_record_write.u16le(0), require_record_write.u16le(0)));
11
+ }
12
+ //#endregion
13
+ exports.writePersistDirectoryAtom = writePersistDirectoryAtom;
14
+ exports.writeUserEditAtom = writeUserEditAtom;
@@ -0,0 +1,16 @@
1
+ //#region src/stream/persist-write.d.ts
2
+ interface PersistDirectoryEntryToWrite {
3
+ readonly persistId: number;
4
+ readonly offset: number;
5
+ }
6
+ declare function writePersistDirectoryAtom(entries: readonly PersistDirectoryEntryToWrite[]): Uint8Array<ArrayBuffer>;
7
+ interface UserEditFields {
8
+ readonly lastSlideIdRef: number;
9
+ readonly offsetLastEdit: number;
10
+ readonly offsetPersistDirectory: number;
11
+ readonly docPersistIdRef: number;
12
+ readonly persistIdSeed: number;
13
+ }
14
+ declare function writeUserEditAtom(fields: UserEditFields): Uint8Array<ArrayBuffer>;
15
+ //#endregion
16
+ export { PersistDirectoryEntryToWrite, UserEditFields, writePersistDirectoryAtom, writeUserEditAtom };
@@ -0,0 +1,16 @@
1
+ //#region src/stream/persist-write.d.ts
2
+ interface PersistDirectoryEntryToWrite {
3
+ readonly persistId: number;
4
+ readonly offset: number;
5
+ }
6
+ declare function writePersistDirectoryAtom(entries: readonly PersistDirectoryEntryToWrite[]): Uint8Array<ArrayBuffer>;
7
+ interface UserEditFields {
8
+ readonly lastSlideIdRef: number;
9
+ readonly offsetLastEdit: number;
10
+ readonly offsetPersistDirectory: number;
11
+ readonly docPersistIdRef: number;
12
+ readonly persistIdSeed: number;
13
+ }
14
+ declare function writeUserEditAtom(fields: UserEditFields): Uint8Array<ArrayBuffer>;
15
+ //#endregion
16
+ export { PersistDirectoryEntryToWrite, UserEditFields, writePersistDirectoryAtom, writeUserEditAtom };
@@ -0,0 +1,12 @@
1
+ import { RT_PersistDirectoryAtom, RT_UserEditAtom } from "../record/types.js";
2
+ import { concatBytes, u16le, u32le, u8, writeAtom } from "../record/write.js";
3
+ //#region src/stream/persist-write.ts
4
+ function writePersistDirectoryAtom(entries) {
5
+ const data = concatBytes(...entries.map((entry) => concatBytes(u32le(entry.persistId & 1048575 | 1 << 20), u32le(entry.offset))));
6
+ return writeAtom(RT_PersistDirectoryAtom, data);
7
+ }
8
+ function writeUserEditAtom(fields) {
9
+ return writeAtom(RT_UserEditAtom, concatBytes(u32le(fields.lastSlideIdRef), u16le(0), u8(0), u8(3), u32le(fields.offsetLastEdit), u32le(fields.offsetPersistDirectory), u32le(fields.docPersistIdRef), u32le(fields.persistIdSeed), u16le(0), u16le(0)));
10
+ }
11
+ //#endregion
12
+ export { writePersistDirectoryAtom, writeUserEditAtom };