fontastic 1.2.0 → 1.3.1

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.
Files changed (75) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +29 -0
  3. package/README.md +6 -0
  4. package/app/Application.js +4 -4
  5. package/app/Application.ts +13 -13
  6. package/app/config/database.js +1 -1
  7. package/app/config/database.ts +1 -1
  8. package/app/config/mimes.js +23 -23
  9. package/app/config/mimes.ts +35 -29
  10. package/app/core/ConfigManager.js +27 -0
  11. package/app/core/ConfigManager.ts +28 -0
  12. package/app/core/FontFinder.js +66 -15
  13. package/app/core/FontFinder.ts +81 -22
  14. package/app/core/FontManager.js +20 -18
  15. package/app/core/FontManager.ts +21 -19
  16. package/app/core/FontObject.js +44 -24
  17. package/app/core/FontObject.ts +47 -27
  18. package/app/core/MessageHandler.js +70 -19
  19. package/app/core/MessageHandler.ts +82 -21
  20. package/app/core/SystemManager.js +5 -1
  21. package/app/core/SystemManager.ts +5 -1
  22. package/app/database/entity/Collection.schema.js +20 -18
  23. package/app/database/entity/Collection.schema.ts +22 -21
  24. package/app/database/repository/Collection.repository.js +17 -18
  25. package/app/database/repository/Collection.repository.ts +27 -18
  26. package/app/database/repository/Store.repository.js +13 -18
  27. package/app/database/repository/Store.repository.ts +13 -21
  28. package/app/enums/ChannelType.js +18 -0
  29. package/app/enums/ChannelType.ts +24 -0
  30. package/app/main.js +79 -2
  31. package/app/main.ts +100 -3
  32. package/app/package.json +1 -1
  33. package/app/types/NativeThemeState.js +3 -0
  34. package/app/types/NativeThemeState.ts +4 -0
  35. package/app/types/ScanProgress.js +3 -0
  36. package/app/types/ScanProgress.ts +6 -0
  37. package/app/types/SystemPreferencesState.js +3 -0
  38. package/app/types/SystemPreferencesState.ts +4 -0
  39. package/app/types/index.js +3 -0
  40. package/app/types/index.ts +3 -0
  41. package/package.json +1 -1
  42. package/src/app/core/services/database/database.service.ts +6 -0
  43. package/src/app/core/services/message/message.service.ts +33 -1
  44. package/src/app/core/services/presentation/presentation.service.ts +93 -1
  45. package/src/app/layout/footer/footer.component.html +13 -2
  46. package/src/app/layout/footer/footer.component.ts +18 -2
  47. package/src/app/layout/navigation/navigation.component.html +11 -9
  48. package/src/app/layout/navigation/navigation.component.ts +35 -0
  49. package/src/app/settings/ai-keys/ai-keys.component.ts +13 -18
  50. package/src/app/settings/danger-zone/danger-zone.component.html +8 -0
  51. package/src/app/settings/danger-zone/danger-zone.component.ts +12 -0
  52. package/src/app/settings/news-api/news-api.component.ts +6 -8
  53. package/src/app/settings/theme/theme.component.html +15 -2
  54. package/src/app/settings/theme/theme.component.ts +4 -0
  55. package/src/app/shared/components/datagrid/datagrid.component.html +8 -17
  56. package/src/app/shared/components/datagrid/datagrid.component.ts +6 -10
  57. package/src/app/shared/components/glyphs/glyphs.component.html +5 -15
  58. package/src/app/shared/components/glyphs/glyphs.component.ts +3 -0
  59. package/src/app/shared/components/preview/preview.component.html +1 -1
  60. package/src/app/shared/components/preview/preview.component.ts +3 -8
  61. package/src/app/shared/components/prompt-dialog/prompt-dialog.component.html +2 -2
  62. package/src/app/shared/components/prompt-dialog/prompt-dialog.component.ts +2 -1
  63. package/src/app/shared/components/rule-builder/rule-builder.component.html +18 -6
  64. package/src/app/shared/components/rule-builder/rule-builder.component.ts +34 -2
  65. package/src/app/shared/components/search/search.component.html +9 -36
  66. package/src/app/shared/components/search/search.component.ts +2 -1
  67. package/src/app/shared/components/waterfall/waterfall.component.html +1 -3
  68. package/src/app/shared/components/waterfall/waterfall.component.ts +2 -1
  69. package/src/app/shared/directives/disabled-opacity/disabled-opacity.directive.ts +18 -0
  70. package/src/app/shared/directives/hover-highlight/hover-highlight.directive.ts +38 -0
  71. package/src/app/shared/directives/index.ts +5 -0
  72. package/src/app/shared/directives/modal-backdrop/modal-backdrop.directive.ts +18 -0
  73. package/src/app/shared/directives/scroll-reset/scroll-reset.directive.ts +15 -0
  74. package/src/app/shared/directives/stop-propagation/stop-propagation.directive.ts +12 -0
  75. package/src/index.html +1 -1
@@ -18,13 +18,25 @@ const path = require("path");
18
18
  const fetch = require('node-fetch');
19
19
  class FontManager {
20
20
  constructor(systemManager, configManager, connectionManager) {
21
+ this.catalog = new FontCatalog_1.default();
21
22
  this.systemManager = systemManager;
22
23
  this.configManager = configManager;
23
24
  this.connectionManager = connectionManager;
24
25
  }
25
26
  fetchLatestNews(args) {
26
27
  return __awaiter(this, void 0, void 0, function* () {
27
- const response = yield fetch(args.endpoint);
28
+ // Retrieve API key securely from main process storage
29
+ let apiKey = args.apiKey;
30
+ if (!apiKey) {
31
+ const secureKey = this.configManager.getSecure('secure.news.apiKey');
32
+ if (secureKey) {
33
+ apiKey = secureKey;
34
+ }
35
+ }
36
+ if (!apiKey)
37
+ return { articles: [] };
38
+ const endpoint = `https://newsapi.org/v2/top-headlines?country=${args.country || 'us'}&apiKey=${apiKey}`;
39
+ const response = yield fetch(endpoint);
28
40
  const data = yield response.json();
29
41
  if (data === null || data === void 0 ? void 0 : data.articles) {
30
42
  this.configManager.set(StorageType_1.StorageType.News, Object.assign(Object.assign({}, this.configManager.get(StorageType_1.StorageType.News)), { articles: data.articles, ts: Date.now() }));
@@ -55,37 +67,27 @@ class FontManager {
55
67
  copyFiles(files, collectionId) {
56
68
  return __awaiter(this, void 0, void 0, function* () {
57
69
  const dest = this.getDestinationFolder(collectionId);
58
- console.log('[FontManager.copyFiles] dest:', dest, 'files:', files);
59
- const catalog = new FontCatalog_1.default();
60
- yield catalog.copyFiles(files, dest);
61
- const catalogFiles = files.map((file) => path.join(dest, path.basename(file)));
62
- console.log('[FontManager.copyFiles] catalogFiles:', catalogFiles);
63
- return catalogFiles;
70
+ yield this.catalog.copyFiles(files, dest);
71
+ return files.map((file) => path.join(dest, path.basename(file)));
64
72
  });
65
73
  }
66
74
  copyFolder(src, collectionId) {
67
75
  return __awaiter(this, void 0, void 0, function* () {
68
76
  const dest = this.getDestinationFolder(collectionId);
69
- console.log('[FontManager.copyFolder] src:', src, 'dest:', dest);
70
- const catalog = new FontCatalog_1.default();
71
- yield catalog.copyFolder(src, dest);
77
+ yield this.catalog.copyFolder(src, dest);
72
78
  return dest;
73
79
  });
74
80
  }
75
- scanFiles(files, options) {
81
+ scanFiles(files, options, onProgress) {
76
82
  return __awaiter(this, void 0, void 0, function* () {
77
- console.log('[FontManager.scanFiles] files:', files, 'options:', options);
78
- const finder = new FontFinder_1.default(this.connectionManager);
83
+ const finder = new FontFinder_1.default(this.connectionManager, onProgress);
79
84
  yield finder.scanFiles(files, options);
80
- console.log('[FontManager.scanFiles] done, processed:', finder.counter, 'errors:', finder.errors);
81
85
  });
82
86
  }
83
- scanFolder(dir, options) {
87
+ scanFolder(dir, options, onProgress) {
84
88
  return __awaiter(this, void 0, void 0, function* () {
85
- console.log('[FontManager.scanFolder] dir:', dir, 'options:', options);
86
- const finder = new FontFinder_1.default(this.connectionManager);
89
+ const finder = new FontFinder_1.default(this.connectionManager, onProgress);
87
90
  yield finder.scanFolder(dir, options);
88
- console.log('[FontManager.scanFolder] done, processed:', finder.counter, 'errors:', finder.errors);
89
91
  });
90
92
  }
91
93
  showMessageBox(options) {
@@ -5,7 +5,7 @@ import ConfigManager from './ConfigManager';
5
5
  import ConnectionManager from './ConnectionManager';
6
6
 
7
7
  import FontCatalog from './FontCatalog';
8
- import FontFinder from './FontFinder';
8
+ import FontFinder, { ProgressCallback } from './FontFinder';
9
9
  import { execute } from '../helpers/command';
10
10
 
11
11
  import { StorageType } from '../enums/StorageType';
@@ -18,6 +18,7 @@ export default class FontManager {
18
18
  systemManager: SystemManager;
19
19
  configManager: ConfigManager;
20
20
  connectionManager: ConnectionManager;
21
+ private catalog = new FontCatalog();
21
22
 
22
23
  constructor(systemManager: SystemManager, configManager: ConfigManager, connectionManager: ConnectionManager) {
23
24
  this.systemManager = systemManager;
@@ -26,7 +27,18 @@ export default class FontManager {
26
27
  }
27
28
 
28
29
  async fetchLatestNews(args: any) {
29
- const response = await fetch(args.endpoint);
30
+ // Retrieve API key securely from main process storage
31
+ let apiKey = args.apiKey;
32
+ if (!apiKey) {
33
+ const secureKey = this.configManager.getSecure('secure.news.apiKey');
34
+ if (secureKey) {
35
+ apiKey = secureKey;
36
+ }
37
+ }
38
+ if (!apiKey) return { articles: [] };
39
+
40
+ const endpoint = `https://newsapi.org/v2/top-headlines?country=${args.country || 'us'}&apiKey=${apiKey}`;
41
+ const response = await fetch(endpoint);
30
42
  const data = await response.json();
31
43
  if (data?.articles) {
32
44
  this.configManager.set(StorageType.News, {
@@ -58,34 +70,24 @@ export default class FontManager {
58
70
 
59
71
  async copyFiles(files: string[], collectionId: number): Promise<string[]> {
60
72
  const dest = this.getDestinationFolder(collectionId);
61
- console.log('[FontManager.copyFiles] dest:', dest, 'files:', files);
62
- const catalog = new FontCatalog();
63
- await catalog.copyFiles(files, dest);
64
- const catalogFiles = files.map((file) => path.join(dest, path.basename(file)));
65
- console.log('[FontManager.copyFiles] catalogFiles:', catalogFiles);
66
- return catalogFiles;
73
+ await this.catalog.copyFiles(files, dest);
74
+ return files.map((file) => path.join(dest, path.basename(file)));
67
75
  }
68
76
 
69
77
  async copyFolder(src: string, collectionId: number): Promise<string> {
70
78
  const dest = this.getDestinationFolder(collectionId);
71
- console.log('[FontManager.copyFolder] src:', src, 'dest:', dest);
72
- const catalog = new FontCatalog();
73
- await catalog.copyFolder(src, dest);
79
+ await this.catalog.copyFolder(src, dest);
74
80
  return dest;
75
81
  }
76
82
 
77
- async scanFiles(files: string[], options: any) {
78
- console.log('[FontManager.scanFiles] files:', files, 'options:', options);
79
- const finder = new FontFinder(this.connectionManager);
83
+ async scanFiles(files: string[], options: any, onProgress?: ProgressCallback) {
84
+ const finder = new FontFinder(this.connectionManager, onProgress);
80
85
  await finder.scanFiles(files, options);
81
- console.log('[FontManager.scanFiles] done, processed:', finder.counter, 'errors:', finder.errors);
82
86
  }
83
87
 
84
- async scanFolder(dir: string, options: any) {
85
- console.log('[FontManager.scanFolder] dir:', dir, 'options:', options);
86
- const finder = new FontFinder(this.connectionManager);
88
+ async scanFolder(dir: string, options: any, onProgress?: ProgressCallback) {
89
+ const finder = new FontFinder(this.connectionManager, onProgress);
87
90
  await finder.scanFolder(dir, options);
88
- console.log('[FontManager.scanFolder] done, processed:', finder.counter, 'errors:', finder.errors);
89
91
  }
90
92
 
91
93
  showMessageBox(options: any) {
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const fontkit = require("fontkit");
3
+ const fontkit = require('fontkit');
4
+ const MAX_CACHE_SIZE = 50;
5
+ const fontCache = new Map();
4
6
  class FontObject {
5
7
  constructor(fp) {
6
8
  try {
@@ -10,6 +12,20 @@ class FontObject {
10
12
  this.setError(fp, err.message);
11
13
  }
12
14
  }
15
+ static fromCache(fp) {
16
+ const cached = fontCache.get(fp);
17
+ if (cached)
18
+ return cached;
19
+ const obj = new FontObject(fp);
20
+ if (!obj.hasError()) {
21
+ if (fontCache.size >= MAX_CACHE_SIZE) {
22
+ const firstKey = fontCache.keys().next().value;
23
+ fontCache.delete(firstKey);
24
+ }
25
+ fontCache.set(fp, obj);
26
+ }
27
+ return obj;
28
+ }
13
29
  setFont(font) {
14
30
  this.font = font;
15
31
  }
@@ -23,31 +39,35 @@ class FontObject {
23
39
  return this.error;
24
40
  }
25
41
  hasError() {
26
- return this.error ? true : false;
42
+ return !!this.error;
27
43
  }
28
44
  getNamesTable() {
29
- const names = (this.font && this.font.name && this.font.name.records) ? this.font.name.records : false;
30
- let item = {};
31
- item.compatible_full_name = (names && names.compatibleFullName) ? names.compatibleFullName.en : "";
32
- item.copyright = (names && names.copyright) ? names.copyright.en : "";
33
- item.description = (names && names.description) ? names.description.en : "";
34
- item.designer = (names && names.designer) ? names.designer.en : "";
35
- item.designer_url = (names && names.designerURL) ? names.designerURL.en : "";
36
- item.font_family = (names && names.fontFamily) ? names.fontFamily.en : "";
37
- item.font_subfamily = (names && names.fontSubfamily) ? names.fontSubfamily.en : "";
38
- item.full_name = (names && names.fullName) ? names.fullName.en : "";
39
- item.license = (names && names.license) ? names.license.en : "";
40
- item.license_url = (names && names.licenseURL) ? names.licenseURL.en : "";
41
- item.manufacturer = (names && names.manufacturer) ? names.manufacturer.en : "";
42
- item.manufacturer_url = (names && names.manufacturerURL) ? names.manufacturerURL.en : "";
43
- item.post_script_name = (names && names.postScriptName) ? names.postScriptName.en : "";
44
- item.preferred_family = (names && names.preferredFamily) ? names.preferredFamily.en : "";
45
- item.preferred_sub_family = (names && names.preferredSubfamily) ? names.preferredSubfamily.en : "";
46
- item.sample_text = (names && names.sampleText) ? names.sampleText.en : "";
47
- item.trademark = (names && names.trademark) ? names.trademark.en : "";
48
- item.unique_id = (names && names.uniqueSubfamily) ? names.uniqueSubfamily.en : "";
49
- item.version = (names && names.version) ? names.version.en : "";
50
- return item;
45
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
46
+ if (this.namesTable)
47
+ return this.namesTable;
48
+ const names = (_b = (_a = this.font) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.records;
49
+ this.namesTable = {
50
+ compatible_full_name: (_d = (_c = names === null || names === void 0 ? void 0 : names.compatibleFullName) === null || _c === void 0 ? void 0 : _c.en) !== null && _d !== void 0 ? _d : '',
51
+ copyright: (_f = (_e = names === null || names === void 0 ? void 0 : names.copyright) === null || _e === void 0 ? void 0 : _e.en) !== null && _f !== void 0 ? _f : '',
52
+ description: (_h = (_g = names === null || names === void 0 ? void 0 : names.description) === null || _g === void 0 ? void 0 : _g.en) !== null && _h !== void 0 ? _h : '',
53
+ designer: (_k = (_j = names === null || names === void 0 ? void 0 : names.designer) === null || _j === void 0 ? void 0 : _j.en) !== null && _k !== void 0 ? _k : '',
54
+ designer_url: (_m = (_l = names === null || names === void 0 ? void 0 : names.designerURL) === null || _l === void 0 ? void 0 : _l.en) !== null && _m !== void 0 ? _m : '',
55
+ font_family: (_p = (_o = names === null || names === void 0 ? void 0 : names.fontFamily) === null || _o === void 0 ? void 0 : _o.en) !== null && _p !== void 0 ? _p : '',
56
+ font_subfamily: (_r = (_q = names === null || names === void 0 ? void 0 : names.fontSubfamily) === null || _q === void 0 ? void 0 : _q.en) !== null && _r !== void 0 ? _r : '',
57
+ full_name: (_t = (_s = names === null || names === void 0 ? void 0 : names.fullName) === null || _s === void 0 ? void 0 : _s.en) !== null && _t !== void 0 ? _t : '',
58
+ license: (_v = (_u = names === null || names === void 0 ? void 0 : names.license) === null || _u === void 0 ? void 0 : _u.en) !== null && _v !== void 0 ? _v : '',
59
+ license_url: (_x = (_w = names === null || names === void 0 ? void 0 : names.licenseURL) === null || _w === void 0 ? void 0 : _w.en) !== null && _x !== void 0 ? _x : '',
60
+ manufacturer: (_z = (_y = names === null || names === void 0 ? void 0 : names.manufacturer) === null || _y === void 0 ? void 0 : _y.en) !== null && _z !== void 0 ? _z : '',
61
+ manufacturer_url: (_1 = (_0 = names === null || names === void 0 ? void 0 : names.manufacturerURL) === null || _0 === void 0 ? void 0 : _0.en) !== null && _1 !== void 0 ? _1 : '',
62
+ post_script_name: (_3 = (_2 = names === null || names === void 0 ? void 0 : names.postScriptName) === null || _2 === void 0 ? void 0 : _2.en) !== null && _3 !== void 0 ? _3 : '',
63
+ preferred_family: (_5 = (_4 = names === null || names === void 0 ? void 0 : names.preferredFamily) === null || _4 === void 0 ? void 0 : _4.en) !== null && _5 !== void 0 ? _5 : '',
64
+ preferred_sub_family: (_7 = (_6 = names === null || names === void 0 ? void 0 : names.preferredSubfamily) === null || _6 === void 0 ? void 0 : _6.en) !== null && _7 !== void 0 ? _7 : '',
65
+ sample_text: (_9 = (_8 = names === null || names === void 0 ? void 0 : names.sampleText) === null || _8 === void 0 ? void 0 : _8.en) !== null && _9 !== void 0 ? _9 : '',
66
+ trademark: (_11 = (_10 = names === null || names === void 0 ? void 0 : names.trademark) === null || _10 === void 0 ? void 0 : _10.en) !== null && _11 !== void 0 ? _11 : '',
67
+ unique_id: (_13 = (_12 = names === null || names === void 0 ? void 0 : names.uniqueSubfamily) === null || _12 === void 0 ? void 0 : _12.en) !== null && _13 !== void 0 ? _13 : '',
68
+ version: (_15 = (_14 = names === null || names === void 0 ? void 0 : names.version) === null || _14 === void 0 ? void 0 : _14.en) !== null && _15 !== void 0 ? _15 : '',
69
+ };
70
+ return this.namesTable;
51
71
  }
52
72
  }
53
73
  exports.default = FontObject;
@@ -1,9 +1,12 @@
1
- const fontkit = require("fontkit");
1
+ const fontkit = require('fontkit');
2
2
 
3
- export default class FontObject {
3
+ const MAX_CACHE_SIZE = 50;
4
+ const fontCache = new Map<string, FontObject>();
4
5
 
6
+ export default class FontObject {
5
7
  font: any;
6
8
  error: any;
9
+ private namesTable: any;
7
10
 
8
11
  constructor(fp: string) {
9
12
  try {
@@ -13,6 +16,20 @@ export default class FontObject {
13
16
  }
14
17
  }
15
18
 
19
+ static fromCache(fp: string): FontObject {
20
+ const cached = fontCache.get(fp);
21
+ if (cached) return cached;
22
+ const obj = new FontObject(fp);
23
+ if (!obj.hasError()) {
24
+ if (fontCache.size >= MAX_CACHE_SIZE) {
25
+ const firstKey = fontCache.keys().next().value;
26
+ fontCache.delete(firstKey);
27
+ }
28
+ fontCache.set(fp, obj);
29
+ }
30
+ return obj;
31
+ }
32
+
16
33
  setFont(font: any) {
17
34
  this.font = font;
18
35
  }
@@ -30,33 +47,36 @@ export default class FontObject {
30
47
  }
31
48
 
32
49
  hasError() {
33
- return this.error ? true : false;
50
+ return !!this.error;
34
51
  }
35
52
 
36
53
  getNamesTable() {
37
- const names = (this.font && this.font.name && this.font.name.records) ? this.font.name.records : false;
38
-
39
- let item: any = {};
40
- item.compatible_full_name = (names && names.compatibleFullName) ? names.compatibleFullName.en : "";
41
- item.copyright = (names && names.copyright) ? names.copyright.en : "";
42
- item.description = (names && names.description) ? names.description.en : "";
43
- item.designer = (names && names.designer) ? names.designer.en : "";
44
- item.designer_url = (names && names.designerURL) ? names.designerURL.en : "";
45
- item.font_family = (names && names.fontFamily) ? names.fontFamily.en : "";
46
- item.font_subfamily = (names && names.fontSubfamily) ? names.fontSubfamily.en : "";
47
- item.full_name = (names && names.fullName) ? names.fullName.en : "";
48
- item.license = (names && names.license) ? names.license.en : "";
49
- item.license_url = (names && names.licenseURL) ? names.licenseURL.en : "";
50
- item.manufacturer = (names && names.manufacturer) ? names.manufacturer.en : "";
51
- item.manufacturer_url = (names && names.manufacturerURL) ? names.manufacturerURL.en : "";
52
- item.post_script_name = (names && names.postScriptName) ? names.postScriptName.en : "";
53
- item.preferred_family = (names && names.preferredFamily) ? names.preferredFamily.en : "";
54
- item.preferred_sub_family = (names && names.preferredSubfamily) ? names.preferredSubfamily.en : "";
55
- item.sample_text = (names && names.sampleText) ? names.sampleText.en : "";
56
- item.trademark = (names && names.trademark) ? names.trademark.en : "";
57
- item.unique_id = (names && names.uniqueSubfamily) ? names.uniqueSubfamily.en : "";
58
- item.version = (names && names.version) ? names.version.en : "";
59
-
60
- return item;
54
+ if (this.namesTable) return this.namesTable;
55
+
56
+ const names = this.font?.name?.records;
57
+
58
+ this.namesTable = {
59
+ compatible_full_name: names?.compatibleFullName?.en ?? '',
60
+ copyright: names?.copyright?.en ?? '',
61
+ description: names?.description?.en ?? '',
62
+ designer: names?.designer?.en ?? '',
63
+ designer_url: names?.designerURL?.en ?? '',
64
+ font_family: names?.fontFamily?.en ?? '',
65
+ font_subfamily: names?.fontSubfamily?.en ?? '',
66
+ full_name: names?.fullName?.en ?? '',
67
+ license: names?.license?.en ?? '',
68
+ license_url: names?.licenseURL?.en ?? '',
69
+ manufacturer: names?.manufacturer?.en ?? '',
70
+ manufacturer_url: names?.manufacturerURL?.en ?? '',
71
+ post_script_name: names?.postScriptName?.en ?? '',
72
+ preferred_family: names?.preferredFamily?.en ?? '',
73
+ preferred_sub_family: names?.preferredSubfamily?.en ?? '',
74
+ sample_text: names?.sampleText?.en ?? '',
75
+ trademark: names?.trademark?.en ?? '',
76
+ unique_id: names?.uniqueSubfamily?.en ?? '',
77
+ version: names?.version?.en ?? '',
78
+ };
79
+
80
+ return this.namesTable;
61
81
  }
62
82
  }
@@ -12,15 +12,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const electron_1 = require("electron");
13
13
  const FontObject_1 = require("./FontObject");
14
14
  const AppLogger_1 = require("./AppLogger");
15
- // import { Logger } from '../database/entity/Logger.schema';
16
- // import { Store, StoreManyAndCountType } from '../database/entity/Store.schema';
17
15
  const ChannelType_1 = require("../enums/ChannelType");
18
16
  class MessageHandler {
19
- constructor(systemManager, configManager, connectionManager, fontManager) {
17
+ constructor(systemManager, configManager, connectionManager, fontManager, mainWindow) {
20
18
  this.systemManager = systemManager;
21
19
  this.configManager = configManager;
22
20
  this.connectionManager = connectionManager;
23
21
  this.fontManager = fontManager;
22
+ this.mainWindow = mainWindow;
24
23
  }
25
24
  on(channel, done) {
26
25
  return electron_1.ipcMain.on(channel, done);
@@ -44,6 +43,17 @@ class MessageHandler {
44
43
  this.handle(ChannelType_1.ChannelType.IPC_SET_CONFIG, (_event, args) => __awaiter(this, void 0, void 0, function* () { return this.configManager.set(args.key, args.values); }));
45
44
  this.handle(ChannelType_1.ChannelType.IPC_GET_CONFIG, (_event, args) => __awaiter(this, void 0, void 0, function* () { return this.configManager.get(args.key); }));
46
45
  this.handle(ChannelType_1.ChannelType.IPC_ZAP_CONFIG, (_event) => __awaiter(this, void 0, void 0, function* () { return this.configManager.clear(); }));
46
+ // Safe Storage
47
+ this.handle(ChannelType_1.ChannelType.IPC_SAFE_STORE, (_event, args) => __awaiter(this, void 0, void 0, function* () {
48
+ this.configManager.setSecure(args.key, args.value);
49
+ }));
50
+ this.handle(ChannelType_1.ChannelType.IPC_SAFE_RETRIEVE, (_event, key) => __awaiter(this, void 0, void 0, function* () {
51
+ return this.configManager.getSecure(key);
52
+ }));
53
+ // Session: Clear Cache
54
+ this.handle(ChannelType_1.ChannelType.IPC_CLEAR_CACHE, () => __awaiter(this, void 0, void 0, function* () {
55
+ yield electron_1.session.defaultSession.clearCache();
56
+ }));
47
57
  // Connection Manager
48
58
  this.handle(ChannelType_1.ChannelType.IPC_DBCONNECTION_CREATE, (_event, args) => __awaiter(this, void 0, void 0, function* () { return this.configManager.createDbConnection(args); }));
49
59
  this.handle(ChannelType_1.ChannelType.IPC_DBCONNECTION_ENABLE, (_event, args) => this.configManager.enableDbConnection(args));
@@ -68,21 +78,45 @@ class MessageHandler {
68
78
  this.handle(ChannelType_1.ChannelType.IPC_EXEC_CMD, (_event, args) => __awaiter(this, void 0, void 0, function* () { return this.fontManager.executeCommand(args).catch((err) => this.sendMessage('error', err.message)); }));
69
79
  this.handle(ChannelType_1.ChannelType.IPC_AUTH_USER, (_event, args) => __awaiter(this, void 0, void 0, function* () { return this.fontManager.systemAuthenticate(args); }));
70
80
  this.handle(ChannelType_1.ChannelType.IPC_SCAN_FILES, (_event, args) => __awaiter(this, void 0, void 0, function* () {
71
- console.log('[IPC_SCAN_FILES] args:', JSON.stringify(args));
72
- const catalogFiles = yield this.fontManager.copyFiles(args.files, args.collectionId);
73
- console.log('[IPC_SCAN_FILES] copied to catalog:', catalogFiles);
74
- yield this.fontManager.scanFiles(catalogFiles, { collection_id: args.collectionId });
75
- console.log('[IPC_SCAN_FILES] scan complete');
81
+ const { port1, port2 } = new electron_1.MessageChannelMain();
82
+ this.mainWindow.webContents.postMessage(ChannelType_1.ChannelType.IPC_SCAN_PROGRESS_PORT, null, [port2]);
83
+ const onProgress = (progress) => {
84
+ try {
85
+ port1.postMessage(progress);
86
+ }
87
+ catch (_a) {
88
+ // Port may be closed if renderer navigated away
89
+ }
90
+ };
91
+ try {
92
+ const catalogFiles = yield this.fontManager.copyFiles(args.files, args.collectionId);
93
+ yield this.fontManager.scanFiles(catalogFiles, { collection_id: args.collectionId }, onProgress);
94
+ }
95
+ finally {
96
+ port1.close();
97
+ }
76
98
  }));
77
99
  this.handle(ChannelType_1.ChannelType.IPC_SCAN_FOLDERS, (_event, args) => __awaiter(this, void 0, void 0, function* () {
78
- console.log('[IPC_SCAN_FOLDERS] args:', JSON.stringify(args));
79
- const promises = args.folders.map((sourceFolder) => __awaiter(this, void 0, void 0, function* () {
80
- const dest = yield this.fontManager.copyFolder(sourceFolder, args.collectionId);
81
- console.log('[IPC_SCAN_FOLDERS] copied to:', dest);
82
- yield this.fontManager.scanFolder(dest, { collection_id: args.collectionId });
83
- console.log('[IPC_SCAN_FOLDERS] scan complete for:', dest);
84
- }));
85
- yield Promise.allSettled(promises);
100
+ const { port1, port2 } = new electron_1.MessageChannelMain();
101
+ this.mainWindow.webContents.postMessage(ChannelType_1.ChannelType.IPC_SCAN_PROGRESS_PORT, null, [port2]);
102
+ const onProgress = (progress) => {
103
+ try {
104
+ port1.postMessage(progress);
105
+ }
106
+ catch (_a) {
107
+ // Port may be closed if renderer navigated away
108
+ }
109
+ };
110
+ try {
111
+ const promises = args.folders.map((sourceFolder) => __awaiter(this, void 0, void 0, function* () {
112
+ const dest = yield this.fontManager.copyFolder(sourceFolder, args.collectionId);
113
+ yield this.fontManager.scanFolder(dest, { collection_id: args.collectionId }, onProgress);
114
+ }));
115
+ yield Promise.allSettled(promises);
116
+ }
117
+ finally {
118
+ port1.close();
119
+ }
86
120
  }));
87
121
  this.handle(ChannelType_1.ChannelType.IPC_FETCH_NEWS, (_event, args) => __awaiter(this, void 0, void 0, function* () { return this.fontManager.fetchLatestNews(args); }));
88
122
  this.handle(ChannelType_1.ChannelType.IPC_SHOW_MESSAGE_BOX, (_event, options) => __awaiter(this, void 0, void 0, function* () { return this.fontManager.showMessageBox(options); }));
@@ -158,13 +192,30 @@ class MessageHandler {
158
192
  const sc = yield this.connectionManager.getSmartCollectionRepository().findOneBy({ id: args.id });
159
193
  if (!sc)
160
194
  return [[], 0];
161
- const rules = JSON.parse(sc.rules);
195
+ let rules;
196
+ try {
197
+ rules = JSON.parse(sc.rules);
198
+ }
199
+ catch (_a) {
200
+ return [[], 0];
201
+ }
162
202
  return yield this.connectionManager.getStoreRepository().evaluateSmartRules(rules, sc.match_type, {
163
203
  skip: args.skip,
164
204
  take: args.take,
165
205
  order: args.order,
166
206
  });
167
207
  }));
208
+ this.handle(ChannelType_1.ChannelType.IPC_SMART_COLLECTION_PREVIEW, (_event, args) => __awaiter(this, void 0, void 0, function* () {
209
+ var _a;
210
+ let rules;
211
+ try {
212
+ rules = typeof args.rules === 'string' ? JSON.parse(args.rules) : args.rules;
213
+ }
214
+ catch (_b) {
215
+ return [[], 0];
216
+ }
217
+ return yield this.connectionManager.getStoreRepository().evaluateSmartRules(rules, (_a = args.match_type) !== null && _a !== void 0 ? _a : 'AND', {});
218
+ }));
168
219
  // Store
169
220
  this.handle(ChannelType_1.ChannelType.IPC_STORE_FIND, (_event, args) => __awaiter(this, void 0, void 0, function* () {
170
221
  return yield this.connectionManager.getStore().find(args);
@@ -219,7 +270,7 @@ class MessageHandler {
219
270
  }));
220
271
  this.handle(ChannelType_1.ChannelType.IPC_FONT_METRICS, (_event, filePath) => __awaiter(this, void 0, void 0, function* () {
221
272
  var _a, _b, _c, _d, _e;
222
- const fontObject = new FontObject_1.default(filePath);
273
+ const fontObject = FontObject_1.default.fromCache(filePath);
223
274
  if (fontObject.hasError()) {
224
275
  return null;
225
276
  }
@@ -233,7 +284,7 @@ class MessageHandler {
233
284
  };
234
285
  }));
235
286
  this.handle(ChannelType_1.ChannelType.IPC_FONT_GLYPHS, (_event, filePath) => __awaiter(this, void 0, void 0, function* () {
236
- const fontObject = new FontObject_1.default(filePath);
287
+ const fontObject = FontObject_1.default.fromCache(filePath);
237
288
  if (fontObject.hasError()) {
238
289
  return [];
239
290
  }