diff --git a/packages/excel-builder-vanilla-types/dist/index.d.ts b/packages/excel-builder-vanilla-types/dist/index.d.ts index 38b7253..b346017 100644 --- a/packages/excel-builder-vanilla-types/dist/index.d.ts +++ b/packages/excel-builder-vanilla-types/dist/index.d.ts @@ -1,7 +1,5 @@ // Generated by dts-bundle-generator v9.5.1 -import { ZipOptions } from 'fflate'; - export type XMLNodeOption = { attributes?: { [key: string]: any; @@ -470,6 +468,40 @@ export interface ChartOptions { showSeriesName?: boolean; }; } +/** + * Options for compressing data into a DEFLATE format + */ +export interface DeflateOptions { + /** + * The level of compression to use, ranging from 0-9 (default: 6). + * 0 will store the data without compression. + * 1 is fastest but compresses the worst, 9 is slowest but compresses the best. + */ + level?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; + /** + * The memory level to use, ranging from 0-12. Increasing this increases speed and compression ratio at the cost of memory. + * The default value is automatically determined based on the size of the input data. + */ + mem?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; + /** A buffer containing common byte sequences in the input data that can be used to significantly improve compression ratios.*/ + dictionary?: Uint8Array; +} +/** Attributes for files added to a ZIP archive object */ +export interface ZipAttributes { + /** The operating system of origin for this file, 0 (the default) */ + os?: number; + /** The file's attributes*/ + attrs?: number; + /** Extra metadata to add to the file. */ + extra?: Record; + /** The comment to attach to the file. */ + comment?: string; + /** When the file was last modified. Defaults to the current time. */ + mtime?: Date | string | number; +} +/** Options for creating a ZIP archive */ +export interface ZipOptions extends DeflateOptions, ZipAttributes { +} /** * @module Excel/Util */ diff --git a/packages/excel-builder-vanilla-types/package.json b/packages/excel-builder-vanilla-types/package.json index edb42f8..b6b4279 100644 --- a/packages/excel-builder-vanilla-types/package.json +++ b/packages/excel-builder-vanilla-types/package.json @@ -48,8 +48,5 @@ "funding": { "type": "ko_fi", "url": "https://ko-fi.com/ghiscoding" - }, - "dependencies": { - "fflate": "catalog:" } } diff --git a/packages/excel-builder-vanilla/src/factory.ts b/packages/excel-builder-vanilla/src/factory.ts index 280895c..209dc5e 100644 --- a/packages/excel-builder-vanilla/src/factory.ts +++ b/packages/excel-builder-vanilla/src/factory.ts @@ -1,6 +1,7 @@ -import { strToU8, type ZipOptions, zip } from 'fflate'; +import { strToU8, zip } from 'fflate'; import { Workbook } from './Excel/Workbook.js'; +import type { ZipOptions } from './interfaces.js'; type InferOutputByType = T extends 'Blob' ? Blob : T extends 'Uint8Array' ? Uint8Array : any; diff --git a/packages/excel-builder-vanilla/src/interfaces.ts b/packages/excel-builder-vanilla/src/interfaces.ts index bc5230a..1f0ac9d 100644 --- a/packages/excel-builder-vanilla/src/interfaces.ts +++ b/packages/excel-builder-vanilla/src/interfaces.ts @@ -322,3 +322,41 @@ export interface ChartOptions { showSeriesName?: boolean; }; } + +// -- +// inlined fflate interface to avoid direct dependency in the @excel-builder-vanilla/types package +/** + * Options for compressing data into a DEFLATE format + */ +export interface DeflateOptions { + /** + * The level of compression to use, ranging from 0-9 (default: 6). + * 0 will store the data without compression. + * 1 is fastest but compresses the worst, 9 is slowest but compresses the best. + */ + level?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; + /** + * The memory level to use, ranging from 0-12. Increasing this increases speed and compression ratio at the cost of memory. + * The default value is automatically determined based on the size of the input data. + */ + mem?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; + /** A buffer containing common byte sequences in the input data that can be used to significantly improve compression ratios.*/ + dictionary?: Uint8Array; +} + +/** Attributes for files added to a ZIP archive object */ +export interface ZipAttributes { + /** The operating system of origin for this file, 0 (the default) */ + os?: number; + /** The file's attributes*/ + attrs?: number; + /** Extra metadata to add to the file. */ + extra?: Record; + /** The comment to attach to the file. */ + comment?: string; + /** When the file was last modified. Defaults to the current time. */ + mtime?: Date | string | number; +} + +/** Options for creating a ZIP archive */ +export interface ZipOptions extends DeflateOptions, ZipAttributes {} diff --git a/packages/excel-builder-vanilla/src/streaming.ts b/packages/excel-builder-vanilla/src/streaming.ts index 758a676..e724f9e 100644 --- a/packages/excel-builder-vanilla/src/streaming.ts +++ b/packages/excel-builder-vanilla/src/streaming.ts @@ -1,7 +1,8 @@ -import { strToU8, type ZipOptions, zipSync } from 'fflate'; +import { strToU8, zipSync } from 'fflate'; import type { Workbook } from './Excel/Workbook.js'; import { base64ToUint8Array } from './factory.js'; +import type { ZipOptions } from './interfaces.js'; export interface ExcelFileStreamOptions { chunkSize?: number; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bde9471..de9b85f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,7 +14,7 @@ catalogs: version: 2.0.1 remove-glob: specifier: ^1.2.1 - version: 1.2.0 + version: 1.2.1 sass: specifier: ^1.99.0 version: 1.99.0 @@ -113,11 +113,7 @@ importers: specifier: 'catalog:' version: 8.0.13(@types/node@25.9.1)(esbuild@0.27.4)(sass@1.99.0)(yaml@2.9.0) - packages/excel-builder-vanilla-types: - dependencies: - fflate: - specifier: 'catalog:' - version: 0.8.3 + packages/excel-builder-vanilla-types: {} packages: