mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-19 19:16:29 +08:00
chore: bump up @blocksuite/affine version to v0.18.0 (#8899)
This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@blocksuite/affine](https://redirect.github.com/toeverything/blocksuite) ([source](https://redirect.github.com/toeverything/blocksuite/tree/HEAD/packages/affine/all), [changelog](https://redirect.github.com/toeverything/blocksuite/blob/master/packages/blocks/CHANGELOG.md)) | [`0.17.33` -> `0.18.0`](https://renovatebot.com/diffs/npm/@blocksuite%2faffine/0.17.33/0.18.0) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>toeverything/blocksuite (@​blocksuite/affine)</summary> ### [`v0.18.0`](https://redirect.github.com/toeverything/blocksuite/blob/HEAD/packages/affine/all/CHANGELOG.md#0180) [Compare Source](https://redirect.github.com/toeverything/blocksuite/compare/v0.17.33...v0.18.0) ##### Minor Changes - [`9daa1f3`](https://redirect.github.com/toeverything/blocksuite/commit/9daa1f3): ## Feat - feat(blocks): markdown adapter reference serialization and deserialization ([#​8782](https://redirect.github.com/toeverything/blocksuite/issues/8782)) - feat(blocks): add lazy loading to image and iframe ([#​8773](https://redirect.github.com/toeverything/blocksuite/issues/8773)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/toeverything/AFFiNE). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xOS4wIiwidXBkYXRlZEluVmVyIjoiMzkuMTkuMCIsInRhcmdldEJyYW5jaCI6ImNhbmFyeSIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->
This commit is contained in:
@@ -1,135 +0,0 @@
|
||||
import { Unreachable } from '@affine/env/constant';
|
||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||
import { applyUpdate, Doc as YDoc, encodeStateAsUpdate } from 'yjs';
|
||||
|
||||
import {
|
||||
checkWorkspaceCompatibility,
|
||||
forceUpgradePages,
|
||||
migrateGuidCompatibility,
|
||||
MigrationPoint,
|
||||
upgradeV1ToV2,
|
||||
} from '../../../blocksuite';
|
||||
import { Entity } from '../../../framework';
|
||||
import { LiveData } from '../../../livedata';
|
||||
import type { WorkspaceMetadata } from '../metadata';
|
||||
import type { WorkspaceDestroyService } from '../services/destroy';
|
||||
import type { WorkspaceFactoryService } from '../services/factory';
|
||||
import type { WorkspaceService } from '../services/workspace';
|
||||
|
||||
export class WorkspaceUpgrade extends Entity {
|
||||
needUpgrade$ = new LiveData(false);
|
||||
upgrading$ = new LiveData(false);
|
||||
|
||||
constructor(
|
||||
private readonly workspaceService: WorkspaceService,
|
||||
private readonly workspaceFactory: WorkspaceFactoryService,
|
||||
private readonly workspaceDestroy: WorkspaceDestroyService
|
||||
) {
|
||||
super();
|
||||
this.checkIfNeedUpgrade();
|
||||
workspaceService.workspace.docCollection.doc.on('update', () => {
|
||||
this.checkIfNeedUpgrade();
|
||||
});
|
||||
}
|
||||
|
||||
checkIfNeedUpgrade() {
|
||||
const needUpgrade = !!checkWorkspaceCompatibility(
|
||||
this.workspaceService.workspace.docCollection,
|
||||
this.workspaceService.workspace.flavour === WorkspaceFlavour.AFFINE_CLOUD
|
||||
);
|
||||
this.needUpgrade$.next(needUpgrade);
|
||||
return needUpgrade;
|
||||
}
|
||||
|
||||
async upgrade(): Promise<WorkspaceMetadata | null> {
|
||||
if (this.upgrading$.value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
this.upgrading$.next(true);
|
||||
|
||||
try {
|
||||
await this.workspaceService.workspace.engine.waitForDocSynced();
|
||||
|
||||
const step = checkWorkspaceCompatibility(
|
||||
this.workspaceService.workspace.docCollection,
|
||||
this.workspaceService.workspace.flavour ===
|
||||
WorkspaceFlavour.AFFINE_CLOUD
|
||||
);
|
||||
|
||||
if (!step) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Clone a new doc to prevent change events.
|
||||
const clonedDoc = new YDoc({
|
||||
guid: this.workspaceService.workspace.docCollection.doc.guid,
|
||||
});
|
||||
applyDoc(clonedDoc, this.workspaceService.workspace.docCollection.doc);
|
||||
|
||||
if (step === MigrationPoint.SubDoc) {
|
||||
const newWorkspace = await this.workspaceFactory.create(
|
||||
WorkspaceFlavour.LOCAL,
|
||||
async (workspace, blobStorage) => {
|
||||
await upgradeV1ToV2(clonedDoc, workspace.doc);
|
||||
migrateGuidCompatibility(clonedDoc);
|
||||
await forceUpgradePages(
|
||||
workspace.doc,
|
||||
this.workspaceService.workspace.docCollection.schema
|
||||
);
|
||||
const blobList =
|
||||
await this.workspaceService.workspace.docCollection.blobSync.list();
|
||||
|
||||
for (const blobKey of blobList) {
|
||||
const blob =
|
||||
await this.workspaceService.workspace.docCollection.blobSync.get(
|
||||
blobKey
|
||||
);
|
||||
if (blob) {
|
||||
await blobStorage.set(blobKey, blob);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
await this.workspaceDestroy.deleteWorkspace(
|
||||
this.workspaceService.workspace.meta
|
||||
);
|
||||
return newWorkspace;
|
||||
} else if (step === MigrationPoint.GuidFix) {
|
||||
migrateGuidCompatibility(clonedDoc);
|
||||
await forceUpgradePages(
|
||||
clonedDoc,
|
||||
this.workspaceService.workspace.docCollection.schema
|
||||
);
|
||||
applyDoc(this.workspaceService.workspace.docCollection.doc, clonedDoc);
|
||||
await this.workspaceService.workspace.engine.waitForDocSynced();
|
||||
return null;
|
||||
} else if (step === MigrationPoint.BlockVersion) {
|
||||
await forceUpgradePages(
|
||||
clonedDoc,
|
||||
this.workspaceService.workspace.docCollection.schema
|
||||
);
|
||||
applyDoc(this.workspaceService.workspace.docCollection.doc, clonedDoc);
|
||||
await this.workspaceService.workspace.engine.waitForDocSynced();
|
||||
return null;
|
||||
} else {
|
||||
throw new Unreachable();
|
||||
}
|
||||
} finally {
|
||||
this.upgrading$.next(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function applyDoc(target: YDoc, result: YDoc) {
|
||||
applyUpdate(target, encodeStateAsUpdate(result));
|
||||
for (const targetSubDoc of target.subdocs.values()) {
|
||||
const resultSubDocs = Array.from(result.subdocs.values());
|
||||
const resultSubDoc = resultSubDocs.find(
|
||||
item => item.guid === targetSubDoc.guid
|
||||
);
|
||||
if (resultSubDoc) {
|
||||
applyDoc(targetSubDoc, resultSubDoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import { WorkspaceDBService } from '../../db';
|
||||
import { getAFFiNEWorkspaceSchema } from '../global-schema';
|
||||
import type { WorkspaceScope } from '../scopes/workspace';
|
||||
import { WorkspaceEngineService } from '../services/engine';
|
||||
import { WorkspaceUpgradeService } from '../services/upgrade';
|
||||
|
||||
export class Workspace extends Entity {
|
||||
constructor(public readonly scope: WorkspaceScope) {
|
||||
@@ -64,10 +63,6 @@ export class Workspace extends Entity {
|
||||
return this.framework.get(WorkspaceEngineService).engine;
|
||||
}
|
||||
|
||||
get upgrade() {
|
||||
return this.framework.get(WorkspaceUpgradeService).upgrade;
|
||||
}
|
||||
|
||||
name$ = LiveData.from<string | undefined>(
|
||||
new Observable(subscriber => {
|
||||
subscriber.next(this.docCollection.meta.name);
|
||||
|
||||
@@ -16,7 +16,6 @@ import { GlobalCache, GlobalState } from '../storage';
|
||||
import { WorkspaceEngine } from './entities/engine';
|
||||
import { WorkspaceList } from './entities/list';
|
||||
import { WorkspaceProfile } from './entities/profile';
|
||||
import { WorkspaceUpgrade } from './entities/upgrade';
|
||||
import { Workspace } from './entities/workspace';
|
||||
import {
|
||||
WorkspaceLocalCacheImpl,
|
||||
@@ -32,7 +31,6 @@ import { WorkspaceListService } from './services/list';
|
||||
import { WorkspaceProfileService } from './services/profile';
|
||||
import { WorkspaceRepositoryService } from './services/repo';
|
||||
import { WorkspaceTransformService } from './services/transform';
|
||||
import { WorkspaceUpgradeService } from './services/upgrade';
|
||||
import { WorkspaceService } from './services/workspace';
|
||||
import { WorkspacesService } from './services/workspaces';
|
||||
import { WorkspaceProfileCacheStore } from './stores/profile-cache';
|
||||
@@ -72,12 +70,6 @@ export function configureWorkspaceModule(framework: Framework) {
|
||||
.entity(Workspace, [WorkspaceScope])
|
||||
.service(WorkspaceEngineService, [WorkspaceScope])
|
||||
.entity(WorkspaceEngine, [WorkspaceService])
|
||||
.service(WorkspaceUpgradeService)
|
||||
.entity(WorkspaceUpgrade, [
|
||||
WorkspaceService,
|
||||
WorkspaceFactoryService,
|
||||
WorkspaceDestroyService,
|
||||
])
|
||||
.impl(WorkspaceLocalState, WorkspaceLocalStateImpl, [
|
||||
WorkspaceService,
|
||||
GlobalState,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { DebugLogger } from '@affine/debug';
|
||||
|
||||
import { fixWorkspaceVersion } from '../../../blocksuite';
|
||||
import { Service } from '../../../framework';
|
||||
import { ObjectPool } from '../../../utils';
|
||||
import type { Workspace } from '../entities/workspace';
|
||||
@@ -105,9 +104,6 @@ export class WorkspaceRepositoryService extends Service {
|
||||
workspace.engine.setRootDoc(workspace.docCollection.doc);
|
||||
workspace.engine.start();
|
||||
|
||||
// apply compatibility fix
|
||||
fixWorkspaceVersion(workspace.docCollection.doc);
|
||||
|
||||
this.framework.emitEvent(WorkspaceInitialized, workspace);
|
||||
|
||||
this.profileRepo
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import { Service } from '../../../framework';
|
||||
import { WorkspaceUpgrade } from '../entities/upgrade';
|
||||
|
||||
export class WorkspaceUpgradeService extends Service {
|
||||
upgrade = this.framework.createEntity(WorkspaceUpgrade);
|
||||
}
|
||||
Reference in New Issue
Block a user