mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-01 09:30:01 +08:00
refactor(editor): add gfx entry in bs global package (#10612)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { IS_IPAD } from '@blocksuite/global/env';
|
||||
import { nextTick, Vec } from '@blocksuite/global/utils';
|
||||
import { Vec } from '@blocksuite/global/gfx';
|
||||
import { nextTick } from '@blocksuite/global/utils';
|
||||
|
||||
import { UIEventState, UIEventStateContext } from '../base.js';
|
||||
import type { UIEventDispatcher } from '../dispatcher.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { IPoint } from '@blocksuite/global/utils';
|
||||
import type { IPoint } from '@blocksuite/global/gfx';
|
||||
|
||||
export function isFarEnough(a: IPoint, b: IPoint) {
|
||||
const dx = a.x - b.x;
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import {
|
||||
assertType,
|
||||
Bound,
|
||||
DisposableGroup,
|
||||
getCommonBound,
|
||||
getCommonBoundWithRotation,
|
||||
type IBound,
|
||||
last,
|
||||
} from '@blocksuite/global/utils';
|
||||
} from '@blocksuite/global/gfx';
|
||||
import { assertType, DisposableGroup, last } from '@blocksuite/global/utils';
|
||||
import type { BlockModel } from '@blocksuite/store';
|
||||
import { Signal } from '@preact/signals-core';
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { IBound } from '@blocksuite/global/utils';
|
||||
import type { IBound } from '@blocksuite/global/gfx';
|
||||
import {
|
||||
Bound,
|
||||
getBoundWithRotation,
|
||||
intersects,
|
||||
} from '@blocksuite/global/utils';
|
||||
} from '@blocksuite/global/gfx';
|
||||
import type { BlockModel, Store } from '@blocksuite/store';
|
||||
|
||||
import { compare } from '../utils/layer.js';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Bound } from '@blocksuite/global/gfx';
|
||||
import {
|
||||
assertType,
|
||||
Bound,
|
||||
DisposableGroup,
|
||||
last,
|
||||
Slot,
|
||||
|
||||
@@ -5,7 +5,7 @@ import type {
|
||||
PointLocation,
|
||||
SerializedXYWH,
|
||||
XYWH,
|
||||
} from '@blocksuite/global/utils';
|
||||
} from '@blocksuite/global/gfx';
|
||||
|
||||
import type { EditorHost } from '../../view/element/lit-host.js';
|
||||
import type { GfxGroupModel, GfxModel } from './model.js';
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import type {
|
||||
Constructor,
|
||||
IVec,
|
||||
SerializedXYWH,
|
||||
XYWH,
|
||||
} from '@blocksuite/global/utils';
|
||||
import type { IVec, SerializedXYWH, XYWH } from '@blocksuite/global/gfx';
|
||||
import {
|
||||
Bound,
|
||||
deserializeXYWH,
|
||||
@@ -15,7 +10,8 @@ import {
|
||||
polygonGetPointTangent,
|
||||
polygonNearestPoint,
|
||||
rotatePoints,
|
||||
} from '@blocksuite/global/utils';
|
||||
} from '@blocksuite/global/gfx';
|
||||
import type { Constructor } from '@blocksuite/global/utils';
|
||||
import { BlockModel } from '@blocksuite/store';
|
||||
|
||||
import {
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import {
|
||||
Bound,
|
||||
deserializeXYWH,
|
||||
DisposableGroup,
|
||||
getBoundWithRotation,
|
||||
getPointsFromBoundWithRotation,
|
||||
isEqual,
|
||||
type IVec,
|
||||
linePolygonIntersects,
|
||||
PointLocation,
|
||||
@@ -13,9 +11,9 @@ import {
|
||||
randomSeed,
|
||||
rotatePoints,
|
||||
type SerializedXYWH,
|
||||
Slot,
|
||||
type XYWH,
|
||||
} from '@blocksuite/global/utils';
|
||||
} from '@blocksuite/global/gfx';
|
||||
import { DisposableGroup, isEqual, Slot } from '@blocksuite/global/utils';
|
||||
import { createMutex } from 'lib0/mutex';
|
||||
import * as Y from 'yjs';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { IVec, SerializedXYWH, XYWH } from '@blocksuite/global/utils';
|
||||
import type { IVec, SerializedXYWH, XYWH } from '@blocksuite/global/gfx';
|
||||
import {
|
||||
Bound,
|
||||
deserializeXYWH,
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
polygonGetPointTangent,
|
||||
polygonNearestPoint,
|
||||
rotatePoints,
|
||||
} from '@blocksuite/global/utils';
|
||||
} from '@blocksuite/global/gfx';
|
||||
import { mutex } from 'lib0';
|
||||
|
||||
import type { EditorHost } from '../../../view/index.js';
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import {
|
||||
getCommonBoundWithRotation,
|
||||
type IPoint,
|
||||
} from '@blocksuite/global/gfx';
|
||||
import {
|
||||
assertType,
|
||||
DisposableGroup,
|
||||
getCommonBoundWithRotation,
|
||||
groupBy,
|
||||
type IPoint,
|
||||
Slot,
|
||||
} from '@blocksuite/global/utils';
|
||||
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
import type { ServiceIdentifier } from '@blocksuite/global/di';
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import {
|
||||
DisposableGroup,
|
||||
type IBound,
|
||||
type IPoint,
|
||||
Slot,
|
||||
} from '@blocksuite/global/utils';
|
||||
import type { IBound, IPoint } from '@blocksuite/global/gfx';
|
||||
import { DisposableGroup, Slot } from '@blocksuite/global/utils';
|
||||
import { Signal } from '@preact/signals-core';
|
||||
|
||||
import type { PointerEventState } from '../../event/index.js';
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { type Container, createIdentifier } from '@blocksuite/global/di';
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import {
|
||||
type Bound,
|
||||
DisposableGroup,
|
||||
type IVec,
|
||||
} from '@blocksuite/global/utils';
|
||||
import type { Bound, IVec } from '@blocksuite/global/gfx';
|
||||
import { DisposableGroup } from '@blocksuite/global/utils';
|
||||
import type { Extension } from '@blocksuite/store';
|
||||
|
||||
import type { PointerEventState } from '../../event/index.js';
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import {
|
||||
Bound,
|
||||
clamp,
|
||||
debounce,
|
||||
type IPoint,
|
||||
type IVec,
|
||||
Slot,
|
||||
Vec,
|
||||
} from '@blocksuite/global/utils';
|
||||
} from '@blocksuite/global/gfx';
|
||||
import { debounce, Slot } from '@blocksuite/global/utils';
|
||||
import { signal } from '@preact/signals-core';
|
||||
|
||||
import type { GfxViewportElement } from '.';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import { Bound } from '@blocksuite/global/utils';
|
||||
import { Bound } from '@blocksuite/global/gfx';
|
||||
import { computed } from '@preact/signals-core';
|
||||
import { nothing } from 'lit';
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
"./env": "./src/env/index.ts",
|
||||
"./exceptions": "./src/exceptions/index.ts",
|
||||
"./di": "./src/di/index.ts",
|
||||
"./types": "./src/types/index.ts"
|
||||
"./types": "./src/types/index.ts",
|
||||
"./gfx": "./src/gfx/index.ts"
|
||||
},
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
@@ -30,6 +31,12 @@
|
||||
],
|
||||
"di": [
|
||||
"dist/di/index.d.ts"
|
||||
],
|
||||
"types": [
|
||||
"dist/types/index.d.ts"
|
||||
],
|
||||
"gfx": [
|
||||
"dist/gfx/index.d.ts"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
+1
-3
@@ -1,5 +1,4 @@
|
||||
// control coords are not relative to start or end
|
||||
import { assertExists } from './assert.js';
|
||||
import { CURVETIME_EPSILON, isZero } from './math.js';
|
||||
import { Bound, type IVec, PointLocation, Vec } from './model/index.js';
|
||||
|
||||
@@ -111,7 +110,7 @@ export function getBezierNearestTime(
|
||||
function refine(t: number) {
|
||||
if (t >= 0 && t <= 1) {
|
||||
const tmpPoint = getBezierPoint(values, t);
|
||||
assertExists(tmpPoint);
|
||||
if (!tmpPoint) return false;
|
||||
const dist = Vec.dist2(point, tmpPoint);
|
||||
if (dist < minDist) {
|
||||
minDist = dist;
|
||||
@@ -137,7 +136,6 @@ export function getBezierNearestPoint(
|
||||
) {
|
||||
const t = getBezierNearestTime(values, point);
|
||||
const pointOnCurve = getBezierPoint(values, t);
|
||||
assertExists(pointOnCurve);
|
||||
return pointOnCurve;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
export * from './bound.js';
|
||||
export * from './curve.js';
|
||||
export * from './math.js';
|
||||
export * from './model/index.js';
|
||||
export * from './perfect-freehand/index.js';
|
||||
export * from './polyline.js';
|
||||
export * from './xywh.js';
|
||||
@@ -1,18 +1,10 @@
|
||||
export * from './assert.js';
|
||||
export * from './bound.js';
|
||||
export * from './crypto.js';
|
||||
export * from './curve.js';
|
||||
export * from './disposable.js';
|
||||
export * from './function.js';
|
||||
export * from './iterable.js';
|
||||
export * from './logger.js';
|
||||
export * from './math.js';
|
||||
export * from './model/index.js';
|
||||
export * from './perfect-freehand/index.js';
|
||||
export * from './polyline.js';
|
||||
export * from './signal-watcher.js';
|
||||
export * from './slot.js';
|
||||
export * from './types.js';
|
||||
export * from './with-disposable.js';
|
||||
export type { SerializedXYWH, XYWH } from './xywh.js';
|
||||
export { deserializeXYWH, serializeXYWH } from './xywh.js';
|
||||
|
||||
Reference in New Issue
Block a user