@senlinz/import-export 0.1.0-beta.22 → 0.1.0-beta.24

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.
@@ -1,34 +1,86 @@
1
+ /**
2
+ * Stable scalar cell types supported by the public API.
3
+ */
4
+ type ExcelColumnDataType = "text" | "number" | "date" | "image";
5
+ /**
6
+ * Runtime support:
7
+ * - Browser ESM environments with `Blob`, `FileReader`, `atob`, and `URL.createObjectURL`.
8
+ * - Node.js can use `fromExcel`, `toExcel`, and `generateExcelTemplate` when compatible browser globals are available.
9
+ *
10
+ * Known limitations:
11
+ * - Import validates headers strictly against `columns[].name` order and position.
12
+ * - Grouped export expects parent columns and data groups to be declared before children.
13
+ * - Image export requires `imageFetcher`.
14
+ */
1
15
  interface ExcelDefinition {
16
+ /** File name used for template/export downloads. */
2
17
  name: string;
18
+ /** Worksheet name used for export and preferred during import. */
3
19
  sheetName?: string;
20
+ /** Stable schema definition for worksheet columns. */
4
21
  columns: ExcelColumnDefinition[];
22
+ /** Optional workbook author metadata written into generated files. */
5
23
  author?: string;
24
+ /** Workbook creation time accepted as a `Date` or ISO-like string. */
6
25
  createTime?: Date | string;
26
+ /** Optional merged title row rendered above the header. */
7
27
  title?: string;
28
+ /** Height of the optional merged title row in worksheet units. */
8
29
  titleHeight?: number;
30
+ /** Format applied to the optional merged title row. */
9
31
  titleFormat?: ExcelCellFormatDefinition;
32
+ /** Default height used for data rows when exporting a worksheet. */
10
33
  defaultRowHeight?: number;
34
+ /** Height applied to header rows during template/export generation. */
11
35
  headerRowHeight?: number;
36
+ /** Horizontal column offset before writing the header. */
12
37
  dx?: number;
38
+ /** Vertical row offset before writing the header. */
13
39
  dy?: number;
40
+ /** Freezes the header area so column labels remain visible while scrolling. */
14
41
  isHeaderFreeze?: boolean;
42
+ /** Optional progress callback receiving values from `0` to `100` during long-running work. */
15
43
  progressCallback?: (progress: number) => void;
44
+ /**
45
+ * Required when any exported column uses `dataType: "image"`.
46
+ * The callback must resolve to image bytes for the provided URL or identifier.
47
+ */
16
48
  imageFetcher?: (url: string) => Promise<Uint8Array>;
17
49
  }
18
50
  interface ExcelColumnDefinition {
51
+ /** Stable programmatic key used to map row objects. Must be unique within a definition. */
19
52
  key: string;
53
+ /** Visible worksheet header label. */
20
54
  name: string;
55
+ /** Column width used for template/export rendering. */
21
56
  width?: number;
57
+ /** Excel note/comment attached to the header cell. */
22
58
  note?: string;
23
- dataType?: "string" | "number" | "date" | "image";
59
+ /**
60
+ * Supported values:
61
+ * - `text`
62
+ * - `number`
63
+ * - `date`
64
+ * - `image`
65
+ */
66
+ dataType?: ExcelColumnDataType;
67
+ /** Drop-down allowed values used for template validation and import expectations. */
24
68
  allowedValues?: string[];
69
+ /** Parent header key for multi-row headers. Parent columns must be declared first. */
25
70
  parent?: string;
71
+ /** Header background color in a CSS-like hex string such as `#RRGGBB`. */
26
72
  backgroundColor?: string;
73
+ /** Header text color in a CSS-like hex string such as `#RRGGBB`. */
27
74
  color?: string;
75
+ /** Whether the header text should be rendered bold. */
28
76
  bold?: boolean;
77
+ /** Base format applied to cells in this column. */
29
78
  format?: ExcelCellFormatDefinition;
79
+ /** Conditional or direct format overrides applied to exported cell values. */
30
80
  valueFormat?: ExcelCellFormatDefinition[] | ExcelCellFormatDefinition;
81
+ /** Optional logical group identifier for nested export data. */
31
82
  dataGroup?: string;
83
+ /** Optional parent group identifier. Referenced groups must be declared first. */
32
84
  dataGroupParent?: string;
33
85
  }
34
86
  interface ExcelCellFormatDefinition {
@@ -43,7 +95,8 @@ interface ExcelCellFormatDefinition {
43
95
  backgroundColor?: string;
44
96
  align?: 'left' | 'center' | 'right';
45
97
  alignVertical?: 'top' | 'center' | 'bottom';
98
+ /** Excel-compatible number format string used for date display. */
46
99
  dateFormat?: string;
47
100
  borderColor?: string;
48
101
  }
49
- export { ExcelDefinition, ExcelColumnDefinition, ExcelCellFormatDefinition };
102
+ export { ExcelDefinition, ExcelColumnDefinition, ExcelCellFormatDefinition, ExcelColumnDataType };
@@ -1,6 +1,8 @@
1
1
  export type * from './ExcelDefinition';
2
+ export type { InitializeWasmOptions } from './runtime.js';
2
3
  import { ExcelDefinition } from './ExcelDefinition';
3
4
  import { importExcel, exportExcel, downloadExcelTemplate, fromExcel, toExcel, generateExcelTemplate } from './utils.js';
5
+ import { bundledWasmSource, initializeWasm } from './runtime.js';
4
6
  declare function getUtils(): {
5
7
  importExcel: typeof importExcel;
6
8
  exportExcel: typeof exportExcel;
@@ -9,9 +11,10 @@ declare function getUtils(): {
9
11
  toExcel: typeof toExcel;
10
12
  generateExcelTemplate: typeof generateExcelTemplate;
11
13
  };
12
- declare function _importExcel<T>(defintion: ExcelDefinition): Promise<T[]>;
13
- declare function _exportExcel<T>(defintion: ExcelDefinition, data: T[]): Promise<void>;
14
+ declare function _importExcel<T>(definition: ExcelDefinition): Promise<T[]>;
15
+ declare function _exportExcel<T>(definition: ExcelDefinition, data: T[]): Promise<void>;
14
16
  declare function _fromExcel<T>(definition: ExcelDefinition, buffer: Uint8Array): Promise<T[]>;
15
17
  declare function _toExcel<T>(definition: ExcelDefinition, data: T[]): Promise<Uint8Array>;
16
- declare function _downloadExcelTemplate(defintion: ExcelDefinition): Promise<void>;
17
- export { getUtils, _importExcel as importExcel, _exportExcel as exportExcel, _fromExcel as fromExcel, _toExcel as toExcel, _downloadExcelTemplate as downloadExcelTemplate };
18
+ declare function _downloadExcelTemplate(definition: ExcelDefinition): Promise<void>;
19
+ declare function _generateExcelTemplate(definition: ExcelDefinition): Promise<Uint8Array>;
20
+ export { bundledWasmSource, getUtils, initializeWasm, _importExcel as importExcel, _exportExcel as exportExcel, _fromExcel as fromExcel, _toExcel as toExcel, _downloadExcelTemplate as downloadExcelTemplate, _generateExcelTemplate as generateExcelTemplate, };
@@ -0,0 +1,20 @@
1
+ type WasmInitializationInputKind = 'source' | 'bytes' | 'module';
2
+ interface InitializeWasmOptions {
3
+ /**
4
+ * Gzipped base64-encoded WASM source text.
5
+ */
6
+ source?: string;
7
+ /**
8
+ * Raw WebAssembly bytes loaded by the caller.
9
+ */
10
+ bytes?: BufferSource;
11
+ /**
12
+ * A precompiled WebAssembly module loaded by the caller.
13
+ */
14
+ module?: WebAssembly.Module;
15
+ }
16
+ declare const bundledWasmSource: string;
17
+ declare function ensureWasmInitialized(): void;
18
+ declare function initializeWasm(options?: InitializeWasmOptions): void;
19
+ export { bundledWasmSource, ensureWasmInitialized, initializeWasm, };
20
+ export type { InitializeWasmOptions, WasmInitializationInputKind, };
@@ -1,10 +1,9 @@
1
1
  import { ExcelDefinition } from './ExcelDefinition';
2
- declare function initializeWasm(): void;
3
2
  declare function _fromExcel<T>(definition: ExcelDefinition, buffer: Uint8Array): Promise<T[]>;
4
- declare function _toExcel<T>(definition: ExcelDefinition, data: T[]): Promise<any>;
3
+ declare function _toExcel<T>(definition: ExcelDefinition, data: T[]): Promise<Uint8Array<ArrayBufferLike>>;
5
4
  declare function generateExcelTemplate(definition: ExcelDefinition): Promise<Uint8Array<ArrayBufferLike>>;
6
5
  declare function downloadExcelTemplate(definition: ExcelDefinition): Promise<void>;
7
6
  declare function download(data: Uint8Array | string, name: string, type?: string): void;
8
- declare function importExcel<T>(defintion: ExcelDefinition): Promise<T[]>;
7
+ declare function importExcel<T>(definition: ExcelDefinition): Promise<T[]>;
9
8
  declare function exportExcel<T>(definition: ExcelDefinition, data: T[]): Promise<void>;
10
- export { importExcel, exportExcel, downloadExcelTemplate, _fromExcel as fromExcel, _toExcel as toExcel, generateExcelTemplate, initializeWasm, download };
9
+ export { importExcel, exportExcel, downloadExcelTemplate, _fromExcel as fromExcel, _toExcel as toExcel, generateExcelTemplate, download };
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@senlinz/import-export",
3
- "version": "0.1.0-beta.22",
3
+ "version": "0.1.0-beta.24",
4
4
  "description": "import/export excel core",
5
5
  "files": [
6
6
  "dist/**/*.js",
7
7
  "dist/**/*.d.ts",
8
- "README.md"
8
+ "README.md",
9
+ "README.zh.md"
9
10
  ],
10
11
  "type": "module",
11
12
  "module": "dist/index.js",
@@ -38,7 +39,7 @@
38
39
  },
39
40
  "dependencies": {
40
41
  "fflate": "^0.8.2",
41
- "@senlinz/import-export-wasm": "0.1.0-beta.22"
42
+ "@senlinz/import-export-wasm": "0.1.0-beta.24"
42
43
  },
43
44
  "keywords": [
44
45
  "rust",
@@ -56,7 +57,7 @@
56
57
  "scripts": {
57
58
  "build": "rollup -c",
58
59
  "dev": "rollup -c -w",
59
- "test": "jest",
60
- "e2e-serve": "serve dist"
60
+ "test": "playwright test -c playwright.config.ts",
61
+ "e2e-serve": "serve -l 8080 ."
61
62
  }
62
63
  }