Files
AFFiNE-Mirror/blocksuite/integration-test/src/__tests__/utils/renderer-entry.ts
doodlewind be9f44fc4f fix(editor): worker loading in webpack env (#10832)
### 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.
2025-03-14 05:26:57 +00:00

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();