clickgo-native 0.0.18 → 1.0.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/LICENSE +1 -1
- package/README.md +15 -18
- package/dist/index.d.ts +70 -5
- package/dist/index.js +240 -239
- package/dist/lib/fs.d.ts +1 -0
- package/dist/lib/fs.js +215 -294
- package/dist/lib/tool.d.ts +6 -0
- package/dist/lib/tool.js +10 -8
- package/dist/pre.js +3 -38
- package/package.json +7 -7
- package/dist/pre.d.ts +0 -1
- package/eslint.config.js +0 -22
package/dist/lib/fs.d.ts
CHANGED
package/dist/lib/fs.js
CHANGED
|
@@ -1,327 +1,248 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.refreshDrives = refreshDrives;
|
|
46
|
-
exports.getContent = getContent;
|
|
47
|
-
exports.putContent = putContent;
|
|
48
|
-
exports.readLink = readLink;
|
|
49
|
-
exports.symlink = symlink;
|
|
50
|
-
exports.unlink = unlink;
|
|
51
|
-
exports.stats = stats;
|
|
52
|
-
exports.mkdir = mkdir;
|
|
53
|
-
exports.rmdir = rmdir;
|
|
54
|
-
exports.chmod = chmod;
|
|
55
|
-
exports.rename = rename;
|
|
56
|
-
exports.readDir = readDir;
|
|
57
|
-
exports.copyFile = copyFile;
|
|
58
|
-
const fs = __importStar(require("fs"));
|
|
59
|
-
const tool = __importStar(require("./tool"));
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as lTool from './tool.js';
|
|
3
|
+
/** --- 当前系统平台 --- */
|
|
60
4
|
const platform = process.platform;
|
|
5
|
+
/** --- windows 下驱动器列表 --- */
|
|
61
6
|
const drives = [];
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
catch (_a) {
|
|
75
|
-
}
|
|
7
|
+
/** --- 更新 drives 列表 --- */
|
|
8
|
+
export async function refreshDrives() {
|
|
9
|
+
if (platform !== 'win32') {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
drives.length = 0;
|
|
13
|
+
for (let i = 0; i < 26; ++i) {
|
|
14
|
+
const char = String.fromCharCode(97 + i);
|
|
15
|
+
try {
|
|
16
|
+
await fs.promises.stat(char + ':/');
|
|
17
|
+
drives.push(char);
|
|
76
18
|
}
|
|
77
|
-
|
|
19
|
+
catch { }
|
|
20
|
+
}
|
|
78
21
|
}
|
|
79
|
-
function getContent(path, options) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
'end': end
|
|
91
|
-
});
|
|
92
|
-
const data = [];
|
|
93
|
-
rs.on('data', function (chunk) {
|
|
94
|
-
if (!(chunk instanceof Buffer)) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
data.push(chunk);
|
|
98
|
-
}).on('end', function () {
|
|
99
|
-
const buf = Buffer.concat(data);
|
|
100
|
-
if (encoding) {
|
|
101
|
-
resolve(buf.toString());
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
resolve(buf);
|
|
105
|
-
}
|
|
106
|
-
}).on('error', function () {
|
|
107
|
-
resolve(null);
|
|
108
|
-
});
|
|
22
|
+
export async function getContent(path, options) {
|
|
23
|
+
path = lTool.formatPath(path);
|
|
24
|
+
const encoding = options.encoding;
|
|
25
|
+
const start = options.start;
|
|
26
|
+
const end = options.end;
|
|
27
|
+
if (start || end) {
|
|
28
|
+
return new Promise(function (resolve) {
|
|
29
|
+
const rs = fs.createReadStream(path, {
|
|
30
|
+
'encoding': encoding,
|
|
31
|
+
'start': start,
|
|
32
|
+
'end': end
|
|
109
33
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
34
|
+
const data = [];
|
|
35
|
+
rs.on('data', function (chunk) {
|
|
36
|
+
if (!(chunk instanceof Buffer)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
data.push(chunk);
|
|
40
|
+
}).on('end', function () {
|
|
41
|
+
const buf = Buffer.concat(data);
|
|
113
42
|
if (encoding) {
|
|
114
|
-
|
|
115
|
-
'encoding': encoding
|
|
116
|
-
});
|
|
43
|
+
resolve(buf.toString());
|
|
117
44
|
}
|
|
118
45
|
else {
|
|
119
|
-
|
|
46
|
+
resolve(buf);
|
|
120
47
|
}
|
|
48
|
+
}).on('error', function () {
|
|
49
|
+
resolve(null);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
try {
|
|
55
|
+
if (encoding) {
|
|
56
|
+
return await fs.promises.readFile(path, {
|
|
57
|
+
'encoding': encoding
|
|
58
|
+
});
|
|
121
59
|
}
|
|
122
|
-
|
|
123
|
-
return
|
|
60
|
+
else {
|
|
61
|
+
return await fs.promises.readFile(path);
|
|
124
62
|
}
|
|
125
63
|
}
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
function putContent(path, data, options) {
|
|
129
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
path = tool.formatPath(path);
|
|
131
|
-
try {
|
|
132
|
-
yield fs.promises.writeFile(path, data, options);
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
catch (_a) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
function readLink(path, encoding) {
|
|
141
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
path = tool.formatPath(path);
|
|
143
|
-
try {
|
|
144
|
-
return yield fs.promises.readlink(path, {
|
|
145
|
-
'encoding': encoding
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
catch (_a) {
|
|
64
|
+
catch {
|
|
149
65
|
return null;
|
|
150
66
|
}
|
|
151
|
-
}
|
|
67
|
+
}
|
|
152
68
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
});
|
|
69
|
+
export async function putContent(path, data, options) {
|
|
70
|
+
path = lTool.formatPath(path);
|
|
71
|
+
try {
|
|
72
|
+
await fs.promises.writeFile(path, data, options);
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
165
78
|
}
|
|
166
|
-
function
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
try {
|
|
179
|
-
yield fs.promises.unlink(path);
|
|
180
|
-
return true;
|
|
181
|
-
}
|
|
182
|
-
catch (_b) {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
});
|
|
79
|
+
export async function readLink(path, encoding) {
|
|
80
|
+
path = lTool.formatPath(path);
|
|
81
|
+
try {
|
|
82
|
+
return await fs.promises.readlink(path, {
|
|
83
|
+
'encoding': encoding
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
186
89
|
}
|
|
187
|
-
function
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
'blksize': item.blksize,
|
|
198
|
-
'atimeMs': item.atimeMs,
|
|
199
|
-
'mtimeMs': item.mtimeMs,
|
|
200
|
-
'ctimeMs': item.ctimeMs,
|
|
201
|
-
'birthtimeMs': item.birthtimeMs,
|
|
202
|
-
'atime': item.atime,
|
|
203
|
-
'mtime': item.mtime,
|
|
204
|
-
'ctime': item.ctime,
|
|
205
|
-
'birthtime': item.birthtime
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
catch (_a) {
|
|
209
|
-
return null;
|
|
210
|
-
}
|
|
211
|
-
});
|
|
90
|
+
export async function symlink(filePath, linkPath, type) {
|
|
91
|
+
filePath = lTool.formatPath(filePath);
|
|
92
|
+
linkPath = lTool.formatPath(linkPath);
|
|
93
|
+
try {
|
|
94
|
+
await fs.promises.symlink(filePath, linkPath, type);
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
212
100
|
}
|
|
213
|
-
function
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const stats = yield fs.promises.lstat(path);
|
|
217
|
-
if (stats.isDirectory()) {
|
|
218
|
-
return true;
|
|
219
|
-
}
|
|
101
|
+
export async function unlink(path) {
|
|
102
|
+
path = lTool.formatPath(path);
|
|
103
|
+
for (let i = 0; i <= 2; ++i) {
|
|
220
104
|
try {
|
|
221
|
-
|
|
222
|
-
'recursive': true,
|
|
223
|
-
'mode': mode
|
|
224
|
-
});
|
|
105
|
+
await fs.promises.unlink(path);
|
|
225
106
|
return true;
|
|
226
107
|
}
|
|
227
|
-
catch
|
|
228
|
-
|
|
108
|
+
catch {
|
|
109
|
+
await lTool.sleep(250);
|
|
229
110
|
}
|
|
230
|
-
}
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
await fs.promises.unlink(path);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
231
119
|
}
|
|
232
|
-
function
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
120
|
+
export async function stats(path) {
|
|
121
|
+
path = lTool.formatPath(path);
|
|
122
|
+
try {
|
|
123
|
+
const item = await fs.promises.lstat(path);
|
|
124
|
+
return {
|
|
125
|
+
isFile: item.isFile(),
|
|
126
|
+
isDirectory: item.isDirectory(),
|
|
127
|
+
isSymbolicLink: item.isSymbolicLink(),
|
|
128
|
+
'size': item.size,
|
|
129
|
+
'blksize': item.blksize,
|
|
130
|
+
'atimeMs': item.atimeMs,
|
|
131
|
+
'mtimeMs': item.mtimeMs,
|
|
132
|
+
'ctimeMs': item.ctimeMs,
|
|
133
|
+
'birthtimeMs': item.birthtimeMs,
|
|
134
|
+
'atime': item.atime,
|
|
135
|
+
'mtime': item.mtime,
|
|
136
|
+
'ctime': item.ctime,
|
|
137
|
+
'birthtime': item.birthtime
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
247
143
|
}
|
|
248
|
-
function
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
144
|
+
export async function mkdir(path, mode) {
|
|
145
|
+
path = lTool.formatPath(path);
|
|
146
|
+
const stats = await fs.promises.lstat(path);
|
|
147
|
+
if (stats.isDirectory()) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
// --- 深度创建目录 ---
|
|
151
|
+
try {
|
|
152
|
+
await fs.promises.mkdir(path, {
|
|
153
|
+
'recursive': true,
|
|
154
|
+
'mode': mode
|
|
155
|
+
});
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
259
161
|
}
|
|
260
|
-
function
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
162
|
+
export async function rmdir(path) {
|
|
163
|
+
path = lTool.formatPath(path);
|
|
164
|
+
const stats = await fs.promises.lstat(path);
|
|
165
|
+
if (!stats.isDirectory()) {
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
await fs.promises.rmdir(path);
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
272
175
|
}
|
|
273
|
-
function
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
176
|
+
export async function chmod(path, mod) {
|
|
177
|
+
path = lTool.formatPath(path);
|
|
178
|
+
try {
|
|
179
|
+
await fs.promises.chmod(path, mod);
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
export async function rename(oldPath, newPath) {
|
|
187
|
+
oldPath = lTool.formatPath(oldPath);
|
|
188
|
+
newPath = lTool.formatPath(newPath);
|
|
189
|
+
try {
|
|
190
|
+
await fs.promises.rename(oldPath, newPath);
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
export async function readDir(path, encoding) {
|
|
198
|
+
try {
|
|
199
|
+
const list = [];
|
|
200
|
+
if (platform === 'win32') {
|
|
201
|
+
// --- 此处不能用 formatPath,因为还要读 drives ---
|
|
202
|
+
if (path === '/') {
|
|
203
|
+
for (const item of drives) {
|
|
204
|
+
list.push({
|
|
205
|
+
isFile: false,
|
|
206
|
+
isDirectory: true,
|
|
207
|
+
isSymbolicLink: false,
|
|
208
|
+
'name': item
|
|
209
|
+
});
|
|
291
210
|
}
|
|
211
|
+
return list;
|
|
292
212
|
}
|
|
293
|
-
|
|
294
|
-
'
|
|
295
|
-
'withFileTypes': true
|
|
296
|
-
});
|
|
297
|
-
for (const item of dlist) {
|
|
298
|
-
if (item.name === '.' || item.name === '..') {
|
|
299
|
-
continue;
|
|
300
|
-
}
|
|
301
|
-
list.push({
|
|
302
|
-
isFile: item.isFile(),
|
|
303
|
-
isDirectory: item.isDirectory(),
|
|
304
|
-
isSymbolicLink: item.isSymbolicLink(),
|
|
305
|
-
'name': item.name
|
|
306
|
-
});
|
|
213
|
+
else {
|
|
214
|
+
path = path[1] + ':' + path.slice(2);
|
|
307
215
|
}
|
|
308
|
-
return list;
|
|
309
216
|
}
|
|
310
|
-
|
|
311
|
-
|
|
217
|
+
const dlist = await fs.promises.readdir(path, {
|
|
218
|
+
'encoding': encoding,
|
|
219
|
+
'withFileTypes': true
|
|
220
|
+
});
|
|
221
|
+
for (const item of dlist) {
|
|
222
|
+
if (item.name === '.' || item.name === '..') {
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
list.push({
|
|
226
|
+
isFile: item.isFile(),
|
|
227
|
+
isDirectory: item.isDirectory(),
|
|
228
|
+
isSymbolicLink: item.isSymbolicLink(),
|
|
229
|
+
'name': item.name
|
|
230
|
+
});
|
|
312
231
|
}
|
|
313
|
-
|
|
232
|
+
return list;
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
return [];
|
|
236
|
+
}
|
|
314
237
|
}
|
|
315
|
-
function copyFile(src, dest) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
});
|
|
238
|
+
export async function copyFile(src, dest) {
|
|
239
|
+
src = lTool.formatPath(src);
|
|
240
|
+
dest = lTool.formatPath(dest);
|
|
241
|
+
try {
|
|
242
|
+
await fs.promises.copyFile(src, dest);
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
327
248
|
}
|
package/dist/lib/tool.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --- 间隔一段时间 ---
|
|
3
|
+
* @param ms 间隔毫秒
|
|
4
|
+
*/
|
|
1
5
|
export declare function sleep(ms: number): Promise<void>;
|
|
6
|
+
/** --- path 要额外处理一下,因为 windows 下可能有点不一样 --- */
|
|
2
7
|
export declare function formatPath(path: string): string;
|
|
8
|
+
/** --- 将真实路径转换回去 --- */
|
|
3
9
|
export declare function parsePath(path: string): string;
|
package/dist/lib/tool.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sleep = sleep;
|
|
4
|
-
exports.formatPath = formatPath;
|
|
5
|
-
exports.parsePath = parsePath;
|
|
1
|
+
/** --- 当前系统平台 --- */
|
|
6
2
|
const platform = process.platform;
|
|
7
|
-
|
|
3
|
+
/**
|
|
4
|
+
* --- 间隔一段时间 ---
|
|
5
|
+
* @param ms 间隔毫秒
|
|
6
|
+
*/
|
|
7
|
+
export function sleep(ms) {
|
|
8
8
|
return new Promise(function (resolve) {
|
|
9
9
|
setTimeout(function () {
|
|
10
10
|
resolve();
|
|
11
11
|
}, ms);
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
/** --- path 要额外处理一下,因为 windows 下可能有点不一样 --- */
|
|
15
|
+
export function formatPath(path) {
|
|
15
16
|
if (platform !== 'win32') {
|
|
16
17
|
return path;
|
|
17
18
|
}
|
|
@@ -21,7 +22,8 @@ function formatPath(path) {
|
|
|
21
22
|
path = path.replace(/\//g, '\\');
|
|
22
23
|
return path[1] + ':' + path.slice(2);
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
/** --- 将真实路径转换回去 --- */
|
|
26
|
+
export function parsePath(path) {
|
|
25
27
|
if (platform !== 'win32') {
|
|
26
28
|
return path;
|
|
27
29
|
}
|
package/dist/pre.js
CHANGED
|
@@ -1,41 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const electron = __importStar(require("electron"));
|
|
2
|
+
const electron = require('electron');
|
|
3
|
+
|
|
37
4
|
electron.contextBridge.exposeInMainWorld('clickgoNative', {
|
|
38
|
-
invoke:
|
|
39
|
-
return electron.ipcRenderer.invoke('pre', name, ...param);
|
|
40
|
-
}
|
|
5
|
+
invoke: (name, ...param) => electron.ipcRenderer.invoke('pre', name, ...param)
|
|
41
6
|
});
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clickgo-native",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "The software developed with ClickGo will run in Windows, Mac OS, Linux.",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"clickgo",
|
|
7
8
|
"clickgo-native"
|
|
8
9
|
],
|
|
9
|
-
"main": "dist/index.js",
|
|
10
|
+
"main": "./dist/index.js",
|
|
10
11
|
"author": "hanguoshuai",
|
|
11
12
|
"license": "Apache-2.0",
|
|
12
13
|
"types": "./dist/index.d.ts",
|
|
@@ -15,11 +16,10 @@
|
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
17
18
|
"@litert/eslint-plugin-rules": "^0.3.1",
|
|
18
|
-
"@
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"electron": "^37.2.2",
|
|
19
|
+
"@types/node": "^24.3.3",
|
|
20
|
+
"clickgo": "^4.0.3",
|
|
21
|
+
"electron": "^37.4.0",
|
|
22
22
|
"jszip": "^3.10.1",
|
|
23
|
-
"typescript": "^5.
|
|
23
|
+
"typescript": "^5.9.2"
|
|
24
24
|
}
|
|
25
25
|
}
|
package/dist/pre.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|