clickgo-native 0.0.9 → 0.0.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/dist/index.js CHANGED
@@ -96,7 +96,7 @@ const methods = {
96
96
  'cg-set-state': {
97
97
  'once': false,
98
98
  handler: function (t, state) {
99
- if (!form || !state) {
99
+ if (!hasFrame || !form || !state) {
100
100
  return;
101
101
  }
102
102
  if (!verifyToken(t)) {
@@ -308,6 +308,68 @@ const methods = {
308
308
  });
309
309
  }
310
310
  },
311
+ 'cg-form-open': {
312
+ 'once': false,
313
+ handler: function (t, options = {}) {
314
+ var _a, _b, _c, _d, _e;
315
+ var _f, _g, _h;
316
+ if (!t || !form) {
317
+ return null;
318
+ }
319
+ if (!verifyToken(t)) {
320
+ return null;
321
+ }
322
+ (_a = options.filters) !== null && _a !== void 0 ? _a : (options.filters = []);
323
+ (_b = options.props) !== null && _b !== void 0 ? _b : (options.props = {});
324
+ (_c = (_f = options.props).file) !== null && _c !== void 0 ? _c : (_f.file = true);
325
+ (_d = (_g = options.props).directory) !== null && _d !== void 0 ? _d : (_g.directory = false);
326
+ (_e = (_h = options.props).multi) !== null && _e !== void 0 ? _e : (_h.multi = false);
327
+ const paths = electron.dialog.showOpenDialogSync(form, {
328
+ 'defaultPath': options.path ? exports.tool.formatPath(options.path) : undefined,
329
+ 'filters': options.filters.map((item) => {
330
+ return {
331
+ 'name': item.name,
332
+ 'extensions': item.accept,
333
+ };
334
+ }),
335
+ 'properties': [
336
+ options.props.file ? 'openFile' : '',
337
+ options.props.directory ? 'openDirectory' : '',
338
+ options.props.multi ? 'multiSelections' : '',
339
+ ].filter(item => item),
340
+ });
341
+ if (!paths) {
342
+ return null;
343
+ }
344
+ return paths.map(item => exports.tool.parsePath(item));
345
+ }
346
+ },
347
+ 'cg-form-save': {
348
+ 'once': false,
349
+ handler: function (t, options = {}) {
350
+ var _a;
351
+ if (!t || !form) {
352
+ return null;
353
+ }
354
+ if (!verifyToken(t)) {
355
+ return null;
356
+ }
357
+ (_a = options.filters) !== null && _a !== void 0 ? _a : (options.filters = []);
358
+ const path = electron.dialog.showSaveDialogSync(form, {
359
+ 'defaultPath': options.path ? exports.tool.formatPath(options.path) : undefined,
360
+ 'filters': options.filters.map((item) => {
361
+ return {
362
+ 'name': item.name,
363
+ 'extensions': item.accept,
364
+ };
365
+ }),
366
+ });
367
+ if (!path) {
368
+ return null;
369
+ }
370
+ return exports.tool.parsePath(path);
371
+ }
372
+ },
311
373
  'cg-ping': {
312
374
  'once': false,
313
375
  handler: function (t) {
@@ -446,23 +508,16 @@ function createForm(p) {
446
508
  }
447
509
  form.show();
448
510
  });
449
- if (p.startsWith('https://') || p.startsWith('http://')) {
450
- form.loadURL(p).catch(function (e) {
451
- throw e;
452
- });
453
- }
454
- else {
455
- const lio = p.indexOf('?');
456
- const search = lio === -1 ? '' : p.slice(lio + 1);
457
- if (lio !== -1) {
458
- p = p.slice(0, lio);
459
- }
460
- form.loadFile(p, {
461
- 'search': search
462
- }).catch(function (e) {
463
- throw e;
464
- });
511
+ const lio = p.indexOf('?');
512
+ const search = lio === -1 ? '' : p.slice(lio + 1);
513
+ if (lio !== -1) {
514
+ p = p.slice(0, lio);
465
515
  }
516
+ form.loadFile(p, {
517
+ 'search': search
518
+ }).catch(function (e) {
519
+ throw e;
520
+ });
466
521
  form.on('close', function () {
467
522
  form = undefined;
468
523
  });
package/dist/lib/fs.js CHANGED
@@ -58,15 +58,6 @@ exports.copyFile = copyFile;
58
58
  const fs = __importStar(require("fs"));
59
59
  const tool = __importStar(require("./tool"));
60
60
  const platform = process.platform;
61
- function formatPath(path) {
62
- if (platform !== 'win32') {
63
- return path;
64
- }
65
- if (path === '/') {
66
- return path;
67
- }
68
- return path[1] + ':' + path.slice(2);
69
- }
70
61
  const drives = [];
71
62
  function refreshDrives() {
72
63
  return __awaiter(this, void 0, void 0, function* () {
@@ -87,7 +78,7 @@ function refreshDrives() {
87
78
  }
88
79
  function getContent(path, options) {
89
80
  return __awaiter(this, void 0, void 0, function* () {
90
- path = formatPath(path);
81
+ path = tool.formatPath(path);
91
82
  const encoding = options.encoding;
92
83
  const start = options.start;
93
84
  const end = options.end;
@@ -136,7 +127,7 @@ function getContent(path, options) {
136
127
  }
137
128
  function putContent(path, data, options) {
138
129
  return __awaiter(this, void 0, void 0, function* () {
139
- path = formatPath(path);
130
+ path = tool.formatPath(path);
140
131
  try {
141
132
  yield fs.promises.writeFile(path, data, options);
142
133
  return true;
@@ -148,7 +139,7 @@ function putContent(path, data, options) {
148
139
  }
149
140
  function readLink(path, encoding) {
150
141
  return __awaiter(this, void 0, void 0, function* () {
151
- path = formatPath(path);
142
+ path = tool.formatPath(path);
152
143
  try {
153
144
  return yield fs.promises.readlink(path, {
154
145
  'encoding': encoding
@@ -161,8 +152,8 @@ function readLink(path, encoding) {
161
152
  }
162
153
  function symlink(filePath, linkPath, type) {
163
154
  return __awaiter(this, void 0, void 0, function* () {
164
- filePath = formatPath(filePath);
165
- linkPath = formatPath(linkPath);
155
+ filePath = tool.formatPath(filePath);
156
+ linkPath = tool.formatPath(linkPath);
166
157
  try {
167
158
  yield fs.promises.symlink(filePath, linkPath, type);
168
159
  return true;
@@ -174,7 +165,7 @@ function symlink(filePath, linkPath, type) {
174
165
  }
175
166
  function unlink(path) {
176
167
  return __awaiter(this, void 0, void 0, function* () {
177
- path = formatPath(path);
168
+ path = tool.formatPath(path);
178
169
  for (let i = 0; i <= 2; ++i) {
179
170
  try {
180
171
  yield fs.promises.unlink(path);
@@ -195,7 +186,7 @@ function unlink(path) {
195
186
  }
196
187
  function stats(path) {
197
188
  return __awaiter(this, void 0, void 0, function* () {
198
- path = formatPath(path);
189
+ path = tool.formatPath(path);
199
190
  try {
200
191
  const item = yield fs.promises.lstat(path);
201
192
  return {
@@ -221,7 +212,7 @@ function stats(path) {
221
212
  }
222
213
  function mkdir(path, mode) {
223
214
  return __awaiter(this, void 0, void 0, function* () {
224
- path = formatPath(path);
215
+ path = tool.formatPath(path);
225
216
  const stats = yield fs.promises.lstat(path);
226
217
  if (stats.isDirectory()) {
227
218
  return true;
@@ -240,7 +231,7 @@ function mkdir(path, mode) {
240
231
  }
241
232
  function rmdir(path) {
242
233
  return __awaiter(this, void 0, void 0, function* () {
243
- path = formatPath(path);
234
+ path = tool.formatPath(path);
244
235
  const stats = yield fs.promises.lstat(path);
245
236
  if (!stats.isDirectory()) {
246
237
  return true;
@@ -256,7 +247,7 @@ function rmdir(path) {
256
247
  }
257
248
  function chmod(path, mod) {
258
249
  return __awaiter(this, void 0, void 0, function* () {
259
- path = formatPath(path);
250
+ path = tool.formatPath(path);
260
251
  try {
261
252
  yield fs.promises.chmod(path, mod);
262
253
  return true;
@@ -268,8 +259,8 @@ function chmod(path, mod) {
268
259
  }
269
260
  function rename(oldPath, newPath) {
270
261
  return __awaiter(this, void 0, void 0, function* () {
271
- oldPath = formatPath(oldPath);
272
- newPath = formatPath(newPath);
262
+ oldPath = tool.formatPath(oldPath);
263
+ newPath = tool.formatPath(newPath);
273
264
  try {
274
265
  yield fs.promises.rename(oldPath, newPath);
275
266
  return true;
@@ -323,8 +314,8 @@ function readDir(path, encoding) {
323
314
  }
324
315
  function copyFile(src, dest) {
325
316
  return __awaiter(this, void 0, void 0, function* () {
326
- src = formatPath(src);
327
- dest = formatPath(dest);
317
+ src = tool.formatPath(src);
318
+ dest = tool.formatPath(dest);
328
319
  try {
329
320
  yield fs.promises.copyFile(src, dest);
330
321
  return true;
@@ -1 +1,3 @@
1
1
  export declare function sleep(ms: number): Promise<void>;
2
+ export declare function formatPath(path: string): string;
3
+ export declare function parsePath(path: string): string;
package/dist/lib/tool.js CHANGED
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sleep = sleep;
4
+ exports.formatPath = formatPath;
5
+ exports.parsePath = parsePath;
6
+ const platform = process.platform;
4
7
  function sleep(ms) {
5
8
  return new Promise(function (resolve) {
6
9
  setTimeout(function () {
@@ -8,3 +11,23 @@ function sleep(ms) {
8
11
  }, ms);
9
12
  });
10
13
  }
14
+ function formatPath(path) {
15
+ if (platform !== 'win32') {
16
+ return path;
17
+ }
18
+ if (path === '/') {
19
+ return path;
20
+ }
21
+ path = path.replace(/\//g, '\\');
22
+ return path[1] + ':' + path.slice(2);
23
+ }
24
+ function parsePath(path) {
25
+ if (platform !== 'win32') {
26
+ return path;
27
+ }
28
+ path = path.replace(/\\/g, '/');
29
+ if (path === '/') {
30
+ return path;
31
+ }
32
+ return '/' + path[0].toLowerCase() + path.slice(2);
33
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clickgo-native",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "The software developed with ClickGo will run in Windows, Mac OS, Linux.",
5
5
  "keywords": [
6
6
  "clickgo",
@@ -9,17 +9,17 @@
9
9
  "main": "dist/index.js",
10
10
  "author": "hanguoshuai",
11
11
  "license": "Apache-2.0",
12
- "types": "./dist/index.ts",
12
+ "types": "./dist/index.d.ts",
13
13
  "scripts": {
14
14
  "native": "electron ./dist/test"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@litert/eslint-plugin-rules": "^0.3.1",
18
- "@types/node": "^24.0.13",
18
+ "@types/node": "^24.0.14",
19
19
  "typescript": "^5.8.3"
20
20
  },
21
21
  "dependencies": {
22
- "clickgo": "^3.16.17",
22
+ "clickgo": "^3.16.18",
23
23
  "electron": "^37.2.1"
24
24
  }
25
25
  }
package/types/loader.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import * as litertLoader from '@litert/loader';
2
-
3
- declare global {
4
- type ILoader = litertLoader.ILoader;
5
- type ILoaderUrl = litertLoader.ILoaderUrl;
6
-
7
- const loader: typeof litertLoader.loader;
8
- const __invoke: typeof litertLoader.__invoke;
9
- const __preprocess: typeof litertLoader.__preprocess;
10
- }