xshell 1.2.10 → 1.2.11

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/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export * from './utils.ts';
4
4
  export * from './file.ts';
5
5
  export * from './process.ts';
6
6
  export * from './net.ts';
7
+ export { path } from './path.ts';
package/index.js CHANGED
@@ -4,4 +4,5 @@ export * from "./utils.js";
4
4
  export * from "./file.js";
5
5
  export * from "./process.js";
6
6
  export * from "./net.js";
7
+ export { path } from "./path.js";
7
8
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.2.10",
3
+ "version": "1.2.11",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -56,7 +56,7 @@
56
56
  "@stylistic/eslint-plugin": "^2.13.0",
57
57
  "@svgr/webpack": "^8.1.0",
58
58
  "@types/sass-loader": "^8.0.9",
59
- "@types/ws": "^8.5.13",
59
+ "@types/ws": "^8.5.14",
60
60
  "@typescript-eslint/eslint-plugin": "^8.21.0",
61
61
  "@typescript-eslint/parser": "^8.21.0",
62
62
  "@typescript-eslint/utils": "^8.21.0",
@@ -96,7 +96,7 @@
96
96
  "tslib": "^2.8.1",
97
97
  "typescript": "^5.7.3",
98
98
  "ua-parser-js": "^2.0.0",
99
- "undici": "^7.2.3",
99
+ "undici": "^7.3.0",
100
100
  "vinyl": "^3.0.0",
101
101
  "vinyl-fs": "^4.0.0",
102
102
  "webpack": "^5.97.1",
@@ -114,8 +114,8 @@
114
114
  "@types/koa-compress": "^4.0.6",
115
115
  "@types/lodash": "^4.17.14",
116
116
  "@types/mime-types": "^2.1.4",
117
- "@types/node": "^22.10.7",
118
- "@types/react": "^19.0.7",
117
+ "@types/node": "^22.10.10",
118
+ "@types/react": "^19.0.8",
119
119
  "@types/through2": "^2.0.41",
120
120
  "@types/tough-cookie": "^4.0.5",
121
121
  "@types/ua-parser-js": "^0.7.39",
package/storage.d.ts CHANGED
@@ -10,3 +10,13 @@ export declare let storage: {
10
10
  list(): string[];
11
11
  delete(key: string): void;
12
12
  };
13
+ export declare let db: {
14
+ store_name: "kv-store";
15
+ db: IDBDatabase;
16
+ wait_request<TResult>(request: IDBOpenDBRequest | IDBRequest): Promise<TResult>;
17
+ open(): Promise<void>;
18
+ transaction(mode: IDBTransactionMode): IDBObjectStore;
19
+ get<TReturn = any>(key: IDBValidKey): Promise<TReturn>;
20
+ set(key: IDBValidKey, value: any): Promise<void>;
21
+ delete(key: string): Promise<void>;
22
+ };
package/storage.js CHANGED
@@ -26,4 +26,42 @@ export let storage = {
26
26
  localStorage.removeItem(key);
27
27
  }
28
28
  };
29
+ export let db = {
30
+ store_name: 'kv-store',
31
+ db: null,
32
+ async wait_request(request) {
33
+ return new Promise((resolve, reject) => {
34
+ request.onerror = event => {
35
+ reject(request.error);
36
+ };
37
+ request.onsuccess = event => {
38
+ resolve(request.result);
39
+ };
40
+ });
41
+ },
42
+ async open() {
43
+ let request = indexedDB.open('storage');
44
+ request.onupgradeneeded = event => {
45
+ request.result.createObjectStore(this.store_name);
46
+ };
47
+ this.db = await this.wait_request(request);
48
+ },
49
+ transaction(mode) {
50
+ return this.db.transaction(this.store_name, mode)
51
+ .objectStore(this.store_name);
52
+ },
53
+ async get(key) {
54
+ return this.wait_request(this.transaction('readonly').get(key));
55
+ },
56
+ async set(key, value) {
57
+ // 当 uint8array 长度与底层的 arraybuffer 长度不同时,可能是其中的一个 view,为了存储效率直接创建一个独立的 arraybuffer
58
+ if (value && value instanceof Uint8Array && value.byteLength !== value.buffer.byteLength)
59
+ value = value.slice();
60
+ await this.wait_request(this.transaction('readwrite').put(value, key));
61
+ },
62
+ async delete(key) {
63
+ return this.wait_request(this.transaction('readwrite')
64
+ .delete(key));
65
+ }
66
+ };
29
67
  //# sourceMappingURL=storage.js.map