From 8ed9d03cdca233cfc2ff743a648378f99d0065a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B1=A1=E6=95=B0?= Date: Thu, 9 Jan 2025 22:57:32 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E7=89=88=E6=9C=AC=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 +- .../core/src/services/asset/FontService.ts | 4 + packages/utils/src/color.ts | 1 + site/.dumi/theme/plugin.ts | 106 ------------------ site/package.json | 1 + 5 files changed, 9 insertions(+), 107 deletions(-) delete mode 100644 site/.dumi/theme/plugin.ts diff --git a/package.json b/package.json index 9e88de448f..2aa525558e 100644 --- a/package.json +++ b/package.json @@ -79,6 +79,7 @@ "@commitlint/cli": "^19.2.1", "@commitlint/config-conventional": "^19.1.0", "@types/jest": "^29.5.1", + "@types/lodash": "^4.17.14", "@types/offscreencanvas": "^2019.7.0", "@types/pixelmatch": "^5.2.5", "@types/pngjs": "^6.0.3", @@ -87,7 +88,7 @@ "babel-plugin-transform-import-css-l7": "^0.0.6", "case-police": "^0.6.1", "cross-env": "^7.0.2", - "eslint": "^8.54.0", + "eslint": "^9.17.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-jest": "^27.9.0", "eslint-plugin-jsx-a11y": "^6.8.0", @@ -117,6 +118,7 @@ "stylelint": "^16.3.0", "stylelint-config-standard": "^36.0.0", "stylelint-declaration-block-no-ignored-properties": "^2.8.0", + "swr": "^2.2.5", "terminate": "latest", "ts-jest": "^29.1.1", "ts-node": "^10.9.2", diff --git a/packages/core/src/services/asset/FontService.ts b/packages/core/src/services/asset/FontService.ts index 421aa91e18..b16a1fcf5a 100644 --- a/packages/core/src/services/asset/FontService.ts +++ b/packages/core/src/services/asset/FontService.ts @@ -241,9 +241,11 @@ export default class FontService extends EventEmitter implements IFontService { // 3. layout characters if (sdf) { + // @ts-ignore const tinySDF = new TinySDF(fontSize, buffer, radius, cutoff, fontFamily, fontWeight); // used to store distance values from tinySDF // tinySDF.size equals `fontSize + buffer * 2` + // @ts-ignore const imageData = ctx.getImageData(0, 0, tinySDF.size, tinySDF.size); for (const char of characterSet) { if (iconfont) { @@ -254,8 +256,10 @@ export default class FontService extends EventEmitter implements IFontService { const icon = String.fromCharCode(parseInt(char.replace('&#x', '').replace(';', ''), 16)); const iconData = tinySDF.draw(icon); + // @ts-ignore populateAlphaChannel(iconData, imageData); } else { + // @ts-ignore populateAlphaChannel(tinySDF.draw(char), imageData); } // populateAlphaChannel(tinySDF.draw(char), imageData); diff --git a/packages/utils/src/color.ts b/packages/utils/src/color.ts index a16960c46d..dc8e072341 100644 --- a/packages/utils/src/color.ts +++ b/packages/utils/src/color.ts @@ -1,3 +1,4 @@ +// @ts-ignore import * as d3 from 'd3-color'; import type { Context } from 'vm'; export interface IColorRamp { diff --git a/site/.dumi/theme/plugin.ts b/site/.dumi/theme/plugin.ts deleted file mode 100644 index d672ec7f44..0000000000 --- a/site/.dumi/theme/plugin.ts +++ /dev/null @@ -1,106 +0,0 @@ -import cheerio from 'cheerio'; -import type { IApi } from 'dumi'; -import fs from 'fs'; -import path from 'path'; -import readMarkdown from 'read-markdown'; - -export default (api: IApi) => { - api.describe({ - key: 'docsMeta', - config: { - schema(joi) { - return joi.string(); - }, - }, - // enableBy: api.EnableBy.config - }); - - api.modifyExportHTMLFiles(async (files: Array<{ path: string; content: string }>) => { - const newFiles = await Promise.all( - files.map(async (file) => { - const pathItems = file.path.split('/'); - const prefix = pathItems[0]; - let pathstr = file.path; - // API/Tutorial - if ((prefix === 'en' || prefix === 'zh') && pathItems[1] !== 'examples') { - pathstr = - '../../docs/' + file.path.substring(3).replace(/\/index\.html/, `.${prefix}.md`); - } - - if (pathItems[0] === 'api' || pathItems[0] === 'tutorial') { - pathstr = '../../docs/' + file.path.replace(/\/index.html/, '.zh.md'); - } - - if (pathItems[0] === 'common') { - pathstr = '../../docs/' + file.path.replace(/\/index.html/, '.md'); - } - - // Examples - if ((prefix === 'en' || prefix === 'zh') && pathItems[1] === 'examples') { - pathstr = '../../' + pathItems.slice(1).join('/').replace(/html/, `${prefix}.md`); - } - if (pathItems[0] === 'examples') { - pathstr = '../../' + pathItems.join('/').replace(/\.html/, '.zh.md'); - } - - // custom - - if (pathItems[0] === 'custom') { - pathstr = '../../' + file.path.replace(/\/index.html/, '.md'); - } - - // const md = `./docs/${pathstr}`; - const md = path.resolve(__dirname, pathstr); - - const keywords: string[] = []; - - // 提取demo 关键字 - if (pathItems[0] === 'examples' || pathItems[1] === 'examples') { - const metaPath = md.split('/').slice(0, -1).join('/') + '/demo/meta.json'; - if (fs.existsSync(metaPath)) { - const metas = JSON.parse(fs.readFileSync(metaPath, 'utf-8')); - - keywords.push( - ...metas.demos.map((demo: any) => { - return demo.title.zh ? demo.title.zh : demo.title; - }), - ); - } - } - - if (fs.existsSync(md)) { - const str = await readMarkdown(md); - const mdData = str[md].data || {}; - const { title, description } = mdData; - const $ = cheerio.load(file.content); - - if (description) { - $('head').append(``); - $('head').append(` 0) { - $('head').append(``); - } - if (title) { - const main = $('title').text(); - const newTitle = `${title} | ${main}`; - $('head').append(``); - $('title').text(newTitle); - } - - file.content = $.html(); - } else { - console.log('no file', md, file.path); - } - - return file; - }), - ); - return newFiles; - }); -}; diff --git a/site/package.json b/site/package.json index 5d43fb40f1..27de503dbd 100644 --- a/site/package.json +++ b/site/package.json @@ -55,6 +55,7 @@ "geojson2svg": "^1.3.3", "geotiff": "^2.0.7", "lerc": "^3.0.0", + "swr": "^2.3.0", "lodash-es": "^4.17.21", "pbf": "^3.2.1", "pmtiles": "^2.7.2",