Merge branch 'master' into feat/browser-packer

# Conflicts:
#	demo/demo13.js
#	package.json
#	src/export/packer/compiler.ts
#	src/file/media/data.ts
#	src/file/media/media.ts
This commit is contained in:
Dolan
2018-08-10 01:40:29 +01:00
196 changed files with 5665 additions and 407 deletions

View File

@ -1,4 +1,3 @@
import * as fs from "fs";
import * as JSZip from "jszip";
import * as xml from "xml";
@ -26,9 +25,9 @@ interface IXmlifyedFileMapping {
}
export class Compiler {
private formatter: Formatter;
private readonly formatter: Formatter;
constructor(private file: File) {
constructor(private readonly file: File) {
this.formatter = new Formatter();
}
@ -47,8 +46,8 @@ export class Compiler {
zip.file(xmlifiedFile.path, xmlifiedFile.data);
}
for (const data of this.file.Media.array) {
const mediaData = await this.readFile(data.path);
for (const data of this.file.Media.Array) {
const mediaData = data.stream;
zip.file(`word/media/${data.fileName}`, mediaData);
}
@ -112,17 +111,4 @@ export class Compiler {
},
};
}
private readFile(path: string): Promise<Buffer> {
return new Promise((resolve, reject) => {
fs.readFile(path, (err, data) => {
if (err) {
reject();
return;
}
resolve(data);
});
});
}
}