fix: fix idraw dts issue

This commit is contained in:
chenshenhai 2024-06-09 22:59:47 +08:00
parent 0a61e8e404
commit e80e033054
2 changed files with 22 additions and 3 deletions

View file

@ -284,9 +284,10 @@ export class iDraw {
store.destroy();
}
getViewCenter() {
getViewCenter(): PointSize {
const { viewScaleInfo, viewSizeInfo } = this.getViewInfo();
return calcViewCenter({ viewScaleInfo, viewSizeInfo });
const pointSize: PointSize = calcViewCenter({ viewScaleInfo, viewSizeInfo });
return pointSize;
}
$onBoardWatcherEvents() {

View file

@ -2,6 +2,7 @@ import ts from 'typescript';
import { Project } from 'ts-morph';
import type { CompilerOptions } from 'ts-morph';
import path from 'path';
import fs from 'fs';
import * as glob from 'glob';
import { packages } from './config';
import { joinPackagePath } from './util/project';
@ -18,10 +19,28 @@ async function build() {
console.log(`Remove packages/${dirName}/dist/`);
removeFullDir(`${pkgDir}/dist`);
buildPackage(dirName);
checkPackageDts(dirName);
console.log(`Build ESM of ${dirName} successfully!`);
}
}
function checkPackageDts(dirName: string) {
console.log(`Checking dts files for ${dirName} ...`);
const pattern = '**/*.js';
const cwd = joinPackagePath(dirName, 'dist');
const files = glob.sync(pattern, { cwd });
for (let i = 0; i < files.length; i++) {
const jsFilePath = files[i];
const dtsFilePath = jsFilePath.replace(/.js$/, '.d.ts');
const dtsAbsolutePath = path.join(cwd, dtsFilePath);
if (!(fs.existsSync(dtsAbsolutePath) && fs.statSync(dtsAbsolutePath).isFile())) {
throw Error(`ERROR: lack ${dirName}/dist/${dtsFilePath} `);
}
}
console.log(`Check dts files of ${dirName} successfully!`);
}
function buildPackage(dirName: string) {
const pattern = '**/*.ts';
const cwd = joinPackagePath(dirName, 'src');
@ -37,7 +56,6 @@ function buildPackage(dirName: string) {
// const compilerOptions = tsConfig.compilerOptions;
const compilerOptions: CompilerOptions = {
noUnusedLocals: true,
declaration: true,
sourceMap: false,
target: ts.ScriptTarget.ES2015,