chuijs 3.6.3 → 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 -570
  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 +7128 -7128
  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
@@ -1,76 +1,82 @@
1
- chui_tree_view {
2
- display: flex;
3
- flex-direction: column;
4
- height: max-content;
5
- font-size: var(--font_default_size);
6
- font-weight:500;
7
- border: none;
8
- margin: var(--margin);
9
- border-radius: var(--border_radius);
10
- }
11
-
12
- chui_tree_view_main_test {
13
- display: flex;
14
- flex-direction: column;
15
- height: max-content;
16
- width: -webkit-fill-available;
17
- font-size: var(--font_default_size);
18
- font-weight:500;
19
- border-radius: var(--border_radius);
20
- border: none;
21
- }
22
-
23
- tree_view_button {
24
- cursor: pointer;
25
- padding: var(--main_padding);
26
- width: -webkit-fill-available;
27
- text-align: left;
28
- outline: none;
29
- display: flex;
30
- align-items: center;
31
- flex-direction: row;
32
- border-radius: var(--border_radius);
33
- color: var(--text_color);
34
- border: none;
35
- }
36
-
37
- tree_view_panel {
38
- padding: 0 0 0 10px;
39
- display: block;
40
- overflow: hidden;
41
- width: -webkit-fill-available;
42
- max-height: 0;
43
- border-bottom-right-radius: var(--border_radius);
44
- border-bottom-left-radius: var(--border_radius);
45
- color: var(--text_color);
46
- border: none;
47
- }
48
-
49
- tree_view_html {
50
- padding: 0;
51
- width: -webkit-fill-available;
52
- display: flex;
53
- border: none;
54
- flex-direction: column
55
- }
56
-
57
- tree_view_button:hover {
58
- color: var(--blue_prime_background);
59
- background: var(--blue_prime_background);
60
- }
61
-
62
- tree_view_button:hover tree_view_button_text {
63
- color: var(--text_color_hover);
64
- }
65
-
66
- tree_view_button:hover chui_icon {
67
- color: var(--text_color_hover);
68
- }
69
-
70
- .tree_view_button_active {
71
- color: var(--blue_prime_background)
72
- }
73
-
74
- .tree_view_button_active chui_icon {
75
- color: var(--blue_prime_background);
1
+ chui_tree_view {
2
+ display: flex;
3
+ flex-direction: column;
4
+ height: max-content;
5
+ font-size: var(--font_default_size);
6
+ font-weight:500;
7
+ border: none;
8
+ margin: var(--margin);
9
+ border-radius: var(--border_radius);
10
+ }
11
+
12
+ chui_tree_view_main_test {
13
+ display: flex;
14
+ flex-direction: column;
15
+ height: max-content;
16
+ width: -webkit-fill-available;
17
+ font-size: var(--font_default_size);
18
+ font-weight:500;
19
+ border-radius: var(--border_radius);
20
+ background: var(--element_background);
21
+ border: none;
22
+ }
23
+
24
+ tree_view_button {
25
+ cursor: pointer;
26
+ padding: var(--main_padding);
27
+ width: -webkit-fill-available;
28
+ text-align: left;
29
+ outline: none;
30
+ display: flex;
31
+ align-items: center;
32
+ flex-direction: row;
33
+ border-radius: var(--border_radius);
34
+ color: var(--text_color);
35
+ border: none;
36
+ }
37
+
38
+ tree_view_panel {
39
+ padding: 0 0 0 10px;
40
+ display: block;
41
+ overflow: hidden;
42
+ width: -webkit-fill-available;
43
+ max-height: 0;
44
+ border-bottom-right-radius: var(--border_radius);
45
+ border-bottom-left-radius: var(--border_radius);
46
+ color: var(--text_color);
47
+ border: none;
48
+ }
49
+
50
+ tree_view_html {
51
+ padding: 0;
52
+ width: -webkit-fill-available;
53
+ display: flex;
54
+ border: none;
55
+ flex-direction: column
56
+ }
57
+
58
+ tree_view_button:hover {
59
+ background: var(--blue_prime_background);
60
+ color: var(--text_color_hover);
61
+ }
62
+
63
+ tree_view_button:active {
64
+ background: var(--element_background_prime);
65
+ }
66
+
67
+ tree_view_button:hover tree_view_button_text {
68
+ color: var(--text_color_hover);
69
+ }
70
+
71
+ tree_view_button:hover chui_icon {
72
+ color: var(--text_color_hover);
73
+ }
74
+
75
+ .tree_view_button_active {
76
+ background: var(--blue_prime_background);
77
+ color: var(--text_color_hover);
78
+ }
79
+
80
+ .tree_view_button_active chui_icon {
81
+ color: var(--text_color_hover);
76
82
  }
@@ -1,91 +1,91 @@
1
- const {Icon, Icons} = require("../chui_icons/icons");
2
-
3
- class TreeView {
4
- #chui_tree_view = document.createElement(`chui_tree_view`);
5
- constructor(options = { width: String(), components: [] }) {
6
- require('../../modules/chui_functions').setStyles(__dirname + "/styles.css", 'chUiJS_TreeView');
7
- let main_test = document.createElement(`chui_tree_view_main_test`);
8
- if (options.width !== undefined) {
9
- this.#chui_tree_view.style.width = options.width;
10
- } else {
11
- this.#chui_tree_view.style.width = 'max-content'
12
- }
13
- options.components.forEach(buttons => {
14
- main_test.appendChild(buttons.button)
15
- if (buttons.panel !== undefined) {
16
- main_test.appendChild(buttons.panel)
17
- }
18
- })
19
- this.#chui_tree_view.appendChild(main_test)
20
- }
21
- set() {
22
- return this.#chui_tree_view;
23
- }
24
- static Button(options = { title: String(), listener: () => {} }) {
25
- let button = document.createElement('tree_view_button');
26
- button.addEventListener("click", options.listener);
27
- let button_text = document.createElement('tree_view_button_text');
28
- button_text.innerHTML = options.title;
29
- button.appendChild(button_text)
30
- return {
31
- title: options.title,
32
- button: button
33
- };
34
- }
35
- static ExpandButton(options = { title: String(), subButtons: [], components: [] }) {
36
- let button = document.createElement('tree_view_button');
37
- let panel = document.createElement('tree_view_panel')
38
- button.addEventListener('click', (e) => {
39
- button.classList.toggle('tree_view_button_active')
40
- let panel = button.nextElementSibling;
41
- if (panel.style.maxHeight) {
42
- panel.style.maxHeight = panel.scrollHeight + "px";
43
- setTimeout(() => {
44
- button.children[1].children[0].style.transform = 'rotate(0deg)';
45
- panel.style.maxHeight = null;
46
- button.style.borderBottomLeftRadius = 'var(--border_radius)';
47
- button.style.borderBottomRightRadius = 'var(--border_radius)';
48
- }, 1);
49
- } else {
50
- setTimeout(() => {
51
- button.children[1].children[0].style.transform = 'rotate(180deg)';
52
- button.style.borderBottomLeftRadius = '0px';
53
- button.style.borderBottomRightRadius = '0px';
54
- panel.style.maxHeight = panel.scrollHeight + "px";
55
- panel.addEventListener('transitionend', () => {
56
- if (panel.style.maxHeight) panel.style.maxHeight = "max-content";
57
- });
58
- }, 1);
59
- }
60
- })
61
- let button_text = document.createElement('tree_view_button_text');
62
- button_text.innerHTML = options.title;
63
- button.appendChild(button_text)
64
- let barrow = document.createElement('tree_view_button_arrow')
65
- barrow.style.marginLeft = 'auto'
66
- barrow.innerHTML = new Icon(Icons.HARDWARE.KEYBOARD_ARROW_DOWN).getHTML();
67
- button.appendChild(barrow)
68
- let html = document.createElement('tree_view_html')
69
- if (options.subButtons !== undefined) {
70
- options.subButtons.forEach(sub => {
71
- html.appendChild(sub.button)
72
- if (sub.panel !== undefined) {
73
- html.appendChild(sub.panel)
74
- }
75
- })
76
- }
77
- if (options.components !== undefined) {
78
- options.components.forEach(sub => {
79
- html.appendChild(sub.set())
80
- })
81
- }
82
- panel.appendChild(html)
83
- return {
84
- title: options.title,
85
- button: button,
86
- panel: panel
87
- };
88
- }
89
- }
90
-
1
+ const {Icon, Icons} = require("../chui_icons/icons");
2
+
3
+ class TreeView {
4
+ #chui_tree_view = document.createElement(`chui_tree_view`);
5
+ constructor(options = { width: String(), components: [] }) {
6
+ require('../../modules/chui_functions').setStyles(__dirname + "/styles.css", 'chUiJS_TreeView');
7
+ let main_test = document.createElement(`chui_tree_view_main_test`);
8
+ if (options.width !== undefined) {
9
+ this.#chui_tree_view.style.width = options.width;
10
+ } else {
11
+ this.#chui_tree_view.style.width = 'max-content'
12
+ }
13
+ options.components.forEach(buttons => {
14
+ main_test.appendChild(buttons.button)
15
+ if (buttons.panel !== undefined) {
16
+ main_test.appendChild(buttons.panel)
17
+ }
18
+ })
19
+ this.#chui_tree_view.appendChild(main_test)
20
+ }
21
+ set() {
22
+ return this.#chui_tree_view;
23
+ }
24
+ static Button(options = { title: String(), listener: () => {} }) {
25
+ let button = document.createElement('tree_view_button');
26
+ button.addEventListener("click", options.listener);
27
+ let button_text = document.createElement('tree_view_button_text');
28
+ button_text.innerHTML = options.title;
29
+ button.appendChild(button_text)
30
+ return {
31
+ title: options.title,
32
+ button: button
33
+ };
34
+ }
35
+ static ExpandButton(options = { title: String(), subButtons: [], components: [] }) {
36
+ let button = document.createElement('tree_view_button');
37
+ let panel = document.createElement('tree_view_panel')
38
+ button.addEventListener('click', (e) => {
39
+ button.classList.toggle('tree_view_button_active')
40
+ let panel = button.nextElementSibling;
41
+ if (panel.style.maxHeight) {
42
+ panel.style.maxHeight = panel.scrollHeight + "px";
43
+ setTimeout(() => {
44
+ button.children[1].children[0].style.transform = 'rotate(0deg)';
45
+ panel.style.maxHeight = null;
46
+ button.style.borderBottomLeftRadius = 'var(--border_radius)';
47
+ button.style.borderBottomRightRadius = 'var(--border_radius)';
48
+ }, 1);
49
+ } else {
50
+ setTimeout(() => {
51
+ button.children[1].children[0].style.transform = 'rotate(180deg)';
52
+ button.style.borderBottomLeftRadius = '0px';
53
+ button.style.borderBottomRightRadius = '0px';
54
+ panel.style.maxHeight = panel.scrollHeight + "px";
55
+ panel.addEventListener('transitionend', () => {
56
+ if (panel.style.maxHeight) panel.style.maxHeight = "max-content";
57
+ });
58
+ }, 1);
59
+ }
60
+ })
61
+ let button_text = document.createElement('tree_view_button_text');
62
+ button_text.innerHTML = options.title;
63
+ button.appendChild(button_text)
64
+ let barrow = document.createElement('tree_view_button_arrow')
65
+ barrow.style.marginLeft = 'auto'
66
+ barrow.innerHTML = new Icon(Icons.HARDWARE.KEYBOARD_ARROW_DOWN).getHTML();
67
+ button.appendChild(barrow)
68
+ let html = document.createElement('tree_view_html')
69
+ if (options.subButtons !== undefined) {
70
+ options.subButtons.forEach(sub => {
71
+ html.appendChild(sub.button)
72
+ if (sub.panel !== undefined) {
73
+ html.appendChild(sub.panel)
74
+ }
75
+ })
76
+ }
77
+ if (options.components !== undefined) {
78
+ options.components.forEach(sub => {
79
+ html.appendChild(sub.set())
80
+ })
81
+ }
82
+ panel.appendChild(html)
83
+ return {
84
+ title: options.title,
85
+ button: button,
86
+ panel: panel
87
+ };
88
+ }
89
+ }
90
+
91
91
  exports.TreeView = TreeView
@@ -1,28 +1,28 @@
1
- chui_webview {
2
- position: relative;
3
- width: -webkit-fill-available;
4
- height: 100%
5
- }
6
-
7
- chui_load {
8
- display: flex;
9
- width: -webkit-fill-available;
10
- height: 100%;
11
- position: absolute;
12
- top: 0;
13
- left: 0;
14
- justify-content: center;
15
- align-items: center;
16
- z-index: 0;
17
- }
18
-
19
- webview {
20
- height: 100%;
21
- width: -webkit-fill-available;
22
- display: none;
23
- z-index: 1;
24
- }
25
-
26
- webview.hide {
27
- visibility: hidden;
1
+ chui_webview {
2
+ position: relative;
3
+ width: -webkit-fill-available;
4
+ height: 100%
5
+ }
6
+
7
+ chui_load {
8
+ display: flex;
9
+ width: -webkit-fill-available;
10
+ height: 100%;
11
+ position: absolute;
12
+ top: 0;
13
+ left: 0;
14
+ justify-content: center;
15
+ align-items: center;
16
+ z-index: 0;
17
+ }
18
+
19
+ webview {
20
+ height: 100%;
21
+ width: -webkit-fill-available;
22
+ display: none;
23
+ z-index: 1;
24
+ }
25
+
26
+ webview.hide {
27
+ visibility: hidden;
28
28
  }
@@ -1,104 +1,104 @@
1
- const { Animation } = require('../../modules/chui_animations/animations')
2
- const { Spinner } = require('../chui_spinner/spinner')
3
- const {Log} = require("../../../framework/modules/chui_logger/chui_logger");
4
-
5
- class WebView {
6
- #id = require("randomstring").generate()
7
- #main_block = document.createElement('chui_webview')
8
- #WebView = document.createElement('webview')
9
- #chui_load = document.createElement('chui_load')
10
- constructor(url = String(), dev = false) {
11
- require('../../modules/chui_functions').setStyles(__dirname + '/styles.css', 'chUiJS_WebView');
12
- this.#WebView.setAttribute('id', this.#id)
13
- this.#WebView.setAttribute('src', url)
14
- this.#WebView.setAttribute('nodeintegration', 'true');
15
- this.#WebView.setAttribute('plugins', 'true')
16
- this.#WebView.setAttribute('useragent', getFirefoxUserAgent())
17
- this.#WebView.setAttribute('disablewebsecurity', 'true')
18
- this.#WebView.setAttribute('allowpopups', 'true')
19
- this.#WebView.setAttribute("webpreferences", "allowRunningInsecureContent, javascript=yes")
20
- let spinner = new Spinner(Spinner.SIZE.BIG);
21
- this.#chui_load.appendChild(spinner.set());
22
- this.#main_block.appendChild(this.#WebView)
23
- const loadStart = () => {
24
- this.#main_block.appendChild(this.#chui_load)
25
- }
26
- const loadStop = () => {
27
- new Animation(this.#WebView).fadeIn();
28
- this.#main_block.removeChild(this.#chui_load)
29
- if (dev) this.#WebView.openDevTools();
30
- }
31
- this.#WebView.addEventListener('did-start-loading', loadStart)
32
- this.#WebView.addEventListener('did-stop-loading', loadStop)
33
- }
34
- setPartition(partition = String()) {
35
- this.#WebView.partition = partition;
36
- }
37
- setPreload(path = String()) {
38
- this.#WebView.preload = "file://" + path;
39
- }
40
- addStartLoadEvent(listener = () => {}) {
41
- this.#WebView.addEventListener('did-start-loading', listener)
42
- }
43
- addStopLoadEvent(listener = () => {}) {
44
- this.#WebView.addEventListener('did-stop-loading', listener)
45
- }
46
- addFinishLoadEvent(listener = () => {}) {
47
- this.#WebView.addEventListener('did-finish-load', listener)
48
- }
49
- async executeJavaScript(code = String()) {
50
- try {
51
- await this.#WebView.executeJavaScript(code);
52
- } catch (err) {
53
- Log.error(err)
54
- }
55
- }
56
- insertCustomRes(options = { cssPath: String(), jsPath: String() }) {
57
- this.#WebView.addEventListener('did-frame-finish-load', async () => {
58
- const fs = require('fs');
59
- if (options.cssPath !== undefined) {
60
- let data = fs.readFileSync(options.cssPath, 'utf8');
61
- this.#WebView.insertCSS(String(data)).catch(r => Log.error(r));
62
- }
63
- if (options.jsPath !== undefined) {
64
- try {
65
- const data = fs.readFileSync(options.jsPath, 'utf8');
66
- await this.#WebView.executeJavaScript(data);
67
- } catch (err) {
68
- Log.error(err);
69
- }
70
- }
71
- })
72
- }
73
- async send(channel = String(), ...args) {
74
- await this.#WebView.send(channel, args)
75
- }
76
- setUrl(url = String()) {
77
- this.#WebView.setAttribute('src', url)
78
- }
79
- getWebContentsId() {
80
- return this.#WebView.getWebContentsId()
81
- }
82
- set() {
83
- return this.#main_block
84
- }
85
- }
86
-
87
- const getFirefoxUserAgent = () => {
88
- const rootUAs = {
89
- mac: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:FXVERSION.0) Gecko/20100101 Firefox/FXVERSION.0',
90
- windows: 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:FXVERSION.0) Gecko/20100101 Firefox/FXVERSION.0',
91
- linux: 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:FXVERSION.0) Gecko/20100101 Firefox/FXVERSION.0',
92
- };
93
- let rootUA;
94
- if (process.platform === 'win32') {
95
- rootUA = rootUAs.windows;
96
- } else if (process.platform === 'darwin') {
97
- rootUA = rootUAs.mac;
98
- } else {
99
- rootUA = rootUAs.linux;
100
- }
101
- return rootUA.replace(/FXVERSION/g, 91 + Math.floor((Date.now() - 1628553600000) / (4.1 * 7 * 24 * 60 * 60 * 1000)));
102
- };
103
-
1
+ const { Animation } = require('../../modules/chui_animations/animations')
2
+ const { Spinner } = require('../chui_spinner/spinner')
3
+ const {Log} = require("../../../framework/modules/chui_logger/chui_logger");
4
+
5
+ class WebView {
6
+ #id = require("randomstring").generate()
7
+ #main_block = document.createElement('chui_webview')
8
+ #WebView = document.createElement('webview')
9
+ #chui_load = document.createElement('chui_load')
10
+ constructor(url = String(), dev = false) {
11
+ require('../../modules/chui_functions').setStyles(__dirname + '/styles.css', 'chUiJS_WebView');
12
+ this.#WebView.setAttribute('id', this.#id)
13
+ this.#WebView.setAttribute('src', url)
14
+ this.#WebView.setAttribute('nodeintegration', 'true');
15
+ this.#WebView.setAttribute('plugins', 'true')
16
+ this.#WebView.setAttribute('useragent', getFirefoxUserAgent())
17
+ this.#WebView.setAttribute('disablewebsecurity', 'true')
18
+ this.#WebView.setAttribute('allowpopups', 'true')
19
+ this.#WebView.setAttribute("webpreferences", "allowRunningInsecureContent, javascript=yes")
20
+ let spinner = new Spinner(Spinner.SIZE.BIG);
21
+ this.#chui_load.appendChild(spinner.set());
22
+ this.#main_block.appendChild(this.#WebView)
23
+ const loadStart = () => {
24
+ this.#main_block.appendChild(this.#chui_load)
25
+ }
26
+ const loadStop = () => {
27
+ new Animation(this.#WebView).fadeIn();
28
+ this.#main_block.removeChild(this.#chui_load)
29
+ if (dev) this.#WebView.openDevTools();
30
+ }
31
+ this.#WebView.addEventListener('did-start-loading', loadStart)
32
+ this.#WebView.addEventListener('did-stop-loading', loadStop)
33
+ }
34
+ setPartition(partition = String()) {
35
+ this.#WebView.partition = partition;
36
+ }
37
+ setPreload(path = String()) {
38
+ this.#WebView.preload = "file://" + path;
39
+ }
40
+ addStartLoadEvent(listener = () => {}) {
41
+ this.#WebView.addEventListener('did-start-loading', listener)
42
+ }
43
+ addStopLoadEvent(listener = () => {}) {
44
+ this.#WebView.addEventListener('did-stop-loading', listener)
45
+ }
46
+ addFinishLoadEvent(listener = () => {}) {
47
+ this.#WebView.addEventListener('did-finish-load', listener)
48
+ }
49
+ async executeJavaScript(code = String()) {
50
+ try {
51
+ await this.#WebView.executeJavaScript(code);
52
+ } catch (err) {
53
+ Log.error(err)
54
+ }
55
+ }
56
+ insertCustomRes(options = { cssPath: String(), jsPath: String() }) {
57
+ this.#WebView.addEventListener('did-frame-finish-load', async () => {
58
+ const fs = require('fs');
59
+ if (options.cssPath !== undefined) {
60
+ let data = fs.readFileSync(options.cssPath, 'utf8');
61
+ this.#WebView.insertCSS(String(data)).catch(r => Log.error(r));
62
+ }
63
+ if (options.jsPath !== undefined) {
64
+ try {
65
+ const data = fs.readFileSync(options.jsPath, 'utf8');
66
+ await this.#WebView.executeJavaScript(data);
67
+ } catch (err) {
68
+ Log.error(err);
69
+ }
70
+ }
71
+ })
72
+ }
73
+ async send(channel = String(), ...args) {
74
+ await this.#WebView.send(channel, args)
75
+ }
76
+ setUrl(url = String()) {
77
+ this.#WebView.setAttribute('src', url)
78
+ }
79
+ getWebContentsId() {
80
+ return this.#WebView.getWebContentsId()
81
+ }
82
+ set() {
83
+ return this.#main_block
84
+ }
85
+ }
86
+
87
+ const getFirefoxUserAgent = () => {
88
+ const rootUAs = {
89
+ mac: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:FXVERSION.0) Gecko/20100101 Firefox/FXVERSION.0',
90
+ windows: 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:FXVERSION.0) Gecko/20100101 Firefox/FXVERSION.0',
91
+ linux: 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:FXVERSION.0) Gecko/20100101 Firefox/FXVERSION.0',
92
+ };
93
+ let rootUA;
94
+ if (process.platform === 'win32') {
95
+ rootUA = rootUAs.windows;
96
+ } else if (process.platform === 'darwin') {
97
+ rootUA = rootUAs.mac;
98
+ } else {
99
+ rootUA = rootUAs.linux;
100
+ }
101
+ return rootUA.replace(/FXVERSION/g, 91 + Math.floor((Date.now() - 1628553600000) / (4.1 * 7 * 24 * 60 * 60 * 1000)));
102
+ };
103
+
104
104
  exports.WebView = WebView