mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
### TL;DR Created dedicated worker entry points to avoid dynamic imports. ### What changed? - Painters are provided during worker initialization - Removed `ParagraphPaintConfigExtension` and the associated configuration system - Created dedicated worker entry points in both the integration test and frontend packages - Modified `ViewportLayoutPainter` to accept painters in its constructor - Updated the `TurboRendererConfig` interface to require a `painterWorkerEntry` function ### Why make this change? Webpack support. Extension objects in main thread are not available to be passed into workers. Dynamic painter path import is hard to support in webpack environment. With the [webpack-ignore](https://webpack.js.org/api/module-methods/#webpackignore) rule, there are still build errors in webpack.
29 lines
774 B
TypeScript
29 lines
774 B
TypeScript
import { ParagraphLayoutHandlerExtension } from '@blocksuite/affine/blocks/paragraph';
|
|
import {
|
|
TurboRendererConfigFactory,
|
|
ViewportTurboRendererExtension,
|
|
ViewportTurboRendererIdentifier,
|
|
} from '@blocksuite/affine/gfx/turbo-renderer';
|
|
|
|
import { addSampleNotes } from './doc-generator.js';
|
|
import { createPainterWorker, setupEditor } from './setup.js';
|
|
|
|
async function init() {
|
|
setupEditor('edgeless', [
|
|
ParagraphLayoutHandlerExtension,
|
|
TurboRendererConfigFactory({
|
|
painterWorkerEntry: createPainterWorker,
|
|
}),
|
|
ViewportTurboRendererExtension,
|
|
]);
|
|
addSampleNotes(doc, 100);
|
|
doc.load();
|
|
|
|
const renderer = editor.std.get(
|
|
ViewportTurboRendererIdentifier
|
|
) as ViewportTurboRendererExtension;
|
|
window.renderer = renderer;
|
|
}
|
|
|
|
init();
|