ts-run-test 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/dictionaries/project.xml +7 -0
- package/.idea/inspectionProfiles/Project_Default.xml +22 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/misc.xml +10 -0
- package/.idea/modules.xml +8 -0
- package/.idea/ts-run-test.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/.release-it.json +23 -0
- package/CHANGELOG.md +6 -0
- package/_test_/EventBus.ts +33 -0
- package/_test_/EventLoop.js +60 -0
- package/_test_/EventLoop.ts +85 -0
- package/_test_/IO.ts +62 -0
- package/_test_/ShengBei.html +84 -0
- package/_test_/__dirname.ts +17 -0
- package/_test_/aaaa.cjs +4 -0
- package/_test_/array.ts +26 -0
- package/_test_/async.ts +58 -0
- package/_test_/bfc.html +28 -0
- package/_test_/bin.ts +26 -0
- package/_test_/buffer.ts +21 -0
- package/_test_/build-icons/icon.ico +0 -0
- package/_test_/build-icons/icon_1024x1024.png +0 -0
- package/_test_/build-icons/icon_128x128.png +0 -0
- package/_test_/build-icons/icon_16x16.png +0 -0
- package/_test_/build-icons/icon_256x256.png +0 -0
- package/_test_/build-icons/icon_32x32.png +0 -0
- package/_test_/build-icons/icon_48x48.png +0 -0
- package/_test_/build-icons/icon_512x512.png +0 -0
- package/_test_/build-icons/icon_64x64.png +0 -0
- package/_test_/build-icons/splash/splash_100.png +0 -0
- package/_test_/build-icons/splash/splash_200.png +0 -0
- package/_test_/build-icons/tray/tray_black.png +0 -0
- package/_test_/build-icons/tray/tray_white.png +0 -0
- package/_test_/check.ts +65 -0
- package/_test_/closures.ts +12 -0
- package/_test_/copy.ts +25 -0
- package/_test_/debounce.ts +71 -0
- package/_test_/decorator.ts +37 -0
- package/_test_/deepCopy.ts +35 -0
- package/_test_/dom.ts +19 -0
- package/_test_/fetch.ts +45 -0
- package/_test_/get-template-version.ts +48 -0
- package/_test_/get.ts +52 -0
- package/_test_/gh.ts +19 -0
- package/_test_/gh_test.ts +93 -0
- package/_test_/icon.ico +0 -0
- package/_test_/icon.png +0 -0
- package/_test_/icon.ts +120 -0
- package/_test_/iconsize.ts +30 -0
- package/_test_/iterator.ts +112 -0
- package/_test_/link.ts +10 -0
- package/_test_/my/instanceof.ts +35 -0
- package/_test_/my/new.ts +22 -0
- package/_test_/new.ts +6 -0
- package/_test_/object.ts +2 -0
- package/_test_/observer.html +40 -0
- package/_test_/package.json +49 -0
- package/_test_/prototype.ts +27 -0
- package/_test_/proxy.ts +6 -0
- package/_test_/random.ts +29 -0
- package/_test_/react.ts +0 -0
- package/_test_/reg.ts +1 -0
- package/_test_/register.ts +61 -0
- package/_test_/release.config.cts +11 -0
- package/_test_/result.ts +37 -0
- package/_test_/task.ts +196 -0
- package/_test_/temp.md +8 -0
- package/_test_/tesp.ts +23 -0
- package/_test_/test.ts +59 -0
- package/_test_/typed.ts +55 -0
- package/_test_/worker.html +23 -0
- package/_test_/worker.js +4 -0
- package/_test_/worker.ts +5 -0
- package/_test_/xhr.ts +27 -0
- package/_test_//347/210/254/350/231/253.html +93 -0
- package/cache/00a25bc33880251d135060b213749534.jpg +0 -0
- package/cache/10_1730106978_t_NW.jpg +0 -0
- package/cache/11_1730104692_t_NW.jpg +0 -0
- package/cache/15_1730601804_t_NW.jpg +0 -0
- package/cache/17_1730434147_t_NW.jpg +0 -0
- package/cache/19ca581d7f9bf915d3cfb64299a9d5e0.jpg +0 -0
- package/cache/1ccf0b78ab293de8b2aa984773cf315b.jpg +0 -0
- package/cache/21a7518978f91278e75600b75390654e.jpg +0 -0
- package/cache/26ec1ad41910fa9f6236a98c8165a4f3.jpg +0 -0
- package/cache/2_1730114275_t_NW.jpg +0 -0
- package/cache/2a8542fbba235dda9d40c417a94083b5.jpg +0 -0
- package/cache/38_1730084632_t_NW.jpg +0 -0
- package/cache/45205cfc98b45aba7284124f730d37a4.jpg +0 -0
- package/cache/4_1730111766_t_NW.jpg +0 -0
- package/cache/544139e9bbc38597242c2a3d2ba9ede3.jpg +0 -0
- package/cache/60_1729079556_t_NW.jpg +0 -0
- package/cache/61_1729079251_t_NW.jpg +0 -0
- package/cache/65_1729078235_t_NW.jpg +0 -0
- package/cache/6b553b33cb2bc5423ca0a825a9596d7e.jpg +0 -0
- package/cache/74f7bbcd04af36cd224ebed548ba9f96.jpg +0 -0
- package/cache/762fa502959439d4ab1cc2f124c5fe31.jpg +0 -0
- package/cache/7_1730108771_t_NW.jpg +0 -0
- package/cache/82_1730202406_t_NW.jpg +0 -0
- package/cache/861641b72e0aa40abd4ad87c473100f6.jpg +0 -0
- package/cache/91_1730201579_t_NW.jpg +0 -0
- package/cache/95c1eceb38272ac57be2d1f14af3baa5.jpg +0 -0
- package/cache/99cae3416ed7d4ebce46003c291d5cc2.jpg +0 -0
- package/cache/9cf9878a0e979c6b9965ef415cfb43f1.jpg +0 -0
- package/cache/9e9db2fd267dc561244225efc1a872b3.jpg +0 -0
- package/cache/bc7bde2766d07dadd7fafd80854d6c5c.jpg +0 -0
- package/cache/c18d359f69c6b975604549f56237bfa8.jpg +0 -0
- package/cache/cf8143cd193619f57fc1ae06aed1ffec.jpg +0 -0
- package/cache/f3a5f2b40033da74d857c8dc0244948a.jpg +0 -0
- package/cache/f5d0336a68ec2b35eeb76706b02576bd.jpg +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +2 -0
- package/dist/ip2region.cjs +11 -0
- package/dist/ip2region.d.cts +1 -0
- package/dist/ip2region.d.ts +1 -0
- package/dist/ip2region.js +20 -0
- package/dist/npm.d.ts +1 -0
- package/dist/npm.js +3 -0
- package/dist/pkg-filed.d.ts +1 -0
- package/dist/pkg-filed.js +18 -0
- package/dist/restore-wechat-images.d.ts +1 -0
- package/dist/restore-wechat-images.js +39 -0
- package/package.json +43 -0
- package/record.md +59 -0
- package/src/copyDir.ts +21 -0
- package/src/example.png +0 -0
- package/src/formatText.ts +83 -0
- package/src/index.ts +1 -0
- package/src/ip2region.cts +13 -0
- package/src/npm.ts +5 -0
- package/src/pkg-filed.ts +30 -0
- package/src/puppeteer.ts +51 -0
- package/src/restore-wechat-images.ts +50 -0
- package/src/try.ts +9 -0
- package/src/useCrawler.ts +31 -0
- package/tsconfig.json +20 -0
- package/tsdown.config.ts +15 -0
package/_test_/test.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// import { exec } from 'node:child_process'
|
|
2
|
+
//
|
|
3
|
+
//
|
|
4
|
+
// // exec(`npm view puppeteer version`, (err, stdout) => {
|
|
5
|
+
// // console.log(err ? undefined : stdout.trim())
|
|
6
|
+
// // })
|
|
7
|
+
//
|
|
8
|
+
//
|
|
9
|
+
const execAsync = (cmd: string) => {
|
|
10
|
+
return new Promise<string | undefined>(r => {
|
|
11
|
+
exec(cmd, (err, stdout) => r(err ? undefined : stdout.trim()))
|
|
12
|
+
})
|
|
13
|
+
}
|
|
14
|
+
import { exec, spawnSync } from 'node:child_process'
|
|
15
|
+
//
|
|
16
|
+
// console.log(await execAsync('npm view puppeteer version'))
|
|
17
|
+
// console.log(55)
|
|
18
|
+
import { promisify } from 'node:util'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const execa = promisify(exec)
|
|
22
|
+
|
|
23
|
+
async function lsExample() {
|
|
24
|
+
const { stdout, stderr } = await execa('npm view puppeteer version')
|
|
25
|
+
console.log('stdout:', stdout)
|
|
26
|
+
console.error('stderr:', stderr)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
lsExample()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
export const isGitRepo = async (dir?: string) => {
|
|
33
|
+
const target = dir ? `./${ dir }` : '.'
|
|
34
|
+
const cmd = `git -C "${ target }" rev-parse --is-inside-work-tree`
|
|
35
|
+
const res = await execAsync(cmd)
|
|
36
|
+
return !!res
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// console.log(await isGitRepo())
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
console.log(JSON.parse('true'))
|
|
43
|
+
console.log(JSON.parse('true\n'))
|
|
44
|
+
console.log(JSON.parse('true '))
|
|
45
|
+
console.log(!!('tru11e'))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
const gr = () => {
|
|
49
|
+
const { stdout, stderr } = spawnSync('git', [ 'remote', 'get-url', 'origin' ])
|
|
50
|
+
return stderr ? undefined : stdout.toString().trim()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const gh = (url: string) => {
|
|
54
|
+
const reg = /github(?:\.com)?[:/](.+?)\/(.+?)(\/.+?)?(\.git)?$/
|
|
55
|
+
const [ _, user, repo ] = url.match(reg) ?? []
|
|
56
|
+
return user ? [ user, repo ] : undefined
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
console.log(gr())
|
package/_test_/typed.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
type KeyOf<T> = keyof T;
|
|
2
|
+
|
|
3
|
+
type MembersType<T> = T extends Array<infer U> ? U : never;
|
|
4
|
+
|
|
5
|
+
type ToArray<T> = T extends Array<infer U> ? Array<U> : Array<T>;
|
|
6
|
+
|
|
7
|
+
type ArgType<T> = T extends (...args: infer U) => infer R ? U : never;
|
|
8
|
+
|
|
9
|
+
type ReturnTyp<T> = T extends (...args: infer A) => infer U ? U : never;
|
|
10
|
+
|
|
11
|
+
type Shift<T> = T extends [ unknown, ...args: infer U ] ? U : never;
|
|
12
|
+
|
|
13
|
+
type Pop<T> = T extends [ ...args: infer R, unknown ] ? R : never;
|
|
14
|
+
|
|
15
|
+
type FlatObjectTuple<T> = { [K in keyof T]: T[K] };
|
|
16
|
+
|
|
17
|
+
type AssertEqual<T, U> = [ T ] extends [ U ] ? ([ U ] extends [ T ] ? true : false) : false
|
|
18
|
+
|
|
19
|
+
type DeepPartial<T> = {
|
|
20
|
+
[K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type NoNullAble<T> = T extends null | undefined ? never : T;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// ------------------
|
|
27
|
+
|
|
28
|
+
type A = ToArray<string>
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
const x = (x: string) => {
|
|
32
|
+
return 'x'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type X = ReturnTyp<typeof x>;
|
|
36
|
+
|
|
37
|
+
const arrCc = [ 99, '99' ]
|
|
38
|
+
type CC = MembersType<typeof arrCc>
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
type TShift = Shift<[ string, number, boolean ]>
|
|
42
|
+
type TPop = Pop<[ string, number, boolean ]>
|
|
43
|
+
|
|
44
|
+
type Boo = AssertEqual<[ string ], [ number ]>
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
type Obj = { a: { b: number; c: string }, b: number };
|
|
48
|
+
type PartialObj = DeepPartial<Obj>;
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
type Aa = NoNullAble<undefined>
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
const acc = [ 1, 2, undefined ]
|
|
55
|
+
const c = acc.filter((k): k is Exclude<typeof k, undefined> => k !== undefined)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Title</title>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
|
|
9
|
+
</body>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
const worker = new Worker('./worker.js')
|
|
13
|
+
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
worker.postMessage('789')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
worker.onmessage = event => {
|
|
19
|
+
console.log(event.data)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
</script>
|
|
23
|
+
</html>
|
package/_test_/worker.js
ADDED
package/_test_/worker.ts
ADDED
package/_test_/xhr.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const xhrFn = () => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
const xhr = new XMLHttpRequest()
|
|
4
|
+
xhr.open('GET', 'https://peiyanlu.github.io/vite-press/')
|
|
5
|
+
xhr.onreadystatechange = () => {
|
|
6
|
+
if (xhr.readyState == 4) {
|
|
7
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
8
|
+
resolve(xhr.responseText)
|
|
9
|
+
} else {
|
|
10
|
+
reject(xhr.response)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
xhr.send()
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const test = async () => {
|
|
20
|
+
return 5
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
console.log(await test())
|
|
24
|
+
console.log(await test().then(a => a))
|
|
25
|
+
|
|
26
|
+
export { }
|
|
27
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<title>链接预览 Demo</title>
|
|
6
|
+
<style>
|
|
7
|
+
.preview-box {
|
|
8
|
+
position: absolute;
|
|
9
|
+
background: #FFFFFF;
|
|
10
|
+
border: 1px solid #CCCCCC;
|
|
11
|
+
padding: 12px;
|
|
12
|
+
border-radius: 8px;
|
|
13
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
14
|
+
max-width: 300px;
|
|
15
|
+
display: none;
|
|
16
|
+
z-index: 9999;
|
|
17
|
+
font-family: sans-serif;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.preview-box h4 {
|
|
21
|
+
margin: 0 0 6px;
|
|
22
|
+
font-size: 16px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.preview-box p {
|
|
26
|
+
margin: 0;
|
|
27
|
+
font-size: 13px;
|
|
28
|
+
color: #555555;
|
|
29
|
+
}
|
|
30
|
+
</style>
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
<h2>鼠标悬停查看链接信息</h2>
|
|
34
|
+
<p>
|
|
35
|
+
👉 <a href="https://peiyanlu.github.io/vite-press/" class="preview-link">VitePress 主页</a>
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
<div id="previewBox" class="preview-box"></div>
|
|
39
|
+
|
|
40
|
+
<script>
|
|
41
|
+
const previewBox = document.getElementById('previewBox');
|
|
42
|
+
let hoverTimer = null;
|
|
43
|
+
|
|
44
|
+
// 悬停处理
|
|
45
|
+
document.querySelectorAll('.preview-link').forEach(link => {
|
|
46
|
+
link.addEventListener('mouseenter', async (e) => {
|
|
47
|
+
const href = link.href;
|
|
48
|
+
const rect = link.getBoundingClientRect();
|
|
49
|
+
|
|
50
|
+
// 设置浮窗位置
|
|
51
|
+
previewBox.style.left = rect.left + 'px';
|
|
52
|
+
previewBox.style.top = (rect.bottom + 8 + window.scrollY) + 'px';
|
|
53
|
+
previewBox.style.display = 'block';
|
|
54
|
+
previewBox.innerHTML = '加载中...';
|
|
55
|
+
|
|
56
|
+
// 取消之前的计时器
|
|
57
|
+
if (hoverTimer) clearTimeout(hoverTimer);
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
const res = await fetch(href, { mode: 'cors' });
|
|
61
|
+
const html = await res.text();
|
|
62
|
+
const doc = new DOMParser().parseFromString(html, 'text/html');
|
|
63
|
+
|
|
64
|
+
const title = doc.querySelector('title')?.innerText || '无标题';
|
|
65
|
+
const desc = doc.querySelector('meta[name="description"]')?.content || '无描述信息';
|
|
66
|
+
|
|
67
|
+
previewBox.innerHTML = `
|
|
68
|
+
<h4>${ title }</h4>
|
|
69
|
+
<p>${ desc }</p>
|
|
70
|
+
`;
|
|
71
|
+
} catch (err) {
|
|
72
|
+
previewBox.innerHTML = `<p>❌ 获取失败:${ err.message }</p>`;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
link.addEventListener('mouseleave', () => {
|
|
77
|
+
// 延迟隐藏,避免用户突然移出
|
|
78
|
+
hoverTimer = setTimeout(() => {
|
|
79
|
+
previewBox.style.display = 'none';
|
|
80
|
+
}, 300);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
previewBox.addEventListener('mouseenter', () => {
|
|
84
|
+
if (hoverTimer) clearTimeout(hoverTimer); // 用户移入浮窗,保持显示
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
previewBox.addEventListener('mouseleave', () => {
|
|
88
|
+
previewBox.style.display = 'none';
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
</script>
|
|
92
|
+
</body>
|
|
93
|
+
</html>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.d.ts
ADDED
|
File without changes
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ip2region_1 = __importDefault(require("ip2region"));
|
|
7
|
+
const ip = '127.0.0.1';
|
|
8
|
+
const query = new ip2region_1.default();
|
|
9
|
+
const ipAddress = query.search(ip);
|
|
10
|
+
console.log('>>> ipAddress:', ipAddress);
|
|
11
|
+
// >>> ipAddress: { country: '', province: '', city: '内网IP', isp: '内网IP' }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import IP2Region from "ip2region";
|
|
3
|
+
|
|
4
|
+
//#region rolldown:runtime
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __commonJS = (cb, mod) => function() {
|
|
7
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/ip2region.cts
|
|
12
|
+
var require_ip2region = __commonJS({ "src/ip2region.cts"() {
|
|
13
|
+
const ip = "127.0.0.1";
|
|
14
|
+
const query = new IP2Region();
|
|
15
|
+
const ipAddress = query.search(ip);
|
|
16
|
+
console.log(">>> ipAddress:", ipAddress);
|
|
17
|
+
} });
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export default require_ip2region();
|
package/dist/npm.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/npm.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getFiledValue: (pkg: string, filed?: string) => Promise<[string, string]>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { exec } from 'node:child_process';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
const pkg = JSON.parse(readFileSync(join(process.cwd(), '..', 'package.json'), 'utf8'));
|
|
5
|
+
const deps = Object.keys({ ...pkg.dependencies, ...pkg.devDependencies });
|
|
6
|
+
export const getFiledValue = (pkg, filed = 'version') => {
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
exec(`pnpm view ${pkg} ${filed} --json`, { encoding: 'utf8' }, (err, stdout) => {
|
|
9
|
+
resolve([pkg, err ? '' : JSON.parse(stdout)]);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
const getLicense = (pkg) => getFiledValue(pkg, 'license');
|
|
14
|
+
const licenses = await Promise.all(deps.map(getLicense));
|
|
15
|
+
console.log('已安装依赖许可证:', licenses);
|
|
16
|
+
const getVersion = (pkg) => getFiledValue(pkg, 'version');
|
|
17
|
+
const versions = await Promise.all(deps.map(getVersion));
|
|
18
|
+
console.log('已安装依赖版本:', versions);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { writeFile } from 'fs/promises';
|
|
3
|
+
import { basename, join } from 'path';
|
|
4
|
+
import { globSync } from 'tinyglobby';
|
|
5
|
+
const getFileType = (buffer) => {
|
|
6
|
+
const jpg = Buffer.from([0xff, 0xd8, 0xff]);
|
|
7
|
+
const png = Buffer.from([0x89, 0x50, 0x4e, 0x47]);
|
|
8
|
+
const sub = (s, e) => buffer.subarray(s, e);
|
|
9
|
+
if (sub(0, 3).equals(jpg)) {
|
|
10
|
+
return 'jpg';
|
|
11
|
+
}
|
|
12
|
+
if (sub(0, 4).equals(png)) {
|
|
13
|
+
return 'png';
|
|
14
|
+
}
|
|
15
|
+
if (['GIF87a', 'GIF89a'].includes(sub(0, 6).toString())) {
|
|
16
|
+
return 'gif';
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const readDatFiles = (dir) => {
|
|
20
|
+
return globSync(['**/*.dat'], { cwd: dir })
|
|
21
|
+
.map((file) => join(dir, file));
|
|
22
|
+
};
|
|
23
|
+
const restoreDatImages = (files, output) => {
|
|
24
|
+
files.forEach(async (filepath) => {
|
|
25
|
+
const buffer = readFileSync(filepath);
|
|
26
|
+
const ext = getFileType(buffer);
|
|
27
|
+
if (ext) {
|
|
28
|
+
const filename = basename(filepath).replace(/\.dat$/, `.${ext}`);
|
|
29
|
+
const newFilepath = join(output, filename);
|
|
30
|
+
await writeFile(newFilepath, buffer);
|
|
31
|
+
console.log(`✔ Restored: ${filepath} -> ${filename}`);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.warn(`✖ Unknown type file: ${filepath}`);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const root = 'C:\\Users\\ASUS\\Documents';
|
|
39
|
+
restoreDatImages(readDatFiles(root), 'E:\\ts-run-test\\cache');
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ts-run-test",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"lib": "tsdown -c tsdown.config.ts"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@peiyanlu/cli-utils": "^0.0.1",
|
|
13
|
+
"@peiyanlu/release": "file:E:/@peiyanlu/release/peiyanlu-release-0.0.0.tgz",
|
|
14
|
+
"@types/minimist": "^1.2.5",
|
|
15
|
+
"@types/node": "^22.15.16",
|
|
16
|
+
"@types/react": "^19.1.8",
|
|
17
|
+
"@types/semver": "^7.7.1",
|
|
18
|
+
"crawler": "^2.0.2",
|
|
19
|
+
"github-url-to-object": "^4.0.6",
|
|
20
|
+
"ip2region": "^2.3.0",
|
|
21
|
+
"minimist": "^1.2.8",
|
|
22
|
+
"puppeteer": "^24.9.0",
|
|
23
|
+
"react": "^19.1.0",
|
|
24
|
+
"release-it": "^19.1.0",
|
|
25
|
+
"semver": "^7.7.3",
|
|
26
|
+
"tinyglobby": "^0.2.13",
|
|
27
|
+
"vit": "^0.0.1",
|
|
28
|
+
"vite": "^7.3.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/crawler": "^1.2.7",
|
|
32
|
+
"icon-gen": "^5.0.0",
|
|
33
|
+
"png-to-ico": "^3.0.1",
|
|
34
|
+
"sharp": "^0.34.5",
|
|
35
|
+
"tsdown": "^0.12.3",
|
|
36
|
+
"tsx": "^4.21.0",
|
|
37
|
+
"typescript": "^5.5.3"
|
|
38
|
+
},
|
|
39
|
+
"private": false,
|
|
40
|
+
"pnpm": {
|
|
41
|
+
"neverBuiltDependencies": []
|
|
42
|
+
}
|
|
43
|
+
}
|
package/record.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
1 输入 URL 到浏览器渲染全过程
|
|
2
|
+
|
|
3
|
+
2 强缓存、协商缓存
|
|
4
|
+
|
|
5
|
+
3 TCP 处于计算机网络那一层
|
|
6
|
+
|
|
7
|
+
DIV 垂直剧中
|
|
8
|
+
|
|
9
|
+
什么是BFC
|
|
10
|
+
|
|
11
|
+
选择器优先级
|
|
12
|
+
|
|
13
|
+
vue 的 data 为什么返是一个函数,如果是对象会怎么样
|
|
14
|
+
|
|
15
|
+
vue3 有哪些改进
|
|
16
|
+
|
|
17
|
+
vue nextStick 的作用和原理
|
|
18
|
+
|
|
19
|
+
vue-router
|
|
20
|
+
|
|
21
|
+
普通类型和对象类型有什么区别
|
|
22
|
+
|
|
23
|
+
函数的参数是一个对象,传递的是什么
|
|
24
|
+
|
|
25
|
+
什么是浅拷贝和深拷贝,如何实现,有什么区别
|
|
26
|
+
|
|
27
|
+
为什么不使用 JSON.stringify 拷贝,除了undefined还有哪些会丢失
|
|
28
|
+
|
|
29
|
+
垃圾回收
|
|
30
|
+
|
|
31
|
+
宏任务、微任务
|
|
32
|
+
|
|
33
|
+
new 一个实例发生了什么
|
|
34
|
+
|
|
35
|
+
什么是原型 原型链 原型链的最顶层是什么
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class 继承的实现原理
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
Promise 的三种状态,then 返回的是新 Promise 吗
|
|
42
|
+
async/await 为什么可以以同步的方式使用+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
React 中哪些方法会导致页面刷新
|
|
46
|
+
|
|
47
|
+
React 为什么不推荐使用 index 作为 key
|
|
48
|
+
|
|
49
|
+
setState 是同步还是异步
|
|
50
|
+
|
|
51
|
+
如何解决难题
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
不同设备兼容问题,找不到解决方案,你如何处理
|
|
55
|
+
|
|
56
|
+
老项目如何重构升级,你会怎么做
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
页面性能优化
|
package/src/copyDir.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { copyFile, mkdir, readdir } from 'node:fs/promises'
|
|
2
|
+
import { join } from 'path'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const copyDir = async (src: string, dist: string) => {
|
|
6
|
+
await mkdir(dist, { recursive: true })
|
|
7
|
+
|
|
8
|
+
const files = await readdir(src, { withFileTypes: true })
|
|
9
|
+
await Promise.all(files.map(async (file) => {
|
|
10
|
+
const srcPath = join(src, file.name)
|
|
11
|
+
const distPath = join(dist, file.name)
|
|
12
|
+
if (file.isDirectory()) {
|
|
13
|
+
await copyDir(srcPath, distPath)
|
|
14
|
+
} else {
|
|
15
|
+
await copyFile(srcPath, distPath)
|
|
16
|
+
}
|
|
17
|
+
}))
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
console.log(join(process.cwd(), '../_test_'), join(process.cwd(), '../dist1'))
|
|
21
|
+
console.log(await copyDir(join(process.cwd(), '../_test_'), join(process.cwd(), '../dist1')))
|
package/src/example.png
ADDED
|
Binary file
|