xshell 1.1.11 → 1.1.13

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.1.11",
3
+ "version": "1.1.13",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
package/path.d.ts CHANGED
@@ -54,7 +54,7 @@ export declare function extname(path: string): string;
54
54
  /** `/` */
55
55
  export declare const sep = "/";
56
56
  /** The platform-specific file delimiter. ';' or ':'. */
57
- export declare const delimiter: ";" | ":";
57
+ export declare const delimiter: ":" | ";";
58
58
  /** Returns an object from a path string - the opposite of format().
59
59
  @param path path to evaluate.
60
60
  @throws {TypeError} if `path` is not a string. */
@@ -81,7 +81,7 @@ export declare let path: {
81
81
  basename: typeof basename;
82
82
  extname: typeof extname;
83
83
  sep: string;
84
- delimiter: ";" | ":";
84
+ delimiter: ":" | ";";
85
85
  parse: typeof parse;
86
86
  format: typeof format;
87
87
  toNamespacedPath: typeof toNamespacedPath;
@@ -343,21 +343,22 @@ Object.defineProperties(String.prototype, {
343
343
  return fp.endsWith('/') ? fp : `${fp}/`;
344
344
  },
345
345
  fdir() {
346
- return this.strip_end(this.fname);
346
+ return this.fp.strip_end(this.fname);
347
347
  },
348
348
  fname() {
349
- const ilast = this.lastIndexOf('/');
349
+ const { fp } = this;
350
+ const ilast = fp.lastIndexOf('/');
350
351
  if (ilast === -1)
351
- return this; // 没有斜杠时返回整个字符串
352
+ return fp; // 没有斜杠时返回整个字符串
352
353
  // 以斜杠结尾的情况
353
- if (ilast === this.length - 1) {
354
- const iprev = this.lastIndexOf('/', ilast - 1);
354
+ if (ilast === fp.length - 1) {
355
+ const iprev = fp.lastIndexOf('/', ilast - 1);
355
356
  return iprev === -1
356
- ? this // 只有一个斜杠且在末尾
357
- : this.slice(iprev + 1);
357
+ ? fp // 只有一个斜杠且在末尾
358
+ : fp.slice(iprev + 1);
358
359
  }
359
360
  // 返回最后一个斜杠后的内容
360
- return this.slice(ilast + 1);
361
+ return fp.slice(ilast + 1);
361
362
  },
362
363
  fext() {
363
364
  const { fname } = this;
package/prototype.js CHANGED
@@ -380,21 +380,22 @@ if (!globalThis.my_prototype_defined) {
380
380
  return fp.endsWith('/') ? fp : `${fp}/`;
381
381
  },
382
382
  fdir() {
383
- return this.strip_end(this.fname);
383
+ return this.fp.strip_end(this.fname);
384
384
  },
385
385
  fname() {
386
- const ilast = this.lastIndexOf('/');
386
+ const { fp } = this;
387
+ const ilast = fp.lastIndexOf('/');
387
388
  if (ilast === -1)
388
- return this; // 没有斜杠时返回整个字符串
389
+ return fp; // 没有斜杠时返回整个字符串
389
390
  // 以斜杠结尾的情况
390
- if (ilast === this.length - 1) {
391
- const iprev = this.lastIndexOf('/', ilast - 1);
391
+ if (ilast === fp.length - 1) {
392
+ const iprev = fp.lastIndexOf('/', ilast - 1);
392
393
  return iprev === -1
393
- ? this // 只有一个斜杠且在末尾
394
- : this.slice(iprev + 1);
394
+ ? fp // 只有一个斜杠且在末尾
395
+ : fp.slice(iprev + 1);
395
396
  }
396
397
  // 返回最后一个斜杠后的内容
397
- return this.slice(ilast + 1);
398
+ return fp.slice(ilast + 1);
398
399
  },
399
400
  fext() {
400
401
  const { fname } = this;
package/server.d.ts CHANGED
@@ -118,7 +118,7 @@ export declare class Server {
118
118
  - redirect?: `manual` 重定向处理策略,默认按原样返回给客户端
119
119
  - timeout?: `1000 * 5` 请求超时时间,可以传入 0 禁用超时
120
120
  - throw_error?: `false` 在遇到 request 请求错误时直接 throw 出来,而不是自动设置到 response */
121
- request(ctx: Context, path_url: string | URL, { headers: headers_, redirect, queries, timeout, throw_error }?: ServerRequestOptions): Promise<true>;
121
+ request(ctx: Context, path_url: string | URL, { headers: headers_, redirect, queries, timeout, throw_error, proxy }?: ServerRequestOptions): Promise<true>;
122
122
  static filter_response_headers(headers: RawResponse['headers']): Record<string, string>;
123
123
  /** 提供静态文件
124
124
  @example
@@ -163,5 +163,6 @@ export interface ServerRequestOptions {
163
163
  redirect?: RequestOptions['redirect'];
164
164
  timeout?: RequestOptions['timeout'];
165
165
  throw_error?: boolean;
166
+ proxy?: RequestOptions['proxy'];
166
167
  }
167
168
  export declare const text_plain: "text/plain; charset=utf-8";
package/server.js CHANGED
@@ -493,7 +493,7 @@ export class Server {
493
493
  - redirect?: `manual` 重定向处理策略,默认按原样返回给客户端
494
494
  - timeout?: `1000 * 5` 请求超时时间,可以传入 0 禁用超时
495
495
  - throw_error?: `false` 在遇到 request 请求错误时直接 throw 出来,而不是自动设置到 response */
496
- async request(ctx, path_url, { headers: headers_, redirect = 'manual', queries, timeout, throw_error } = {}) {
496
+ async request(ctx, path_url, { headers: headers_, redirect = 'manual', queries, timeout, throw_error, proxy } = {}) {
497
497
  const { request: { method, headers, query: _queries, body, ip } } = ctx;
498
498
  let { response } = ctx;
499
499
  const x_forwarded_for = headers['x-forwarded-for'] ? `${headers['x-forwarded-for']}, ${ip}` : ip;
@@ -513,7 +513,8 @@ export class Server {
513
513
  : { ...headers, 'x-forwarded-for': x_forwarded_for }),
514
514
  raw: true,
515
515
  redirect,
516
- timeout
516
+ timeout,
517
+ proxy
517
518
  });
518
519
  response.status = response_.status;
519
520
  response.set(Server.filter_response_headers(response_.headers));
@@ -79,7 +79,7 @@ export declare function encode(str: string): Uint8Array<ArrayBufferLike>;
79
79
  在流式处理 (buffer 可能不完整) 时,应使用独立的 TextDecoder 实例调用 decode(buffer, { stream: true }) */
80
80
  export declare function decode(buffer: Uint8Array): string;
81
81
  /** 字符串字典序比较 */
82
- export declare function strcmp(l: string, r: string): 1 | 0 | -1;
82
+ export declare function strcmp(l: string, r: string): 0 | 1 | -1;
83
83
  /** 比较 1.10.02 这种版本号
84
84
  - l, r: 两个版本号字符串
85
85
  - loose?: 宽松模式,允许两个版本号格式(位数)不一致 */
package/utils.d.ts CHANGED
@@ -40,7 +40,7 @@ export declare function filter_values<TObj extends Record<string, any>>(obj: TOb
40
40
  /** 忽略对象中的 keys, 返回新对象 */
41
41
  export declare function omit<TObj>(obj: TObj, omit_keys: string[]): TObj;
42
42
  /** 字符串字典序比较 */
43
- export declare function strcmp(l: string, r: string): 1 | 0 | -1;
43
+ export declare function strcmp(l: string, r: string): 0 | 1 | -1;
44
44
  /** 比较 1.10.02 这种版本号
45
45
  - l, r: 两个版本号字符串
46
46
  - loose?: 宽松模式,允许两个版本号格式(位数)不一致 */