@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.
Files changed (106) hide show
  1. package/AGENTS.md +20 -0
  2. package/dist/aws/s3/{server → _shared}/awsS3File.cjs +1 -1
  3. package/dist/aws/s3/{server → _shared}/awsS3File.d.cts +1 -1
  4. package/dist/aws/s3/{server → _shared}/awsS3File.d.mts +1 -1
  5. package/dist/aws/s3/{server → _shared}/awsS3File.mjs +1 -1
  6. package/dist/aws/s3/_shared/index.cjs +3 -0
  7. package/dist/aws/s3/_shared/index.d.cts +3 -0
  8. package/dist/aws/s3/_shared/index.d.mts +3 -0
  9. package/dist/aws/s3/_shared/index.mjs +2 -0
  10. package/dist/aws/s3/_shared/types.cjs +0 -0
  11. package/dist/aws/s3/_shared/types.d.cts +35 -0
  12. package/dist/aws/s3/_shared/types.d.mts +35 -0
  13. package/dist/aws/s3/_shared/types.mjs +1 -0
  14. package/dist/aws/s3/server/AwsS3.cjs +83 -4
  15. package/dist/aws/s3/server/AwsS3.d.cts +19 -26
  16. package/dist/aws/s3/server/AwsS3.d.mts +19 -26
  17. package/dist/aws/s3/server/AwsS3.mjs +81 -2
  18. package/dist/aws/s3/server/index.cjs +3 -2
  19. package/dist/aws/s3/server/index.d.cts +4 -3
  20. package/dist/aws/s3/server/index.d.mts +4 -3
  21. package/dist/aws/s3/server/index.mjs +2 -1
  22. package/dist/file/_shared/dataFileType.cjs +2 -0
  23. package/dist/file/_shared/dataFileType.d.cts +2 -0
  24. package/dist/file/_shared/dataFileType.d.mts +2 -0
  25. package/dist/file/_shared/dataFileType.mjs +2 -0
  26. package/dist/file/_shared/fileMimeType.cjs +2 -0
  27. package/dist/file/_shared/fileMimeType.mjs +2 -0
  28. package/dist/file/_shared/fileType.d.cts +2 -0
  29. package/dist/file/_shared/fileType.d.mts +2 -0
  30. package/dist/googleCloud/bigquery/_shared/index.d.cts +2 -2
  31. package/dist/googleCloud/bigquery/_shared/index.d.mts +2 -2
  32. package/dist/googleCloud/bigquery/_shared/types.d.cts +54 -0
  33. package/dist/googleCloud/bigquery/_shared/types.d.mts +54 -0
  34. package/dist/googleCloud/bigquery/client/index.d.cts +2 -2
  35. package/dist/googleCloud/bigquery/client/index.d.mts +2 -2
  36. package/dist/googleCloud/bigquery/server/GoogleCloudBigquery.cjs +158 -7
  37. package/dist/googleCloud/bigquery/server/GoogleCloudBigquery.d.cts +47 -31
  38. package/dist/googleCloud/bigquery/server/GoogleCloudBigquery.d.mts +47 -31
  39. package/dist/googleCloud/bigquery/server/GoogleCloudBigquery.mjs +158 -7
  40. package/dist/googleCloud/bigquery/server/index.d.cts +3 -3
  41. package/dist/googleCloud/bigquery/server/index.d.mts +3 -3
  42. package/dist/googleCloud/drive/server/GoogleCloudDrive.cjs +85 -0
  43. package/dist/googleCloud/drive/server/GoogleCloudDrive.d.cts +34 -0
  44. package/dist/googleCloud/drive/server/GoogleCloudDrive.d.mts +34 -0
  45. package/dist/googleCloud/drive/server/GoogleCloudDrive.mjs +85 -0
  46. package/dist/stream/server/index.cjs +11 -0
  47. package/dist/stream/server/index.d.cts +4 -1
  48. package/dist/stream/server/index.d.mts +4 -1
  49. package/dist/stream/server/index.mjs +4 -1
  50. package/dist/stream/server/json/logic.cjs +18 -0
  51. package/dist/stream/server/json/logic.d.cts +27 -0
  52. package/dist/stream/server/json/logic.d.mts +27 -0
  53. package/dist/stream/server/json/logic.mjs +16 -0
  54. package/dist/stream/server/json/read.cjs +46 -0
  55. package/dist/stream/server/json/read.d.cts +7 -0
  56. package/dist/stream/server/json/read.d.mts +7 -0
  57. package/dist/stream/server/json/read.mjs +42 -0
  58. package/dist/stream/server/json/write.cjs +69 -0
  59. package/dist/stream/server/json/write.d.cts +14 -0
  60. package/dist/stream/server/json/write.d.mts +14 -0
  61. package/dist/stream/server/json/write.mjs +63 -0
  62. package/dist/stream/server/sort.cjs +12 -23
  63. package/dist/stream/server/sort.d.cts +10 -6
  64. package/dist/stream/server/sort.d.mts +10 -6
  65. package/dist/stream/server/sort.mjs +12 -23
  66. package/dist/xlsx/_shared/createXlsx.cjs +12 -22
  67. package/dist/xlsx/_shared/createXlsx.mjs +12 -22
  68. package/dist/xlsx/_shared/modifyXlsx.cjs +32 -44
  69. package/dist/xlsx/_shared/modifyXlsx.mjs +32 -44
  70. package/dist/xlsx/client/index.cjs +0 -1
  71. package/dist/xlsx/client/index.mjs +0 -1
  72. package/dist/xlsx/server/index.cjs +0 -1
  73. package/dist/xlsx/server/index.mjs +0 -1
  74. package/dist/zip/_shared/ZipArchive.cjs +49 -0
  75. package/dist/zip/_shared/ZipArchive.d.cts +24 -0
  76. package/dist/zip/_shared/ZipArchive.d.mts +24 -0
  77. package/dist/zip/_shared/ZipArchive.mjs +48 -0
  78. package/dist/zip/_shared/crc32.cjs +24 -0
  79. package/dist/zip/_shared/crc32.d.cts +4 -0
  80. package/dist/zip/_shared/crc32.d.mts +4 -0
  81. package/dist/zip/_shared/crc32.mjs +23 -0
  82. package/dist/zip/_shared/deflate.cjs +21 -0
  83. package/dist/zip/_shared/deflate.d.cts +10 -0
  84. package/dist/zip/_shared/deflate.d.mts +10 -0
  85. package/dist/zip/_shared/deflate.mjs +19 -0
  86. package/dist/zip/_shared/index.cjs +12 -0
  87. package/dist/zip/_shared/index.d.cts +6 -0
  88. package/dist/zip/_shared/index.d.mts +6 -0
  89. package/dist/zip/_shared/index.mjs +6 -0
  90. package/dist/zip/_shared/readZip.cjs +63 -0
  91. package/dist/zip/_shared/readZip.d.cts +9 -0
  92. package/dist/zip/_shared/readZip.d.mts +9 -0
  93. package/dist/zip/_shared/readZip.mjs +62 -0
  94. package/dist/zip/_shared/writeZip.cjs +105 -0
  95. package/dist/zip/_shared/writeZip.d.cts +7 -0
  96. package/dist/zip/_shared/writeZip.d.mts +7 -0
  97. package/dist/zip/_shared/writeZip.mjs +104 -0
  98. package/dist/zip/client/index.cjs +12 -0
  99. package/dist/zip/client/index.d.cts +6 -0
  100. package/dist/zip/client/index.d.mts +6 -0
  101. package/dist/zip/client/index.mjs +6 -0
  102. package/dist/zip/server/index.cjs +12 -0
  103. package/dist/zip/server/index.d.cts +6 -0
  104. package/dist/zip/server/index.d.mts +6 -0
  105. package/dist/zip/server/index.mjs +6 -0
  106. 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 (await import("jszip")).default.loadAsync(template);
50
+ const zip = await require_zip__shared_ZipArchive.ZipArchive.load(template);
50
51
  if (logo) {
51
- zip.file("xl/media/image1.png", logo);
52
- const contentTypesFile = zip.file("[Content_Types].xml");
53
- if (contentTypesFile) {
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.file("[Content_Types].xml", contentTypesXml);
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.file(filename);
65
- if (!existing && sheet.createIfMissing) {
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 workbookFile = zip.file("xl/workbook.xml");
69
- if (workbookFile) {
70
- const workbookXml = await workbookFile.async("string");
71
- zip.file("xl/workbook.xml", workbookXml.replace("</sheets>", () => {
72
- return `<sheet name="${require_xlsx__shared_cell.getEscapedXml(name)}" sheetId="${sheet.index}" r:id="${rId}"/></sheets>`;
73
- }));
74
- }
75
- const relsFile = zip.file("xl/_rels/workbook.xml.rels");
76
- if (relsFile) {
77
- const relsXml = await relsFile.async("string");
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 (!existing) continue;
86
- let xml = sheet.modify(await existing.async("string"));
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.file(`xl/drawings/drawing${drawingNum}.xml`, buildDrawingXml(logoWidthEmu, logoHeightEmu));
94
- zip.file(`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>`);
95
- const contentTypesFile = zip.file("[Content_Types].xml");
96
- if (contentTypesFile) {
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.file("[Content_Types].xml", contentTypesXml);
95
+ zip.set("[Content_Types].xml", contentTypesXml);
103
96
  }
104
97
  const sheetRelsPath = `xl/worksheets/_rels/sheet${sheet.index}.xml.rels`;
105
- const sheetRelsFile = zip.file(sheetRelsPath);
106
- if (sheetRelsFile) {
107
- const relsXml = await sheetRelsFile.async("string");
108
- zip.file(sheetRelsPath, relsXml.replace("</Relationships>", () => {
109
- return `<Relationship Id="${drawingRId}" Type="${DRAWING_REL_TYPE}" Target="../drawings/drawing${drawingNum}.xml"/></Relationships>`;
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.file(filename, xml);
108
+ zip.set(filename, xml);
118
109
  }
119
- return zip.generateAsync({
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 (await import("jszip")).default.loadAsync(template);
49
+ const zip = await ZipArchive.load(template);
49
50
  if (logo) {
50
- zip.file("xl/media/image1.png", logo);
51
- const contentTypesFile = zip.file("[Content_Types].xml");
52
- if (contentTypesFile) {
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.file("[Content_Types].xml", contentTypesXml);
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.file(filename);
64
- if (!existing && sheet.createIfMissing) {
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 workbookFile = zip.file("xl/workbook.xml");
68
- if (workbookFile) {
69
- const workbookXml = await workbookFile.async("string");
70
- zip.file("xl/workbook.xml", workbookXml.replace("</sheets>", () => {
71
- return `<sheet name="${getEscapedXml(name)}" sheetId="${sheet.index}" r:id="${rId}"/></sheets>`;
72
- }));
73
- }
74
- const relsFile = zip.file("xl/_rels/workbook.xml.rels");
75
- if (relsFile) {
76
- const relsXml = await relsFile.async("string");
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 (!existing) continue;
85
- let xml = sheet.modify(await existing.async("string"));
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.file(`xl/drawings/drawing${drawingNum}.xml`, buildDrawingXml(logoWidthEmu, logoHeightEmu));
93
- zip.file(`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>`);
94
- const contentTypesFile = zip.file("[Content_Types].xml");
95
- if (contentTypesFile) {
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.file("[Content_Types].xml", contentTypesXml);
94
+ zip.set("[Content_Types].xml", contentTypesXml);
102
95
  }
103
96
  const sheetRelsPath = `xl/worksheets/_rels/sheet${sheet.index}.xml.rels`;
104
- const sheetRelsFile = zip.file(sheetRelsPath);
105
- if (sheetRelsFile) {
106
- const relsXml = await sheetRelsFile.async("string");
107
- zip.file(sheetRelsPath, relsXml.replace("</Relationships>", () => {
108
- return `<Relationship Id="${drawingRId}" Type="${DRAWING_REL_TYPE}" Target="../drawings/drawing${drawingNum}.xml"/></Relationships>`;
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.file(filename, xml);
107
+ zip.set(filename, xml);
117
108
  }
118
- return zip.generateAsync({
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,4 @@
1
+ //#region src/zip/_shared/crc32.d.ts
2
+ /** CRC-32 (IEEE 802.3) checksum, as required by the ZIP file format. */
3
+ export declare const getCrc32: (bytes: Uint8Array) => number;
4
+ //#endregion
@@ -0,0 +1,4 @@
1
+ //#region src/zip/_shared/crc32.d.ts
2
+ /** CRC-32 (IEEE 802.3) checksum, as required by the ZIP file format. */
3
+ export declare const getCrc32: (bytes: Uint8Array) => number;
4
+ //#endregion
@@ -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 };