Skip to content

Commit

Permalink
Merge pull request #326 from idrawjs/dev-v0.4
Browse files Browse the repository at this point in the history
fix: fix idraw dts issue
  • Loading branch information
chenshenhai authored Jun 9, 2024
2 parents f94f090 + ee87f3c commit af42725
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 44 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": false,
"version": "0.4.0-beta.27",
"version": "0.4.0-beta.28",
"workspaces": [
"packages/*"
],
Expand Down
8 changes: 4 additions & 4 deletions packages/board/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@idraw/board",
"version": "0.4.0-beta.27",
"version": "0.4.0-beta.28",
"description": "",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand All @@ -21,12 +21,12 @@
"author": "chenshenhai",
"license": "MIT",
"devDependencies": {
"@idraw/types": "workspace:^0.4.0-beta.27"
"@idraw/types": "workspace:^0.4.0-beta.28"
},
"dependencies": {},
"peerDependencies": {
"@idraw/util": "workspace:^0.4.0-beta.27",
"@idraw/renderer": "workspace:^0.4.0-beta.27"
"@idraw/util": "workspace:^0.4.0-beta.28",
"@idraw/renderer": "workspace:^0.4.0-beta.28"
},
"publishConfig": {
"access": "public",
Expand Down
10 changes: 5 additions & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@idraw/core",
"version": "0.4.0-beta.27",
"version": "0.4.0-beta.28",
"description": "",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand All @@ -21,13 +21,13 @@
"author": "chenshenhai",
"license": "MIT",
"devDependencies": {
"@idraw/types": "workspace:^0.4.0-beta.27"
"@idraw/types": "workspace:^0.4.0-beta.28"
},
"dependencies": {},
"peerDependencies": {
"@idraw/board": "workspace:^0.4.0-beta.27",
"@idraw/renderer": "workspace:^0.4.0-beta.27",
"@idraw/util": "workspace:^0.4.0-beta.27"
"@idraw/board": "workspace:^0.4.0-beta.28",
"@idraw/renderer": "workspace:^0.4.0-beta.28",
"@idraw/util": "workspace:^0.4.0-beta.28"
},
"publishConfig": {
"access": "public",
Expand Down
8 changes: 4 additions & 4 deletions packages/figma/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@idraw/figma",
"version": "0.4.0-beta.27",
"version": "0.4.0-beta.28",
"description": "",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand All @@ -11,16 +11,16 @@
"dist/**/*.js"
],
"dependencies": {
"@idraw/types": "workspace:^0.4.0-beta.27",
"@idraw/util": "workspace:^0.4.0-beta.27",
"@idraw/types": "workspace:^0.4.0-beta.28",
"@idraw/util": "workspace:^0.4.0-beta.28",
"kiwi-schema": "^0.5.0",
"matrix-inverse": "^2.0.0",
"pako": "^2.1.0",
"uzip": "^0.20201231.0"
},
"devDependencies": {
"@types/pako": "^2.0.3",
"@idraw/types": "workspace:^0.4.0-beta.27"
"@idraw/types": "workspace:^0.4.0-beta.28"
},
"repository": {
"type": "git",
Expand Down
12 changes: 6 additions & 6 deletions packages/idraw/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "idraw",
"version": "0.4.0-beta.27",
"version": "0.4.0-beta.28",
"description": "",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand All @@ -22,11 +22,11 @@
"license": "MIT",
"devDependencies": {},
"dependencies": {
"@idraw/board": "workspace:^0.4.0-beta.27",
"@idraw/core": "workspace:^0.4.0-beta.27",
"@idraw/renderer": "workspace:^0.4.0-beta.27",
"@idraw/types": "workspace:^0.4.0-beta.27",
"@idraw/util": "workspace:^0.4.0-beta.27"
"@idraw/board": "workspace:^0.4.0-beta.28",
"@idraw/core": "workspace:^0.4.0-beta.28",
"@idraw/renderer": "workspace:^0.4.0-beta.28",
"@idraw/types": "workspace:^0.4.0-beta.28",
"@idraw/util": "workspace:^0.4.0-beta.28"
},
"publishConfig": {
"access": "public",
Expand Down
5 changes: 3 additions & 2 deletions packages/idraw/src/idraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions packages/renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@idraw/renderer",
"version": "0.4.0-beta.27",
"version": "0.4.0-beta.28",
"description": "",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand All @@ -21,11 +21,11 @@
"author": "chenshenhai",
"license": "MIT",
"devDependencies": {
"@idraw/types": "workspace:^0.4.0-beta.27"
"@idraw/types": "workspace:^0.4.0-beta.28"
},
"dependencies": {},
"peerDependencies": {
"@idraw/util": "workspace:^0.4.0-beta.27"
"@idraw/util": "workspace:^0.4.0-beta.28"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@idraw/types",
"version": "0.4.0-beta.27",
"version": "0.4.0-beta.28",
"description": "",
"main": "src/index.ts",
"types": "src/index.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/util/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@idraw/util",
"version": "0.4.0-beta.27",
"version": "0.4.0-beta.28",
"description": "",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
32 changes: 16 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion scripts/build-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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');
Expand All @@ -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,
Expand Down

0 comments on commit af42725

Please sign in to comment.