mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 10:52:40 +08:00
fix(editor): type import in vite worker env (#10856)
The dependencies of `@blocksuite/affine-gfx-turbo-renderer` in work is now all type imports.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import {
|
||||
type BlockLayout,
|
||||
type BlockLayoutPainter,
|
||||
BlockLayoutPainterExtension,
|
||||
type TextRect,
|
||||
type WorkerToHostMessage,
|
||||
import type {
|
||||
BlockLayout,
|
||||
BlockLayoutPainter,
|
||||
TextRect,
|
||||
WorkerToHostMessage,
|
||||
} from '@blocksuite/affine-gfx-turbo-renderer';
|
||||
import { BlockLayoutPainterExtension } from '@blocksuite/affine-gfx-turbo-renderer/painter';
|
||||
|
||||
interface SentenceLayout {
|
||||
text: string;
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import { createIdentifier } from '@blocksuite/global/di';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
|
||||
import type { BlockLayoutPainter } from '../types';
|
||||
|
||||
export const BlockPainterProvider = createIdentifier<BlockLayoutPainter>(
|
||||
'block-painter-provider'
|
||||
);
|
||||
|
||||
export const BlockLayoutPainterExtension = (
|
||||
type: string,
|
||||
painter: new () => BlockLayoutPainter
|
||||
): ExtensionType => {
|
||||
return {
|
||||
setup: di => {
|
||||
di.addImpl(BlockPainterProvider(type), painter);
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -1,4 +1,3 @@
|
||||
export * from './extension';
|
||||
export * from './layout/block-layout-provider';
|
||||
export * from './painter/painter.worker';
|
||||
export * from './text-utils';
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { Container, type ServiceProvider } from '@blocksuite/global/di';
|
||||
import {
|
||||
Container,
|
||||
createIdentifier,
|
||||
type ServiceProvider,
|
||||
} from '@blocksuite/global/di';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
|
||||
import { BlockPainterProvider } from '../extension';
|
||||
import type {
|
||||
BlockLayoutPainter,
|
||||
HostToWorkerMessage,
|
||||
@@ -9,6 +12,21 @@ import type {
|
||||
WorkerToHostMessage,
|
||||
} from '../types';
|
||||
|
||||
export const BlockPainterProvider = createIdentifier<BlockLayoutPainter>(
|
||||
'block-painter-provider'
|
||||
);
|
||||
|
||||
export const BlockLayoutPainterExtension = (
|
||||
type: string,
|
||||
painter: new () => BlockLayoutPainter
|
||||
): ExtensionType => {
|
||||
return {
|
||||
setup: di => {
|
||||
di.addImpl(BlockPainterProvider(type), painter);
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export class ViewportLayoutPainter {
|
||||
private readonly canvas: OffscreenCanvas = new OffscreenCanvas(0, 0);
|
||||
private ctx: OffscreenCanvasRenderingContext2D | null = null;
|
||||
|
||||
Reference in New Issue
Block a user