xshell 1.0.28 → 1.0.30

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/.eslintrc.json ADDED
@@ -0,0 +1,175 @@
1
+ {
2
+ "$schema": "./.eslintrc.schema.json",
3
+
4
+ "root": true,
5
+
6
+ "ignorePatterns": [
7
+ "**/*.d.ts"
8
+ ],
9
+
10
+ "parser": "@typescript-eslint/parser",
11
+ "parserOptions": {
12
+ "ecmaVersion": "latest",
13
+ "sourceType": "module",
14
+ "project": "./tsconfig.json",
15
+ "ecmaFeatures": {
16
+ "jsx": true
17
+ }
18
+ },
19
+
20
+ "plugins": [
21
+ "@typescript-eslint",
22
+ "react",
23
+ "xlint"
24
+ ],
25
+
26
+ "settings": {
27
+ "react": {
28
+ "version": "detect"
29
+ }
30
+ },
31
+
32
+ "env": {
33
+ "node": true,
34
+ "browser": true
35
+ },
36
+
37
+ "rules": {
38
+ "xlint/fold-jsdoc-comments": "error",
39
+
40
+ // 取代 nonblock-statement-body-position
41
+ "xlint/nonblock-statement-body-position-with-indentation": "error",
42
+
43
+ "xlint/empty-bracket-spacing": "error",
44
+
45
+ // a + b**c
46
+ "xlint/space-infix-ops-except-exponentiation": "error",
47
+
48
+ "xlint/space-in-for-statement": "error",
49
+
50
+ "xlint/jsx-no-redundant-parenthesis-in-return": "error",
51
+
52
+ "xlint/keep-indent": "error",
53
+
54
+
55
+ "@typescript-eslint/semi": ["error", "never"],
56
+ "@typescript-eslint/no-extra-semi": "error",
57
+ "semi-style": ["error", "first"],
58
+
59
+ // 使用 ===
60
+ "eqeqeq": "error",
61
+
62
+ // 父类尽量返回 this 类型
63
+ "@typescript-eslint/prefer-return-this-type": "error",
64
+
65
+ // 尽量使用 . 访问属性而不是 []
66
+ "@typescript-eslint/dot-notation": "error",
67
+
68
+ // 必须 throw Error
69
+ "@typescript-eslint/no-throw-literal": "error",
70
+
71
+ // ------------ async
72
+ // 返回 Promise 的函数一定要标记为 async 函数
73
+ "@typescript-eslint/promise-function-async": "error",
74
+
75
+ // 不要 return await promise, 直接 return promise, 除非外面有 try catch
76
+ "@typescript-eslint/return-await": "error",
77
+
78
+ // ------------ 括号
79
+
80
+ // a => { } 而不是 (a) => { }
81
+ "arrow-parens": ["error", "as-needed", { "requireForBlockBody": false }],
82
+
83
+ // 不要多余的大括号
84
+ // if (true)
85
+ // console.log()
86
+ "curly": ["error", "multi"],
87
+
88
+ // 简单属性不要冗余的大括号 <Component prop='simple-value' />
89
+ "react/jsx-curly-brace-presence": ["error", "never"],
90
+
91
+ // ------------ 空格
92
+
93
+ // { a, b } 这样的对象,大括号里面要有空格
94
+ "@typescript-eslint/object-curly-spacing": ["error", "always"],
95
+
96
+ // [a, b, c]
97
+ "@typescript-eslint/comma-spacing": "error",
98
+
99
+ // foo()
100
+ "@typescript-eslint/func-call-spacing": "error",
101
+
102
+ // a => { } 中箭头左右两边空格
103
+ "arrow-spacing": ["error"],
104
+
105
+ // 注释双斜杠后面要有空格
106
+ "spaced-comment": ["error", "always", { "markers": ["/"] }],
107
+
108
+ // 函数声明中,名称后面要有空格
109
+ "@typescript-eslint/space-before-function-paren": "error",
110
+
111
+ // { return true } 这样的 block 大括号里面要有空格
112
+ "block-spacing": ["error", "always"],
113
+
114
+ // aaa: 123
115
+ "@typescript-eslint/key-spacing": ["error", { "beforeColon": false, "afterColon": true, "mode": "minimum" }],
116
+
117
+ // aaa: string
118
+ "@typescript-eslint/type-annotation-spacing": "error",
119
+
120
+ // if ()
121
+ "@typescript-eslint/keyword-spacing": ["error", { "before": true, "after": true }],
122
+
123
+ // if (1) { }
124
+ "@typescript-eslint/space-before-blocks": "error",
125
+
126
+ // case 1: ...
127
+ "switch-colon-spacing": "error",
128
+
129
+ // <Hello name={firstname} />
130
+ "react/jsx-equals-spacing": ["error", "never"],
131
+
132
+ // 不允许使用 tab
133
+ "no-tabs": "error",
134
+
135
+ // 使用 \n 换行
136
+ "linebreak-style": ["error", "unix"],
137
+
138
+ // 文件以 \n 结尾
139
+ "eol-last": ["error", "always"],
140
+
141
+ // ------------ 引号
142
+
143
+ // 用单引号
144
+ "jsx-quotes": ["error", "prefer-single"],
145
+
146
+ // 用单引号
147
+ "quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": false }],
148
+
149
+ // 不要冗余的引号包裹属性
150
+ "quote-props": ["error", "as-needed", { "keywords": false, "unnecessary": true }],
151
+
152
+ // ------------ 其它
153
+ // boolean 属性不要冗余的 ={true} <Component boolprop />
154
+ "react/jsx-boolean-value": ["error", "never"],
155
+
156
+ // 没有 children 的 Component 写成闭合标签 <Component />
157
+ "react/self-closing-comp": "error",
158
+
159
+ // 单行类型声明用 `,` 分割,多行类型声明结尾不要加分号
160
+ "@typescript-eslint/member-delimiter-style": ["error", {
161
+ "multiline": {
162
+ "delimiter": "none",
163
+ "requireLast": false
164
+ },
165
+ "singleline": {
166
+ "delimiter": "comma",
167
+ "requireLast": false
168
+ }
169
+ }],
170
+
171
+ "@typescript-eslint/prefer-includes": "error",
172
+
173
+ "@typescript-eslint/prefer-regexp-exec": "error"
174
+ }
175
+ }
package/file.js CHANGED
@@ -134,7 +134,7 @@ export async function flist(fpd, options = {}) {
134
134
  :
135
135
  fp))).flat();
136
136
  else if (stats)
137
- return Promise.all(fps.map(fp => fstat(absolute ? fp : fpd + fp)));
137
+ return Promise.all(fps.map(async (fp) => fstat(absolute ? fp : fpd + fp)));
138
138
  else
139
139
  return fps;
140
140
  }
package/i18n/rwdict.js CHANGED
@@ -62,7 +62,7 @@ export class RWDict extends Dict {
62
62
  console.error(`${`已存在 ${id} 词条:`.red} ${JSON.stringify(item)}`);
63
63
  console.error(`${'M? '.yellow}${_translation.replace(/\n/g, '\\n')} → ${translation.replace(/\n/g, '\\n')}`);
64
64
  if (!dryrun)
65
- console.error(`如要更新翻译请设置 { overwrite: true },否则使用 i18n.t('text', { context: 'xxx' }) 标记文本以区分。\n`);
65
+ console.error('如要更新翻译请设置 { overwrite: true },否则使用 i18n.t(\'text\', { context: \'xxx\' }) 标记文本以区分。\n');
66
66
  return;
67
67
  }
68
68
  else {
@@ -5,14 +5,14 @@ let Trans = 0;
5
5
  function is_t(node) {
6
6
  if (types.isCallExpression(node)) {
7
7
  // t('chtext')
8
- if (types.isIdentifier(node.callee) && node.callee.name === "t")
8
+ if (types.isIdentifier(node.callee) && node.callee.name === 't')
9
9
  return true;
10
10
  // i18n.t('chtext') | i18n.__('chtext')
11
11
  if (types.isMemberExpression(node.callee) &&
12
12
  types.isIdentifier(node.callee.object) &&
13
13
  types.isIdentifier(node.callee.property) &&
14
- node.callee.object.name === "i18n" &&
15
- (node.callee.property.name === "t" || node.callee.property.name === '__'))
14
+ node.callee.object.name === 'i18n' &&
15
+ (node.callee.property.name === 't' || node.callee.property.name === '__'))
16
16
  return true;
17
17
  }
18
18
  return false;
@@ -22,7 +22,7 @@ function is_trans(node) {
22
22
  return (types.isJSXElement(node) &&
23
23
  types.isJSXOpeningElement(node.openingElement) &&
24
24
  types.isJSXIdentifier(node.openingElement.name) &&
25
- node.openingElement.name.name === "Trans");
25
+ node.openingElement.name.name === 'Trans');
26
26
  }
27
27
  const has_unmarked_chinese_characters = (str) => !t && !Trans && /[\u4e00-\u9fa5]/.test(str);
28
28
  export function Checker({ filepath }) {
@@ -28,7 +28,7 @@ export function mix_parse_trans_from_string_by_babel(parser) {
28
28
  return;
29
29
  const getLiteralValue = literal => {
30
30
  if (t.isTemplateLiteral(literal))
31
- return literal.quasis.map(element => element.value.cooked).join("");
31
+ return literal.quasis.map(element => element.value.cooked).join('');
32
32
  return literal.value;
33
33
  };
34
34
  const attr = castArray(node.openingElement.attributes).reduce((acc, attribute) => {
@@ -53,26 +53,24 @@ export function mix_parse_trans_from_string_by_babel(parser) {
53
53
  if (t.isLiteral(property.value))
54
54
  obj[property.key.name] = getLiteralValue(property.value);
55
55
  else // Unable to get value of the property
56
- obj[property.key.name] = "";
56
+ obj[property.key.name] = '';
57
57
  return obj;
58
58
  }, {});
59
- /**
60
- * 防止 count 被忽略,如
61
- * ```jsx
62
- * <Trans count={arr.length}>
63
- * 一二三{{ count: arr.length }}
64
- * </Trans>
65
- * ```
66
- */
59
+ /** 防止 count 被忽略,如
60
+ ```jsx
61
+ <Trans count={arr.length}>
62
+ 一二三{{ count: arr.length }}
63
+ </Trans>
64
+ ``` */
67
65
  }
68
- else if (name === "count")
66
+ else if (name === 'count')
69
67
  acc[name] = 0;
70
68
  }
71
69
  return acc;
72
70
  }, {});
73
71
  const transKey = trim(attr[i18nKey]);
74
- const defaultsString = attr[defaultsKey] || "";
75
- if (typeof defaultsString !== "string")
72
+ const defaultsString = attr[defaultsKey] || '';
73
+ if (typeof defaultsString !== 'string')
76
74
  this.log(`defaults value must be a static string, saw ${defaultsString.yellow}`);
77
75
  // https://www.i18next.com/translation-function/essentials#overview-options
78
76
  const tOptions = attr.tOptions;
@@ -81,10 +79,10 @@ export function mix_parse_trans_from_string_by_babel(parser) {
81
79
  defaultValue: defaultsString || nodes_to_string(node.children, filepath, on_error),
82
80
  fallbackKey,
83
81
  };
84
- if (Object.prototype.hasOwnProperty.call(attr, "count"))
82
+ if (Object.prototype.hasOwnProperty.call(attr, 'count'))
85
83
  options.count = Number(attr.count) || 0;
86
- if (Object.prototype.hasOwnProperty.call(attr, "ns")) {
87
- if (typeof options.ns !== "string")
84
+ if (Object.prototype.hasOwnProperty.call(attr, 'ns')) {
85
+ if (typeof options.ns !== 'string')
88
86
  this.log(`The ns attribute must be a string, saw ${attr.ns?.yellow}`);
89
87
  options.ns = attr.ns;
90
88
  }
@@ -103,11 +101,11 @@ export function mix_parse_trans_from_string_by_babel(parser) {
103
101
  on_error(() => {
104
102
  console.error('');
105
103
  const { line, column } = (err && err.loc) || { line: 1, column: 1 };
106
- console.error([filepath, line, column].join(":").yellow);
104
+ console.error([filepath, line, column].join(':').yellow);
107
105
  console.error(`Unable to parse ${component?.blue} component.\n`.red);
108
106
  if (!filepath)
109
107
  console.error(String(code).red);
110
- console.error((" " + err.message).red);
108
+ console.error((' ' + err.message).red);
111
109
  });
112
110
  }
113
111
  return this;
@@ -119,9 +117,9 @@ function nodes_to_string(nodes, filepath, onError) {
119
117
  nodes.forEach((node, i) => {
120
118
  if (t.isJSXText(node) || t.isStringLiteral(node)) {
121
119
  const value = node.value
122
- .replace(/^[\r\n]+\s*/g, "") // remove leading spaces containing a leading newline character
123
- .replace(/[\r\n]+\s*$/g, "") // remove trailing spaces containing a leading newline character
124
- .replace(/[\r\n]+\s*/g, " "); // replace spaces containing a leading newline character with a single space character
120
+ .replace(/^[\r\n]+\s*/g, '') // remove leading spaces containing a leading newline character
121
+ .replace(/[\r\n]+\s*$/g, '') // remove trailing spaces containing a leading newline character
122
+ .replace(/[\r\n]+\s*/g, ' '); // replace spaces containing a leading newline character with a single space character
125
123
  if (!value)
126
124
  return;
127
125
  memo += value;
@@ -139,7 +137,7 @@ function nodes_to_string(nodes, filepath, onError) {
139
137
  onError(() => {
140
138
  const { line, column } = (node.expression && node.expression.loc.start) || { line: 1, column: 1 };
141
139
  console.error('');
142
- console.error([filepath, line, column].join(":").yellow);
140
+ console.error([filepath, line, column].join(':').yellow);
143
141
  console.error('Unsupported JSX expression. Only static values or {{interpolation}} blocks are supported.'.red);
144
142
  });
145
143
  }
package/net.browser.js CHANGED
@@ -188,12 +188,11 @@ export async function connect_websocket(url, { protocols, on_message, on_error,
188
188
  console.log(`${websocket.url} ${t('已正常关闭')}`);
189
189
  else { // 异常关闭,认为发生了错误,进行错误处理
190
190
  const error = new WebSocketConnectionError(websocket, event, `${t('连接被关闭')}, code: ${event.code}${event.reason ? `, ${t('原因')}: ${event.reason}` : ''}`);
191
- if (settled) {
191
+ if (settled)
192
192
  if (on_error)
193
193
  on_error(error, websocket);
194
194
  else // 既然用户不传 on_error, 就当 unhandled error 抛出来
195
195
  throw error;
196
- }
197
196
  else {
198
197
  settled = true;
199
198
  reject(error);
@@ -205,12 +204,11 @@ export async function connect_websocket(url, { protocols, on_message, on_error,
205
204
  // https://blog.insiderattack.net/promises-next-ticks-and-immediates-nodejs-event-loop-part-3-9226cbe7a6aa
206
205
  // close 的错误信息比较多,这里延后触发 error 事件,放到微任务队列之后的 timers 队列中
207
206
  setTimeout(() => {
208
- if (settled) {
207
+ if (settled)
209
208
  if (on_error)
210
209
  on_error(error, websocket);
211
210
  else // 既然用户不传 on_error, 就当 unhandled error 抛出来
212
211
  throw error;
213
- }
214
212
  else {
215
213
  settled = true;
216
214
  reject(error);
@@ -319,7 +317,7 @@ export class Remote {
319
317
  /** 幂等,保证 websocket 已连接,否则抛出异常,不需要手动调用,在其它方法中已默认自动重连
320
318
  作为接收方需要传入使用的 websocket 连接,确保这个这个连接的状态 */
321
319
  async connect(websocket) {
322
- if (this.initiator) {
320
+ if (this.initiator)
323
321
  if (this.lwebsocket.resource?.readyState === WebSocket.OPEN)
324
322
  return;
325
323
  else if (!this.url)
@@ -342,7 +340,6 @@ export class Remote {
342
340
  on_error: this.on_error.bind(this)
343
341
  });
344
342
  });
345
- }
346
343
  else if (websocket.readyState === WebSocket.OPEN)
347
344
  return;
348
345
  else
package/net.d.ts CHANGED
@@ -17,7 +17,7 @@ export declare enum MyProxy {
17
17
  export declare const cookies: {
18
18
  store: MemoryCookieStore;
19
19
  jar: CookieJar;
20
- get(domain_or_url: string, str?: boolean): Cookie[] | Promise<string> | Promise<Cookie[]>;
20
+ get(domain_or_url: string, str?: boolean): Cookie[] | Promise<Cookie[] | string>;
21
21
  };
22
22
  export { Cookie };
23
23
  export interface BasicAuth {
package/net.js CHANGED
@@ -359,12 +359,11 @@ on_message, on_error, on_close }) {
359
359
  });
360
360
  websocket.addEventListener('error', event => {
361
361
  const error = new WebSocketConnectionError(websocket, event, event.error?.message);
362
- if (settled) {
362
+ if (settled)
363
363
  if (on_error)
364
364
  on_error(error, websocket);
365
365
  else // 既然用户不传 on_error, 就当 unhandled error 抛出来
366
366
  throw error;
367
- }
368
367
  else {
369
368
  settled = true;
370
369
  reject(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -45,9 +45,9 @@
45
45
  ]
46
46
  },
47
47
  "dependencies": {
48
- "@babel/core": "^7.21.8",
49
- "@babel/parser": "^7.21.8",
50
- "@babel/traverse": "^7.21.5",
48
+ "@babel/core": "^7.22.1",
49
+ "@babel/parser": "^7.22.4",
50
+ "@babel/traverse": "^7.22.4",
51
51
  "@koa/cors": "^4.0.0",
52
52
  "@types/ws": "^8.5.4",
53
53
  "byte-size": "^8.1.1",
@@ -75,7 +75,7 @@
75
75
  "react": "^18.2.0",
76
76
  "react-i18next": "^12.3.1",
77
77
  "resolve-path": "^1.4.0",
78
- "strip-ansi": "^7.0.1",
78
+ "strip-ansi": "^7.1.0",
79
79
  "through2": "^4.0.2",
80
80
  "tough-cookie": "^4.1.2",
81
81
  "tslib": "^2.5.2",
@@ -87,8 +87,8 @@
87
87
  "ws": "^8.13.0"
88
88
  },
89
89
  "devDependencies": {
90
- "@babel/types": "^7.21.5",
91
- "@types/babel__traverse": "^7.18.5",
90
+ "@babel/types": "^7.22.4",
91
+ "@types/babel__traverse": "^7.20.0",
92
92
  "@types/byte-size": "^8.1.0",
93
93
  "@types/chardet": "^0.8.1",
94
94
  "@types/fs-extra": "^11.0.1",
@@ -96,16 +96,21 @@
96
96
  "@types/js-cookie": "^3.0.3",
97
97
  "@types/koa": "^2.13.6",
98
98
  "@types/koa-compress": "^4.0.3",
99
- "@types/lodash": "^4.14.194",
100
- "@types/node": "^20.2.1",
99
+ "@types/lodash": "^4.14.195",
100
+ "@types/node": "^20.2.5",
101
101
  "@types/qs": "^6.9.7",
102
- "@types/react": "^18.2.6",
102
+ "@types/react": "^18.2.7",
103
103
  "@types/through2": "^2.0.38",
104
104
  "@types/tough-cookie": "^4.0.2",
105
105
  "@types/vinyl-fs": "^3.0.2",
106
- "@types/vscode": "^1.78.0",
106
+ "@types/vscode": "^1.78.1",
107
+ "@typescript-eslint/eslint-plugin": "^5.59.8",
108
+ "@typescript-eslint/parser": "^5.59.8",
109
+ "eslint": "^8.41.0",
110
+ "eslint-plugin-react": "^7.32.2",
111
+ "eslint-plugin-xlint": "^1.0.6",
107
112
  "source-map-loader": "^4.0.1",
108
- "ts-loader": "^9.4.2"
113
+ "ts-loader": "^9.4.3"
109
114
  },
110
115
  "scripts": {
111
116
  "start": "node --title=xshell --inspect=0.0.0.0:8420 ./xshell.js",
package/process.js CHANGED
@@ -181,7 +181,7 @@ export const exe_winterm = `C:/Users/${userInfo().username}/AppData/Local/Micros
181
181
  - args: 调用参数 call parameter
182
182
  - options?: WinTermOptions
183
183
  */
184
- export function term(exe, args = [], { cwd = 'd:/t/', print = true, title,
184
+ export async function term(exe, args = [], { cwd = 'd:/t/', print = true, title,
185
185
  // env
186
186
  } = {}) {
187
187
  return start(exe_winterm, [
@@ -260,8 +260,8 @@ Object.defineProperties(String.prototype, {
260
260
  return this;
261
261
  let text_;
262
262
  text_ = this
263
- .replace(new RegExp(cjk + `(['"])`, 'g'), '$1 $2')
264
- .replace(new RegExp(`(['"])` + cjk, 'g'), '$1 $2')
263
+ .replace(new RegExp(cjk + '([\'"])', 'g'), '$1 $2')
264
+ .replace(new RegExp('([\'"])' + cjk, 'g'), '$1 $2')
265
265
  .replace(/(["']+)\s*(.+?)\s*(["']+)/g, '$1$2$3')
266
266
  .replace(new RegExp(cjk + '([\\+\\-\\*\\/=&\\\\\\|<>])([A-Za-z0-9])', 'g'), '$1 $2 $3')
267
267
  .replace(new RegExp('([A-Za-z0-9])([\\+\\-\\*\\/=&\\\\\\|<>])' + cjk, 'g'), '$1 $2 $3');
package/prototype.js CHANGED
@@ -282,8 +282,8 @@ if (!global.my_prototype_defined) {
282
282
  return this;
283
283
  let text_;
284
284
  text_ = this
285
- .replace(new RegExp(cjk + `(['"])`, 'g'), '$1 $2')
286
- .replace(new RegExp(`(['"])` + cjk, 'g'), '$1 $2')
285
+ .replace(new RegExp(cjk + '([\'"])', 'g'), '$1 $2')
286
+ .replace(new RegExp('([\'"])' + cjk, 'g'), '$1 $2')
287
287
  .replace(/(["']+)\s*(.+?)\s*(["']+)/g, '$1$2$3')
288
288
  .replace(new RegExp(cjk + '([\\+\\-\\*\\/=&\\\\\\|<>])([A-Za-z0-9])', 'g'), '$1 $2 $3')
289
289
  .replace(new RegExp('([A-Za-z0-9])([\\+\\-\\*\\/=&\\\\\\|<>])' + cjk, 'g'), '$1 $2 $3');
package/repl.js CHANGED
@@ -311,6 +311,7 @@ export async function pollute_global() {
311
311
  if (mod?.__esModule)
312
312
  return mod;
313
313
  let result = {};
314
+ // eslint-disable-next-line eqeqeq
314
315
  if (mod != null)
315
316
  for (let k in mod)
316
317
  if (Object.hasOwnProperty.call(mod, k))
package/server.js CHANGED
@@ -122,9 +122,8 @@ export class Server {
122
122
  request.body = JSON.parse(req.body.toString());
123
123
  else if (ctx.is('application/x-www-form-urlencoded'))
124
124
  request.body = qs.parse(req.body.toString());
125
- else if (ctx.is('multipart/form-data')) {
125
+ else if (ctx.is('multipart/form-data'))
126
126
  throw new Error('multipart/form-data is not supported');
127
- }
128
127
  else
129
128
  request.body = req.body;
130
129
  }
@@ -300,7 +299,7 @@ export class Server {
300
299
  assert(stats.size <= Number.MAX_SAFE_INTEGER);
301
300
  let start = range[1] ? parseInt(range[1]) : undefined;
302
301
  let end = range[2] ? parseInt(range[2]) : Number(stats.size) - 1;
303
- if (typeof start == 'undefined') {
302
+ if (start === undefined) {
304
303
  start = Number(stats.size) - end;
305
304
  end = Number(stats.size) - 1;
306
305
  }
@@ -11,7 +11,8 @@ export interface Deferred<TValue> extends Promise<TValue> {
11
11
  reject(reason?: Error): void;
12
12
  }
13
13
  /** 创建一个 promise,后续可调用 promise.resolve, promise.reject 方法设置其状态和值
14
- - initial?: `undefined` 传入非 undefined 值(包括 null)时直接设置为 resolved 状态 */
14
+ - initial?: `undefined` 传入非 undefined 值(包括 null)时直接设置为 resolved 状态
15
+ 注: 下面的方法不能标记为 aysnc function, 否则会对返回值再做一层 Promise.resolve() 导致 reject, resolve 属性丢失 */
15
16
  export declare function defer<TValue>(initial?: TValue): Deferred<TValue>;
16
17
  export interface LockedAction<TResource, TResult> {
17
18
  (resource: TResource): TResult | Promise<TResult>;
package/utils.browser.js CHANGED
@@ -17,7 +17,9 @@ export async function timeout(milliseconds) {
17
17
  throw error;
18
18
  }
19
19
  /** 创建一个 promise,后续可调用 promise.resolve, promise.reject 方法设置其状态和值
20
- - initial?: `undefined` 传入非 undefined 值(包括 null)时直接设置为 resolved 状态 */
20
+ - initial?: `undefined` 传入非 undefined 值(包括 null)时直接设置为 resolved 状态
21
+ 注: 下面的方法不能标记为 aysnc function, 否则会对返回值再做一层 Promise.resolve() 导致 reject, resolve 属性丢失 */
22
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
21
23
  export function defer(initial) {
22
24
  if (initial === undefined) {
23
25
  let resolve;
package/utils.d.ts CHANGED
@@ -51,7 +51,8 @@ export interface Deferred<TValue> extends Promise<TValue> {
51
51
  reject(reason?: Error): void;
52
52
  }
53
53
  /** 创建一个 promise,后续可调用 promise.resolve, promise.reject 方法设置其状态和值
54
- - initial?: `undefined` 传入非 undefined 值(包括 null)时直接设置为 resolved 状态 */
54
+ - initial?: `undefined` 传入非 undefined 值(包括 null)时直接设置为 resolved 状态
55
+ 注: 下面的方法不能标记为 aysnc function, 否则会对返回值再做一层 Promise.resolve() 导致 reject, resolve 属性丢失 */
55
56
  export declare function defer<TValue>(initial?: TValue): Deferred<TValue>;
56
57
  export interface LockedAction<TResource, TResult> {
57
58
  (resource: TResource): TResult | Promise<TResult>;
package/utils.js CHANGED
@@ -156,7 +156,9 @@ export async function timeout(milliseconds) {
156
156
  throw error;
157
157
  }
158
158
  /** 创建一个 promise,后续可调用 promise.resolve, promise.reject 方法设置其状态和值
159
- - initial?: `undefined` 传入非 undefined 值(包括 null)时直接设置为 resolved 状态 */
159
+ - initial?: `undefined` 传入非 undefined 值(包括 null)时直接设置为 resolved 状态
160
+ 注: 下面的方法不能标记为 aysnc function, 否则会对返回值再做一层 Promise.resolve() 导致 reject, resolve 属性丢失 */
161
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
160
162
  export function defer(initial) {
161
163
  if (initial === undefined) {
162
164
  let resolve;