Skip to content

Commit

Permalink
chore: 清理依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
KonghaYao committed May 31, 2024
1 parent 1771a27 commit 9118ec4
Show file tree
Hide file tree
Showing 8 changed files with 4,357 additions and 3,529 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 中文 Web Font 切割工具
# 中文 Web Font 切割工具 cn-font-split

![updateTime](https://img.shields.io/badge/更新时间-2024/03/23-green)
![author](https://img.shields.io/badge/author-江夏尧-green)
Expand All @@ -7,7 +7,7 @@

![CodeFactor](https://www.codefactor.io/repository/github/konghayao/cn-font-split/badge)
![NPM License](https://img.shields.io/npm/l/%40konghayao%2Fcn-font-split)
| [中文网字计划](https://chinese-font.netlify.app/) | [Github](https://github.com/KonghaYao/cn-font-split) | [在线使用](https://chinese-font.netlify.app/online-split/)|
| [中文网字计划](https://chinese-font.netlify.app/) | [Github](https://github.com/KonghaYao/cn-font-split) | [在线使用 Online](https://chinese-font.netlify.app/online-split/)|
| ------------------------------------------------- | ---------------------------------------------------- |---------------------------------------------------- |

## 简介
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"prettier": "3.0.3",
"vite": "^5.0.13",
"vite-plugin-solid": "^2.10.2",
"rollup": "3.29.4",
"rollup": "^4.18.0",
"rollup-plugin-analyzer": "^4.0.0",
"typescript": "^5.2.2"
}
Expand Down
38 changes: 22 additions & 16 deletions packages/edge-provider/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@ Assets.pathTransform = (innerPath) =>
'./',
'https://cdn.jsdelivr.net/npm/@konghayao/cn-font-split/dist/browser/',
);


const UA =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36';
const kv = await Deno.openKv();
const app = new Application();
const router = new Router();

// 上传文件并存储
router.post('/upload', async (ctx) => {
const buffer = await ctx.request.body.arrayBuffer();
const name = ctx.request.headers.get('filename');
const hash = new Md5('md5').update(buffer).toString();
console.log(hash);
const cacheURL = await kv.get([hash]);
console.log(cacheURL);
// console.log(hash);
const cacheURL = await kv.get(["files", hash]);
// console.log(cacheURL);
if (cacheURL.value) {
ctx.response.body = JSON.stringify({
code: 50,
Expand All @@ -32,7 +35,7 @@ router.post('/upload', async (ctx) => {
});
} else {
const url = await upload(new Blob([buffer]), name, hash);
await kv.set([hash], url);
await kv.set(["files", hash], url);
ctx.response.body = JSON.stringify({
code: 0,
data: { name, hash, url },
Expand All @@ -41,7 +44,7 @@ router.post('/upload', async (ctx) => {
});
// kv.set(["f7ee05dd168d7623046d621c8193c336" ], "https://we.tl/t-eCzYb8ZH3m")
const downloadFromKV = async (hash) => {
const url = (await kv.get([hash])).value;
const url = (await kv.get(['files', hash])).value;
if (url) {
return download(url);
} else {
Expand Down Expand Up @@ -83,6 +86,9 @@ router.get('/split', async (ctx) => {
app.use(router.routes());
console.log('Server listening on http://localhost:8000');
await app.listen({ port: 8000 });



/**
* download file from shortend_url
* @param {*} shortened_url
Expand All @@ -104,7 +110,7 @@ async function download(shortened_url) {
},
).then((res) => res.json());
});
console.log(res.direct_link);
// console.log(res.direct_link);
return fetch(res.direct_link);
}
/**
Expand Down Expand Up @@ -156,9 +162,9 @@ async function upload(file, filename, hash) {
},
).then((res) => res.json());
let authorization = transfer.storm_upload_token;
console.log('transfer', transfer);
// console.log('transfer', transfer);
const urls = JSON.parse(atob(authorization.split('.')[1]));
console.log('checked', urls);
// console.log('checked', urls);
authorization = 'Bearer ' + authorization;
await fetch(urls['storm.preflight_batch_url'], {
headers: {
Expand Down Expand Up @@ -194,12 +200,12 @@ async function upload(file, filename, hash) {
credentials: 'include',
}).then(async (res) => {
if (res.status !== 200) {
console.log(await res.text());
// console.log(await res.text());
throw new Error('preflict');
}
return res.blob();
});
console.log('preflict');
// console.log('preflict');
const blocks = await fetch(urls['storm.announce_blocks_url'], {
headers: {
accept: 'application/json',
Expand All @@ -226,7 +232,7 @@ async function upload(file, filename, hash) {
credentials: 'include',
}).then((res) => res.json());
const url = blocks.data.blocks[0].presigned_put_url;
console.log('got upload server url');
// console.log('got upload server url');
await fetch(url, {
headers: {
accept: '*/*',
Expand Down Expand Up @@ -255,7 +261,7 @@ async function upload(file, filename, hash) {
mode: 'cors',
credentials: 'omit',
}).then((res) => {
console.log(res.status);
// console.log(res.status);
if (res.status >= 300) {
throw Error('upload failed');
}
Expand All @@ -264,7 +270,7 @@ async function upload(file, filename, hash) {
await new Promise((resolve) => {
setTimeout(resolve, 3000);
});
console.log('get Callback URL');
// console.log('get Callback URL');
const result = await fetch(urls['storm.create_batch_url'], {
headers: {
accept: 'application/json',
Expand Down Expand Up @@ -298,7 +304,7 @@ async function upload(file, filename, hash) {
mode: 'cors',
credentials: 'include',
}).then((res) => res.json());
console.log(result);
// console.log(result);
const finalize = await fetch(
'https://wetransfer.com/api/v4/transfers/' + transfer.id + '/finalize',
{
Expand Down Expand Up @@ -331,7 +337,7 @@ async function upload(file, filename, hash) {
method: 'PUT',
},
).then((res) => res.json());
console.log(transfer.id);
console.log(finalize);
// console.log(transfer.id);
// console.log(finalize);
return finalize.shortened_url;
}
4 changes: 0 additions & 4 deletions packages/subsets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,13 @@
"workerpool": "^9.1.1"
},
"devDependencies": {
"@napi-rs/woff-build-wasm32-wasi": "^0.2.0",
"@rollup/plugin-terser": "^0.4.4",
"@types/byte-size": "^8.1.1",
"@types/md5": "^2.3.4",
"@types/opentype.js": "^1.3.7",
"@types/workerpool": "^6.4.5",
"@vitest/browser": "^1.6.0",
"comlink": "^4.4.1",
"live-server": "^1.2.2",
"path-browserify": "^1.0.1",
"resolve": "^1.22.8",
"vitest": "^1.6.0",
"webdriverio": "^8.20.4"
}
Expand Down
6 changes: 0 additions & 6 deletions packages/subsets/rollup.config.browser.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import analyze from 'rollup-plugin-analyzer';
import common from '@rollup/plugin-commonjs';
import fse from 'fs-extra';
import resolve from '@rollup/plugin-node-resolve';
Expand Down Expand Up @@ -72,10 +71,5 @@ export default {
preferBuiltins: true,
}),

analyze({
summaryOnly: true,
writeTo: (str) =>
fse.outputFileSync('dist/browser/index.analyze.txt', str),
}),
],
};
5 changes: 0 additions & 5 deletions packages/subsets/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import analyze from 'rollup-plugin-analyzer';
import fse from 'fs-extra';
import resolve from '@rollup/plugin-node-resolve';
import condition from '@forsee/rollup-plugin-conditional';
Expand All @@ -23,9 +22,5 @@ export default {
extensions: ['.ts', '.html'],
moduleDirectories: [],
}),
analyze({
summaryOnly: true,
writeTo: (str) => fse.outputFileSync('dist/index.analyze.txt', str),
}),
],
};
20 changes: 1 addition & 19 deletions packages/subsets/src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,7 @@ declare module 'omt:*' {
declare module 'https://deno.land/[email protected]/node/url.ts' {
export * from 'node:url';
}
declare module 'comlink/dist/esm/node-adapter.mjs' {
import { Endpoint } from 'comlink/dist/esm/protocol';
import { tinf_uncompress as inflate } from '@konghayao/opentype.js/src/[email protected]';
export interface NodeEndpoint {
postMessage(message: any, transfer?: any[]): void;
on(
type: string,
listener: EventListenerOrEventListenerObject,
options?: {},
): void;
off(
type: string,
listener: EventListenerOrEventListenerObject,
options?: {},
): void;
start?: () => void;
}
export default function nodeEndpoint(nep: NodeEndpoint): Endpoint;
}

declare module '@konghayao/opentype.js' {
export * from '@types/opentype.js';
}
Expand Down
Loading

0 comments on commit 9118ec4

Please sign in to comment.