xshell 1.1.25 → 1.2.0
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/builder.d.ts +2 -2
- package/builder.js +1 -1
- package/file.d.ts +1 -2
- package/file.js +15 -16
- package/io.browser.d.ts +22 -0
- package/io.browser.js +537 -0
- package/io.d.ts +22 -0
- package/io.js +537 -0
- package/net.browser.d.ts +1 -30
- package/net.browser.js +6 -53
- package/net.d.ts +1 -30
- package/net.js +6 -53
- package/package.json +1 -1
- package/process.js +1 -0
- package/prototype.browser.d.ts +19 -6
- package/prototype.browser.js +20 -6
- package/prototype.d.ts +19 -6
- package/prototype.js +20 -6
- package/server.d.ts +2 -2
- package/server.js +17 -17
- package/utils.browser.d.ts +7 -1
- package/utils.browser.js +19 -2
- package/utils.d.ts +10 -4
- package/utils.js +23 -5
package/builder.d.ts
CHANGED
|
@@ -89,7 +89,7 @@ export declare class Bundler {
|
|
|
89
89
|
target: 'nodejs' | 'web';
|
|
90
90
|
production: boolean;
|
|
91
91
|
fpd_out: string;
|
|
92
|
-
source_map:
|
|
92
|
+
source_map: BundlerOptions['source_map'];
|
|
93
93
|
dependencies: DependencyId[];
|
|
94
94
|
analyzer: boolean;
|
|
95
95
|
config: Webpack.Configuration;
|
|
@@ -154,7 +154,7 @@ export declare class Bundler {
|
|
|
154
154
|
- assets: false 时只包括在 script 标签加载的文件; true 时包括 assets, maps 等 */
|
|
155
155
|
resolve_dependency_assets(_dependencies: DependencyId[], assets: boolean, { production, source_map }?: {
|
|
156
156
|
production?: boolean;
|
|
157
|
-
source_map?:
|
|
157
|
+
source_map?: BundlerOptions['source_map'];
|
|
158
158
|
}): (string | AssetOption)[];
|
|
159
159
|
copy_files({ dependencies, production, assets, fpd_root, fpd_out, print }?: {
|
|
160
160
|
dependencies?: DependencyId[];
|
package/builder.js
CHANGED
|
@@ -378,7 +378,7 @@ export class Bundler {
|
|
|
378
378
|
} : {}
|
|
379
379
|
},
|
|
380
380
|
ignoreWarnings: [
|
|
381
|
-
...
|
|
381
|
+
...source_map ? [/Failed to parse source map/] : [],
|
|
382
382
|
...this.license ? [
|
|
383
383
|
/** LicenseWebpackPlugin 会添加过时的 string 类型的 warning,无法被正则表达式的逻辑匹配,这里只能手动用函数过滤 */
|
|
384
384
|
(warning) => typeof warning === 'string' && warning.startsWith('license-webpack-plugin: could not find any license ')
|
package/file.d.ts
CHANGED
|
@@ -11,8 +11,7 @@ export declare const ramdisk: boolean;
|
|
|
11
11
|
export declare function fexists(fp: string, { print }?: {
|
|
12
12
|
print?: boolean;
|
|
13
13
|
}): boolean;
|
|
14
|
-
/**
|
|
15
|
-
open file, return FileHandle
|
|
14
|
+
/** 打开或创建文件,返回 FileHandle, 如果文件夹不存在,会自动创建文件夹
|
|
16
15
|
Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented
|
|
17
16
|
by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains
|
|
18
17
|
a colon, Node.js will open a file system stream, as described by [this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams).
|
package/file.js
CHANGED
|
@@ -3,7 +3,7 @@ import { isUint8Array } from 'util/types';
|
|
|
3
3
|
import { path } from "./path.js";
|
|
4
4
|
import { t } from "./i18n/instance.js";
|
|
5
5
|
import { to_json } from "./prototype.js";
|
|
6
|
-
import { check, Lock, WritableMemoryStream } from "./utils.js";
|
|
6
|
+
import { check, Lock, WritableMemoryStream, url_width } from "./utils.js";
|
|
7
7
|
export { fsp };
|
|
8
8
|
export const encodings = ['utf-8', 'gb18030', 'shift-jis', 'utf-16le'];
|
|
9
9
|
export const ramdisk = fexists('T:/TEMP/', { print: false });
|
|
@@ -15,8 +15,7 @@ export function fexists(fp, { print = true } = {}) {
|
|
|
15
15
|
console.log(exists ? t('已存在') : t('不存在'), fp);
|
|
16
16
|
return exists;
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
19
|
-
open file, return FileHandle
|
|
18
|
+
/** 打开或创建文件,返回 FileHandle, 如果文件夹不存在,会自动创建文件夹
|
|
20
19
|
Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented
|
|
21
20
|
by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains
|
|
22
21
|
a colon, Node.js will open a file system stream, as described by [this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams).
|
|
@@ -27,13 +26,10 @@ export function fexists(fp, { print = true } = {}) {
|
|
|
27
26
|
export async function fopen(fp, flags = 'r', { mode, print } = {}) {
|
|
28
27
|
if (print)
|
|
29
28
|
console.log(t('打开文件'), fp);
|
|
29
|
+
await fmkdir(fp.fdir, { print: false });
|
|
30
30
|
return Object.assign(await fsp.open(fp, flags, mode), { fp, flags, mode });
|
|
31
31
|
}
|
|
32
|
-
export async function fread(fp, {
|
|
33
|
-
if (dir) {
|
|
34
|
-
check(dir.isdir, t('dir 必须以 / 结尾'));
|
|
35
|
-
fp = dir + fp;
|
|
36
|
-
}
|
|
32
|
+
export async function fread(fp, { encoding = 'utf-8', print = true } = {}) {
|
|
37
33
|
check(!fp.isdir, t('fp 必须是文件,不能以 / 结尾'));
|
|
38
34
|
check(path.isAbsolute(fp), `${t('fp 必须是绝对路径:')} ${fp}`);
|
|
39
35
|
check(encoding !== 'auto');
|
|
@@ -284,7 +280,7 @@ export async function fcopy(fp_src, fp_dst, { print = true, overwrite = true, fi
|
|
|
284
280
|
if (!isdir && filter)
|
|
285
281
|
throw new Error(t('filter 选项只适用于 fp_src 为文件夹'));
|
|
286
282
|
if (print)
|
|
287
|
-
|
|
283
|
+
log_action('复制', fp_src, fp_dst);
|
|
288
284
|
if (isdir)
|
|
289
285
|
if (filter) {
|
|
290
286
|
await fmkdir(fp_dst, { print });
|
|
@@ -331,7 +327,7 @@ export async function fmove(fp_src, fp_dst, { overwrite = false, print = true }
|
|
|
331
327
|
check(fp_src.isdir === fp_dst.isdir, t('fp_src 和 fp_dst 必须同为文件路径或文件夹路径'));
|
|
332
328
|
check(path.isAbsolute(fp_src) && path.isAbsolute(fp_dst), t('fp_src 和 fp_dst 必须为完整路径'));
|
|
333
329
|
if (print)
|
|
334
|
-
|
|
330
|
+
log_action('移动', fp_src, fp_dst);
|
|
335
331
|
if (!overwrite && fexists(fp_dst, { print: false }))
|
|
336
332
|
throw new Error(`${t('已存在')} ${fp_dst}`);
|
|
337
333
|
await fmkdir(fp_dst.fdir, { print: false });
|
|
@@ -367,7 +363,7 @@ export async function frename(fp, fp_, { fpd, print = true, overwrite = true } =
|
|
|
367
363
|
}
|
|
368
364
|
check(path.isAbsolute(fp) && path.isAbsolute(fp_), t('fp 和 fp_ 必须是绝对路径'));
|
|
369
365
|
if (print)
|
|
370
|
-
|
|
366
|
+
log_action('重命名', fp, fp_);
|
|
371
367
|
if (!overwrite && fexists(fp_, { print: false }))
|
|
372
368
|
throw new Error(`${t('已存在')} ${fp}`);
|
|
373
369
|
await fsp.rename(fp, fp_);
|
|
@@ -420,7 +416,7 @@ export async function flink(fp_real, fp_link, { junction = false, print = true,
|
|
|
420
416
|
return;
|
|
421
417
|
}
|
|
422
418
|
if (print)
|
|
423
|
-
|
|
419
|
+
log_action('已将源文件', fp_real, fp_link, '链接到');
|
|
424
420
|
if (junction)
|
|
425
421
|
await fsp.symlink(fp_real, fp_link, 'junction');
|
|
426
422
|
else
|
|
@@ -469,7 +465,7 @@ async function _zip(data, fp_zip, { dirname, print = { files: true, info: true }
|
|
|
469
465
|
entries = data;
|
|
470
466
|
}
|
|
471
467
|
if (print.info)
|
|
472
|
-
|
|
468
|
+
log_action('开始压缩', fpd_src ? ` ${fpd_src}` : '文件索引', fp_zip ? `${fp_zip}/${dirname || '{entries}'}` : '内存');
|
|
473
469
|
const { default: archiver } = await import('archiver');
|
|
474
470
|
let archive = archiver('zip');
|
|
475
471
|
let ostream = fp_zip ?
|
|
@@ -490,14 +486,14 @@ async function _zip(data, fp_zip, { dirname, print = { files: true, info: true }
|
|
|
490
486
|
const fdata = entries[fp];
|
|
491
487
|
if (fdata instanceof Uint8Array) {
|
|
492
488
|
if (print.files)
|
|
493
|
-
|
|
489
|
+
log_action('压缩', fdata.length.to_fsize_str(), fp);
|
|
494
490
|
archive.append(Buffer.isBuffer(fdata) ? fdata : Buffer.from(fdata.buffer), { name: fp });
|
|
495
491
|
}
|
|
496
492
|
else {
|
|
497
493
|
check(fp.isdir === fdata.isdir);
|
|
498
494
|
check(path.isAbsolute(fdata));
|
|
499
495
|
if (print.files)
|
|
500
|
-
|
|
496
|
+
log_action('压缩', fdata, fp);
|
|
501
497
|
if (fp.isdir)
|
|
502
498
|
archive.directory(fdata, fp);
|
|
503
499
|
else
|
|
@@ -517,7 +513,7 @@ export async function ftail(fp, handler, { print = true } = {}) {
|
|
|
517
513
|
const { size } = await fstat(fp);
|
|
518
514
|
let pointer = Number(size);
|
|
519
515
|
let lock = new Lock(await fopen(fp));
|
|
520
|
-
let fbuf =
|
|
516
|
+
let fbuf = Buffer.allocUnsafe(2 ** 20);
|
|
521
517
|
let strbuf = '';
|
|
522
518
|
let decoder = new TextDecoder();
|
|
523
519
|
if (print)
|
|
@@ -563,4 +559,7 @@ export async function freplace(fp, pattern, replacement, { print = true } = {})
|
|
|
563
559
|
await fwrite(fp, (await fread(fp, { print }))
|
|
564
560
|
.replaceAll(pattern, replacement), { print });
|
|
565
561
|
}
|
|
562
|
+
function log_action(action, fp_src, fp_dst, sep = '->') {
|
|
563
|
+
console.log(`${`${action} ${fp_src}`.pad(url_width)} ${sep} ${fp_dst}`);
|
|
564
|
+
}
|
|
566
565
|
//# sourceMappingURL=file.js.map
|
package/io.browser.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import './prototype.browser.ts';
|
|
2
|
+
/** 二进制消息格式, 按 key 的顺序序列化值 */
|
|
3
|
+
export interface Message<TData = any> {
|
|
4
|
+
/** rpc id: 在 rpc 系统中认为是唯一的。用来在单个 websocket 连接上同时进行多个 rpc 请求。
|
|
5
|
+
多个相同 id 的 message 组成一个请求流 */
|
|
6
|
+
id?: number;
|
|
7
|
+
/** 只在 rpc 发起时指定被调用的 function name,发起时 rpc 时必传 */
|
|
8
|
+
func?: string;
|
|
9
|
+
/** 传输的数据
|
|
10
|
+
- rpc 发起方调用 func 的参数(此时为数组),或者请求流 message 携带的数据
|
|
11
|
+
- 调用结果(通常为单个返回值)或者响应流的数据,传给请求发起方 */
|
|
12
|
+
data?: TData;
|
|
13
|
+
/** 通知对方这里产生的错误,本质上类似 data 也是一种数据,并不代表 rpc 的结束,后续可能继续有 rpc message 交换 */
|
|
14
|
+
error?: Error;
|
|
15
|
+
/** 通过这个 flag 主动表明这是发往对方的最后一个 message, 对方可以销毁 handler 了
|
|
16
|
+
并非强制,可以设置,由双方的函数自己约定 */
|
|
17
|
+
done?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** 用这个符号来标识 message 对象 */
|
|
20
|
+
export declare const message_symbol: unique symbol;
|
|
21
|
+
export declare function parse<TReturn>(_buf: Uint8Array): TReturn;
|
|
22
|
+
export declare function pack(obj: any): Uint8Array<ArrayBuffer>;
|