diff --git a/src/global.ts b/global.d.ts similarity index 90% rename from src/global.ts rename to global.d.ts index 6cc2969..90a0beb 100644 --- a/src/global.ts +++ b/global.d.ts @@ -1,14 +1,14 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ declare namespace GlobalMixins { - type JlCanvasType = import('./app').IJlCanvas; - type CanvasProperties = import('./app').ICanvasProperties; - type GraphicApp = import('./app').IGraphicApp; - type JlGraphicType = import('./core').JlGraphic; - type GraphicData = import('./core').GraphicData; - type GraphicState = import('./core').GraphicState; - type GraphicTransform = import('./core').GraphicTransform; - type GraphicTransformEvent = import('./plugins').GraphicTransformEvent; - type BoundsGraphic = import('./plugins').BoundsGraphic; + type JlCanvasType = import('./src/app').IJlCanvas; + type CanvasProperties = import('./src/app').ICanvasProperties; + type GraphicApp = import('./src/app').IGraphicApp; + type JlGraphicType = import('./src/core').JlGraphic; + type GraphicData = import('./src/core').GraphicData; + type GraphicState = import('./src/core').GraphicState; + type GraphicTransform = import('./src/core').GraphicTransform; + type GraphicTransformEvent = import('./src/plugins').GraphicTransformEvent; + type BoundsGraphic = import('./src/plugins').BoundsGraphic; type IPointDataType = import('pixi.js').IPointData; type PointType = import('pixi.js').Point; type FederatedMouseEvent = import('pixi.js').FederatedMouseEvent; diff --git a/lib/global.d.ts b/lib/global.d.ts deleted file mode 100644 index 8d901f0..0000000 --- a/lib/global.d.ts +++ /dev/null @@ -1,143 +0,0 @@ -declare namespace GlobalMixins { - type JlCanvasType = import('./app').IJlCanvas; - type CanvasProperties = import('./app').ICanvasProperties; - type GraphicApp = import('./app').IGraphicApp; - type JlGraphicType = import('./core').JlGraphic; - type GraphicData = import('./core').GraphicData; - type GraphicState = import('./core').GraphicState; - type GraphicTransform = import('./core').GraphicTransform; - type GraphicTransformEvent = import('./plugins').GraphicTransformEvent; - type BoundsGraphic = import('./plugins').BoundsGraphic; - type IPointDataType = import('pixi.js').IPointData; - type PointType = import('pixi.js').Point; - type FederatedMouseEvent = import('pixi.js').FederatedMouseEvent; - type DisplayObjectType = import('pixi.js').DisplayObject; - type ContainerType = import('pixi.js').Container; - interface DisplayObjectEvents { - 'enter-absorbable-area': [number | undefined, number | undefined]; - 'out-absorbable-area': [number | undefined, number | undefined]; - dataupdate: [newVal: any, oldVal: any]; - stateupdate: [newVal: any, oldVal: any]; - repaint: [DisplayObjectType]; - transformstart: [e: GraphicTransformEvent]; - transforming: [e: GraphicTransformEvent]; - transformend: [e: GraphicTransformEvent]; - _rightclick: [e: FederatedMouseEvent]; - _leftclick: [e: FederatedMouseEvent]; - selected: [DisplayObjectType]; - unselected: [DisplayObjectType]; - childselected: [DisplayObjectType]; - childunselected: [DisplayObjectType]; - } - interface GraphicAppEvents { - } - interface DisplayObject { - _selectable: boolean; - _selected: boolean; - selectable: boolean; - selected: boolean; - _childEdit: boolean; - childEdit: boolean; - _transformSave: boolean; - transformSave: boolean; - _assistantAppendMap: Map | null; - assistantAppendMap: Map; - _draggable: boolean; - draggable: boolean; - _shiftStartPoint: PointType | null; - shiftStartPoint: PointType | null; - _shiftLastPoint: PointType | null; - shiftLastPoint: PointType | null; - _scalable: boolean; - scalable: boolean; - _keepAspectRatio: boolean; - keepAspectRatio: boolean; - _rotatable: boolean; - rotatable: boolean; - worldAngle: number; - /** - * 获取所有父级元素叠加缩放 - */ - getAllParentScaled(): PointType; - /** - * 获取位置在画布的坐标 - */ - getPositionOnCanvas(): PointType; - /** - * 通过画布坐标更新位置 - * @param p 画布坐标 - */ - updatePositionByCanvasPosition(p: IPointData): void; - /** - * 保存变换数据 - */ - saveTransform(): GraphicTransform; - /** - * 加载变换 - * @param transform 变换数据 - */ - loadTransform(transform: GraphicTransform): void; - isChild(obj: DisplayObject): boolean; - isParent(obj: DisplayObject): boolean; - isAssistantAppend(): boolean; - addAssistantAppend(...appends: D[]): void; - removeAssistantAppend(...appends: DisplayObjectType[]): void; - removeAssistantAppendByName(...names: string[]): void; - removeAllAssistantAppend(): void; - getAssistantAppend(name: string): D | undefined; - isGraphic(): boolean; - getGraphic(): G | null; - isGraphicChild(): boolean; - onAddToCanvas(canvas: JlCanvasType): void; - onRemoveFromCanvas(canvas: JlCanvasType): void; - isInCanvas(): boolean; - getCanvas(): JlCanvasType; - isCanvas(): boolean; - getViewport(): Viewport; - getGraphicApp(): GraphicApp; - /** - * 图形本地坐标转为画布坐标 - * @param p 图形本地坐标 - */ - localToCanvasPoint(p: IPointData): PointType; - /** - * 批量转换图形本地坐标为画布坐标 - * @param points 图形本地坐标 - */ - localToCanvasPoints(...points: IPointData[]): PointType[]; - /** - * 画布坐标转为图形本地坐标 - * @param p 画布坐标 - */ - canvasToLocalPoint(p: IPointData): PointType; - /** - * 批量转换画布坐标为图形本地坐标 - * @param points 画布坐标 - */ - canvasToLocalPoints(...points: IPointData[]): PointType[]; - /** - * 本地坐标转为屏幕坐标 - * @param p 本地坐标 - */ - localToScreenPoint(p: IPointData): PointType; - /** - * 批量转换本地坐标为屏幕坐标 - * @param points 本地坐标 - */ - localToScreenPoints(...points: IPointData[]): PointType[]; - /** - * 屏幕坐标转为本地坐标 - * @param p 屏幕坐标 - */ - screenToLocalPoint(p: IPointData): PointType; - /** - * 批量转换屏幕坐标为本地坐标 - * @param points 屏幕坐标 - */ - screenToLocalPoints(...points: IPointData[]): PointType[]; - localBoundsToCanvasPoints(): PointType[]; - } - interface Graphics { - drawBezierCurve(p1: IPointData, p2: IPointData, cp1: IPointData, cp2: IPointData, segmentsCount: number): Graphics; - } -} diff --git a/lib/index.d.ts b/lib/index.d.ts index 50cf0ef..3cc0b15 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -1,4 +1,3 @@ -/// export * as GraphicsExtras from '@pixi/graphics-extras'; export * from './app'; export * from './core'; diff --git a/package.json b/package.json index 5e66fd0..a9605f1 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,10 @@ "scripts": { "build": "rollup -c rollup.config.ts --configPlugin typescript" }, + "files": [ + "lib", + "*.d.ts" + ], "dependencies": { "@pixi/graphics-extras": "^7.3.2", "@pixi/utils": "^7.3.2", diff --git a/rollup.config.ts b/rollup.config.ts index 11ee6f1..38ff13b 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -22,7 +22,7 @@ const config: RollupOptions = { typescript({ declaration: true, declarationDir: 'lib', - include: ['src/**/*'], + include: ['src/**/*', "global.d.ts"], tsconfig: './tsconfig.json', }), ], diff --git a/src/index.ts b/src/index.ts index beb920d..3cc0b15 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,4 @@ -/// export * as GraphicsExtras from '@pixi/graphics-extras'; - export * from './app'; export * from './core'; export * from './graphic'; diff --git a/tsconfig.json b/tsconfig.json index 1f51d45..779b0f6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,6 @@ "lib": ["esnext", "dom"], "useDefineForClassFields": true }, - "include": ["src/**/*.ts", "rollup.config.ts"], + "include": ["src/**/*.ts", "rollup.config.ts", "global.d.ts"], "exclude": ["node_modules"] }