Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(debug): add snapshot save (#670)

Gpound.liu5a60d149e61e
diff --git a/examples/sheets/package.json b/examples/sheets/package.json
index 8643b5f203..4b07c946d5 100644
--- a/examples/sheets/package.json
+++ b/examples/sheets/package.json
@@ -22,6 +22,7 @@
"@univerjs/docs-ui": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/uniscript": "workspace:*",
+ "@univerjs/local-save": "workspace:*",
"@wendellhu/redi": "^0.12.11",
"data": "workspace:*",
"monaco-editor": "0.44.0"
diff --git a/examples/sheets/src/sheets-plugin-debugger/commands/operations/saveSnapshot.operations.ts b/examples/sheets/src/sheets-plugin-debugger/commands/operations/saveSnapshot.operations.ts
new file mode 100644
index 0000000000..27d1a9311f
--- /dev/null
+++ b/examples/sheets/src/sheets-plugin-debugger/commands/operations/saveSnapshot.operations.ts
@@ -0,0 +1,79 @@
+// eslint-disable-next-line import/no-extraneous-dependencies
+import type { ICommand, IStyleData, IWorkbookData } from '@univerjs/core';
+import { CommandType, ISnapshotPersistenceService, IUniverInstanceService, ObjectMatrix } from '@univerjs/core';
+import { ExportController, RecordController } from '@univerjs/local-save';
+import type { IAccessor } from '@wendellhu/redi';
+
+export interface ISaveSnapshotParams {
+ value: 'sheet' | 'workbook' | 'record';
+}
+
+const filterStyle = (workbookData: IWorkbookData) => {
+ const sheets = workbookData.sheets;
+ const cacheStyle: Record<string, IStyleData> = {};
+ Object.keys(sheets).forEach((sheetId) => {
+ const sheet = sheets[sheetId];
+ new ObjectMatrix(sheet.cellData).forValue((_r, _c, value) => {
+ const s = value?.s;
+ if (s && typeof s === 'string') {
+ const style = workbookData.styles[s];
+ if (style) {
+ cacheStyle[s] = style;
+ }
+ }
+ });
+ });
+ workbookData.styles = cacheStyle;
+ return workbookData;
+};
+export const SaveSnapshotOptions: ICommand = {
+ id: 'debugger.operation.saveSnapshot',
+ type: CommandType.OPERATION,
+ handler: async (accessor: IAccessor, params: ISaveSnapshotParams) => {
+ const univerInstanceService = accessor.get(IUniverInstanceService);
+ const localPersistenceService = accessor.get(ISnapshotPersistenceService);
+ const exportController = accessor.get(ExportController);
+ const recordController = accessor.get(RecordController);
+
+ const workbook = univerInstanceService.getCurrentUniverSheetInstance();
+ const worksheet = workbook.getActiveSheet();
+ const snapshot = localPersistenceService.saveWorkbook(workbook);
+ const gitHash = process.env.GIT_COMMIT_HASH;
+ const gitBranch = process.env.GIT_REF_NAME;
+ const buildTime = process.env.BUILD_TIME;
+ (snapshot as any).__env__ = { gitHash, gitBranch, buildTime };
+ const preName = new Date().toLocaleString();
+ switch (params.value) {
+ case 'sheet': {
+ const sheetId = worksheet.getSheetId();
+ const sheet = snapshot.sheets[sheetId];
+ snapshot.sheets = { [sheetId]: sheet };
+ snapshot.sheetOrder = [sheetId];
+ }
+ // eslint-disable-next-line no-fallthrough
+ case 'workbook': {
+ const text = JSON.stringify(filterStyle(snapshot), null, 2);
+ // navigator.clipboard.writeText(text);
+ exportController.exportJson(text, `${preName} snapshot`);
+
+ break;
+ }
+ case 'record': {
+ let endCommands = () => [];
+
+ recordController.record().subscribe((v) => {
+ if (v.type === 'start') {
+ endCommands = recordController.startSaveCommands() as any;
+ }
+ if (v.type === 'finish') {
+ const commands = endCommands();
+ exportController.exportWebm(v.data, `${preName} video`);
+ const commandsText = JSON.stringify(commands, null, 2);
+ exportController.exportJson(commandsText, `${preName} commands`);
+ }
+ });
+ }
+ }
+ return true;
+ },
+};
diff --git a/examples/sheets/src/sheets-plugin-debugger/controllers/debugger.controller.ts b/examples/sheets/src/sheets-plugin-debugger/controllers/debugger.controller.ts
index 7f326c3845..3e54dd8988 100644
--- a/examples/sheets/src/sheets-plugin-debugger/controllers/debugger.controller.ts
+++ b/examples/sheets/src/sheets-plugin-debugger/controllers/debugger.controller.ts
@@ -1,4 +1,5 @@
-import { Disposable, ICommandService } from '@univerjs/core';
+import { Disposable, ICommandService, ISnapshotPersistenceService } from '@univerjs/core';
+import { ExportController, LocalSnapshotService, RecordController } from '@univerjs/local-save';
import { IMenuService } from '@univerjs/ui';
import { Inject, Injector } from '@wendellhu/redi';
@@ -7,6 +8,7 @@ import { DialogOperation } from '../commands/operations/dialog.operation';
import { LocaleOperation } from '../commands/operations/locale.operation';
import { MessageOperation } from '../commands/operations/message.operation';
import { NotificationOperation } from '../commands/operations/notification.operation';
+import { SaveSnapshotOptions } from '../commands/operations/saveSnapshot.operations';
import { SetEditable } from '../commands/operations/set.editable.operation';
import { SidebarOperation } from '../commands/operations/sidebar.operation';
import { ThemeOperation } from '../commands/operations/theme.operation';
@@ -16,6 +18,7 @@ import {
LocaleMenuItemFactory,
MessageMenuItemFactory,
NotificationMenuItemFactory,
+ SaveSnapshotSetEditableMenuItemFactory,
SetEditableMenuItemFactory,
SidebarMenuItemFactory,
ThemeMenuItemFactory,
@@ -39,7 +42,12 @@ export class DebuggerController extends Disposable {
MessageOperation,
SidebarOperation,
SetEditable,
+ SaveSnapshotOptions,
].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
+
+ this._injector.add([ISnapshotPersistenceService, { useClass: LocalSnapshotService }]);
+ this._injector.add([ExportController]);
+ this._injector.add([RecordController]);
}
private _initializeContextMenu() {
@@ -52,6 +60,7 @@ export class DebuggerController extends Disposable {
ConfirmMenuItemFactory,
SidebarMenuItemFactory,
SetEditableMenuItemFactory,
+ SaveSnapshotSetEditableMenuItemFactory,
].forEach((factory) => {
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory)));
});
diff --git a/examples/sheets/src/sheets-plugin-debugger/controllers/menu.ts b/examples/sheets/src/sheets-plugin-debugger/controllers/menu.ts
index f49fbff556..f6c0f8ab0f 100644
--- a/examples/sheets/src/sheets-plugin-debugger/controllers/menu.ts
+++ b/examples/sheets/src/sheets-plugin-debugger/controllers/menu.ts
@@ -9,6 +9,7 @@ import { DialogOperation } from '../commands/operations/dialog.operation';
import { LocaleOperation } from '../commands/operations/locale.operation';
import { MessageOperation } from '../commands/operations/message.operation';
import { NotificationOperation } from '../commands/operations/notification.operation';
+import { SaveSnapshotOptions } from '../commands/operations/saveSnapshot.operations';
import { SetEditable } from '../commands/operations/set.editable.operation';
import { SidebarOperation } from '../commands/operations/sidebar.operation';
import { ThemeOperation } from '../commands/operations/theme.operation';
@@ -168,3 +169,26 @@ export function SetEditableMenuItemFactory(accessor: IAccessor): IMenuSelectorIt
],
};
}
+
+export function SaveSnapshotSetEditableMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
+ return {
+ id: SaveSnapshotOptions.id,
+ type: MenuItemType.SELECTOR,
+ title: 'debugger.snapshot',
+ positions: [MenuPosition.TOOLBAR_OTHERS],
+ selections: [
+ {
+ label: 'saveWorkbook',
+ value: 'workbook',
+ },
+ {
+ label: 'saveSheet',
+ value: 'sheet',
+ },
+ {
+ label: 'record',
+ value: 'record',
+ },
+ ],
+ };
+}
diff --git a/examples/sheets/src/sheets-plugin-debugger/locale/en-US.ts b/examples/sheets/src/sheets-plugin-debugger/locale/en-US.ts
index bd20541881..01830251f0 100644
--- a/examples/sheets/src/sheets-plugin-debugger/locale/en-US.ts
+++ b/examples/sheets/src/sheets-plugin-debugger/locale/en-US.ts
@@ -8,5 +8,6 @@ export default {
confirm: 'Confirm',
sidebar: 'Sidebar',
editable: 'Editable',
+ snapshot: 'Snapshot',
},
};
diff --git a/examples/sheets/src/sheets-plugin-debugger/locale/zh-CN.ts b/examples/sheets/src/sheets-plugin-debugger/locale/zh-CN.ts
index 52bfc3f209..e3134f2f2f 100644
--- a/examples/sheets/src/sheets-plugin-debugger/locale/zh-CN.ts
+++ b/examples/sheets/src/sheets-plugin-debugger/locale/zh-CN.ts
@@ -8,5 +8,6 @@ export default {
confirm: '确认框',
sidebar: '侧边栏',
editable: '编辑权限',
+ snapshot: '快照',
},
};
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 8a76edc926..ac5e28837c 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -61,7 +61,7 @@ export {
} from './services/permission';
export { ResourceManagerService } from './services/resource-manager/resource-manager.service';
export type { IResourceHook } from './services/resource-manager/type';
-export { IResourceManagerService } from './services/resource-manager/type';
+export { IResourceManagerService, ISnapshotPersistenceService } from './services/resource-manager/type';
export { type IStyleSheet, ThemeService } from './services/theme/theme.service';
export {
type IUndoRedoCommandInfos,
diff --git a/packages/core/src/services/permission/permission.service.ts b/packages/core/src/services/permission/permission.service.ts
index 5c5f50d210..033a200669 100644
--- a/packages/core/src/services/permission/permission.service.ts
+++ b/packages/core/src/services/permission/permission.service.ts
@@ -29,7 +29,7 @@ export class PermissionService extends Disposable implements IPermissionService
@Inject(IUniverInstanceService) private _univerInstanceService: IUniverInstanceService
) {
super();
- this._init();
+ // this._init();
}
private _init() {
diff --git a/packages/core/src/services/resource-manager/type.ts b/packages/core/src/services/resource-manager/type.ts
index 5c753891a8..51d5a2c7cb 100644
--- a/packages/core/src/services/resource-manager/type.ts
+++ b/packages/core/src/services/resource-manager/type.ts
@@ -2,6 +2,10 @@ import type { IDisposable } from '@wendellhu/redi';
import { createIdentifier } from '@wendellhu/redi';
import type { Observable } from 'rxjs';
+import type { Workbook } from '../../sheets/workbook';
+import type { IWorkbookData } from '../../types/interfaces/i-workbook-data';
+import { LifecycleStages, runOnLifecycle } from '../lifecycle/lifecycle';
+
export interface IResourceHook<T = any> {
onChange: (unitID: string, resource: T) => void;
toJson: (unitID: string) => string;
@@ -16,3 +20,9 @@ export interface IResourceManagerService {
}
export const IResourceManagerService = createIdentifier<IResourceManagerService>('resource-manager-service');
+export interface ISnapshotPersistenceService {
+ saveWorkbook: (workbook: Workbook) => IWorkbookData;
+}
+
+export const ISnapshotPersistenceService = createIdentifier<ISnapshotPersistenceService>('ResourcePersistenceService');
+runOnLifecycle(LifecycleStages.Ready, ISnapshotPersistenceService);
diff --git a/packages/local-save/README.md b/packages/local-save/README.md
new file mode 100644
index 0000000000..84def380e1
--- /dev/null
+++ b/packages/local-save/README.md
@@ -0,0 +1,16 @@
+# @univerjs/
+
+[![npm version](https://img.shields.io/npm/v/@univerjs/)](https://npmjs.org/packages/@univerjs/)
+[![license](https://img.shields.io/npm/l/@univerjs/)](https://img.shields.io/npm/l/@univerjs/)
+
+## Introduction
+
+> TODO: Introduction
+
+## Usage
+
+### Installation
+
+```shell
+npm i @univerjs/
+```
diff --git a/packages/local-save/esbuild.config.mjs b/packages/local-save/esbuild.config.mjs
new file mode 100644
index 0000000000..76d459e6ec
--- /dev/null
+++ b/packages/local-save/esbuild.config.mjs
@@ -0,0 +1,18 @@
+import esbuild from 'esbuild';
+
+// eslint-disable-next-line import/no-relative-packages
+import baseConfig, { postBuild } from '../../esbuild.config.mjs';
+
+for (const format of ['cjs', 'esm']) {
+ await esbuild.build({
+ ...baseConfig,
+ globalName: 'UniverLocalSave',
+ entryPoints: {
+ index: './src/index.ts',
+ },
+ outdir: `./lib/${format}`,
+ format,
+ });
+
+ await postBuild(format);
+}
diff --git a/packages/local-save/package.json b/packages/local-save/package.json
new file mode 100644
index 0000000000..271b2d95fd
--- /dev/null
+++ b/packages/local-save/package.json
@@ -0,0 +1,63 @@
+{
+ "name": "@univerjs/local-save",
+ "version": "0.1.0-alpha.1",
+ "description": "",
+ "keywords": [],
+ "author": "DreamNum <[email protected]>",
+ "license": "MIT",
+ "main": "./lib/cjs/index.js",
+ "module": "./lib/esm/index.js",
+ "types": "./lib/types/index.d.ts",
+ "publishConfig": {
+ "access": "public",
+ "main": "./lib/cjs/index.js",
+ "module": "./lib/esm/index.js",
+ "exports": {
+ ".": {
+ "import": "./lib/esm/index.js",
+ "require": "./lib/cjs/index.js",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./*": {
+ "import": "./lib/esm/*",
+ "require": "./lib/cjs/*",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./locale/*": {
+ "import": "./lib/esm/locale/*.js",
+ "require": "./lib/cjs/locale/*.js",
+ "types": "./lib/types/index.d.ts"
+ }
+ }
+ },
+ "exports": {
+ ".": "./src/index.ts",
+ "./*": "./src/*",
+ "./locale/*": "./src/locale/*.ts"
+ },
+ "directories": {
+ "lib": "lib"
+ },
+ "files": [
+ "lib"
+ ],
+ "private": false,
+ "scripts": {
+ "test": "vitest run",
+ "test:watch": "vitest",
+ "coverage": "vitest run --coverage",
+ "esbuild": "node ./esbuild.config.mjs && tsc -p tsconfig.esbuild.json"
+ },
+ "dependencies": {
+ "@univerjs/core": "workspace:*",
+ "@wendellhu/redi": "^0.12.11",
+ "rxjs": "^7.8.1"
+ },
+ "devDependencies": {
+ "@vitest/coverage-istanbul": "^0.34.6",
+ "esbuild": "^0.19.8",
+ "ts-node": "^10.9.1",
+ "typescript": "^5.3.2",
+ "vitest": "^0.34.6"
+ }
+}
diff --git a/packages/local-save/src/controller/export.controller.ts b/packages/local-save/src/controller/export.controller.ts
new file mode 100644
index 0000000000..8a43041f56
--- /dev/null
+++ b/packages/local-save/src/controller/export.controller.ts
@@ -0,0 +1,14 @@
+import { createDownloadElement } from '../util/index';
+
+export class ExportController {
+ exportJson(data: string, fileName: string) {
+ const blob = new Blob([data], { type: 'text/json' });
+ const startDownload = createDownloadElement(`${fileName}.json`, blob);
+ startDownload();
+ }
+
+ exportWebm(data: Blob, fileName: string) {
+ const startDownload = createDownloadElement(`${fileName}.webm`, data);
+ startDownload();
+ }
+}
diff --git a/packages/local-save/src/controller/record.controller.ts b/packages/local-save/src/controller/record.controller.ts
new file mode 100644
index 0000000000..fc50a7bef2
--- /dev/null
+++ b/packages/local-save/src/controller/record.controller.ts
@@ -0,0 +1,57 @@
+import { CommandType, ICommandService } from '@univerjs/core';
+import { Inject } from '@wendellhu/redi';
+import { Observable } from 'rxjs';
+
+export class RecordController {
+ constructor(@Inject(ICommandService) private _commandService: ICommandService) {}
+
+ record() {
+ return new Observable<{ type: 'start' } | { type: 'finish'; data: Blob }>((subscribe) => {
+ navigator.mediaDevices.getDisplayMedia({ video: true }).then((stream) => {
+ subscribe.next({ type: 'start' });
+ const mime = MediaRecorder.isTypeSupported('video/webm; codecs=vp9')
+ ? 'video/webm; codecs=vp9'
+ : 'video/webm';
+ const mediaRecorder = new MediaRecorder(stream, { mimeType: mime });
+
+ const chunks: Blob[] = [];
+ mediaRecorder.addEventListener('dataavailable', function (e) {
+ chunks.push(e.data);
+ });
+
+ mediaRecorder.addEventListener('stop', function () {
+ const blob = new Blob(chunks, { type: chunks[0].type });
+ subscribe.next({ type: 'finish', data: blob });
+ subscribe.complete();
+ });
+
+ mediaRecorder.start();
+ });
+ });
+ }
+
+ startSaveCommands() {
+ type SecondsString = string & {};
+ type CommandString = string & {};
+ type TypeString = string & {};
+ type ParamsString = string & {};
+ const result: Array<[SecondsString, CommandString, TypeString, ParamsString]> = [];
+ const startTime = performance.now();
+ const disposable = this._commandService.onCommandExecuted((commandInfo) => {
+ try {
+ result.push([
+ String((performance.now() - startTime) / 1000),
+ commandInfo.id,
+ String(commandInfo.type || CommandType.COMMAND),
+ JSON.stringify(commandInfo.params || ''),
+ ]);
+ } catch (err) {
+ console.error(`${commandInfo.id} unable to serialize`);
+ }
+ });
+ return () => {
+ disposable.dispose();
+ return result;
+ };
+ }
+}
diff --git a/packages/local-save/src/index.ts b/packages/local-save/src/index.ts
new file mode 100644
index 0000000000..ccc002f25f
--- /dev/null
+++ b/packages/local-save/src/index.ts
@@ -0,0 +1,3 @@
+export { ExportController } from './controller/export.controller';
+export { RecordController } from './controller/record.controller';
+export { LocalSnapshotService } from './services/local-snapshot.service';
diff --git a/packages/local-save/src/plugin.ts b/packages/local-save/src/plugin.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/packages/local-save/src/services/local-snapshot.service.ts b/packages/local-save/src/services/local-snapshot.service.ts
new file mode 100644
index 0000000000..1caa8089cc
--- /dev/null
+++ b/packages/local-save/src/services/local-snapshot.service.ts
@@ -0,0 +1,49 @@
+import type { ISnapshotPersistenceService, Workbook } from '@univerjs/core';
+import { Disposable, IResourceManagerService, IUniverInstanceService } from '@univerjs/core';
+import { Inject } from '@wendellhu/redi';
+
+export class LocalSnapshotService extends Disposable implements ISnapshotPersistenceService {
+ constructor(
+ @Inject(IResourceManagerService) private _resourceManagerService: IResourceManagerService,
+ @Inject(IUniverInstanceService) private _univerInstanceService: IUniverInstanceService
+ ) {
+ super();
+ this._initWorkBook();
+ }
+
+ private _initWorkBook() {
+ this._univerInstanceService.sheetAdded$.subscribe((workbook) => this._initWorkbookFromSnapshot(workbook));
+ const workbooks = this._univerInstanceService.getAllUniverSheetsInstance();
+ workbooks.forEach((workbook) => {
+ this._initWorkbookFromSnapshot(workbook);
+ });
+ }
+
+ private _initWorkbookFromSnapshot(workbook: Workbook) {
+ const workbookId = workbook.getUnitId();
+ const snapshot = workbook.getSnapshot();
+ const resources = this._resourceManagerService.getAllResource(workbookId);
+ resources.forEach((resource) => {
+ const resourceSnapshot = (snapshot.resources || []).find((item) => item.name === resource.resourceName);
+ if (resourceSnapshot) {
+ const model = resource.hook.parseJson(resourceSnapshot.data);
+ resource.hook.onChange(workbookId, model);
+ }
+ });
+ }
+
+ saveWorkbook(workbook: Workbook) {
+ const snapshot = { ...workbook.getSnapshot() };
+ const unitId = workbook.getUnitId();
+ const resourceHooks = this._resourceManagerService.getAllResource(workbook.getUnitId());
+ const resources = resourceHooks.map((resourceHook) => {
+ const data = resourceHook.hook.toJson(unitId);
+ return {
+ name: resourceHook.resourceName,
+ data,
+ };
+ });
+ snapshot.resources = resources;
+ return snapshot;
+ }
+}
diff --git a/packages/local-save/src/util/index.ts b/packages/local-save/src/util/index.ts
new file mode 100644
index 0000000000..34411e6395
--- /dev/null
+++ b/packages/local-save/src/util/index.ts
@@ -0,0 +1,8 @@
+export function createDownloadElement(fileName: string, blob: Blob) {
+ const a = document.createElement('a');
+ a.download = fileName;
+ a.href = window.URL.createObjectURL(blob);
+ return () => {
+ a.click();
+ };
+}
diff --git a/packages/local-save/tsconfig.esbuild.json b/packages/local-save/tsconfig.esbuild.json
new file mode 100644
index 0000000000..45e4773cbf
--- /dev/null
+++ b/packages/local-save/tsconfig.esbuild.json
@@ -0,0 +1,13 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "rootDir": "./src",
+ "outDir": "./lib/types",
+ "declaration": true,
+ "declarationDir": "./lib/types",
+ "declarationMap": true,
+ "emitDeclarationOnly": true,
+ "isolatedModules": false
+ },
+ "exclude": ["**/*.test.ts", "**/*.test.tsx", "**/*.stories.tsx"]
+}
diff --git a/packages/local-save/tsconfig.json b/packages/local-save/tsconfig.json
new file mode 100644
index 0000000000..32d857ca72
--- /dev/null
+++ b/packages/local-save/tsconfig.json
@@ -0,0 +1,10 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "rootDir": "./src",
+ "outDir": "lib",
+ "esModuleInterop": true,
+ "strictPropertyInitialization": false
+ },
+ "include": ["src/**/*"]
+}
diff --git a/packages/local-save/vitest.config.ts b/packages/local-save/vitest.config.ts
new file mode 100644
index 0000000000..3c74cf802f
--- /dev/null
+++ b/packages/local-save/vitest.config.ts
@@ -0,0 +1,9 @@
+import { defineConfig } from 'vitest/config';
+
+export default defineConfig({
+ test: {
+ coverage: {
+ provider: 'istanbul',
+ },
+ },
+});
diff --git a/packages/sheets/src/services/numfmt/numfmt.service.ts b/packages/sheets/src/services/numfmt/numfmt.service.ts
index 0cb44bd300..c7039be15b 100644
--- a/packages/sheets/src/services/numfmt/numfmt.service.ts
+++ b/packages/sheets/src/services/numfmt/numfmt.service.ts
@@ -17,7 +17,7 @@ import { Subject } from 'rxjs';
import type { FormatType, INumfmtItem, INumfmtService, IRefItem, ISnapshot } from './type';
const SHEET_NUMFMT_PLUGIN = 'SHEET_NUMFMT_PLUGIN';
-@OnLifecycle(LifecycleStages.Ready, NumfmtService)
+@OnLifecycle(LifecycleStages.Starting, NumfmtService)
export class NumfmtService extends Disposable implements INumfmtService {
/**
* Map<unitID ,<sheetId ,ObjectMatrix>>
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 99550c6f44..e6d7355015 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -274,6 +274,9 @@ importers:
'@univerjs/engine-render':
specifier: workspace:*
version: link:../../packages/engine-render
+ '@univerjs/local-save':
+ specifier: workspace:*
+ version: link:../../packages/local-save
'@univerjs/rpc':
specifier: workspace:*
version: link:../../packages/rpc
@@ -726,6 +729,34 @@ importers:
specifier: ^0.34.6
+ packages/local-save:
+ dependencies:
+ '@univerjs/core':
+ specifier: workspace:*
+ version: link:../core
+ '@wendellhu/redi':
+ specifier: ^0.12.11
+ version: 0.12.11
+ rxjs:
+ specifier: ^7.8.1
+ version: 7.8.1
+ devDependencies:
+ '@vitest/coverage-istanbul':
+ specifier: ^0.34.6
+ version: 0.34.6([email protected])
+ esbuild:
+ specifier: ^0.19.8
+ version: 0.19.8
+ ts-node:
+ specifier: ^10.9.1
+ typescript:
+ specifier: ^5.3.2
+ version: 5.3.2
+ vitest:
+ specifier: ^0.34.6
+ version: 0.34.6
+
packages/network:
dependencies:
'@univerjs/core':
@@ -6878,12 +6909,6 @@ packages:
undici-types: 5.26.5
dev: true
- resolution: {integrity: sha512-37MXfxkb0vuIlRKHNxwCkb60PNBpR94u4efQuN4JgIAm66zfCDXGSAFCef9XUWFovX2R1ok6Z7MHhtdVXXkkIw==}
- dependencies:
- undici-types: 5.26.5
- dev: true
-
resolution: {integrity: sha512-XJavIpZqiXID5Yxnxv3RUDKTN5b81ddNC3ecsA0SoFXz/QU8OGBwZGMomiq0zw+uuqbL/krztv/DINAQ/EV4gg==}
dependencies:
@@ -7266,7 +7291,7 @@ packages:
istanbul-reports: 3.1.6
picocolors: 1.0.0
test-exclude: 6.0.0
+ vitest: 0.34.6
transitivePeerDependencies:
- supports-color
dev: true
@@ -11930,8 +11955,8 @@ packages:
resolution: {integrity: sha512-EAMEJBsYuyyztxMxW3g7ugGPkrZsV57v0Hmv3mm1uQsmB+QnZuepg731CRaIgeUVSdmsTngOkSnauNF8p7FIhA==}
engines: {node: '>=10'}
dependencies:
- '@babel/core': 7.23.3
- '@babel/parser': 7.23.4
+ '@babel/core': 7.23.5
+ '@babel/parser': 7.23.5
'@istanbuljs/schema': 0.1.3
istanbul-lib-coverage: 3.2.2
semver: 7.5.4
@@ -17541,7 +17566,7 @@ packages:
unist-util-stringify-position: 4.0.0
vfile-message: 4.0.2
resolution: {integrity: sha512-nlBMJ9x6n7/Amaz6F3zJ97EBwR2FkzhBRxF5e+jE6LA3yi6Wtc2lyTij1OnDMIr34v5g/tVQtsVAzhT0jc5ygA==}
engines: {node: '>=v14.18.0'}
hasBin: true
@@ -17551,7 +17576,7 @@ packages:
mlly: 1.4.2
pathe: 1.1.1
picocolors: 1.0.0
- vite: 5.0.2(@types/[email protected])([email protected])
+ vite: 5.0.2(@types/[email protected])([email protected])
transitivePeerDependencies:
- '@types/node'
- less
@@ -17599,43 +17624,6 @@ packages:
fsevents: 2.3.3
dev: true
- resolution: {integrity: sha512-6CCq1CAJCNM1ya2ZZA7+jS2KgnhbzvxakmlIjN24cF/PXhRMzpM/z8QgsVJA/Dm5fWUWnVEsmtBoMhmerPxT0g==}
- engines: {node: ^18.0.0 || >=20.0.0}
- hasBin: true
- peerDependencies:
- '@types/node': ^18.0.0 || >=20.0.0
- less: '*'
- lightningcss: ^1.21.0
- sass: '*'
- stylus: '*'
- sugarss: '*'
- terser: ^5.4.0
- peerDependenciesMeta:
- '@types/node':
- optional: true
- less:
- optional: true
- lightningcss:
- optional: true
- sass:
- optional: true
- stylus:
- optional: true
- sugarss:
- optional: true
- terser:
- optional: true
- dependencies:
- '@types/node': 20.10.2
- esbuild: 0.19.8
- less: 4.2.0
- postcss: 8.4.31
- rollup: 4.5.2
- optionalDependencies:
- fsevents: 2.3.3
- dev: true
-
resolution: {integrity: sha512-6CCq1CAJCNM1ya2ZZA7+jS2KgnhbzvxakmlIjN24cF/PXhRMzpM/z8QgsVJA/Dm5fWUWnVEsmtBoMhmerPxT0g==}
engines: {node: ^18.0.0 || >=20.0.0}
@@ -17706,7 +17694,7 @@ packages:
dependencies:
'@types/chai': 4.3.11
'@types/chai-subset': 1.3.5
- '@types/node': 20.10.2
+ '@types/node': 20.10.3
'@vitest/expect': 0.34.6
'@vitest/runner': 0.34.6
'@vitest/snapshot': 0.34.6
@@ -17725,8 +17713,8 @@ packages:
strip-literal: 1.3.0
tinybench: 2.5.1
tinypool: 0.7.0
- vite: 5.0.2(@types/[email protected])([email protected])
- vite-node: 0.34.6(@types/[email protected])([email protected])
+ vite: 5.0.2(@types/[email protected])([email protected])
+ vite-node: 0.34.6(@types/[email protected])([email protected])
why-is-node-running: 2.2.2
transitivePeerDependencies:
- less
@@ -17771,7 +17759,7 @@ packages:
dependencies:
'@types/chai': 4.3.11
'@types/chai-subset': 1.3.5
- '@types/node': 20.10.2
+ '@types/node': 20.10.3
'@vitest/expect': 0.34.6
'@vitest/runner': 0.34.6
'@vitest/snapshot': 0.34.6
@@ -17791,8 +17779,8 @@ packages:
strip-literal: 1.3.0
tinybench: 2.5.1
tinypool: 0.7.0
- vite: 5.0.2(@types/[email protected])([email protected])
- vite-node: 0.34.6(@types/[email protected])([email protected])
+ vite: 5.0.2(@types/[email protected])([email protected])
+ vite-node: 0.34.6(@types/[email protected])([email protected])
why-is-node-running: 2.2.2
transitivePeerDependencies:
- less
diff --git a/tsconfig.json b/tsconfig.json
index 87e8975791..74d9fdf323 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -85,6 +85,9 @@
{
"path": "./packages/uniscript"
},
+ {
+ "path": "./packages/local-save"
+ },
{
"path": "./examples/data"
},