Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
EYHN committed Jan 3, 2025
1 parent 9ef8fb0 commit d046658
Show file tree
Hide file tree
Showing 29 changed files with 1,295 additions and 1,253 deletions.
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/common/env/src/ua-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export class UaHelper {
}

private isStandaloneMode() {
if (typeof window === 'undefined') {
return false;
}
if ('standalone' in window.navigator) {
return !!window.navigator.standalone;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/common/nbstore/src/__tests__/frontend.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { DocFrontend } from '../frontend/doc';
import { BroadcastChannelAwarenessStorage } from '../impls/broadcast-channel/awareness';
import { IndexedDBDocStorage } from '../impls/idb';
import { AwarenessSyncImpl } from '../sync/awareness';
import { expectYjsEqual } from './utils';
import { DocSyncImpl } from '../sync/doc';
import { expectYjsEqual } from './utils';

test('doc', async () => {
const doc1 = new YDoc({
Expand Down
1 change: 1 addition & 0 deletions packages/common/nbstore/src/connection/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export abstract class AutoReconnectConnection<T = any>
})
.catch(error => {
if (!this.connectingAbort?.signal.aborted) {
console.error('failed to connect', error);
this.setStatus('error', error as any);
}
});
Expand Down
50 changes: 28 additions & 22 deletions packages/common/nbstore/src/storage/doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,38 +112,44 @@ export abstract class DocStorageBase<Opts = {}>
}

async getDoc(docId: string) {
await using _lock = this.isReadonly
const lock = this.isReadonly
? undefined
: await this.lockDocForUpdate(docId);

const snapshot = await this.getDocSnapshot(docId);
const updates = await this.getDocUpdates(docId);
try {
const snapshot = await this.getDocSnapshot(docId);
const updates = await this.getDocUpdates(docId);

if (updates.length) {
const { timestamp, bin, editor } = await this.squash(
snapshot ? [snapshot, ...updates] : updates
);
if (updates.length) {
const { timestamp, bin, editor } = await this.squash(
snapshot ? [snapshot, ...updates] : updates
);

const newSnapshot = {
spaceId: this.spaceId,
docId,
bin,
timestamp,
editor,
};
const newSnapshot = {
spaceId: this.spaceId,
docId,
bin,
timestamp,
editor,
};

// if is readonly, we will not set the new snapshot
if (!this.isReadonly) {
await this.setDocSnapshot(newSnapshot, snapshot);
// if is readonly, we will not set the new snapshot
if (!this.isReadonly) {
await this.setDocSnapshot(newSnapshot, snapshot);

// always mark updates as merged unless throws
await this.markUpdatesMerged(docId, updates);
// always mark updates as merged unless throws
await this.markUpdatesMerged(docId, updates);
}

return newSnapshot;
}

return newSnapshot;
return snapshot;
} finally {
if (lock) {
await lock[Symbol.asyncDispose]();
}
}

return snapshot;
}

async getDocDiff(docId: string, state?: Uint8Array) {
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/apps/electron-renderer/src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@affine/core/bootstrap/electron';
import { getElectronAPIs } from '@affine/electron-api/web-worker';
import {
WorkerConsumer,
Expand Down
10 changes: 5 additions & 5 deletions packages/frontend/apps/ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
9D90BE2B2CCB9876006677DB /* config.xml in Resources */ = {isa = PBXBuildFile; fileRef = 9D90BE1F2CCB9876006677DB /* config.xml */; };
9D90BE2D2CCB9876006677DB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9D90BE222CCB9876006677DB /* Main.storyboard */; };
9D90BE2E2CCB9876006677DB /* public in Resources */ = {isa = PBXBuildFile; fileRef = 9D90BE232CCB9876006677DB /* public */; };
9DFCD1462D27D1D70028C92B /* libaffine_mobile_native.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9DFCD1452D27D1D70028C92B /* libaffine_mobile_native.a */; };
C4C413792CBE705D00337889 /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */; };
C4C97C6E2D0304D100BC2AD1 /* libaffine_mobile_native.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C4C97C6D2D0304D100BC2AD1 /* libaffine_mobile_native.a */; };
C4C97C7C2D030BE000BC2AD1 /* affine_mobile_native.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C97C6F2D0307B700BC2AD1 /* affine_mobile_native.swift */; };
C4C97C7D2D030BE000BC2AD1 /* affine_mobile_nativeFFI.h in Sources */ = {isa = PBXBuildFile; fileRef = C4C97C702D0307B700BC2AD1 /* affine_mobile_nativeFFI.h */; };
C4C97C7E2D030BE000BC2AD1 /* affine_mobile_nativeFFI.modulemap in Sources */ = {isa = PBXBuildFile; fileRef = C4C97C712D0307B700BC2AD1 /* affine_mobile_nativeFFI.modulemap */; };
Expand All @@ -51,10 +51,10 @@
9D90BE202CCB9876006677DB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9D90BE212CCB9876006677DB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
9D90BE232CCB9876006677DB /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = "<group>"; };
9DFCD1452D27D1D70028C92B /* libaffine_mobile_native.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libaffine_mobile_native.a; sourceTree = "<group>"; };
AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App.framework; sourceTree = BUILT_PRODUCTS_DIR; };
AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.release.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.release.xcconfig"; sourceTree = "<group>"; };
C4C97C6B2D03027900BC2AD1 /* libaffine_mobile_native.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libaffine_mobile_native.a; path = "../../../../../target/aarch64-apple-ios-sim/release/libaffine_mobile_native.a"; sourceTree = "<group>"; };
C4C97C6D2D0304D100BC2AD1 /* libaffine_mobile_native.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libaffine_mobile_native.a; sourceTree = "<group>"; };
C4C97C6B2D03027900BC2AD1 /* libaffine_mobile_native.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libaffine_mobile_native.a; path = "../../../../../target/aarch64-apple-ios-sim/debug/libaffine_mobile_native.a"; sourceTree = "<group>"; };
C4C97C6F2D0307B700BC2AD1 /* affine_mobile_native.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = affine_mobile_native.swift; sourceTree = "<group>"; };
C4C97C702D0307B700BC2AD1 /* affine_mobile_nativeFFI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = affine_mobile_nativeFFI.h; sourceTree = "<group>"; };
C4C97C712D0307B700BC2AD1 /* affine_mobile_nativeFFI.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = affine_mobile_nativeFFI.modulemap; sourceTree = "<group>"; };
Expand All @@ -71,8 +71,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C4C97C6E2D0304D100BC2AD1 /* libaffine_mobile_native.a in Frameworks */,
50A285DC2D112B24000D5A6D /* Intelligents in Frameworks */,
9DFCD1462D27D1D70028C92B /* libaffine_mobile_native.a in Frameworks */,
50802D612D112F8700694021 /* Intelligents in Frameworks */,
C4C413792CBE705D00337889 /* Pods_App.framework in Frameworks */,
);
Expand All @@ -85,8 +85,8 @@
isa = PBXGroup;
children = (
C4C97C6B2D03027900BC2AD1 /* libaffine_mobile_native.a */,
C4C97C6D2D0304D100BC2AD1 /* libaffine_mobile_native.a */,
AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */,
9DFCD1452D27D1D70028C92B /* libaffine_mobile_native.a */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down
Loading

0 comments on commit d046658

Please sign in to comment.