chuijs 3.6.2 → 3.6.4

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 (119) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +1203 -162
  3. package/framework/appLayout/default/chui_app_layout.js +747 -747
  4. package/framework/appLayout/default/global_style.css +592 -568
  5. package/framework/appLayout/default/main_theme_style.css +118 -101
  6. package/framework/components/chui_accordion/accordion.js +63 -63
  7. package/framework/components/chui_accordion/styles.css +79 -75
  8. package/framework/components/chui_badge/badge.js +55 -55
  9. package/framework/components/chui_badge/styles.css +29 -29
  10. package/framework/components/chui_button/button.js +48 -48
  11. package/framework/components/chui_button/styles.css +75 -70
  12. package/framework/components/chui_calendar/calendar.js +97 -97
  13. package/framework/components/chui_card/card.js +87 -0
  14. package/framework/components/chui_card/styles.css +72 -0
  15. package/framework/components/chui_code/code.js +18 -18
  16. package/framework/components/chui_code/styles.css +9 -9
  17. package/framework/components/chui_console/console.js +27 -27
  18. package/framework/components/chui_console/styles.css +31 -31
  19. package/framework/components/chui_content_block/content_block.js +51 -51
  20. package/framework/components/chui_content_block/styles.css +2 -2
  21. package/framework/components/chui_context_menu/context_menu.js +230 -0
  22. package/framework/components/chui_context_menu/styles.css +136 -0
  23. package/framework/components/chui_custom_element/custom_element.js +24 -24
  24. package/framework/components/chui_details/details.js +85 -85
  25. package/framework/components/chui_details/styles.css +70 -66
  26. package/framework/components/chui_fieldset/fieldset.js +40 -40
  27. package/framework/components/chui_fieldset/styles.css +24 -24
  28. package/framework/components/chui_form/form.js +40 -40
  29. package/framework/components/chui_form/styles.css +21 -21
  30. package/framework/components/chui_graphs/graphs.js +234 -190
  31. package/framework/components/chui_graphs/styles.css +37 -32
  32. package/framework/components/chui_hero/hero.js +98 -0
  33. package/framework/components/chui_hero/styles.css +91 -0
  34. package/framework/components/chui_html_block/html_block.js +16 -16
  35. package/framework/components/chui_html_block/styles.css +5 -5
  36. package/framework/components/chui_hx/hx.js +15 -15
  37. package/framework/components/chui_hx/styles.css +38 -38
  38. package/framework/components/chui_icons/icons.js +2144 -2144
  39. package/framework/components/chui_icons/styles.css +13 -13
  40. package/framework/components/chui_inputs/chui_check_box/check_box.js +32 -32
  41. package/framework/components/chui_inputs/chui_check_box/styles.css +91 -86
  42. package/framework/components/chui_inputs/chui_combo_box/combo_box.js +166 -150
  43. package/framework/components/chui_inputs/chui_combo_box/styles.css +113 -107
  44. package/framework/components/chui_inputs/chui_date/date.js +177 -174
  45. package/framework/components/chui_inputs/chui_date/styles.css +163 -128
  46. package/framework/components/chui_inputs/chui_email/email.js +61 -61
  47. package/framework/components/chui_inputs/chui_email/styles.css +69 -71
  48. package/framework/components/chui_inputs/chui_file/file.js +76 -76
  49. package/framework/components/chui_inputs/chui_file/styles.css +99 -99
  50. package/framework/components/chui_inputs/chui_multi_combo_box/multi_combo_box.js +295 -295
  51. package/framework/components/chui_inputs/chui_multi_combo_box/styles.css +212 -235
  52. package/framework/components/chui_inputs/chui_number/number.js +108 -108
  53. package/framework/components/chui_inputs/chui_number/styles.css +84 -84
  54. package/framework/components/chui_inputs/chui_password/password.js +99 -99
  55. package/framework/components/chui_inputs/chui_password/styles.css +97 -97
  56. package/framework/components/chui_inputs/chui_radio_button/radio_button.js +45 -45
  57. package/framework/components/chui_inputs/chui_radio_button/styles.css +76 -73
  58. package/framework/components/chui_inputs/chui_select_box/select_box.js +187 -170
  59. package/framework/components/chui_inputs/chui_select_box/styles.css +123 -117
  60. package/framework/components/chui_inputs/chui_text/styles.css +83 -84
  61. package/framework/components/chui_inputs/chui_text/text.js +91 -91
  62. package/framework/components/chui_inputs/chui_text_area/styles.css +57 -57
  63. package/framework/components/chui_inputs/chui_text_area/text_area.js +61 -61
  64. package/framework/components/chui_inputs/chui_toggle/styles.css +66 -61
  65. package/framework/components/chui_inputs/chui_toggle/toggle.js +36 -36
  66. package/framework/components/chui_label/label.js +54 -54
  67. package/framework/components/chui_label/styles.css +11 -11
  68. package/framework/components/chui_media/audio.js +908 -908
  69. package/framework/components/chui_media/audio_styles.css +458 -458
  70. package/framework/components/chui_media/image.js +105 -105
  71. package/framework/components/chui_media/image_styles.css +61 -61
  72. package/framework/components/chui_media/video.js +248 -248
  73. package/framework/components/chui_media/video_styles.css +160 -160
  74. package/framework/components/chui_menu_bar/menu_bar.js +66 -74
  75. package/framework/components/chui_menu_bar/styles.css +114 -76
  76. package/framework/components/chui_modal/modal.js +142 -135
  77. package/framework/components/chui_modal/styles.css +36 -36
  78. package/framework/components/chui_notification/notification.js +72 -72
  79. package/framework/components/chui_notification/notification_download.js +78 -78
  80. package/framework/components/chui_notification/notification_download_progress.css +119 -123
  81. package/framework/components/chui_notification/notification_download_progress.js +105 -105
  82. package/framework/components/chui_notification/notification_update.js +54 -54
  83. package/framework/components/chui_notification/styles.css +91 -91
  84. package/framework/components/chui_notification/styles_download.css +85 -85
  85. package/framework/components/chui_notification/styles_update.css +73 -73
  86. package/framework/components/chui_paragraph/paragraph.js +14 -14
  87. package/framework/components/chui_paragraph/styles.css +6 -6
  88. package/framework/components/chui_popups/popups.js +250 -250
  89. package/framework/components/chui_popups/styles.css +129 -115
  90. package/framework/components/chui_progress_bar/progress_bar.js +28 -28
  91. package/framework/components/chui_progress_bar/styles.css +28 -28
  92. package/framework/components/chui_radio_group/radio_group.js +57 -57
  93. package/framework/components/chui_radio_group/styles.css +3 -3
  94. package/framework/components/chui_slideshow/slideshow.js +75 -75
  95. package/framework/components/chui_slideshow/styles.css +94 -85
  96. package/framework/components/chui_spinner/spinner.js +45 -45
  97. package/framework/components/chui_spinner/styles.css +23 -23
  98. package/framework/components/chui_table/styles.css +42 -42
  99. package/framework/components/chui_table/table.js +234 -234
  100. package/framework/components/chui_tabs/chui_tabs.js +77 -77
  101. package/framework/components/chui_tabs/styles.css +54 -48
  102. package/framework/components/chui_text_editor/styles.css +217 -217
  103. package/framework/components/chui_text_editor/text_editor.js +144 -144
  104. package/framework/components/chui_text_editor/text_editor_panel.js +568 -568
  105. package/framework/components/chui_tree_view/styles.css +81 -75
  106. package/framework/components/chui_tree_view/tree_view.js +90 -90
  107. package/framework/components/chui_webview/styles.css +27 -27
  108. package/framework/components/chui_webview/webview.js +103 -103
  109. package/framework/components/telegram_bot/chui_telegram_bot.js +183 -183
  110. package/framework/modules/chui_animations/animations.js +121 -121
  111. package/framework/modules/chui_animations/styles.css +79 -79
  112. package/framework/modules/chui_fonts.js +7129 -6974
  113. package/framework/modules/chui_functions.js +106 -78
  114. package/framework/modules/chui_logger/chui_logger.js +53 -53
  115. package/framework/modules/chui_page/page.js +86 -86
  116. package/framework/modules/chui_page/styles.css +9 -9
  117. package/framework/tray_bar/chui_menu_items.js +48 -48
  118. package/index.js +570 -555
  119. package/package.json +51 -46
package/index.js CHANGED
@@ -1,555 +1,570 @@
1
- // === ИНСТРУМЕНТЫ ===
2
- const {app, BrowserWindow, Menu, Tray, ipcMain, ipcRenderer, shell, nativeTheme, session, webContents, systemPreferences} = require('electron');
3
- const { dialog } = require('@electron/remote/main');
4
- const Store = require("electron-store");
5
- const path = require("path");
6
- const fs = require("fs");
7
- const os = require("os");
8
-
9
- const request = require('@cypress/request');
10
- const {transliterate} = require("transliteration");
11
- let downloadSession = undefined;
12
- // === === ===
13
- // process.env
14
- process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = "true";
15
- // === === ===
16
-
17
- //ПОЛЯ ВВОДА
18
- const {TextInput} = require('./framework/components/chui_inputs/chui_text/text');
19
- const {DateInput} = require('./framework/components/chui_inputs/chui_date/date');
20
- const {NumberInput} = require('./framework/components/chui_inputs/chui_number/number');
21
- const {EmailInput} = require('./framework/components/chui_inputs/chui_email/email');
22
- const {PasswordInput} = require('./framework/components/chui_inputs/chui_password/password');
23
- const {Select} = require('./framework/components/chui_inputs/chui_select_box/select_box');
24
- const {ComboBox} = require('./framework/components/chui_inputs/chui_combo_box/combo_box');
25
- const {TextArea} = require('./framework/components/chui_inputs/chui_text_area/text_area');
26
- const {RadioButton} = require('./framework/components/chui_inputs/chui_radio_button/radio_button');
27
- const {CheckBox} = require('./framework/components/chui_inputs/chui_check_box/check_box');
28
- const {RadioGroup} = require('./framework/components/chui_radio_group/radio_group');
29
- //==========
30
- const {MenuItem} = require('./framework/tray_bar/chui_menu_items');
31
- const {AppLayout, Route} = require('./framework/appLayout/default/chui_app_layout');
32
- const {Page} = require('./framework/modules/chui_page/page');
33
- const {WebView} = require('./framework/components/chui_webview/webview');
34
- const {Button} = require('./framework/components/chui_button/button');
35
- const {Spinner} = require('./framework/components/chui_spinner/spinner');
36
- const {Icon, Icons} = require('./framework/components/chui_icons/icons');
37
- const {TextEditor} = require('./framework/components/chui_text_editor/text_editor');
38
- const {Badge} = require('./framework/components/chui_badge/badge');
39
- const {Calendar} = require('./framework/components/chui_calendar/calendar');
40
- const {Notification} = require('./framework/components/chui_notification/notification');
41
- const {UpdateNotification} = require("./framework/components/chui_notification/notification_update");
42
- const {DownloadNotification} = require("./framework/components/chui_notification/notification_download");
43
- const {Tabs, Tab} = require('./framework/components/chui_tabs/chui_tabs');
44
- const {BarGraph, PieGraph} = require('./framework/components/chui_graphs/graphs');
45
- const {Toggle} = require('./framework/components/chui_inputs/chui_toggle/toggle');
46
- const {ContentBlock} = require('./framework/components/chui_content_block/content_block');
47
- const {ProgressBar} = require('./framework/components/chui_progress_bar/progress_bar');
48
- const {Label} = require('./framework/components/chui_label/label');
49
- const {Dialog} = require('./framework/components/chui_modal/modal');
50
- const {Paragraph} = require('./framework/components/chui_paragraph/paragraph');
51
- const {H} = require('./framework/components/chui_hx/hx');
52
- const {Table} = require('./framework/components/chui_table/table');
53
- const {Details} = require('./framework/components/chui_details/details');
54
- const {Accordion} = require('./framework/components/chui_accordion/accordion')
55
- const {CodeBlock} = require('./framework/components/chui_code/code')
56
- const {HtmlBlock} = require('./framework/components/chui_html_block/html_block')
57
- const {sleep, render, getDefaultIcon, formatBytes} = require('./framework/modules/chui_functions');
58
- const {FileInput, AcceptTypes} = require("./framework/components/chui_inputs/chui_file/file");
59
- const {TreeView} = require("./framework/components/chui_tree_view/tree_view");
60
- const {Form} = require("./framework/components/chui_form/form");
61
- const {SlideShow} = require("./framework/components/chui_slideshow/slideshow");
62
- const {FieldSet} = require("./framework/components/chui_fieldset/fieldset");
63
- const {Popup} = require("./framework/components/chui_popups/popups");
64
- const {TelegramBot} = require("./framework/components/telegram_bot/chui_telegram_bot");
65
- const {MenuBar} = require("./framework/components/chui_menu_bar/menu_bar");
66
- const {Image} = require('./framework/components/chui_media/image');
67
- const {Audio} = require("./framework/components/chui_media/audio");
68
- const {Video} = require("./framework/components/chui_media/video");
69
- const {CustomElement} = require("./framework/components/chui_custom_element/custom_element");
70
- const {Console} = require("./framework/components/chui_console/console");
71
- const {DownloadProgressNotification} = require("./framework/components/chui_notification/notification_download_progress");
72
- const {MultiComboBox} = require("./framework/components/chui_inputs/chui_multi_combo_box/multi_combo_box");
73
- const {Log} = require("./framework/modules/chui_logger/chui_logger");
74
- const url = require("node:url");
75
-
76
- //VARS
77
- let isQuiting = false;
78
- let context = null;
79
-
80
- class Main {
81
- #tray = undefined;
82
- //
83
- #app_icon = undefined;
84
- #window = undefined;
85
- //
86
- #appName = undefined;
87
- #height = undefined;
88
- #width = undefined;
89
- #minHeight = undefined;
90
- #minWidth = undefined;
91
- #renderer = undefined;
92
- #devToolsOpened = false;
93
- #webSecurity = true;
94
- #resizable = true;
95
- // ПУТИ
96
- #downloadPath = undefined;
97
-
98
- constructor(options = {
99
- name: String(),
100
- sizes: { height: Number(), width: Number(), minHeight: Number(), minWidth: Number() },
101
- render: String(),
102
- devTools: Boolean(),
103
- webSecurity: Boolean(),
104
- resizable: Boolean(),
105
- paths: {
106
- downloadPath: String(),
107
- }
108
- }) {
109
- this.#app_icon = options.icon;
110
- if (this.#app_icon === undefined) {
111
- if (process.platform === "darwin") {
112
- this.#app_icon = Main.#resizeIconTray(getDefaultIcon())
113
- } else {
114
- this.#app_icon = getDefaultIcon();
115
- }
116
- } else {
117
- if (process.platform === "darwin") {
118
- this.#app_icon = Main.#resizeIconTray(options.icon)
119
- } else {
120
- this.#app_icon = options.icon;
121
- }
122
- }
123
- // app.commandLine.appendSwitch('--enable-features', 'OverlayScrollbar')
124
- app.commandLine.appendSwitch('disable-hid-blocklist')
125
- app.commandLine.appendSwitch('enable-features=OverlayScrollbar')
126
- // app.commandLine.appendSwitch("disable-http-cache");
127
- app.commandLine.appendSwitch('enable-transparent-visuals');
128
- app.commandLine.appendSwitch('enable-gpu-rasterization', "true");
129
- app.commandLine.appendSwitch('enable-native-gpu-memory-buffers', "true");
130
- app.commandLine.appendSwitch('high-dpi-support', "true");
131
- app.commandLine.appendSwitch('device-scale-factor', "true");
132
- app.commandLine.appendSwitch('disable-touch-adjustment', "true");
133
- app.commandLine.appendSwitch('main-frame-resizes-are-orientation-changes', "true");
134
- app.commandLine.appendSwitch('disable-pinch', "true");
135
-
136
- try {
137
- this.#downloadPath = options.paths.downloadPath;
138
- } catch (e) {
139
- this.#downloadPath = App.downloadsPath();
140
- }
141
-
142
- // app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');
143
-
144
- // Options
145
- this.#appName = options.name;
146
- this.#height = options.sizes.height;
147
- this.#width = options.sizes.width;
148
- this.#minHeight = options.sizes.minHeight;
149
- this.#minWidth = options.sizes.minWidth;
150
- this.#renderer = options.render;
151
- this.#webSecurity = options.webSecurity;
152
- this.#resizable = options.resizable;
153
- // ===
154
- if (options.devTools) this.#window.webContents.openDevTools();
155
- }
156
-
157
- static #resizeIconTray(image) {
158
- return require('electron').nativeImage.createFromPath(image).resize({width: 16, height: 16});
159
- }
160
-
161
- static #keyToChangeLower(obj, keyToChange, value) {
162
- let keyToChangeLower = keyToChange.toLowerCase();
163
- for (const key of Object.keys(obj)) {
164
- if (key.toLowerCase() === keyToChangeLower) {
165
- obj[key] = value;
166
- return;
167
- }
168
- }
169
- obj[keyToChange] = value;
170
- }
171
-
172
- #createWindow(hideOnClose = Boolean()) {
173
- this.#window = new BrowserWindow({
174
- transparent: false,
175
- width: this.#width,
176
- height: this.#height,
177
- minHeight: this.#minHeight,
178
- minWidth: this.#minWidth,
179
- name: this.#appName,
180
- title: this.#appName,
181
- show: false,
182
- icon: this.#app_icon,
183
- roundedCorners: true,
184
- webPreferences: {
185
- plugins: false,
186
- nodeIntegration: true,
187
- contextIsolation: false,
188
- preload: this.#renderer,
189
- spellcheck: false,
190
- webviewTag: true,
191
- enableRemoteModule: true,
192
- webSecurity: this.#webSecurity,
193
- nodeIntegrationInSubFrames: true,
194
- },
195
- frame: false,
196
- resizable: this.#resizable,
197
- minimizable: true,
198
- maximizable: true,
199
- center: true,
200
- hasShadow: true
201
- });
202
-
203
- if (!this.#webSecurity) {
204
- this.#window.webContents.session.webRequest.onBeforeSendHeaders((details, callback) => {
205
- const {requestHeaders} = details;
206
- Main.#keyToChangeLower(requestHeaders, 'Access-Control-Allow-Origin', ['*']);
207
- Main.#keyToChangeLower(requestHeaders, 'X-Frame-Options', ['*']);
208
- callback({requestHeaders});
209
- },);
210
- this.#window.webContents.session.webRequest.onHeadersReceived((details, callback) => {
211
- const {responseHeaders} = details;
212
- Main.#keyToChangeLower(responseHeaders, 'Access-Control-Allow-Origin', ['*']);
213
- Main.#keyToChangeLower(responseHeaders, 'Access-Control-Allow-Headers', ['*']);
214
- Main.#keyToChangeLower(responseHeaders, 'X-Frame-Options', ['*']);
215
- callback({
216
- responseHeaders, cancel: false
217
- });
218
- });
219
- }
220
-
221
- this.#window.loadURL(url.format({
222
- pathname: path.join(__dirname, 'index.html'),
223
- protocol: 'file:',
224
- slashes: true
225
- })).then(r => {
226
- app.on('before-quit', () => {
227
- isQuiting = true;
228
- });
229
- });
230
-
231
- this.#window.on("ready-to-show", () => setTimeout(() => {
232
- this.#window.show()
233
- // let data = fs.readFileSync(path.join(__dirname, "cam_test.js"), 'utf8');
234
- // this.#window.webContents.executeJavaScript(data)
235
- }, 650))
236
-
237
- if (hideOnClose) {
238
- this.#window.on('close', (evt) => {
239
- if (!isQuiting) evt.preventDefault();
240
- this.#window.hide();
241
- });
242
- }
243
- if (this.#resizable === false) this.#window.webContents.send("chui_resizable_false")
244
- }
245
-
246
- toggleDevTools() {
247
- if (this.#devToolsOpened) {
248
- this.#window.webContents.closeDevTools();
249
- this.#devToolsOpened = false;
250
- } else {
251
- this.#window.webContents.openDevTools();
252
- this.#devToolsOpened = true;
253
- }
254
- }
255
-
256
- #hideAndShow() {
257
- let visible = this.#window.isVisible()
258
- let focus = this.#window.isFocused()
259
-
260
- if (visible && focus) {
261
- this.#window.hide()
262
- } else if (!visible && !focus) {
263
- this.#window.show()
264
- } else {
265
- this.#window.focus()
266
- }
267
- }
268
-
269
- stop() {
270
- if (process.platform !== 'darwin') {
271
- app.quit();
272
- } else {
273
- app.exit(0)
274
- }
275
- }
276
-
277
- restart() {
278
- app.relaunch();
279
- app.exit(0)
280
- }
281
-
282
- getWindow() {
283
- return this.#window;
284
- }
285
-
286
- start(options = {hideOnClose: Boolean(), globalMenu: [], tray: [], extensions: []}) {
287
- nativeTheme.themeSource = "system";
288
-
289
- app.whenReady().then(() => {
290
- session.defaultSession.setPermissionRequestHandler((webContents, permission, callback) => {
291
- if (permission === 'media') {
292
- callback(true); // Approve microphone/camera access
293
- } else {
294
- callback(false);
295
- }
296
- });
297
-
298
- if (options.extensions) {
299
- for (let extension of options.extensions) session.defaultSession.loadExtension(extension).then(r => Log.info(r)).catch(e => Log.error(e))
300
- }
301
- if (options.tray) {
302
- this.#tray = new Tray(this.#app_icon);
303
- const context = Menu.buildFromTemplate(options.tray);
304
- this.#tray.setContextMenu(context);
305
-
306
- this.#tray.on("click", () => this.#hideAndShow())
307
- }
308
- if (options.globalMenu) {
309
- const menu = Menu.buildFromTemplate(options.globalMenu)
310
- Menu.setApplicationMenu(menu)
311
- } else {
312
- Menu.setApplicationMenu(null)
313
- }
314
- this.#createWindow(options.hideOnClose);
315
- ipcMain.on("show_system_notification", (e, title, body) => {
316
- let {Notification} = require('electron');
317
- new Notification({title, body}).show();
318
- })
319
- require("@electron/remote/main").initialize();
320
- require("@electron/remote/main").enable(this.#window.webContents);
321
- })
322
-
323
- ipcMain.on("SEND_LOG_TEXT", (e, text, type) => {
324
- if (type === "info") {
325
- console.info(text)
326
- } else if (type === "error") {
327
- console.error(text)
328
- }
329
- this.#writeLog(text)
330
- })
331
- }
332
-
333
- #writeLog(text) {
334
- let today = new Date().toLocaleDateString().replace("/", ".")
335
- let log_dir_path = path.join(app.getPath("userData"), "logs")
336
- let log_file_path = path.join(log_dir_path, `app_${today}.log`)
337
-
338
- if (!fs.existsSync(log_dir_path)) {
339
- fs.mkdirSync(log_dir_path, { recursive: true });
340
- fs.writeFileSync(log_file_path, "", "utf-8");
341
- }
342
-
343
- fs.writeFile(log_file_path, `${text}\n`, { flag: 'a+' }, err => {
344
- if (err) console.error(err);
345
- });
346
- }
347
-
348
- enableAutoUpdateApp(start = Number()) {
349
- setTimeout(async () => {
350
- const {autoUpdater} = require("electron-updater");
351
- autoUpdater.autoInstallOnAppQuit = false;
352
- let updates = await autoUpdater.checkForUpdates();
353
- if (updates !== null) {
354
- if (updates.versionInfo.version > app.getVersion()) {
355
- await this.#sendNotificationUpdateLoad(this.#appName, `Загрузка новой версии ${updates.versionInfo.version}`);
356
- }
357
- }
358
- autoUpdater.on('update-downloaded', async () => {
359
- await this.#sendNotificationUpdateLoadClose();
360
- await this.#sendNotificationUpdate(this.#appName, `Загрузка завершена`);
361
- setTimeout(async () => await this.#sendNotificationUpdateClose(), 3000);
362
- Log.info("Обновление скачано!");
363
- this.#window.webContents.send("checkUpdatesTrue", true, updates.versionInfo.version);
364
- ipcMain.on("updateInstallConfirm", (e, check) => {
365
- if (check) {
366
- Log.info("Установка обновления...");
367
- autoUpdater.quitAndInstall();
368
- }
369
- })
370
- });
371
- }, start);
372
- }
373
- async #sendNotificationUpdateLoad(text, body) {
374
- this.#window.webContents.send("sendNotificationUpdateLoad", text, body);
375
- }
376
- async #sendNotificationUpdateLoadClose() {
377
- this.#window.webContents.send("sendNotificationUpdateLoadClose");
378
- }
379
- async #sendNotificationUpdate(text, body) {
380
- this.#window.webContents.send("sendNotificationUpdate", text, body);
381
- }
382
- async #sendNotificationUpdateClose() {
383
- this.#window.webContents.send("sendNotificationUpdateClose");
384
- }
385
-
386
- sendDownload(text, body) {
387
- setTimeout(() => this.#window.webContents.send("sendNotificationDownload", text, body), 1)
388
- }
389
- sendDownloadUpdate(text, body) {
390
- setTimeout(() => this.#window.webContents.send("sendNotificationDownloadUpdate", text, body), 1)
391
- }
392
- sendDownloadComplete(text, body) {
393
- setTimeout(() => this.#window.webContents.send("sendNotificationDownloadComplete", text, body), 250)
394
- }
395
- sendDownloadError(text, body) {
396
- setTimeout(() => this.#window.webContents.send("sendNotificationDownloadError", text, body), 250)
397
- }
398
- }
399
-
400
- class Styles {
401
- static WORD_BREAK = {NORMAL: "normal", BREAK_ALL: "break-all", KEEP_ALL: "keep-all", BREAK_WORD: "break-word"}
402
- static TEXT_ALIGN = {CENTER: 'center', END: 'end', START: 'start'};
403
- static ALIGN = {CENTER: 'center', END: 'flex-end', START: 'flex-start', BASELINE: 'baseline', STRETCH: 'stretch'};
404
- static JUSTIFY = {
405
- CENTER: 'center',
406
- END: 'flex-end',
407
- START: 'flex-start',
408
- SPACE_AROUND: 'space-around',
409
- SPACE_BEETWEEN: 'space-between',
410
- SPACE_EVENLY: 'space-evenly'
411
- };
412
- static DIRECTION = {ROW: 'row', COLUMN: 'column'};
413
- static WRAP = {NOWRAP: 'nowrap', WRAP: 'wrap'};
414
- static SIZE = {
415
- AUTO: 'auto',
416
- FIT_CONTENT: 'fit-content',
417
- MAX_CONTENT: 'max-content',
418
- MIN_CONTENT: 'min-content',
419
- WEBKIT_FILL: '-webkit-fill-available',
420
- INHERIT: 'inherit'
421
- };
422
- }
423
-
424
- class Application {
425
- getApp() {
426
- if (process && process.type === 'renderer') {
427
- return require("@electron/remote").app;
428
- } else {
429
- return app;
430
- }
431
- }
432
- getSession() {
433
- if (process && process.type === 'renderer') {
434
- return require("@electron/remote").session;
435
- } else {
436
- return session;
437
- }
438
- }
439
- getWebContents() {
440
- if (process && process.type === 'renderer') {
441
- return require("@electron/remote").webContents;
442
- } else {
443
- return webContents;
444
- }
445
- }
446
- }
447
-
448
- class App {
449
- static get() { return new Application().getApp() }
450
- static getSession() { return new Application().getSession() }
451
- static getWebContents() { return new Application().getWebContents() }
452
- // ПУТИ
453
- static homePath() { return new Application().getApp().getPath("home") }
454
- static appDataPath() { return new Application().getApp().getPath("appData") }
455
- static userDataPath() { return new Application().getApp().getPath("userData") }
456
- static sessionDataPath() { return new Application().getApp().getPath("sessionData") }
457
- static logsPath() { return new Application().getApp().getPath("logs") }
458
- static tempPath() { return new Application().getApp().getPath("temp") }
459
- static exePath() { return new Application().getApp().getPath("exe") }
460
- static modulePath() { return new Application().getApp().getPath("module") }
461
- static desktopPath() { return new Application().getApp().getPath("desktop") }
462
- static documentsPath() { return new Application().getApp().getPath("documents") }
463
- static downloadsPath() { return new Application().getApp().getPath("downloads") }
464
- static musicPath() { return new Application().getApp().getPath("music") }
465
- static picturesPath() { return new Application().getApp().getPath("pictures") }
466
- static videosPath() { return new Application().getApp().getPath("videos") }
467
- static recentPath() { return new Application().getApp().getPath("recent") }
468
- static crashDumpsPath() { return new Application().getApp().getPath("crashDumps") }
469
- }
470
-
471
- module.exports = {
472
- Main: Main,
473
- sleep: sleep,
474
- render: render,
475
- formatBytes: formatBytes,
476
- MenuItem: MenuItem,
477
- Styles: Styles,
478
- AppLayout: AppLayout,
479
- Route: Route,
480
- Page: Page,
481
- WebView: WebView,
482
- Button: Button,
483
- Spinner: Spinner,
484
- TextInput: TextInput,
485
- DateInput: DateInput,
486
- NumberInput: NumberInput,
487
- EmailInput: EmailInput,
488
- PasswordInput: PasswordInput,
489
- Select: Select,
490
- Calendar: Calendar,
491
- Badge: Badge,
492
- TextEditor: TextEditor,
493
- Icon: Icon,
494
- Icons: Icons,
495
- TextArea: TextArea,
496
- CheckBox: CheckBox,
497
- RadioButton: RadioButton,
498
- Details: Details,
499
- Table: Table,
500
- H: H,
501
- Paragraph: Paragraph,
502
- Dialog: Dialog,
503
- Label: Label,
504
- ContentBlock: ContentBlock,
505
- ProgressBar: ProgressBar,
506
- Toggle: Toggle,
507
- Image: Image,
508
- BarGraph: BarGraph,
509
- PieGraph: PieGraph,
510
- Tabs: Tabs,
511
- Tab: Tab,
512
- Notification: Notification,
513
- ComboBox: ComboBox,
514
- MultiComboBox: MultiComboBox,
515
- RadioGroup: RadioGroup,
516
- Accordion: Accordion,
517
- CodeBlock: CodeBlock,
518
- HtmlBlock: HtmlBlock,
519
- FileInput: FileInput,
520
- AcceptTypes: AcceptTypes,
521
- TreeView: TreeView,
522
- Form: Form,
523
- SlideShow: SlideShow,
524
- FieldSet: FieldSet,
525
- Popup: Popup,
526
- MenuBar: MenuBar,
527
- UpdateNotification: UpdateNotification,
528
- DownloadNotification: DownloadNotification,
529
- DownloadProgressNotification: DownloadProgressNotification,
530
- Audio: Audio,
531
- Video: Video,
532
- CustomElement: CustomElement,
533
- Console: Console,
534
- //
535
- TelegramBot: TelegramBot,
536
- //
537
- BrowserWindow: BrowserWindow,
538
- ipcMain: ipcMain,
539
- ipcRenderer: ipcRenderer,
540
- shell: shell,
541
- path: path,
542
- fs: fs,
543
- os: os,
544
- request: request,
545
- transliterate: transliterate,
546
- store: new Store(),
547
- //
548
- App: App,
549
- //
550
- downloadSession: downloadSession,
551
- Log: Log,
552
- chooseFile: dialog,
553
- //
554
- systemPreferences: systemPreferences
555
- }
1
+ // === ИНСТРУМЕНТЫ ===
2
+ const {app, BrowserWindow, Menu, Tray, ipcMain, ipcRenderer, shell, nativeTheme, session, webContents, systemPreferences} = require('electron');
3
+ const { dialog } = require('@electron/remote/main');
4
+ const Store = require("electron-store");
5
+ const path = require("path");
6
+ const fs = require("fs");
7
+ const os = require("os");
8
+
9
+ const request = require('@cypress/request');
10
+ const {transliterate} = require("transliteration");
11
+ let downloadSession = undefined;
12
+ // === === ===
13
+ // process.env
14
+ process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = "true";
15
+ // === === ===
16
+
17
+ //ПОЛЯ ВВОДА
18
+ const {TextInput} = require('./framework/components/chui_inputs/chui_text/text');
19
+ const {DateInput} = require('./framework/components/chui_inputs/chui_date/date');
20
+ const {NumberInput} = require('./framework/components/chui_inputs/chui_number/number');
21
+ const {EmailInput} = require('./framework/components/chui_inputs/chui_email/email');
22
+ const {PasswordInput} = require('./framework/components/chui_inputs/chui_password/password');
23
+ const {Select} = require('./framework/components/chui_inputs/chui_select_box/select_box');
24
+ const {ComboBox} = require('./framework/components/chui_inputs/chui_combo_box/combo_box');
25
+ const {TextArea} = require('./framework/components/chui_inputs/chui_text_area/text_area');
26
+ const {RadioButton} = require('./framework/components/chui_inputs/chui_radio_button/radio_button');
27
+ const {CheckBox} = require('./framework/components/chui_inputs/chui_check_box/check_box');
28
+ const {RadioGroup} = require('./framework/components/chui_radio_group/radio_group');
29
+ //==========
30
+ const {MenuItem} = require('./framework/tray_bar/chui_menu_items');
31
+ const {AppLayout, Route} = require('./framework/appLayout/default/chui_app_layout');
32
+ const {Page} = require('./framework/modules/chui_page/page');
33
+ const {WebView} = require('./framework/components/chui_webview/webview');
34
+ const {Button} = require('./framework/components/chui_button/button');
35
+ const {Spinner} = require('./framework/components/chui_spinner/spinner');
36
+ const {Icon, Icons} = require('./framework/components/chui_icons/icons');
37
+ const {TextEditor} = require('./framework/components/chui_text_editor/text_editor');
38
+ const {Badge} = require('./framework/components/chui_badge/badge');
39
+ const {Calendar} = require('./framework/components/chui_calendar/calendar');
40
+ const {Notification} = require('./framework/components/chui_notification/notification');
41
+ const {UpdateNotification} = require("./framework/components/chui_notification/notification_update");
42
+ const {DownloadNotification} = require("./framework/components/chui_notification/notification_download");
43
+ const {Tabs, Tab} = require('./framework/components/chui_tabs/chui_tabs');
44
+ const {BarGraph, PieGraph} = require('./framework/components/chui_graphs/graphs');
45
+ const {Toggle} = require('./framework/components/chui_inputs/chui_toggle/toggle');
46
+ const {ContentBlock} = require('./framework/components/chui_content_block/content_block');
47
+ const {Card} = require('./framework/components/chui_card/card');
48
+ const {Hero} = require('./framework/components/chui_hero/hero');
49
+ const {ProgressBar} = require('./framework/components/chui_progress_bar/progress_bar');
50
+ const {Label} = require('./framework/components/chui_label/label');
51
+ const {Dialog} = require('./framework/components/chui_modal/modal');
52
+ const {Paragraph} = require('./framework/components/chui_paragraph/paragraph');
53
+ const {H} = require('./framework/components/chui_hx/hx');
54
+ const {Table} = require('./framework/components/chui_table/table');
55
+ const {Details} = require('./framework/components/chui_details/details');
56
+ const {Accordion} = require('./framework/components/chui_accordion/accordion')
57
+ const {CodeBlock} = require('./framework/components/chui_code/code')
58
+ const {HtmlBlock} = require('./framework/components/chui_html_block/html_block')
59
+ const {sleep, render, getDefaultIcon, formatBytes} = require('./framework/modules/chui_functions');
60
+ const {FileInput, AcceptTypes} = require("./framework/components/chui_inputs/chui_file/file");
61
+ const {TreeView} = require("./framework/components/chui_tree_view/tree_view");
62
+ const {Form} = require("./framework/components/chui_form/form");
63
+ const {SlideShow} = require("./framework/components/chui_slideshow/slideshow");
64
+ const {FieldSet} = require("./framework/components/chui_fieldset/fieldset");
65
+ const {Popup} = require("./framework/components/chui_popups/popups");
66
+ const {TelegramBot} = require("./framework/components/telegram_bot/chui_telegram_bot");
67
+ const {MenuBar} = require("./framework/components/chui_menu_bar/menu_bar");
68
+ const { ContextMenu } = require("./framework/components/chui_context_menu/context_menu");
69
+ const {Image} = require('./framework/components/chui_media/image');
70
+ const {Audio} = require("./framework/components/chui_media/audio");
71
+ const {Video} = require("./framework/components/chui_media/video");
72
+ const {CustomElement} = require("./framework/components/chui_custom_element/custom_element");
73
+ const {Console} = require("./framework/components/chui_console/console");
74
+ const {DownloadProgressNotification} = require("./framework/components/chui_notification/notification_download_progress");
75
+ const {MultiComboBox} = require("./framework/components/chui_inputs/chui_multi_combo_box/multi_combo_box");
76
+ const {Log} = require("./framework/modules/chui_logger/chui_logger");
77
+ const url = require("node:url");
78
+
79
+ //VARS
80
+ let isQuiting = false;
81
+ let context = null;
82
+
83
+ class Main {
84
+ #tray = undefined;
85
+ //
86
+ #app_icon = undefined;
87
+ #window = undefined;
88
+ //
89
+ #appName = undefined;
90
+ #height = undefined;
91
+ #width = undefined;
92
+ #minHeight = undefined;
93
+ #minWidth = undefined;
94
+ #renderer = undefined;
95
+ #devTools = false;
96
+ #devToolsOpened = false;
97
+ #webSecurity = true;
98
+ #resizable = true;
99
+ // ПУТИ
100
+ #downloadPath = undefined;
101
+
102
+ constructor(options = {
103
+ name: String(),
104
+ sizes: { height: Number(), width: Number(), minHeight: Number(), minWidth: Number() },
105
+ render: String(),
106
+ devTools: Boolean(),
107
+ webSecurity: Boolean(),
108
+ resizable: Boolean(),
109
+ paths: {
110
+ downloadPath: String(),
111
+ }
112
+ }) {
113
+ this.#app_icon = options.icon;
114
+ if (this.#app_icon === undefined) {
115
+ if (process.platform === "darwin") {
116
+ this.#app_icon = Main.#resizeIconTray(getDefaultIcon())
117
+ } else {
118
+ this.#app_icon = getDefaultIcon();
119
+ }
120
+ } else {
121
+ if (process.platform === "darwin") {
122
+ this.#app_icon = Main.#resizeIconTray(options.icon)
123
+ } else {
124
+ this.#app_icon = options.icon;
125
+ }
126
+ }
127
+ // app.commandLine.appendSwitch('--enable-features', 'OverlayScrollbar')
128
+ app.commandLine.appendSwitch('disable-hid-blocklist')
129
+ app.commandLine.appendSwitch('enable-features=OverlayScrollbar')
130
+ // app.commandLine.appendSwitch("disable-http-cache");
131
+ app.commandLine.appendSwitch('enable-transparent-visuals');
132
+ app.commandLine.appendSwitch('enable-gpu-rasterization', "true");
133
+ app.commandLine.appendSwitch('enable-native-gpu-memory-buffers', "true");
134
+ app.commandLine.appendSwitch('high-dpi-support', "true");
135
+ app.commandLine.appendSwitch('device-scale-factor', "true");
136
+ app.commandLine.appendSwitch('disable-touch-adjustment', "true");
137
+ app.commandLine.appendSwitch('main-frame-resizes-are-orientation-changes', "true");
138
+ app.commandLine.appendSwitch('disable-pinch', "true");
139
+
140
+ try {
141
+ this.#downloadPath = options.paths.downloadPath;
142
+ } catch (e) {
143
+ this.#downloadPath = App.downloadsPath();
144
+ }
145
+
146
+ // app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');
147
+
148
+ // Options
149
+ this.#appName = options.name;
150
+ this.#height = options.sizes.height;
151
+ this.#width = options.sizes.width;
152
+ this.#minHeight = options.sizes.minHeight;
153
+ this.#minWidth = options.sizes.minWidth;
154
+ this.#renderer = options.render;
155
+ this.#webSecurity = options.webSecurity;
156
+ this.#resizable = options.resizable;
157
+ this.#devTools = options.devTools;
158
+ }
159
+
160
+ static #resizeIconTray(image) {
161
+ return require('electron').nativeImage.createFromPath(image).resize({width: 16, height: 16});
162
+ }
163
+
164
+ static #keyToChangeLower(obj, keyToChange, value) {
165
+ let keyToChangeLower = keyToChange.toLowerCase();
166
+ for (const key of Object.keys(obj)) {
167
+ if (key.toLowerCase() === keyToChangeLower) {
168
+ obj[key] = value;
169
+ return;
170
+ }
171
+ }
172
+ obj[keyToChange] = value;
173
+ }
174
+
175
+ #createWindow(hideOnClose = Boolean()) {
176
+ this.#window = new BrowserWindow({
177
+ transparent: false,
178
+ width: this.#width,
179
+ height: this.#height,
180
+ minHeight: this.#minHeight,
181
+ minWidth: this.#minWidth,
182
+ name: this.#appName,
183
+ title: this.#appName,
184
+ show: false,
185
+ icon: this.#app_icon,
186
+ roundedCorners: true,
187
+ webPreferences: {
188
+ plugins: false,
189
+ nodeIntegration: true,
190
+ contextIsolation: false,
191
+ preload: this.#renderer,
192
+ spellcheck: false,
193
+ webviewTag: true,
194
+ enableRemoteModule: true,
195
+ webSecurity: this.#webSecurity,
196
+ nodeIntegrationInSubFrames: true,
197
+ },
198
+ frame: false,
199
+ resizable: this.#resizable,
200
+ minimizable: true,
201
+ maximizable: true,
202
+ center: true,
203
+ hasShadow: true
204
+ });
205
+
206
+ if (!this.#webSecurity) {
207
+ this.#window.webContents.session.webRequest.onBeforeSendHeaders((details, callback) => {
208
+ const {requestHeaders} = details;
209
+ Main.#keyToChangeLower(requestHeaders, 'Access-Control-Allow-Origin', ['*']);
210
+ Main.#keyToChangeLower(requestHeaders, 'X-Frame-Options', ['*']);
211
+ callback({requestHeaders});
212
+ },);
213
+ this.#window.webContents.session.webRequest.onHeadersReceived((details, callback) => {
214
+ const {responseHeaders} = details;
215
+ Main.#keyToChangeLower(responseHeaders, 'Access-Control-Allow-Origin', ['*']);
216
+ Main.#keyToChangeLower(responseHeaders, 'Access-Control-Allow-Headers', ['*']);
217
+ Main.#keyToChangeLower(responseHeaders, 'X-Frame-Options', ['*']);
218
+ callback({
219
+ responseHeaders, cancel: false
220
+ });
221
+ });
222
+ }
223
+
224
+ this.#window.loadURL(url.format({
225
+ pathname: path.join(__dirname, 'index.html'),
226
+ protocol: 'file:',
227
+ slashes: true
228
+ })).then(r => {
229
+ app.on('before-quit', () => {
230
+ isQuiting = true;
231
+ });
232
+ });
233
+
234
+ if (this.#devTools) {
235
+ this.#window.webContents.openDevTools();
236
+ this.#devToolsOpened = true;
237
+ }
238
+
239
+ this.#window.on("ready-to-show", () => setTimeout(() => {
240
+ this.#window.show()
241
+ // let data = fs.readFileSync(path.join(__dirname, "cam_test.js"), 'utf8');
242
+ // this.#window.webContents.executeJavaScript(data)
243
+ }, 650))
244
+
245
+ if (hideOnClose) {
246
+ this.#window.on('close', (evt) => {
247
+ if (!isQuiting) evt.preventDefault();
248
+ this.#window.hide();
249
+ });
250
+ }
251
+ if (this.#resizable === false) {
252
+ this.#window.webContents.on("did-finish-load", () => {
253
+ this.#window.webContents.send("chui_resizable_false")
254
+ })
255
+ }
256
+ }
257
+
258
+ toggleDevTools() {
259
+ if (this.#devToolsOpened) {
260
+ this.#window.webContents.closeDevTools();
261
+ this.#devToolsOpened = false;
262
+ } else {
263
+ this.#window.webContents.openDevTools();
264
+ this.#devToolsOpened = true;
265
+ }
266
+ }
267
+
268
+ #hideAndShow() {
269
+ let visible = this.#window.isVisible()
270
+ let focus = this.#window.isFocused()
271
+
272
+ if (visible && focus) {
273
+ this.#window.hide()
274
+ } else if (!visible && !focus) {
275
+ this.#window.show()
276
+ } else {
277
+ this.#window.focus()
278
+ }
279
+ }
280
+
281
+ stop() {
282
+ if (process.platform !== 'darwin') {
283
+ app.quit();
284
+ } else {
285
+ app.exit(0)
286
+ }
287
+ }
288
+
289
+ restart() {
290
+ app.relaunch();
291
+ app.exit(0)
292
+ }
293
+
294
+ getWindow() {
295
+ return this.#window;
296
+ }
297
+
298
+ start(options = {hideOnClose: Boolean(), globalMenu: [], tray: [], extensions: []}) {
299
+ nativeTheme.themeSource = "system";
300
+
301
+ app.whenReady().then(() => {
302
+ session.defaultSession.setPermissionRequestHandler((webContents, permission, callback) => {
303
+ if (permission === 'media') {
304
+ callback(true); // Approve microphone/camera access
305
+ } else {
306
+ callback(false);
307
+ }
308
+ });
309
+
310
+ if (options.extensions) {
311
+ for (let extension of options.extensions) session.defaultSession.loadExtension(extension).then(r => Log.info(r)).catch(e => Log.error(e))
312
+ }
313
+ if (options.tray) {
314
+ this.#tray = new Tray(this.#app_icon);
315
+ const context = Menu.buildFromTemplate(options.tray);
316
+ this.#tray.setContextMenu(context);
317
+
318
+ this.#tray.on("click", () => this.#hideAndShow())
319
+ }
320
+ if (options.globalMenu) {
321
+ const menu = Menu.buildFromTemplate(options.globalMenu)
322
+ Menu.setApplicationMenu(menu)
323
+ } else {
324
+ Menu.setApplicationMenu(null)
325
+ }
326
+ this.#createWindow(options.hideOnClose);
327
+ ipcMain.on("show_system_notification", (e, title, body) => {
328
+ let {Notification} = require('electron');
329
+ new Notification({title, body}).show();
330
+ })
331
+ require("@electron/remote/main").initialize();
332
+ require("@electron/remote/main").enable(this.#window.webContents);
333
+ })
334
+
335
+ ipcMain.on("SEND_LOG_TEXT", (e, text, type) => {
336
+ if (type === "info") {
337
+ console.info(text)
338
+ } else if (type === "error") {
339
+ console.error(text)
340
+ }
341
+ this.#writeLog(text)
342
+ })
343
+ }
344
+
345
+ #writeLog(text) {
346
+ let today = new Date().toLocaleDateString().replace("/", ".")
347
+ let log_dir_path = path.join(app.getPath("userData"), "logs")
348
+ let log_file_path = path.join(log_dir_path, `app_${today}.log`)
349
+
350
+ if (!fs.existsSync(log_dir_path)) {
351
+ fs.mkdirSync(log_dir_path, { recursive: true });
352
+ fs.writeFileSync(log_file_path, "", "utf-8");
353
+ }
354
+
355
+ fs.writeFile(log_file_path, `${text}\n`, { flag: 'a+' }, err => {
356
+ if (err) console.error(err);
357
+ });
358
+ }
359
+
360
+ enableAutoUpdateApp(start = Number()) {
361
+ setTimeout(async () => {
362
+ const {autoUpdater} = require("electron-updater");
363
+ autoUpdater.autoInstallOnAppQuit = false;
364
+ let updates = await autoUpdater.checkForUpdates();
365
+ if (updates !== null) {
366
+ if (updates.versionInfo.version > app.getVersion()) {
367
+ await this.#sendNotificationUpdateLoad(this.#appName, `Загрузка новой версии ${updates.versionInfo.version}`);
368
+ }
369
+ }
370
+ autoUpdater.on('update-downloaded', async () => {
371
+ await this.#sendNotificationUpdateLoadClose();
372
+ await this.#sendNotificationUpdate(this.#appName, `Загрузка завершена`);
373
+ setTimeout(async () => await this.#sendNotificationUpdateClose(), 3000);
374
+ Log.info("Обновление скачано!");
375
+ this.#window.webContents.send("checkUpdatesTrue", true, updates.versionInfo.version);
376
+ ipcMain.on("updateInstallConfirm", (e, check) => {
377
+ if (check) {
378
+ Log.info("Установка обновления...");
379
+ autoUpdater.quitAndInstall();
380
+ }
381
+ })
382
+ });
383
+ }, start);
384
+ }
385
+ async #sendNotificationUpdateLoad(text, body) {
386
+ this.#window.webContents.send("sendNotificationUpdateLoad", text, body);
387
+ }
388
+ async #sendNotificationUpdateLoadClose() {
389
+ this.#window.webContents.send("sendNotificationUpdateLoadClose");
390
+ }
391
+ async #sendNotificationUpdate(text, body) {
392
+ this.#window.webContents.send("sendNotificationUpdate", text, body);
393
+ }
394
+ async #sendNotificationUpdateClose() {
395
+ this.#window.webContents.send("sendNotificationUpdateClose");
396
+ }
397
+
398
+ sendDownload(text, body) {
399
+ setTimeout(() => this.#window.webContents.send("sendNotificationDownload", text, body), 1)
400
+ }
401
+ sendDownloadUpdate(text, body) {
402
+ setTimeout(() => this.#window.webContents.send("sendNotificationDownloadUpdate", text, body), 1)
403
+ }
404
+ sendDownloadComplete(text, body) {
405
+ setTimeout(() => this.#window.webContents.send("sendNotificationDownloadComplete", text, body), 250)
406
+ }
407
+ sendDownloadError(text, body) {
408
+ setTimeout(() => this.#window.webContents.send("sendNotificationDownloadError", text, body), 250)
409
+ }
410
+ }
411
+
412
+ class Styles {
413
+ static WORD_BREAK = {NORMAL: "normal", BREAK_ALL: "break-all", KEEP_ALL: "keep-all", BREAK_WORD: "break-word"}
414
+ static TEXT_ALIGN = {CENTER: 'center', END: 'end', START: 'start'};
415
+ static ALIGN = {CENTER: 'center', END: 'flex-end', START: 'flex-start', BASELINE: 'baseline', STRETCH: 'stretch'};
416
+ static JUSTIFY = {
417
+ CENTER: 'center',
418
+ END: 'flex-end',
419
+ START: 'flex-start',
420
+ SPACE_AROUND: 'space-around',
421
+ SPACE_BEETWEEN: 'space-between',
422
+ SPACE_EVENLY: 'space-evenly'
423
+ };
424
+ static DIRECTION = {ROW: 'row', COLUMN: 'column'};
425
+ static WRAP = {NOWRAP: 'nowrap', WRAP: 'wrap'};
426
+ static SIZE = {
427
+ AUTO: 'auto',
428
+ FIT_CONTENT: 'fit-content',
429
+ MAX_CONTENT: 'max-content',
430
+ MIN_CONTENT: 'min-content',
431
+ WEBKIT_FILL: '-webkit-fill-available',
432
+ INHERIT: 'inherit'
433
+ };
434
+ }
435
+
436
+ class Application {
437
+ getApp() {
438
+ if (process && process.type === 'renderer') {
439
+ return require("@electron/remote").app;
440
+ } else {
441
+ return app;
442
+ }
443
+ }
444
+ getSession() {
445
+ if (process && process.type === 'renderer') {
446
+ return require("@electron/remote").session;
447
+ } else {
448
+ return session;
449
+ }
450
+ }
451
+ getWebContents() {
452
+ if (process && process.type === 'renderer') {
453
+ return require("@electron/remote").webContents;
454
+ } else {
455
+ return webContents;
456
+ }
457
+ }
458
+ }
459
+
460
+ class App {
461
+ static get() { return new Application().getApp() }
462
+ static getSession() { return new Application().getSession() }
463
+ static getWebContents() { return new Application().getWebContents() }
464
+ // ПУТИ
465
+ static homePath() { return new Application().getApp().getPath("home") }
466
+ static appDataPath() { return new Application().getApp().getPath("appData") }
467
+ static userDataPath() { return new Application().getApp().getPath("userData") }
468
+ static sessionDataPath() { return new Application().getApp().getPath("sessionData") }
469
+ static logsPath() { return new Application().getApp().getPath("logs") }
470
+ static tempPath() { return new Application().getApp().getPath("temp") }
471
+ static exePath() { return new Application().getApp().getPath("exe") }
472
+ static modulePath() { return new Application().getApp().getPath("module") }
473
+ static desktopPath() { return new Application().getApp().getPath("desktop") }
474
+ static documentsPath() { return new Application().getApp().getPath("documents") }
475
+ static downloadsPath() { return new Application().getApp().getPath("downloads") }
476
+ static musicPath() { return new Application().getApp().getPath("music") }
477
+ static picturesPath() { return new Application().getApp().getPath("pictures") }
478
+ static videosPath() { return new Application().getApp().getPath("videos") }
479
+ static recentPath() { return new Application().getApp().getPath("recent") }
480
+ static crashDumpsPath() { return new Application().getApp().getPath("crashDumps") }
481
+ }
482
+
483
+ module.exports = {
484
+ Main: Main,
485
+ sleep: sleep,
486
+ render: render,
487
+ formatBytes: formatBytes,
488
+ MenuItem: MenuItem,
489
+ Styles: Styles,
490
+ AppLayout: AppLayout,
491
+ Route: Route,
492
+ Page: Page,
493
+ WebView: WebView,
494
+ Button: Button,
495
+ Spinner: Spinner,
496
+ TextInput: TextInput,
497
+ DateInput: DateInput,
498
+ NumberInput: NumberInput,
499
+ EmailInput: EmailInput,
500
+ PasswordInput: PasswordInput,
501
+ Select: Select,
502
+ Calendar: Calendar,
503
+ Badge: Badge,
504
+ TextEditor: TextEditor,
505
+ Icon: Icon,
506
+ Icons: Icons,
507
+ TextArea: TextArea,
508
+ CheckBox: CheckBox,
509
+ RadioButton: RadioButton,
510
+ Details: Details,
511
+ Table: Table,
512
+ H: H,
513
+ Paragraph: Paragraph,
514
+ Dialog: Dialog,
515
+ Label: Label,
516
+ ContentBlock: ContentBlock,
517
+ Card: Card,
518
+ Hero: Hero,
519
+ ProgressBar: ProgressBar,
520
+ Toggle: Toggle,
521
+ Image: Image,
522
+ BarGraph: BarGraph,
523
+ PieGraph: PieGraph,
524
+ Tabs: Tabs,
525
+ Tab: Tab,
526
+ Notification: Notification,
527
+ ComboBox: ComboBox,
528
+ MultiComboBox: MultiComboBox,
529
+ RadioGroup: RadioGroup,
530
+ Accordion: Accordion,
531
+ CodeBlock: CodeBlock,
532
+ HtmlBlock: HtmlBlock,
533
+ FileInput: FileInput,
534
+ AcceptTypes: AcceptTypes,
535
+ TreeView: TreeView,
536
+ Form: Form,
537
+ SlideShow: SlideShow,
538
+ FieldSet: FieldSet,
539
+ Popup: Popup,
540
+ MenuBar: MenuBar,
541
+ ContextMenu: ContextMenu,
542
+ UpdateNotification: UpdateNotification,
543
+ DownloadNotification: DownloadNotification,
544
+ DownloadProgressNotification: DownloadProgressNotification,
545
+ Audio: Audio,
546
+ Video: Video,
547
+ CustomElement: CustomElement,
548
+ Console: Console,
549
+ //
550
+ TelegramBot: TelegramBot,
551
+ //
552
+ BrowserWindow: BrowserWindow,
553
+ ipcMain: ipcMain,
554
+ ipcRenderer: ipcRenderer,
555
+ shell: shell,
556
+ path: path,
557
+ fs: fs,
558
+ os: os,
559
+ request: request,
560
+ transliterate: transliterate,
561
+ store: new Store(),
562
+ //
563
+ App: App,
564
+ //
565
+ downloadSession: downloadSession,
566
+ Log: Log,
567
+ chooseFile: dialog,
568
+ //
569
+ systemPreferences: systemPreferences
570
+ }