@8ms/helpers 3.2.6 → 3.2.8
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/AGENTS.md +20 -0
- package/dist/aws/s3/{server → _shared}/awsS3File.cjs +1 -1
- package/dist/aws/s3/{server → _shared}/awsS3File.d.cts +1 -1
- package/dist/aws/s3/{server → _shared}/awsS3File.d.mts +1 -1
- package/dist/aws/s3/{server → _shared}/awsS3File.mjs +1 -1
- package/dist/aws/s3/_shared/index.cjs +3 -0
- package/dist/aws/s3/_shared/index.d.cts +3 -0
- package/dist/aws/s3/_shared/index.d.mts +3 -0
- package/dist/aws/s3/_shared/index.mjs +2 -0
- package/dist/aws/s3/_shared/types.cjs +0 -0
- package/dist/aws/s3/_shared/types.d.cts +35 -0
- package/dist/aws/s3/_shared/types.d.mts +35 -0
- package/dist/aws/s3/_shared/types.mjs +1 -0
- package/dist/aws/s3/server/AwsS3.cjs +83 -4
- package/dist/aws/s3/server/AwsS3.d.cts +19 -26
- package/dist/aws/s3/server/AwsS3.d.mts +19 -26
- package/dist/aws/s3/server/AwsS3.mjs +81 -2
- package/dist/aws/s3/server/index.cjs +3 -2
- package/dist/aws/s3/server/index.d.cts +4 -3
- package/dist/aws/s3/server/index.d.mts +4 -3
- package/dist/aws/s3/server/index.mjs +2 -1
- package/dist/file/_shared/dataFileType.cjs +2 -0
- package/dist/file/_shared/dataFileType.d.cts +2 -0
- package/dist/file/_shared/dataFileType.d.mts +2 -0
- package/dist/file/_shared/dataFileType.mjs +2 -0
- package/dist/file/_shared/fileMimeType.cjs +2 -0
- package/dist/file/_shared/fileMimeType.mjs +2 -0
- package/dist/file/_shared/fileType.d.cts +2 -0
- package/dist/file/_shared/fileType.d.mts +2 -0
- package/dist/googleCloud/bigquery/_shared/index.d.cts +2 -2
- package/dist/googleCloud/bigquery/_shared/index.d.mts +2 -2
- package/dist/googleCloud/bigquery/_shared/types.d.cts +54 -0
- package/dist/googleCloud/bigquery/_shared/types.d.mts +54 -0
- package/dist/googleCloud/bigquery/client/index.d.cts +2 -2
- package/dist/googleCloud/bigquery/client/index.d.mts +2 -2
- package/dist/googleCloud/bigquery/server/GoogleCloudBigquery.cjs +158 -7
- package/dist/googleCloud/bigquery/server/GoogleCloudBigquery.d.cts +47 -31
- package/dist/googleCloud/bigquery/server/GoogleCloudBigquery.d.mts +47 -31
- package/dist/googleCloud/bigquery/server/GoogleCloudBigquery.mjs +158 -7
- package/dist/googleCloud/bigquery/server/index.d.cts +3 -3
- package/dist/googleCloud/bigquery/server/index.d.mts +3 -3
- package/dist/googleCloud/drive/server/GoogleCloudDrive.cjs +85 -0
- package/dist/googleCloud/drive/server/GoogleCloudDrive.d.cts +34 -0
- package/dist/googleCloud/drive/server/GoogleCloudDrive.d.mts +34 -0
- package/dist/googleCloud/drive/server/GoogleCloudDrive.mjs +85 -0
- package/dist/stream/server/index.cjs +11 -0
- package/dist/stream/server/index.d.cts +4 -1
- package/dist/stream/server/index.d.mts +4 -1
- package/dist/stream/server/index.mjs +4 -1
- package/dist/stream/server/json/logic.cjs +18 -0
- package/dist/stream/server/json/logic.d.cts +27 -0
- package/dist/stream/server/json/logic.d.mts +27 -0
- package/dist/stream/server/json/logic.mjs +16 -0
- package/dist/stream/server/json/read.cjs +46 -0
- package/dist/stream/server/json/read.d.cts +7 -0
- package/dist/stream/server/json/read.d.mts +7 -0
- package/dist/stream/server/json/read.mjs +42 -0
- package/dist/stream/server/json/write.cjs +69 -0
- package/dist/stream/server/json/write.d.cts +14 -0
- package/dist/stream/server/json/write.d.mts +14 -0
- package/dist/stream/server/json/write.mjs +63 -0
- package/dist/stream/server/sort.cjs +12 -23
- package/dist/stream/server/sort.d.cts +10 -6
- package/dist/stream/server/sort.d.mts +10 -6
- package/dist/stream/server/sort.mjs +12 -23
- package/dist/xlsx/_shared/createXlsx.cjs +12 -22
- package/dist/xlsx/_shared/createXlsx.mjs +12 -22
- package/dist/xlsx/_shared/modifyXlsx.cjs +32 -44
- package/dist/xlsx/_shared/modifyXlsx.mjs +32 -44
- package/dist/xlsx/client/index.cjs +0 -1
- package/dist/xlsx/client/index.mjs +0 -1
- package/dist/xlsx/server/index.cjs +0 -1
- package/dist/xlsx/server/index.mjs +0 -1
- package/dist/zip/_shared/ZipArchive.cjs +49 -0
- package/dist/zip/_shared/ZipArchive.d.cts +24 -0
- package/dist/zip/_shared/ZipArchive.d.mts +24 -0
- package/dist/zip/_shared/ZipArchive.mjs +48 -0
- package/dist/zip/_shared/crc32.cjs +24 -0
- package/dist/zip/_shared/crc32.d.cts +4 -0
- package/dist/zip/_shared/crc32.d.mts +4 -0
- package/dist/zip/_shared/crc32.mjs +23 -0
- package/dist/zip/_shared/deflate.cjs +21 -0
- package/dist/zip/_shared/deflate.d.cts +10 -0
- package/dist/zip/_shared/deflate.d.mts +10 -0
- package/dist/zip/_shared/deflate.mjs +19 -0
- package/dist/zip/_shared/index.cjs +12 -0
- package/dist/zip/_shared/index.d.cts +6 -0
- package/dist/zip/_shared/index.d.mts +6 -0
- package/dist/zip/_shared/index.mjs +6 -0
- package/dist/zip/_shared/readZip.cjs +63 -0
- package/dist/zip/_shared/readZip.d.cts +9 -0
- package/dist/zip/_shared/readZip.d.mts +9 -0
- package/dist/zip/_shared/readZip.mjs +62 -0
- package/dist/zip/_shared/writeZip.cjs +105 -0
- package/dist/zip/_shared/writeZip.d.cts +7 -0
- package/dist/zip/_shared/writeZip.d.mts +7 -0
- package/dist/zip/_shared/writeZip.mjs +104 -0
- package/dist/zip/client/index.cjs +12 -0
- package/dist/zip/client/index.d.cts +6 -0
- package/dist/zip/client/index.d.mts +6 -0
- package/dist/zip/client/index.mjs +6 -0
- package/dist/zip/server/index.cjs +12 -0
- package/dist/zip/server/index.d.cts +6 -0
- package/dist/zip/server/index.d.mts +6 -0
- package/dist/zip/server/index.mjs +6 -0
- package/package.json +65 -10
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_xlsx__shared_cell = require("./cell.cjs");
|
|
3
|
+
const require_zip__shared_ZipArchive = require("../../zip/_shared/ZipArchive.cjs");
|
|
3
4
|
//#region src/xlsx/_shared/modifyXlsx.ts
|
|
4
5
|
/**
|
|
5
6
|
* Patches an existing .xlsx template: apply per-sheet XML transformations, add
|
|
@@ -46,80 +47,67 @@ const buildDrawingXml = (widthEmu, heightEmu) => {
|
|
|
46
47
|
* @param logo Optional PNG bytes, embedded into sheets with `addLogo`.
|
|
47
48
|
*/
|
|
48
49
|
const modifyXlsx = async (template, sheets, logo) => {
|
|
49
|
-
const zip = await
|
|
50
|
+
const zip = await require_zip__shared_ZipArchive.ZipArchive.load(template);
|
|
50
51
|
if (logo) {
|
|
51
|
-
zip.
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
let contentTypesXml = await contentTypesFile.async("string");
|
|
52
|
+
zip.set("xl/media/image1.png", logo);
|
|
53
|
+
let contentTypesXml = zip.getText("[Content_Types].xml");
|
|
54
|
+
if (null !== contentTypesXml) {
|
|
55
55
|
if (!contentTypesXml.includes(`Extension="png"`)) contentTypesXml = contentTypesXml.replace("</Types>", () => {
|
|
56
56
|
return `<Default Extension="png" ContentType="image/png"/></Types>`;
|
|
57
57
|
});
|
|
58
|
-
zip.
|
|
58
|
+
zip.set("[Content_Types].xml", contentTypesXml);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
let drawingCounter = 0;
|
|
62
62
|
for (const sheet of sheets) {
|
|
63
63
|
const filename = `xl/worksheets/sheet${sheet.index}.xml`;
|
|
64
|
-
let existing = zip.
|
|
65
|
-
if (
|
|
64
|
+
let existing = zip.getText(filename);
|
|
65
|
+
if (null === existing && sheet.createIfMissing) {
|
|
66
66
|
const name = sheet.sheetName ?? `Sheet${sheet.index}`;
|
|
67
67
|
const rId = `rId${sheet.index + 10}`;
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
zip.file("xl/_rels/workbook.xml.rels", relsXml.replace("</Relationships>", () => {
|
|
79
|
-
return `<Relationship Id="${rId}" Type="${WORKSHEET_REL_TYPE}" Target="worksheets/sheet${sheet.index}.xml"/></Relationships>`;
|
|
80
|
-
}));
|
|
81
|
-
}
|
|
82
|
-
zip.file(filename, EMPTY_SHEET_XML);
|
|
83
|
-
existing = zip.file(filename);
|
|
68
|
+
const workbookXml = zip.getText("xl/workbook.xml");
|
|
69
|
+
if (null !== workbookXml) zip.set("xl/workbook.xml", workbookXml.replace("</sheets>", () => {
|
|
70
|
+
return `<sheet name="${require_xlsx__shared_cell.getEscapedXml(name)}" sheetId="${sheet.index}" r:id="${rId}"/></sheets>`;
|
|
71
|
+
}));
|
|
72
|
+
const relsXml = zip.getText("xl/_rels/workbook.xml.rels");
|
|
73
|
+
if (null !== relsXml) zip.set("xl/_rels/workbook.xml.rels", relsXml.replace("</Relationships>", () => {
|
|
74
|
+
return `<Relationship Id="${rId}" Type="${WORKSHEET_REL_TYPE}" Target="worksheets/sheet${sheet.index}.xml"/></Relationships>`;
|
|
75
|
+
}));
|
|
76
|
+
zip.set(filename, EMPTY_SHEET_XML);
|
|
77
|
+
existing = EMPTY_SHEET_XML;
|
|
84
78
|
}
|
|
85
|
-
if (
|
|
86
|
-
let xml = sheet.modify(
|
|
79
|
+
if (null === existing) continue;
|
|
80
|
+
let xml = sheet.modify(existing);
|
|
87
81
|
if (sheet.addLogo && logo) {
|
|
88
82
|
drawingCounter++;
|
|
89
83
|
const drawingNum = drawingCounter;
|
|
90
84
|
const logoWidthEmu = Math.round((sheet.logoWidthPx ?? LOGO_WIDTH_PX) * PX_TO_EMU);
|
|
91
85
|
const logoHeightEmu = Math.round((sheet.logoHeightPx ?? LOGO_HEIGHT_PX) * PX_TO_EMU);
|
|
92
86
|
const drawingRId = `rIdLogo${drawingNum}`;
|
|
93
|
-
zip.
|
|
94
|
-
zip.
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
let contentTypesXml = await contentTypesFile.async("string");
|
|
87
|
+
zip.set(`xl/drawings/drawing${drawingNum}.xml`, buildDrawingXml(logoWidthEmu, logoHeightEmu));
|
|
88
|
+
zip.set(`xl/drawings/_rels/drawing${drawingNum}.xml.rels`, `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${IMAGE_REL_TYPE}" Target="../media/image1.png"/></Relationships>`);
|
|
89
|
+
let contentTypesXml = zip.getText("[Content_Types].xml");
|
|
90
|
+
if (null !== contentTypesXml) {
|
|
98
91
|
const drawingPart = `/xl/drawings/drawing${drawingNum}.xml`;
|
|
99
92
|
if (!contentTypesXml.includes(drawingPart)) contentTypesXml = contentTypesXml.replace("</Types>", () => {
|
|
100
93
|
return `<Override PartName="${drawingPart}" ContentType="${DRAWING_CONTENT_TYPE}"/></Types>`;
|
|
101
94
|
});
|
|
102
|
-
zip.
|
|
95
|
+
zip.set("[Content_Types].xml", contentTypesXml);
|
|
103
96
|
}
|
|
104
97
|
const sheetRelsPath = `xl/worksheets/_rels/sheet${sheet.index}.xml.rels`;
|
|
105
|
-
const
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}));
|
|
111
|
-
} else zip.file(sheetRelsPath, `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="${drawingRId}" Type="${DRAWING_REL_TYPE}" Target="../drawings/drawing${drawingNum}.xml"/></Relationships>`);
|
|
98
|
+
const sheetRelsXml = zip.getText(sheetRelsPath);
|
|
99
|
+
if (null !== sheetRelsXml) zip.set(sheetRelsPath, sheetRelsXml.replace("</Relationships>", () => {
|
|
100
|
+
return `<Relationship Id="${drawingRId}" Type="${DRAWING_REL_TYPE}" Target="../drawings/drawing${drawingNum}.xml"/></Relationships>`;
|
|
101
|
+
}));
|
|
102
|
+
else zip.set(sheetRelsPath, `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="${drawingRId}" Type="${DRAWING_REL_TYPE}" Target="../drawings/drawing${drawingNum}.xml"/></Relationships>`);
|
|
112
103
|
if (!xml.includes("xmlns:r=")) xml = xml.replace("<worksheet ", `<worksheet xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" `);
|
|
113
104
|
xml = xml.replace("</worksheet>", () => {
|
|
114
105
|
return `<drawing r:id="${drawingRId}"/></worksheet>`;
|
|
115
106
|
});
|
|
116
107
|
}
|
|
117
|
-
zip.
|
|
108
|
+
zip.set(filename, xml);
|
|
118
109
|
}
|
|
119
|
-
return zip.
|
|
120
|
-
type: "uint8array",
|
|
121
|
-
compression: "DEFLATE"
|
|
122
|
-
});
|
|
110
|
+
return zip.toBytes();
|
|
123
111
|
};
|
|
124
112
|
//#endregion
|
|
125
113
|
exports.modifyXlsx = modifyXlsx;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getEscapedXml } from "./cell.mjs";
|
|
2
|
+
import { ZipArchive } from "../../zip/_shared/ZipArchive.mjs";
|
|
2
3
|
//#region src/xlsx/_shared/modifyXlsx.ts
|
|
3
4
|
/**
|
|
4
5
|
* Patches an existing .xlsx template: apply per-sheet XML transformations, add
|
|
@@ -45,80 +46,67 @@ const buildDrawingXml = (widthEmu, heightEmu) => {
|
|
|
45
46
|
* @param logo Optional PNG bytes, embedded into sheets with `addLogo`.
|
|
46
47
|
*/
|
|
47
48
|
const modifyXlsx = async (template, sheets, logo) => {
|
|
48
|
-
const zip = await
|
|
49
|
+
const zip = await ZipArchive.load(template);
|
|
49
50
|
if (logo) {
|
|
50
|
-
zip.
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
let contentTypesXml = await contentTypesFile.async("string");
|
|
51
|
+
zip.set("xl/media/image1.png", logo);
|
|
52
|
+
let contentTypesXml = zip.getText("[Content_Types].xml");
|
|
53
|
+
if (null !== contentTypesXml) {
|
|
54
54
|
if (!contentTypesXml.includes(`Extension="png"`)) contentTypesXml = contentTypesXml.replace("</Types>", () => {
|
|
55
55
|
return `<Default Extension="png" ContentType="image/png"/></Types>`;
|
|
56
56
|
});
|
|
57
|
-
zip.
|
|
57
|
+
zip.set("[Content_Types].xml", contentTypesXml);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
let drawingCounter = 0;
|
|
61
61
|
for (const sheet of sheets) {
|
|
62
62
|
const filename = `xl/worksheets/sheet${sheet.index}.xml`;
|
|
63
|
-
let existing = zip.
|
|
64
|
-
if (
|
|
63
|
+
let existing = zip.getText(filename);
|
|
64
|
+
if (null === existing && sheet.createIfMissing) {
|
|
65
65
|
const name = sheet.sheetName ?? `Sheet${sheet.index}`;
|
|
66
66
|
const rId = `rId${sheet.index + 10}`;
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
zip.file("xl/_rels/workbook.xml.rels", relsXml.replace("</Relationships>", () => {
|
|
78
|
-
return `<Relationship Id="${rId}" Type="${WORKSHEET_REL_TYPE}" Target="worksheets/sheet${sheet.index}.xml"/></Relationships>`;
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
zip.file(filename, EMPTY_SHEET_XML);
|
|
82
|
-
existing = zip.file(filename);
|
|
67
|
+
const workbookXml = zip.getText("xl/workbook.xml");
|
|
68
|
+
if (null !== workbookXml) zip.set("xl/workbook.xml", workbookXml.replace("</sheets>", () => {
|
|
69
|
+
return `<sheet name="${getEscapedXml(name)}" sheetId="${sheet.index}" r:id="${rId}"/></sheets>`;
|
|
70
|
+
}));
|
|
71
|
+
const relsXml = zip.getText("xl/_rels/workbook.xml.rels");
|
|
72
|
+
if (null !== relsXml) zip.set("xl/_rels/workbook.xml.rels", relsXml.replace("</Relationships>", () => {
|
|
73
|
+
return `<Relationship Id="${rId}" Type="${WORKSHEET_REL_TYPE}" Target="worksheets/sheet${sheet.index}.xml"/></Relationships>`;
|
|
74
|
+
}));
|
|
75
|
+
zip.set(filename, EMPTY_SHEET_XML);
|
|
76
|
+
existing = EMPTY_SHEET_XML;
|
|
83
77
|
}
|
|
84
|
-
if (
|
|
85
|
-
let xml = sheet.modify(
|
|
78
|
+
if (null === existing) continue;
|
|
79
|
+
let xml = sheet.modify(existing);
|
|
86
80
|
if (sheet.addLogo && logo) {
|
|
87
81
|
drawingCounter++;
|
|
88
82
|
const drawingNum = drawingCounter;
|
|
89
83
|
const logoWidthEmu = Math.round((sheet.logoWidthPx ?? LOGO_WIDTH_PX) * PX_TO_EMU);
|
|
90
84
|
const logoHeightEmu = Math.round((sheet.logoHeightPx ?? LOGO_HEIGHT_PX) * PX_TO_EMU);
|
|
91
85
|
const drawingRId = `rIdLogo${drawingNum}`;
|
|
92
|
-
zip.
|
|
93
|
-
zip.
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
let contentTypesXml = await contentTypesFile.async("string");
|
|
86
|
+
zip.set(`xl/drawings/drawing${drawingNum}.xml`, buildDrawingXml(logoWidthEmu, logoHeightEmu));
|
|
87
|
+
zip.set(`xl/drawings/_rels/drawing${drawingNum}.xml.rels`, `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${IMAGE_REL_TYPE}" Target="../media/image1.png"/></Relationships>`);
|
|
88
|
+
let contentTypesXml = zip.getText("[Content_Types].xml");
|
|
89
|
+
if (null !== contentTypesXml) {
|
|
97
90
|
const drawingPart = `/xl/drawings/drawing${drawingNum}.xml`;
|
|
98
91
|
if (!contentTypesXml.includes(drawingPart)) contentTypesXml = contentTypesXml.replace("</Types>", () => {
|
|
99
92
|
return `<Override PartName="${drawingPart}" ContentType="${DRAWING_CONTENT_TYPE}"/></Types>`;
|
|
100
93
|
});
|
|
101
|
-
zip.
|
|
94
|
+
zip.set("[Content_Types].xml", contentTypesXml);
|
|
102
95
|
}
|
|
103
96
|
const sheetRelsPath = `xl/worksheets/_rels/sheet${sheet.index}.xml.rels`;
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}));
|
|
110
|
-
} else zip.file(sheetRelsPath, `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="${drawingRId}" Type="${DRAWING_REL_TYPE}" Target="../drawings/drawing${drawingNum}.xml"/></Relationships>`);
|
|
97
|
+
const sheetRelsXml = zip.getText(sheetRelsPath);
|
|
98
|
+
if (null !== sheetRelsXml) zip.set(sheetRelsPath, sheetRelsXml.replace("</Relationships>", () => {
|
|
99
|
+
return `<Relationship Id="${drawingRId}" Type="${DRAWING_REL_TYPE}" Target="../drawings/drawing${drawingNum}.xml"/></Relationships>`;
|
|
100
|
+
}));
|
|
101
|
+
else zip.set(sheetRelsPath, `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="${drawingRId}" Type="${DRAWING_REL_TYPE}" Target="../drawings/drawing${drawingNum}.xml"/></Relationships>`);
|
|
111
102
|
if (!xml.includes("xmlns:r=")) xml = xml.replace("<worksheet ", `<worksheet xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" `);
|
|
112
103
|
xml = xml.replace("</worksheet>", () => {
|
|
113
104
|
return `<drawing r:id="${drawingRId}"/></worksheet>`;
|
|
114
105
|
});
|
|
115
106
|
}
|
|
116
|
-
zip.
|
|
107
|
+
zip.set(filename, xml);
|
|
117
108
|
}
|
|
118
|
-
return zip.
|
|
119
|
-
type: "uint8array",
|
|
120
|
-
compression: "DEFLATE"
|
|
121
|
-
});
|
|
109
|
+
return zip.toBytes();
|
|
122
110
|
};
|
|
123
111
|
//#endregion
|
|
124
112
|
export { modifyXlsx };
|
|
@@ -4,7 +4,6 @@ const require_xlsx__shared_cell = require("../_shared/cell.cjs");
|
|
|
4
4
|
const require_xlsx__shared_sheet = require("../_shared/sheet.cjs");
|
|
5
5
|
const require_xlsx__shared_createXlsx = require("../_shared/createXlsx.cjs");
|
|
6
6
|
const require_xlsx__shared_modifyXlsx = require("../_shared/modifyXlsx.cjs");
|
|
7
|
-
require("../_shared/index.cjs");
|
|
8
7
|
exports.buildCellXml = require_xlsx__shared_cell.buildCellXml;
|
|
9
8
|
exports.createXlsx = require_xlsx__shared_createXlsx.createXlsx;
|
|
10
9
|
exports.createXlsxBytes = require_xlsx__shared_createXlsx.createXlsxBytes;
|
|
@@ -3,5 +3,4 @@ import { buildCellXml, getCellColNum, getCellValue, getEscapedXml, setCell } fro
|
|
|
3
3
|
import { getSanitisedSheetName, getUniqueSheetNames } from "../_shared/sheet.mjs";
|
|
4
4
|
import { createXlsx, createXlsxBytes } from "../_shared/createXlsx.mjs";
|
|
5
5
|
import { modifyXlsx } from "../_shared/modifyXlsx.mjs";
|
|
6
|
-
import "../_shared/index.mjs";
|
|
7
6
|
export { buildCellXml, createXlsx, createXlsxBytes, getCellColNum, getCellValue, getColumLetter, getColumnWidth, getEscapedXml, getSanitisedSheetName, getUniqueSheetNames, modifyXlsx, setCell };
|
|
@@ -4,7 +4,6 @@ const require_xlsx__shared_cell = require("../_shared/cell.cjs");
|
|
|
4
4
|
const require_xlsx__shared_sheet = require("../_shared/sheet.cjs");
|
|
5
5
|
const require_xlsx__shared_createXlsx = require("../_shared/createXlsx.cjs");
|
|
6
6
|
const require_xlsx__shared_modifyXlsx = require("../_shared/modifyXlsx.cjs");
|
|
7
|
-
require("../_shared/index.cjs");
|
|
8
7
|
exports.buildCellXml = require_xlsx__shared_cell.buildCellXml;
|
|
9
8
|
exports.createXlsx = require_xlsx__shared_createXlsx.createXlsx;
|
|
10
9
|
exports.createXlsxBytes = require_xlsx__shared_createXlsx.createXlsxBytes;
|
|
@@ -3,5 +3,4 @@ import { buildCellXml, getCellColNum, getCellValue, getEscapedXml, setCell } fro
|
|
|
3
3
|
import { getSanitisedSheetName, getUniqueSheetNames } from "../_shared/sheet.mjs";
|
|
4
4
|
import { createXlsx, createXlsxBytes } from "../_shared/createXlsx.mjs";
|
|
5
5
|
import { modifyXlsx } from "../_shared/modifyXlsx.mjs";
|
|
6
|
-
import "../_shared/index.mjs";
|
|
7
6
|
export { buildCellXml, createXlsx, createXlsxBytes, getCellColNum, getCellValue, getColumLetter, getColumnWidth, getEscapedXml, getSanitisedSheetName, getUniqueSheetNames, modifyXlsx, setCell };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_zip__shared_readZip = require("./readZip.cjs");
|
|
3
|
+
const require_zip__shared_writeZip = require("./writeZip.cjs");
|
|
4
|
+
//#region src/zip/_shared/ZipArchive.ts
|
|
5
|
+
/**
|
|
6
|
+
* An in-memory ZIP archive.
|
|
7
|
+
*
|
|
8
|
+
* Contents are held decompressed, so reads are synchronous and only `load`,
|
|
9
|
+
* `toBytes` and `toBlob` are async. That suits the archives this library deals
|
|
10
|
+
* with — office documents of a few hundred kilobytes — and keeps call sites flat.
|
|
11
|
+
*
|
|
12
|
+
* Insertion order is preserved, and overwriting an existing path keeps its
|
|
13
|
+
* position, so a patched document comes back out in its original part order.
|
|
14
|
+
*/
|
|
15
|
+
var ZipArchive = class ZipArchive {
|
|
16
|
+
entries = /* @__PURE__ */ new Map();
|
|
17
|
+
static async load(bytes) {
|
|
18
|
+
const archive = new ZipArchive();
|
|
19
|
+
for (const [name, content] of await require_zip__shared_readZip.getZipEntries(bytes)) archive.entries.set(name, content);
|
|
20
|
+
return archive;
|
|
21
|
+
}
|
|
22
|
+
has(path) {
|
|
23
|
+
return this.entries.has(path);
|
|
24
|
+
}
|
|
25
|
+
getBytes(path) {
|
|
26
|
+
return this.entries.get(path) ?? null;
|
|
27
|
+
}
|
|
28
|
+
getText(path) {
|
|
29
|
+
const content = this.entries.get(path);
|
|
30
|
+
return content ? new TextDecoder().decode(content) : null;
|
|
31
|
+
}
|
|
32
|
+
set(path, content) {
|
|
33
|
+
this.entries.set(path, "string" === typeof content ? new TextEncoder().encode(content) : content);
|
|
34
|
+
}
|
|
35
|
+
delete(path) {
|
|
36
|
+
return this.entries.delete(path);
|
|
37
|
+
}
|
|
38
|
+
list() {
|
|
39
|
+
return [...this.entries.keys()];
|
|
40
|
+
}
|
|
41
|
+
async toBytes() {
|
|
42
|
+
return require_zip__shared_writeZip.getZipBytes(this.entries);
|
|
43
|
+
}
|
|
44
|
+
async toBlob(mimeType = "application/zip") {
|
|
45
|
+
return new Blob([await this.toBytes()], { type: mimeType });
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
exports.ZipArchive = ZipArchive;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/zip/_shared/ZipArchive.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* An in-memory ZIP archive.
|
|
4
|
+
*
|
|
5
|
+
* Contents are held decompressed, so reads are synchronous and only `load`,
|
|
6
|
+
* `toBytes` and `toBlob` are async. That suits the archives this library deals
|
|
7
|
+
* with — office documents of a few hundred kilobytes — and keeps call sites flat.
|
|
8
|
+
*
|
|
9
|
+
* Insertion order is preserved, and overwriting an existing path keeps its
|
|
10
|
+
* position, so a patched document comes back out in its original part order.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ZipArchive {
|
|
13
|
+
private readonly entries;
|
|
14
|
+
static load(bytes: Uint8Array): Promise<ZipArchive>;
|
|
15
|
+
has(path: string): boolean;
|
|
16
|
+
getBytes(path: string): Uint8Array | null;
|
|
17
|
+
getText(path: string): string | null;
|
|
18
|
+
set(path: string, content: string | Uint8Array): void;
|
|
19
|
+
delete(path: string): boolean;
|
|
20
|
+
list(): string[];
|
|
21
|
+
toBytes(): Promise<Uint8Array>;
|
|
22
|
+
toBlob(mimeType?: string): Promise<Blob>;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/zip/_shared/ZipArchive.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* An in-memory ZIP archive.
|
|
4
|
+
*
|
|
5
|
+
* Contents are held decompressed, so reads are synchronous and only `load`,
|
|
6
|
+
* `toBytes` and `toBlob` are async. That suits the archives this library deals
|
|
7
|
+
* with — office documents of a few hundred kilobytes — and keeps call sites flat.
|
|
8
|
+
*
|
|
9
|
+
* Insertion order is preserved, and overwriting an existing path keeps its
|
|
10
|
+
* position, so a patched document comes back out in its original part order.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ZipArchive {
|
|
13
|
+
private readonly entries;
|
|
14
|
+
static load(bytes: Uint8Array): Promise<ZipArchive>;
|
|
15
|
+
has(path: string): boolean;
|
|
16
|
+
getBytes(path: string): Uint8Array | null;
|
|
17
|
+
getText(path: string): string | null;
|
|
18
|
+
set(path: string, content: string | Uint8Array): void;
|
|
19
|
+
delete(path: string): boolean;
|
|
20
|
+
list(): string[];
|
|
21
|
+
toBytes(): Promise<Uint8Array>;
|
|
22
|
+
toBlob(mimeType?: string): Promise<Blob>;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { getZipEntries } from "./readZip.mjs";
|
|
2
|
+
import { getZipBytes } from "./writeZip.mjs";
|
|
3
|
+
//#region src/zip/_shared/ZipArchive.ts
|
|
4
|
+
/**
|
|
5
|
+
* An in-memory ZIP archive.
|
|
6
|
+
*
|
|
7
|
+
* Contents are held decompressed, so reads are synchronous and only `load`,
|
|
8
|
+
* `toBytes` and `toBlob` are async. That suits the archives this library deals
|
|
9
|
+
* with — office documents of a few hundred kilobytes — and keeps call sites flat.
|
|
10
|
+
*
|
|
11
|
+
* Insertion order is preserved, and overwriting an existing path keeps its
|
|
12
|
+
* position, so a patched document comes back out in its original part order.
|
|
13
|
+
*/
|
|
14
|
+
var ZipArchive = class ZipArchive {
|
|
15
|
+
entries = /* @__PURE__ */ new Map();
|
|
16
|
+
static async load(bytes) {
|
|
17
|
+
const archive = new ZipArchive();
|
|
18
|
+
for (const [name, content] of await getZipEntries(bytes)) archive.entries.set(name, content);
|
|
19
|
+
return archive;
|
|
20
|
+
}
|
|
21
|
+
has(path) {
|
|
22
|
+
return this.entries.has(path);
|
|
23
|
+
}
|
|
24
|
+
getBytes(path) {
|
|
25
|
+
return this.entries.get(path) ?? null;
|
|
26
|
+
}
|
|
27
|
+
getText(path) {
|
|
28
|
+
const content = this.entries.get(path);
|
|
29
|
+
return content ? new TextDecoder().decode(content) : null;
|
|
30
|
+
}
|
|
31
|
+
set(path, content) {
|
|
32
|
+
this.entries.set(path, "string" === typeof content ? new TextEncoder().encode(content) : content);
|
|
33
|
+
}
|
|
34
|
+
delete(path) {
|
|
35
|
+
return this.entries.delete(path);
|
|
36
|
+
}
|
|
37
|
+
list() {
|
|
38
|
+
return [...this.entries.keys()];
|
|
39
|
+
}
|
|
40
|
+
async toBytes() {
|
|
41
|
+
return getZipBytes(this.entries);
|
|
42
|
+
}
|
|
43
|
+
async toBlob(mimeType = "application/zip") {
|
|
44
|
+
return new Blob([await this.toBytes()], { type: mimeType });
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { ZipArchive };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/zip/_shared/crc32.ts
|
|
3
|
+
const POLYNOMIAL = 3988292384;
|
|
4
|
+
let table = null;
|
|
5
|
+
const getTable = () => {
|
|
6
|
+
if (table) return table;
|
|
7
|
+
const next = /* @__PURE__ */ new Uint32Array(256);
|
|
8
|
+
for (let index = 0; index < 256; index++) {
|
|
9
|
+
let value = index;
|
|
10
|
+
for (let bit = 0; bit < 8; bit++) value = 1 === (value & 1) ? POLYNOMIAL ^ value >>> 1 : value >>> 1;
|
|
11
|
+
next[index] = value >>> 0;
|
|
12
|
+
}
|
|
13
|
+
table = next;
|
|
14
|
+
return table;
|
|
15
|
+
};
|
|
16
|
+
/** CRC-32 (IEEE 802.3) checksum, as required by the ZIP file format. */
|
|
17
|
+
const getCrc32 = (bytes) => {
|
|
18
|
+
const lookup = getTable();
|
|
19
|
+
let crc = 4294967295;
|
|
20
|
+
for (let index = 0; index < bytes.length; index++) crc = lookup[(crc ^ bytes[index]) & 255] ^ crc >>> 8;
|
|
21
|
+
return (crc ^ 4294967295) >>> 0;
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.getCrc32 = getCrc32;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/zip/_shared/crc32.ts
|
|
2
|
+
const POLYNOMIAL = 3988292384;
|
|
3
|
+
let table = null;
|
|
4
|
+
const getTable = () => {
|
|
5
|
+
if (table) return table;
|
|
6
|
+
const next = /* @__PURE__ */ new Uint32Array(256);
|
|
7
|
+
for (let index = 0; index < 256; index++) {
|
|
8
|
+
let value = index;
|
|
9
|
+
for (let bit = 0; bit < 8; bit++) value = 1 === (value & 1) ? POLYNOMIAL ^ value >>> 1 : value >>> 1;
|
|
10
|
+
next[index] = value >>> 0;
|
|
11
|
+
}
|
|
12
|
+
table = next;
|
|
13
|
+
return table;
|
|
14
|
+
};
|
|
15
|
+
/** CRC-32 (IEEE 802.3) checksum, as required by the ZIP file format. */
|
|
16
|
+
const getCrc32 = (bytes) => {
|
|
17
|
+
const lookup = getTable();
|
|
18
|
+
let crc = 4294967295;
|
|
19
|
+
for (let index = 0; index < bytes.length; index++) crc = lookup[(crc ^ bytes[index]) & 255] ^ crc >>> 8;
|
|
20
|
+
return (crc ^ 4294967295) >>> 0;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { getCrc32 };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/zip/_shared/deflate.ts
|
|
3
|
+
/**
|
|
4
|
+
* Raw DEFLATE via the platform's Compression Streams API, so there is no
|
|
5
|
+
* dependency and the same code runs in the browser, Node and edge runtimes.
|
|
6
|
+
*
|
|
7
|
+
* Requires Node 21.2+, Chrome 103+, Safari 16.4+ or Firefox 113+.
|
|
8
|
+
*/
|
|
9
|
+
const getTransformed = async (bytes, stream) => {
|
|
10
|
+
const written = new Blob([bytes]).stream().pipeThrough(stream);
|
|
11
|
+
return new Uint8Array(await new Response(written).arrayBuffer());
|
|
12
|
+
};
|
|
13
|
+
const getDeflatedRaw = async (bytes) => {
|
|
14
|
+
return getTransformed(bytes, new CompressionStream("deflate-raw"));
|
|
15
|
+
};
|
|
16
|
+
const getInflatedRaw = async (bytes) => {
|
|
17
|
+
return getTransformed(bytes, new DecompressionStream("deflate-raw"));
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.getDeflatedRaw = getDeflatedRaw;
|
|
21
|
+
exports.getInflatedRaw = getInflatedRaw;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/zip/_shared/deflate.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Raw DEFLATE via the platform's Compression Streams API, so there is no
|
|
4
|
+
* dependency and the same code runs in the browser, Node and edge runtimes.
|
|
5
|
+
*
|
|
6
|
+
* Requires Node 21.2+, Chrome 103+, Safari 16.4+ or Firefox 113+.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getDeflatedRaw: (bytes: Uint8Array) => Promise<Uint8Array>;
|
|
9
|
+
export declare const getInflatedRaw: (bytes: Uint8Array) => Promise<Uint8Array>;
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/zip/_shared/deflate.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Raw DEFLATE via the platform's Compression Streams API, so there is no
|
|
4
|
+
* dependency and the same code runs in the browser, Node and edge runtimes.
|
|
5
|
+
*
|
|
6
|
+
* Requires Node 21.2+, Chrome 103+, Safari 16.4+ or Firefox 113+.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getDeflatedRaw: (bytes: Uint8Array) => Promise<Uint8Array>;
|
|
9
|
+
export declare const getInflatedRaw: (bytes: Uint8Array) => Promise<Uint8Array>;
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/zip/_shared/deflate.ts
|
|
2
|
+
/**
|
|
3
|
+
* Raw DEFLATE via the platform's Compression Streams API, so there is no
|
|
4
|
+
* dependency and the same code runs in the browser, Node and edge runtimes.
|
|
5
|
+
*
|
|
6
|
+
* Requires Node 21.2+, Chrome 103+, Safari 16.4+ or Firefox 113+.
|
|
7
|
+
*/
|
|
8
|
+
const getTransformed = async (bytes, stream) => {
|
|
9
|
+
const written = new Blob([bytes]).stream().pipeThrough(stream);
|
|
10
|
+
return new Uint8Array(await new Response(written).arrayBuffer());
|
|
11
|
+
};
|
|
12
|
+
const getDeflatedRaw = async (bytes) => {
|
|
13
|
+
return getTransformed(bytes, new CompressionStream("deflate-raw"));
|
|
14
|
+
};
|
|
15
|
+
const getInflatedRaw = async (bytes) => {
|
|
16
|
+
return getTransformed(bytes, new DecompressionStream("deflate-raw"));
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { getDeflatedRaw, getInflatedRaw };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_zip__shared_crc32 = require("./crc32.cjs");
|
|
3
|
+
const require_zip__shared_deflate = require("./deflate.cjs");
|
|
4
|
+
const require_zip__shared_readZip = require("./readZip.cjs");
|
|
5
|
+
const require_zip__shared_writeZip = require("./writeZip.cjs");
|
|
6
|
+
const require_zip__shared_ZipArchive = require("./ZipArchive.cjs");
|
|
7
|
+
exports.ZipArchive = require_zip__shared_ZipArchive.ZipArchive;
|
|
8
|
+
exports.getCrc32 = require_zip__shared_crc32.getCrc32;
|
|
9
|
+
exports.getDeflatedRaw = require_zip__shared_deflate.getDeflatedRaw;
|
|
10
|
+
exports.getInflatedRaw = require_zip__shared_deflate.getInflatedRaw;
|
|
11
|
+
exports.getZipBytes = require_zip__shared_writeZip.getZipBytes;
|
|
12
|
+
exports.getZipEntries = require_zip__shared_readZip.getZipEntries;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ZipArchive } from "./ZipArchive.cjs";
|
|
2
|
+
import { getCrc32 } from "./crc32.cjs";
|
|
3
|
+
import { getDeflatedRaw, getInflatedRaw } from "./deflate.cjs";
|
|
4
|
+
import { getZipEntries } from "./readZip.cjs";
|
|
5
|
+
import { getZipBytes } from "./writeZip.cjs";
|
|
6
|
+
export { ZipArchive, getCrc32, getDeflatedRaw, getInflatedRaw, getZipBytes, getZipEntries };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ZipArchive } from "./ZipArchive.mjs";
|
|
2
|
+
import { getCrc32 } from "./crc32.mjs";
|
|
3
|
+
import { getDeflatedRaw, getInflatedRaw } from "./deflate.mjs";
|
|
4
|
+
import { getZipEntries } from "./readZip.mjs";
|
|
5
|
+
import { getZipBytes } from "./writeZip.mjs";
|
|
6
|
+
export { ZipArchive, getCrc32, getDeflatedRaw, getInflatedRaw, getZipBytes, getZipEntries };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { getCrc32 } from "./crc32.mjs";
|
|
2
|
+
import { getDeflatedRaw, getInflatedRaw } from "./deflate.mjs";
|
|
3
|
+
import { getZipEntries } from "./readZip.mjs";
|
|
4
|
+
import { getZipBytes } from "./writeZip.mjs";
|
|
5
|
+
import { ZipArchive } from "./ZipArchive.mjs";
|
|
6
|
+
export { ZipArchive, getCrc32, getDeflatedRaw, getInflatedRaw, getZipBytes, getZipEntries };
|