xshell 1.0.41 → 1.0.42

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -79,7 +79,7 @@
79
79
  "strip-ansi": "^7.1.0",
80
80
  "through2": "^4.0.2",
81
81
  "tough-cookie": "^4.1.3",
82
- "tslib": "^2.6.0",
82
+ "tslib": "^2.6.1",
83
83
  "typescript": "^5.1.6",
84
84
  "undici": "^5.22.1",
85
85
  "vinyl": "^3.0.0",
@@ -100,13 +100,13 @@
100
100
  "@types/mime-types": "^2.1.1",
101
101
  "@types/node": "^20.4.4",
102
102
  "@types/qs": "^6.9.7",
103
- "@types/react": "^18.2.15",
103
+ "@types/react": "^18.2.16",
104
104
  "@types/through2": "^2.0.38",
105
105
  "@types/tough-cookie": "^4.0.2",
106
106
  "@types/vinyl-fs": "^3.0.2",
107
107
  "@types/vscode": "^1.80.0",
108
- "@typescript-eslint/eslint-plugin": "^6.1.0",
109
- "@typescript-eslint/parser": "^6.1.0",
108
+ "@typescript-eslint/eslint-plugin": "^6.2.0",
109
+ "@typescript-eslint/parser": "^6.2.0",
110
110
  "eslint": "^8.45.0",
111
111
  "eslint-plugin-react": "^7.33.0",
112
112
  "eslint-plugin-xlint": "^1.0.6"
package/path.js CHANGED
@@ -4,10 +4,10 @@ export function to_fp(str) {
4
4
  return str;
5
5
  const fp = str.replaceAll('\\', '/');
6
6
  // 转换小写盘符开头的路径
7
- if (fp[1] === ':' && 'a' <= fp[0] && fp[0] <= 'z')
8
- return fp[0].toUpperCase() + fp.slice(1);
9
- else
10
- return fp;
7
+ return fp[1] === ':' && 'a' <= fp[0] && fp[0] <= 'z' ?
8
+ fp[0].toUpperCase() + fp.slice(1)
9
+ :
10
+ fp;
11
11
  }
12
12
  /** Normalize a string path, reducing '..' and '.' parts.
13
13
  When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved.
@@ -78,8 +78,12 @@ declare global {
78
78
  space(this: string): string;
79
79
  /** 等价于 .endsWith('/') */
80
80
  isdir: boolean;
81
- /** 以 `/` 分割的路径 */
81
+ /** 以 `/` 分割的路径,可能以 / 结尾 */
82
82
  fp: string;
83
+ /** 以 `/` 分割的文件夹路径,一定以 / 结尾 */
84
+ fpd: string;
85
+ /** 父文件夹路径 (path.dirname),一定以 `/` 结尾 */
86
+ fdir: string;
83
87
  /** 文件名 (path.basename 的结果), 保留结尾的 /,如:
84
88
  - D:/0/aaa.txt -> aaa.txt
85
89
  - D:/aaa/ -> aaa/ */
@@ -35,6 +35,16 @@ export const brackets = {
35
35
  fat: ['【', '】'],
36
36
  tortoise_shell: ['〔', '〕'],
37
37
  };
38
+ function to_fp(str) {
39
+ if (!str)
40
+ return str;
41
+ const fp = str.replaceAll('\\', '/');
42
+ // 转换小写盘符开头的路径
43
+ return fp[1] === ':' && 'a' <= fp[0] && fp[0] <= 'z' ?
44
+ fp[0].toUpperCase() + fp.slice(1)
45
+ :
46
+ fp;
47
+ }
38
48
  // ------------------------------------ String.prototype
39
49
  Object.defineProperties(String.prototype, {
40
50
  ...to_getter_property_descriptors({
@@ -278,14 +288,13 @@ Object.defineProperties(String.prototype, {
278
288
  return this.endsWith('/');
279
289
  },
280
290
  fp() {
291
+ return to_fp(this);
292
+ },
293
+ fpd() {
281
294
  if (!this)
282
295
  return this;
283
- const fp = this.replaceAll('\\', '/');
284
- // 转换小写盘符开头的路径
285
- if (fp[1] === ':' && 'a' <= fp[0] && fp[0] <= 'z')
286
- return fp[0].toUpperCase() + fp.slice(1);
287
- else
288
- return fp;
296
+ const fp = to_fp(this);
297
+ return fp.endsWith('/') ? fp : `${fp}/`;
289
298
  },
290
299
  fdir() {
291
300
  const fname = (this.endsWith('/') ? this.slice(0, -1) : this).split('/').at(-1);
package/prototype.d.ts CHANGED
@@ -99,9 +99,11 @@ declare global {
99
99
  space(this: string): string;
100
100
  /** 等价于 .endsWith('/') */
101
101
  isdir: boolean;
102
- /** 以 `/` 分割的路径 */
102
+ /** 以 `/` 分割的路径,可能以 / 结尾 */
103
103
  fp: string;
104
- /** 父文件夹路径 (path.dirname),并保证以 `/` 结尾 */
104
+ /** `/` 分割的文件夹路径,一定以 / 结尾 */
105
+ fpd: string;
106
+ /** 父文件夹路径 (path.dirname),一定以 `/` 结尾 */
105
107
  fdir: string;
106
108
  /** 文件名 (path.basename 的结果), 保留结尾的 /,如:
107
109
  - D:/0/aaa.txt -> aaa.txt
package/prototype.js CHANGED
@@ -316,6 +316,10 @@ if (!globalThis.my_prototype_defined) {
316
316
  fp() {
317
317
  return to_fp(this);
318
318
  },
319
+ fpd() {
320
+ const fp = to_fp(this);
321
+ fp.endsWith('/') ? fp : `${fp}/`;
322
+ },
319
323
  fdir() {
320
324
  const fpd = dirname(this);
321
325
  // 有可能 fpd 是 '/'