@veltra/sheet 4.1.2 → 4.1.4
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/dist/components/sheet/float-image-menu.js +1 -2
- package/dist/components/sheet/formula-bar.js +1 -2
- package/dist/components/sheet/formula-suggest-list.js +1 -2
- package/dist/components/sheet/import-file.js +3 -5
- package/dist/components/sheet/insert-count-menu-item.js +1 -2
- package/dist/components/sheet/insert-image.js +1 -2
- package/dist/components/sheet/popup-helpers.js +1 -2
- package/dist/components/sheet/popups/border-popup.js +1 -2
- package/dist/components/sheet/popups/border-preset-glyph.js +1 -2
- package/dist/components/sheet/popups/export-popup.js +1 -2
- package/dist/components/sheet/popups/fill-color-popup.js +1 -2
- package/dist/components/sheet/popups/find-popup.js +1 -2
- package/dist/components/sheet/popups/font-color-popup.js +1 -2
- package/dist/components/sheet/popups/font-size-popup.js +1 -2
- package/dist/components/sheet/popups/functions-popup.js +1 -2
- package/dist/components/sheet/popups/hyperlink-popup.js +1 -2
- package/dist/components/sheet/popups/import.worker.d.ts +1 -3
- package/dist/components/sheet/popups/import.worker.js +23462 -3
- package/dist/components/sheet/popups/insert-image-popup.js +1 -2
- package/dist/components/sheet/sheet-context-menu.js +0 -1
- package/dist/components/sheet/sheet-tabs.js +1 -2
- package/dist/components/sheet/sheet-toolbar.js +1 -2
- package/dist/components/sheet/sheet.js +1 -2
- package/dist/components/sheet/use-cell-link-tooltip.js +1 -2
- package/dist/components/sheet/use-find-replace.js +1 -2
- package/dist/components/sheet/use-formula-ref-select.js +1 -2
- package/dist/components/sheet/use-formula-suggest.js +0 -1
- package/dist/components/sheet/use-sheet-grid.js +1 -2
- package/dist/components/sheet/use-sheet-state.js +2 -3
- package/dist/components/sheet/use-sheet-tabs-bar.js +1 -2
- package/dist/components/sheet/use-tool-groups.js +1 -2
- package/dist/components/sheet/use-tool-popup.js +1 -2
- package/dist/components/sheet/use-toolbar-scroll.js +1 -2
- package/dist/index.js +1 -2
- package/dist/tools/apply-style.js +1 -2
- package/dist/tools/builtin.js +308 -307
- package/dist/tools/context.d.ts +1 -3
- package/dist/tools/context.js +0 -1
- package/dist/tools/download.js +9 -6
- package/dist/tools/export.worker.d.ts +1 -3
- package/dist/tools/export.worker.js +23459 -3
- package/dist/tools/registry.d.ts +4 -4
- package/dist/tools/registry.js +8 -4
- package/dist/types/sheet.d.ts +1 -3
- package/package.json +4 -6
- package/src/components/sheet/__test__/canvas-mock.ts +3 -1
- package/src/components/sheet/__test__/find-shortcut-anchor.test.ts +2 -0
- package/src/components/sheet/__test__/formula-bar.test.ts +6 -3
- package/src/components/sheet/__test__/formula-capability.test.ts +2 -0
- package/src/components/sheet/__test__/functions-popup.test.ts +2 -0
- package/src/components/sheet/__test__/hyperlink-popup.test.ts +2 -0
- package/src/components/sheet/__test__/import-file.test.ts +59 -4
- package/src/components/sheet/__test__/insert-count-menu-item.test.ts +2 -0
- package/src/components/sheet/__test__/insert-image-popup.test.ts +2 -0
- package/src/components/sheet/__test__/insert-image.test.ts +5 -3
- package/src/components/sheet/__test__/sheet-component.test.ts +4 -1
- package/src/components/sheet/__test__/sheet-context-menu.test.ts +2 -2
- package/src/components/sheet/__test__/sheet-grow-on-scroll.test.ts +2 -0
- package/src/components/sheet/__test__/sheet-scrollbar.test.ts +2 -0
- package/src/components/sheet/__test__/sheet-theme.test.ts +2 -0
- package/src/components/sheet/import-file.ts +3 -3
- package/src/index.ts +1 -3
- package/src/tools/__test__/builtin.test.ts +4 -4
- package/src/tools/__test__/context.test.ts +2 -2
- package/src/tools/__test__/download.test.ts +108 -0
- package/src/tools/builtin.ts +345 -344
- package/src/tools/download.ts +9 -5
- package/src/tools/registry.ts +8 -2
- package/src/tools/index.ts +0 -3
package/src/tools/download.ts
CHANGED
|
@@ -29,22 +29,26 @@ async function exportWorkbookXlsxAsync(workbook: Workbook): Promise<Uint8Array>
|
|
|
29
29
|
}
|
|
30
30
|
return await new Promise<Uint8Array>((resolve, reject) => {
|
|
31
31
|
let settled = false
|
|
32
|
-
// worker
|
|
32
|
+
// worker 加载/启动失败(如打包产物缺文件)或内部失败 → 降级主线程导出
|
|
33
33
|
const fallback = (): void => {
|
|
34
34
|
if (settled) return
|
|
35
35
|
settled = true
|
|
36
36
|
worker!.terminate()
|
|
37
|
-
|
|
37
|
+
try {
|
|
38
|
+
resolve(exportWorkbookXlsx(workbook))
|
|
39
|
+
} catch (err) {
|
|
40
|
+
reject(err)
|
|
41
|
+
}
|
|
38
42
|
}
|
|
39
43
|
worker!.onmessage = (e: MessageEvent<ExportWorkerResponse>) => {
|
|
40
44
|
if (settled) return
|
|
41
|
-
settled = true
|
|
42
|
-
worker!.terminate()
|
|
43
45
|
const data = e.data
|
|
44
46
|
if (!data.ok || !data.buffer) {
|
|
45
|
-
|
|
47
|
+
fallback()
|
|
46
48
|
return
|
|
47
49
|
}
|
|
50
|
+
settled = true
|
|
51
|
+
worker!.terminate()
|
|
48
52
|
resolve(data.buffer)
|
|
49
53
|
}
|
|
50
54
|
worker!.onerror = () => fallback()
|
package/src/tools/registry.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TypedEventEmitter } from 'infinitable/sheet'
|
|
2
2
|
|
|
3
|
+
import { BUILTIN_TOOLS } from './builtin'
|
|
3
4
|
import type { SheetContext } from './context'
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -68,6 +69,11 @@ export class ToolRegistry {
|
|
|
68
69
|
private seq = 0
|
|
69
70
|
private emitter = new TypedEventEmitter<ToolRegistryEvents>()
|
|
70
71
|
|
|
72
|
+
/** 装入初始工具(仍经 register 校验);缺省空表 */
|
|
73
|
+
constructor(tools: readonly SheetTool[] = []) {
|
|
74
|
+
for (const tool of tools) this.register(tool)
|
|
75
|
+
}
|
|
76
|
+
|
|
71
77
|
/** 注册工具;同 id 重复注册 = 替换定义并保留原注册位置 */
|
|
72
78
|
register(tool: SheetTool): void {
|
|
73
79
|
if (!tool.id) throw new Error('工具注册失败:id 不能为空')
|
|
@@ -129,10 +135,10 @@ export class ToolRegistry {
|
|
|
129
135
|
}
|
|
130
136
|
|
|
131
137
|
/**
|
|
132
|
-
* 全局默认注册表(USheet
|
|
138
|
+
* 全局默认注册表(USheet 默认渲染这里的工具;内置工具在构造时装入)。
|
|
133
139
|
* 工具是应用级扩展:注册一次,所有 USheet 实例共享。
|
|
134
140
|
*/
|
|
135
|
-
export const defaultToolRegistry = new ToolRegistry()
|
|
141
|
+
export const defaultToolRegistry = new ToolRegistry(BUILTIN_TOOLS)
|
|
136
142
|
|
|
137
143
|
/** 注册工具到默认注册表 */
|
|
138
144
|
export function registerTool(tool: SheetTool): void {
|
package/src/tools/index.ts
DELETED