-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nbstore): integrated new workspace engine
- Loading branch information
Showing
63 changed files
with
848 additions
and
483 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
import '@affine/core/bootstrap/electron'; | ||
import '@affine/component/theme'; | ||
import './global.css'; | ||
|
||
import { apis } from '@affine/electron-api'; | ||
import { bindNativeDBApis } from '@affine/nbstore/sqlite'; | ||
|
||
bindNativeDBApis(apis!.nbstore); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import '@affine/core/bootstrap/electron'; | ||
|
||
import { getElectronAPIs } from '@affine/electron-api/web-worker'; | ||
import { bindNativeDBApis } from '@affine/nbstore/sqlite'; | ||
import { | ||
WorkerConsumer, | ||
type WorkerOps, | ||
} from '@affine/nbstore/worker/consumer'; | ||
import { type MessageCommunicapable, OpConsumer } from '@toeverything/infra/op'; | ||
|
||
const electronAPIs = getElectronAPIs(); | ||
|
||
bindNativeDBApis(electronAPIs.nbstore); | ||
|
||
const consumer = new OpConsumer<WorkerOps>(globalThis as MessageCommunicapable); | ||
|
||
new WorkerConsumer(consumer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import '@affine/core/bootstrap/browser'; | ||
|
||
import { bindNativeDBApis, type NativeDBApis } from '@affine/nbstore/sqlite'; | ||
import { | ||
WorkerConsumer, | ||
type WorkerOps, | ||
} from '@affine/nbstore/worker/consumer'; | ||
import { type MessageCommunicapable, OpConsumer } from '@toeverything/infra/op'; | ||
import { AsyncCall } from 'async-call-rpc'; | ||
|
||
globalThis.addEventListener('message', e => { | ||
if (e.data.type === 'native-db-api-channel') { | ||
const port = e.ports[0] as MessagePort; | ||
const rpc = AsyncCall<NativeDBApis>( | ||
{}, | ||
{ | ||
channel: { | ||
on(listener) { | ||
const f = (e: MessageEvent<any>) => { | ||
listener(e.data); | ||
}; | ||
port.addEventListener('message', f); | ||
return () => { | ||
port.removeEventListener('message', f); | ||
}; | ||
}, | ||
send(data) { | ||
port.postMessage(data); | ||
}, | ||
}, | ||
} | ||
); | ||
bindNativeDBApis(rpc); | ||
port.start(); | ||
} | ||
}); | ||
|
||
const consumer = new OpConsumer<WorkerOps>(globalThis as MessageCommunicapable); | ||
|
||
new WorkerConsumer(consumer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import '@affine/core/bootstrap/browser'; | ||
|
||
import { | ||
WorkerConsumer, | ||
type WorkerOps, | ||
} from '@affine/nbstore/worker/consumer'; | ||
import { type MessageCommunicapable, OpConsumer } from '@toeverything/infra/op'; | ||
|
||
const consumer = new OpConsumer<WorkerOps>(globalThis as MessageCommunicapable); | ||
|
||
new WorkerConsumer(consumer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import '@affine/core/bootstrap/browser'; | ||
|
||
import { | ||
WorkerConsumer, | ||
type WorkerOps, | ||
} from '@affine/nbstore/worker/consumer'; | ||
import { type MessageCommunicapable, OpConsumer } from '@toeverything/infra/op'; | ||
|
||
const consumer = new OpConsumer<WorkerOps>(globalThis as MessageCommunicapable); | ||
|
||
new WorkerConsumer(consumer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
import { polyfillDispose } from './dispose'; | ||
import { polyfillIteratorHelpers } from './iterator-helpers'; | ||
import { polyfillPromise } from './promise-with-resolvers'; | ||
import './dispose'; | ||
import './iterator-helpers'; | ||
import './promise-with-resolvers'; | ||
|
||
import { polyfillEventLoop } from './request-idle-callback'; | ||
import { polyfillResizeObserver } from './resize-observer'; | ||
|
||
polyfillResizeObserver(); | ||
polyfillEventLoop(); | ||
await polyfillPromise(); | ||
await polyfillDispose(); | ||
await polyfillIteratorHelpers(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,2 @@ | ||
export async function polyfillDispose() { | ||
if (typeof Symbol.dispose !== 'symbol') { | ||
// @ts-expect-error ignore | ||
await import('core-js/modules/esnext.symbol.async-dispose'); | ||
// @ts-expect-error ignore | ||
await import('core-js/modules/esnext.symbol.dispose'); | ||
} | ||
} | ||
import 'core-js/modules/esnext.symbol.async-dispose'; | ||
import 'core-js/modules/esnext.symbol.dispose'; |
8 changes: 1 addition & 7 deletions
8
packages/frontend/core/src/bootstrap/polyfill/iterator-helpers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
export async function polyfillIteratorHelpers() { | ||
if (typeof globalThis['Iterator'] !== 'function') { | ||
// @ts-expect-error ignore | ||
// https://github.com/zloirock/core-js/blob/master/packages/core-js/proposals/iterator-helpers-stage-3.js | ||
await import('core-js/proposals/iterator-helpers-stage-3'); | ||
} | ||
} | ||
import 'core-js/proposals/iterator-helpers-stage-3'; |
7 changes: 1 addition & 6 deletions
7
packages/frontend/core/src/bootstrap/polyfill/promise-with-resolvers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
export async function polyfillPromise() { | ||
if (typeof Promise.withResolvers !== 'function') { | ||
// @ts-expect-error ignore | ||
await import('core-js/features/promise/with-resolvers'); | ||
} | ||
} | ||
import 'core-js/features/promise/with-resolvers'; |
Oops, something went wrong.