@canvas-components/xlsx-table 0.1.4 → 0.1.6

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 (38) hide show
  1. package/README.md +340 -220
  2. package/dist/cleaning/worker-loader.d.ts +4 -0
  3. package/dist/cleaning/worker-loader.js +9 -0
  4. package/dist/cleaning/xlsx-cleaning.worker.d.ts +2 -0
  5. package/dist/cleaning/xlsx-cleaning.worker.js +34694 -0
  6. package/dist/file/index.cjs +8289 -0
  7. package/dist/file/index.d.cts +60 -0
  8. package/dist/file/index.d.ts +60 -0
  9. package/dist/file/index.js +8259 -0
  10. package/dist/file/ooxml/index.cjs +8481 -0
  11. package/dist/file/ooxml/index.d.cts +16 -0
  12. package/dist/file/ooxml/index.d.ts +16 -0
  13. package/dist/file/ooxml/index.js +8442 -0
  14. package/dist/file/ooxml/node.cjs +8451 -0
  15. package/dist/file/ooxml/node.d.cts +16 -0
  16. package/dist/file/ooxml/node.d.ts +16 -0
  17. package/dist/file/ooxml/node.js +8412 -0
  18. package/dist/file/worker-loader.d.ts +4 -0
  19. package/dist/file/worker-loader.js +9 -0
  20. package/dist/file/xlsx-file.worker.d.ts +2 -0
  21. package/dist/file/xlsx-file.worker.js +41188 -0
  22. package/dist/file-DZPF-DHF.d.cts +22 -0
  23. package/dist/file-DZPF-DHF.d.ts +22 -0
  24. package/dist/index.cjs +22754 -11711
  25. package/dist/index.d.cts +1163 -326
  26. package/dist/index.d.ts +1163 -326
  27. package/dist/index.js +22599 -11601
  28. package/dist/native-parts/worker-loader.d.ts +87 -0
  29. package/dist/native-parts/worker-loader.js +9 -0
  30. package/dist/native-parts/xlsx-native-parts.worker.d.ts +2 -0
  31. package/dist/native-parts/xlsx-native-parts.worker.js +33766 -0
  32. package/dist/sheet-settings-Bv1KD6XD.d.cts +301 -0
  33. package/dist/sheet-settings-CRncG11p.d.ts +301 -0
  34. package/dist/sheet-settings-ClWkuEGB.d.ts +135 -0
  35. package/dist/sheet-settings-D8pfrp_9.d.cts +135 -0
  36. package/dist/source-initialization-tTsaT4GH.d.cts +6 -0
  37. package/dist/source-initialization-tTsaT4GH.d.ts +6 -0
  38. package/package.json +38 -4
@@ -0,0 +1,135 @@
1
+ import { WorkBook } from 'xlsx';
2
+ import { X as XlsxNativeSheetSettings, c as XlsxDocumentStamp, a as XlsxNativeSheetSettingsPatch, d as XlsxNativeTransaction } from './sheet-settings-CRncG11p.js';
3
+
4
+ /** 所有限制均在调用解压器前检查。ZIP64/分卷/加密暂不支持。 */
5
+ interface XlsxPackageLimits {
6
+ maxCompressedBytes: number;
7
+ maxUncompressedBytes: number;
8
+ maxXmlBytes: number;
9
+ maxEntries: number;
10
+ }
11
+ declare const defaultXlsxPackageLimits: Readonly<XlsxPackageLimits>;
12
+
13
+ /** 标准包条目字节,不是第二份工作簿业务模型。 */
14
+ interface XlsxPackageEntry {
15
+ path: string;
16
+ data: Uint8Array;
17
+ }
18
+ interface XlsxPackageOptions {
19
+ limits?: Partial<XlsxPackageLimits>;
20
+ signal?: AbortSignal;
21
+ }
22
+
23
+ /** 原文区间与命名空间解析是派生信息;不作为第二份可写文档保存。 */
24
+ interface OoxmlAttribute {
25
+ qualifiedName: string;
26
+ localName: string;
27
+ prefix: string;
28
+ namespaceURI: string;
29
+ value: string;
30
+ start: number;
31
+ end: number;
32
+ valueStart: number;
33
+ valueEnd: number;
34
+ quote: string;
35
+ }
36
+ interface OoxmlNode {
37
+ qualifiedName: string;
38
+ localName: string;
39
+ prefix: string;
40
+ namespaceURI: string;
41
+ attributes: OoxmlAttribute[];
42
+ namespaces: Readonly<Record<string, string>>;
43
+ parent: number | null;
44
+ children: number[];
45
+ start: number;
46
+ startTagEnd: number;
47
+ endTagStart: number;
48
+ end: number;
49
+ selfClosing: boolean;
50
+ }
51
+ interface OoxmlDocument {
52
+ xml: string;
53
+ nodes: OoxmlNode[];
54
+ root: number;
55
+ }
56
+ /** 只接受XML预定义与合法数字字符引用,未知实体直接拒绝。 */
57
+ declare function decodeXmlText(value: string): string;
58
+ /** 无DOM的XML tokenizer;保留注释/CDATA/PI原文,限制大小与嵌套深度。 */
59
+ declare function parseOoxmlXml(xml: string): OoxmlDocument;
60
+
61
+ type OoxmlXmlEdit = {
62
+ node: number;
63
+ } & ({
64
+ kind: "setAttribute";
65
+ localName: string;
66
+ namespaceURI?: string;
67
+ prefix?: string;
68
+ value: string;
69
+ } | {
70
+ kind: "removeAttribute";
71
+ localName: string;
72
+ namespaceURI?: string;
73
+ } | {
74
+ kind: "replaceChildren";
75
+ xml: string;
76
+ } | {
77
+ kind: "remove";
78
+ });
79
+ /** 对同一原文的节点索引批量编辑,全部验证并重新解析后才返回。 */
80
+ declare function editOoxmlXml(xml: string, edits: readonly OoxmlXmlEdit[]): string;
81
+
82
+ /** 标准关系的派生索引;外部目标只记录,不访问。 */
83
+ interface OoxmlRelationship {
84
+ id: string;
85
+ type: string;
86
+ target: string;
87
+ external: boolean;
88
+ partPath?: string;
89
+ fragment?: string;
90
+ }
91
+ interface OoxmlPackageIndex {
92
+ partsByPath: ReadonlyMap<string, XlsxPackageEntry>;
93
+ contentTypes: ReadonlyMap<string, string>;
94
+ relationships: ReadonlyMap<string, readonly OoxmlRelationship[]>;
95
+ workbookPath: string;
96
+ sheets: readonly {
97
+ sheetName: string;
98
+ relationshipId: string;
99
+ partPath: string;
100
+ }[];
101
+ }
102
+ /** 原生XML字节仅支持UTF-8/带BOM的UTF-16;未知编码不猜测。 */
103
+ declare function decodeOoxmlXml(bytes: Uint8Array): string;
104
+ /** 解析标准内部相对目标,literal ../允许但绝不越过包根。 */
105
+ declare function resolveOoxmlTarget(owner: string, target: string): {
106
+ path: string;
107
+ fragment?: string;
108
+ };
109
+ /** 检查关系闭包与内容类型,生成只读、可丢弃的标准包索引。 */
110
+ declare function inspectOoxmlPackage(entries: readonly XlsxPackageEntry[]): OoxmlPackageIndex;
111
+ /** 只分配未占用的标准路径,不改变索引或持久数据。 */
112
+ declare function allocateOoxmlPartPath(index: OoxmlPackageIndex, stem: string, extension: string): string;
113
+ /** relId仅在真实owner的关系集合内分配,不重排原id。 */
114
+ declare function allocateOoxmlRelationshipId(index: OoxmlPackageIndex, owner: string): string;
115
+
116
+ /** 从原生bookFiles提取脱离引用的字节;不证明旧CFB导入的压缩流完整性。 */
117
+ declare function readNativeXlsxParts(book: WorkBook): XlsxPackageEntry[];
118
+
119
+ /** 原始部件是源,SheetJS结果仅是cells等标准字段的可重建解析投影。 */
120
+ declare function readWorkbookFromParts(entries: readonly XlsxPackageEntry[]): WorkBook;
121
+
122
+ interface NativeComposition {
123
+ parts: XlsxPackageEntry[];
124
+ changedCells: number;
125
+ changedPaths: string[];
126
+ }
127
+ /** 以原包/原XML为底稿,只有受支持owned字段发生变化;不回写当前book。 */
128
+ declare function composeNativeXlsxParts(input: WorkBook): NativeComposition;
129
+
130
+ declare function readNativeSheetSettings(book: WorkBook, name: string): XlsxNativeSheetSettings;
131
+
132
+ /** 只生成标准部件事务,当前版本/只读/协同能力由核心提交时复核。 */
133
+ declare function buildNativeSheetSettingsTransaction(book: WorkBook, stamp: XlsxDocumentStamp, name: string, patch: XlsxNativeSheetSettingsPatch): XlsxNativeTransaction;
134
+
135
+ export { type NativeComposition as N, type OoxmlAttribute as O, type XlsxPackageOptions as X, type XlsxPackageEntry as a, type OoxmlDocument as b, type OoxmlNode as c, type OoxmlPackageIndex as d, type OoxmlRelationship as e, type OoxmlXmlEdit as f, type XlsxPackageLimits as g, allocateOoxmlPartPath as h, allocateOoxmlRelationshipId as i, buildNativeSheetSettingsTransaction as j, composeNativeXlsxParts as k, decodeOoxmlXml as l, decodeXmlText as m, defaultXlsxPackageLimits as n, editOoxmlXml as o, inspectOoxmlPackage as p, parseOoxmlXml as q, readNativeSheetSettings as r, readNativeXlsxParts as s, readWorkbookFromParts as t, resolveOoxmlTarget as u };
@@ -0,0 +1,135 @@
1
+ import { WorkBook } from 'xlsx';
2
+ import { X as XlsxNativeSheetSettings, c as XlsxDocumentStamp, a as XlsxNativeSheetSettingsPatch, d as XlsxNativeTransaction } from './sheet-settings-Bv1KD6XD.cjs';
3
+
4
+ /** 所有限制均在调用解压器前检查。ZIP64/分卷/加密暂不支持。 */
5
+ interface XlsxPackageLimits {
6
+ maxCompressedBytes: number;
7
+ maxUncompressedBytes: number;
8
+ maxXmlBytes: number;
9
+ maxEntries: number;
10
+ }
11
+ declare const defaultXlsxPackageLimits: Readonly<XlsxPackageLimits>;
12
+
13
+ /** 标准包条目字节,不是第二份工作簿业务模型。 */
14
+ interface XlsxPackageEntry {
15
+ path: string;
16
+ data: Uint8Array;
17
+ }
18
+ interface XlsxPackageOptions {
19
+ limits?: Partial<XlsxPackageLimits>;
20
+ signal?: AbortSignal;
21
+ }
22
+
23
+ /** 原文区间与命名空间解析是派生信息;不作为第二份可写文档保存。 */
24
+ interface OoxmlAttribute {
25
+ qualifiedName: string;
26
+ localName: string;
27
+ prefix: string;
28
+ namespaceURI: string;
29
+ value: string;
30
+ start: number;
31
+ end: number;
32
+ valueStart: number;
33
+ valueEnd: number;
34
+ quote: string;
35
+ }
36
+ interface OoxmlNode {
37
+ qualifiedName: string;
38
+ localName: string;
39
+ prefix: string;
40
+ namespaceURI: string;
41
+ attributes: OoxmlAttribute[];
42
+ namespaces: Readonly<Record<string, string>>;
43
+ parent: number | null;
44
+ children: number[];
45
+ start: number;
46
+ startTagEnd: number;
47
+ endTagStart: number;
48
+ end: number;
49
+ selfClosing: boolean;
50
+ }
51
+ interface OoxmlDocument {
52
+ xml: string;
53
+ nodes: OoxmlNode[];
54
+ root: number;
55
+ }
56
+ /** 只接受XML预定义与合法数字字符引用,未知实体直接拒绝。 */
57
+ declare function decodeXmlText(value: string): string;
58
+ /** 无DOM的XML tokenizer;保留注释/CDATA/PI原文,限制大小与嵌套深度。 */
59
+ declare function parseOoxmlXml(xml: string): OoxmlDocument;
60
+
61
+ type OoxmlXmlEdit = {
62
+ node: number;
63
+ } & ({
64
+ kind: "setAttribute";
65
+ localName: string;
66
+ namespaceURI?: string;
67
+ prefix?: string;
68
+ value: string;
69
+ } | {
70
+ kind: "removeAttribute";
71
+ localName: string;
72
+ namespaceURI?: string;
73
+ } | {
74
+ kind: "replaceChildren";
75
+ xml: string;
76
+ } | {
77
+ kind: "remove";
78
+ });
79
+ /** 对同一原文的节点索引批量编辑,全部验证并重新解析后才返回。 */
80
+ declare function editOoxmlXml(xml: string, edits: readonly OoxmlXmlEdit[]): string;
81
+
82
+ /** 标准关系的派生索引;外部目标只记录,不访问。 */
83
+ interface OoxmlRelationship {
84
+ id: string;
85
+ type: string;
86
+ target: string;
87
+ external: boolean;
88
+ partPath?: string;
89
+ fragment?: string;
90
+ }
91
+ interface OoxmlPackageIndex {
92
+ partsByPath: ReadonlyMap<string, XlsxPackageEntry>;
93
+ contentTypes: ReadonlyMap<string, string>;
94
+ relationships: ReadonlyMap<string, readonly OoxmlRelationship[]>;
95
+ workbookPath: string;
96
+ sheets: readonly {
97
+ sheetName: string;
98
+ relationshipId: string;
99
+ partPath: string;
100
+ }[];
101
+ }
102
+ /** 原生XML字节仅支持UTF-8/带BOM的UTF-16;未知编码不猜测。 */
103
+ declare function decodeOoxmlXml(bytes: Uint8Array): string;
104
+ /** 解析标准内部相对目标,literal ../允许但绝不越过包根。 */
105
+ declare function resolveOoxmlTarget(owner: string, target: string): {
106
+ path: string;
107
+ fragment?: string;
108
+ };
109
+ /** 检查关系闭包与内容类型,生成只读、可丢弃的标准包索引。 */
110
+ declare function inspectOoxmlPackage(entries: readonly XlsxPackageEntry[]): OoxmlPackageIndex;
111
+ /** 只分配未占用的标准路径,不改变索引或持久数据。 */
112
+ declare function allocateOoxmlPartPath(index: OoxmlPackageIndex, stem: string, extension: string): string;
113
+ /** relId仅在真实owner的关系集合内分配,不重排原id。 */
114
+ declare function allocateOoxmlRelationshipId(index: OoxmlPackageIndex, owner: string): string;
115
+
116
+ /** 从原生bookFiles提取脱离引用的字节;不证明旧CFB导入的压缩流完整性。 */
117
+ declare function readNativeXlsxParts(book: WorkBook): XlsxPackageEntry[];
118
+
119
+ /** 原始部件是源,SheetJS结果仅是cells等标准字段的可重建解析投影。 */
120
+ declare function readWorkbookFromParts(entries: readonly XlsxPackageEntry[]): WorkBook;
121
+
122
+ interface NativeComposition {
123
+ parts: XlsxPackageEntry[];
124
+ changedCells: number;
125
+ changedPaths: string[];
126
+ }
127
+ /** 以原包/原XML为底稿,只有受支持owned字段发生变化;不回写当前book。 */
128
+ declare function composeNativeXlsxParts(input: WorkBook): NativeComposition;
129
+
130
+ declare function readNativeSheetSettings(book: WorkBook, name: string): XlsxNativeSheetSettings;
131
+
132
+ /** 只生成标准部件事务,当前版本/只读/协同能力由核心提交时复核。 */
133
+ declare function buildNativeSheetSettingsTransaction(book: WorkBook, stamp: XlsxDocumentStamp, name: string, patch: XlsxNativeSheetSettingsPatch): XlsxNativeTransaction;
134
+
135
+ export { type NativeComposition as N, type OoxmlAttribute as O, type XlsxPackageOptions as X, type XlsxPackageEntry as a, type OoxmlDocument as b, type OoxmlNode as c, type OoxmlPackageIndex as d, type OoxmlRelationship as e, type OoxmlXmlEdit as f, type XlsxPackageLimits as g, allocateOoxmlPartPath as h, allocateOoxmlRelationshipId as i, buildNativeSheetSettingsTransaction as j, composeNativeXlsxParts as k, decodeOoxmlXml as l, decodeXmlText as m, defaultXlsxPackageLimits as n, editOoxmlXml as o, inspectOoxmlPackage as p, parseOoxmlXml as q, readNativeSheetSettings as r, readNativeXlsxParts as s, readWorkbookFromParts as t, resolveOoxmlTarget as u };
@@ -0,0 +1,6 @@
1
+ import { WorkBook } from 'xlsx';
2
+
3
+ /** 为无源程序工作簿创建完整标准源快照;已存在源包时保持原对象,不整本重写。 */
4
+ declare function createNativeSourceWorkbook(book: WorkBook): WorkBook;
5
+
6
+ export { createNativeSourceWorkbook as c };
@@ -0,0 +1,6 @@
1
+ import { WorkBook } from 'xlsx';
2
+
3
+ /** 为无源程序工作簿创建完整标准源快照;已存在源包时保持原对象,不整本重写。 */
4
+ declare function createNativeSourceWorkbook(book: WorkBook): WorkBook;
5
+
6
+ export { createNativeSourceWorkbook as c };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canvas-components/xlsx-table",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Framework-agnostic canvas spreadsheet core for xlsx-table.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -16,7 +16,40 @@
16
16
  "types": "./dist/index.d.ts",
17
17
  "import": "./dist/index.js",
18
18
  "require": "./dist/index.cjs"
19
- }
19
+ },
20
+ "./file": {
21
+ "types": "./dist/file/index.d.ts",
22
+ "import": "./dist/file/index.js",
23
+ "require": "./dist/file/index.cjs"
24
+ },
25
+ "./file/worker-loader": {
26
+ "types": "./dist/file/worker-loader.d.ts",
27
+ "import": "./dist/file/worker-loader.js",
28
+ "default": "./dist/file/worker-loader.js"
29
+ },
30
+ "./file/worker": "./dist/file/xlsx-file.worker.js",
31
+ "./cleaning/worker-loader": {
32
+ "types": "./dist/cleaning/worker-loader.d.ts",
33
+ "import": "./dist/cleaning/worker-loader.js",
34
+ "default": "./dist/cleaning/worker-loader.js"
35
+ },
36
+ "./cleaning/worker": "./dist/cleaning/xlsx-cleaning.worker.js",
37
+ "./file/ooxml": {
38
+ "types": "./dist/file/ooxml/index.d.ts",
39
+ "node": {
40
+ "import": "./dist/file/ooxml/node.js",
41
+ "require": "./dist/file/ooxml/node.cjs"
42
+ },
43
+ "import": "./dist/file/ooxml/index.js",
44
+ "require": "./dist/file/ooxml/index.cjs",
45
+ "default": "./dist/file/ooxml/index.js"
46
+ },
47
+ "./native-parts/worker-loader": {
48
+ "types": "./dist/native-parts/worker-loader.d.ts",
49
+ "import": "./dist/native-parts/worker-loader.js",
50
+ "default": "./dist/native-parts/worker-loader.js"
51
+ },
52
+ "./native-parts/worker": "./dist/native-parts/xlsx-native-parts.worker.js"
20
53
  },
21
54
  "publishConfig": {
22
55
  "access": "public"
@@ -26,9 +59,10 @@
26
59
  "pnpm": ">=9.0.0"
27
60
  },
28
61
  "dependencies": {
29
- "@canvas-components/utils": "0.2.9"
62
+ "xlsx": "^0.18.5",
63
+ "@canvas-components/utils": "0.2.10"
30
64
  },
31
65
  "scripts": {
32
- "build": "tsup --config tsup.config.ts"
66
+ "build": "tsup --config tsup.config.ts && tsup --config tsup.worker.config.ts"
33
67
  }
34
68
  }