plusui-native-core 0.1.38 → 0.1.40

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.
@@ -24,6 +24,7 @@ add_library(plusui STATIC
24
24
  Features/Bindings/CustomBindings/custom_bindings.cpp
25
25
  Features/App/app.cpp
26
26
  Features/Window/window.cpp
27
+ Features/Window/webview.cpp
27
28
  Features/Browser/browser.cpp
28
29
  Features/Display/display.cpp
29
30
  Features/Tray/tray.cpp
@@ -25,6 +25,29 @@ using namespace Microsoft::WRL;
25
25
 
26
26
  namespace plusui {
27
27
 
28
+ namespace {
29
+ constexpr char kHideScrollbarsScript[] = R"(
30
+ (function() {
31
+ var css = "::-webkit-scrollbar{display:none!important;width:0!important;height:0!important;}::-webkit-scrollbar-track{background:transparent!important;}::-webkit-scrollbar-thumb{background:transparent!important;}*{-ms-overflow-style:none!important;scrollbar-width:none!important;scrollbar-color:transparent transparent!important;}";
32
+ var styleId = "__plusui_hide_scrollbars";
33
+ var ensureStyle = function() {
34
+ if (document.getElementById(styleId)) return;
35
+ var style = document.createElement("style");
36
+ style.id = styleId;
37
+ style.type = "text/css";
38
+ style.appendChild(document.createTextNode(css));
39
+ var container = document.head || document.documentElement || document.body;
40
+ if (container) {
41
+ container.appendChild(style);
42
+ }
43
+ };
44
+ ensureStyle();
45
+ document.addEventListener("DOMContentLoaded", ensureStyle);
46
+ window.addEventListener("load", ensureStyle);
47
+ })();
48
+ )";
49
+ } // namespace
50
+
28
51
  // Note: Window::Impl is defined in window.cpp
29
52
  // This file only provides implementations for webview-specific methods
30
53
 
@@ -90,51 +113,9 @@ Window Window::create(void *windowHandle, const WindowConfig &config) {
90
113
  .c_str(),
91
114
  nullptr);
92
115
 
93
- // Hide scrollbars if disabled via comprehensive CSS injection
116
+ // Disable scrollbars if configured
94
117
  if (!pImpl->config.scrollbars) {
95
- std::string scrollbarScript = R"(
96
- (function() {
97
- // Critical: Apply inline styles to prevent scrollbars
98
- if (document.documentElement) {
99
- document.documentElement.style.cssText = 'margin:0 !important;padding:0 !important;overflow:hidden !important;width:100%;height:100%;';
100
- }
101
- if (document.body) {
102
- document.body.style.cssText = 'margin:0 !important;padding:0 !important;overflow:hidden !important;width:100%;height:100%;';
103
- }
104
-
105
- // Create comprehensive style element
106
- var style = document.createElement('style');
107
- style.type = 'text/css';
108
- style.textContent = 'html,body{margin:0!important;padding:0!important;overflow:hidden!important;width:100%;height:100%;position:fixed;top:0;left:0;}*{scrollbar-width:none;}::-webkit-scrollbar{display:none!important;width:0!important;height:0!important;}body *{overflow:hidden!important;}';
109
-
110
- function applyStyle() {
111
- try {
112
- if (document.head) {
113
- document.head.insertBefore(style, document.head.firstChild);
114
- } else if (document.documentElement) {
115
- document.documentElement.insertBefore(style, document.documentElement.firstChild);
116
- } else {
117
- setTimeout(applyStyle, 10);
118
- return;
119
- }
120
- } catch (e) {}
121
- }
122
-
123
- applyStyle();
124
-
125
- // Also apply when DOM is fully ready
126
- if (document.readyState === 'loading') {
127
- document.addEventListener('DOMContentLoaded', function() {
128
- if (document.documentElement) {
129
- document.documentElement.style.overflow = 'hidden';
130
- }
131
- if (document.body) {
132
- document.body.style.overflow = 'hidden';
133
- }
134
- });
135
- }
136
- })();
137
- )";
118
+ std::string scrollbarScript = kHideScrollbarsScript;
138
119
  pImpl->webview->AddScriptToExecuteOnDocumentCreated(
139
120
  std::wstring(scrollbarScript.begin(),
140
121
  scrollbarScript.end())
@@ -706,17 +687,11 @@ Window Window::create(void *windowHandle, const WindowConfig &config) {
706
687
 
707
688
  // Hide scrollbars if disabled
708
689
  if (!win.pImpl->config.scrollbars) {
709
- NSString *scrollbarScript = @"(function() {"
710
- "var css = 'html, body { overflow: hidden !important; margin: 0 !important; padding: 0 !important; } ::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }';"
711
- "var style = document.createElement('style');"
712
- "style.type = 'text/css';"
713
- "style.appendChild(document.createTextNode(css));"
714
- "(document.head || document.documentElement).appendChild(style);"
715
- "})();";
716
-
717
- WKUserScript *scrollScript = [[WKUserScript alloc]
718
- initWithSource:scrollbarScript
719
- injectionTime:WKUserScriptInjectionTimeAtDocumentEnd
690
+ NSString *scrollbarScript = [NSString stringWithUTF8String:kHideScrollbarsScript];
691
+
692
+ WKUserScript *scrollScript = [[WKUserScript alloc]
693
+ initWithSource:scrollbarScript
694
+ injectionTime:WKUserScriptInjectionTimeAtDocumentEnd
720
695
  forMainFrameOnly:NO];
721
696
  [config.userContentController addUserScript:scrollScript];
722
697
  }
@@ -30,6 +30,29 @@ using namespace Microsoft::WRL;
30
30
 
31
31
  namespace plusui {
32
32
 
33
+ namespace {
34
+ constexpr char kHideScrollbarsScript[] = R"(
35
+ (function() {
36
+ var css = "::-webkit-scrollbar{display:none!important;width:0!important;height:0!important;}::-webkit-scrollbar-track{background:transparent!important;}::-webkit-scrollbar-thumb{background:transparent!important;}*{-ms-overflow-style:none!important;scrollbar-width:none!important;scrollbar-color:transparent transparent!important;}";
37
+ var styleId = "__plusui_hide_scrollbars";
38
+ var ensureStyle = function() {
39
+ if (document.getElementById(styleId)) return;
40
+ var style = document.createElement("style");
41
+ style.id = styleId;
42
+ style.type = "text/css";
43
+ style.appendChild(document.createTextNode(css));
44
+ var container = document.head || document.documentElement || document.body;
45
+ if (container) {
46
+ container.appendChild(style);
47
+ }
48
+ };
49
+ ensureStyle();
50
+ document.addEventListener("DOMContentLoaded", ensureStyle);
51
+ window.addEventListener("load", ensureStyle);
52
+ })();
53
+ )";
54
+ } // namespace
55
+
33
56
  struct Window::Impl {
34
57
  void *nativeWindow = nullptr;
35
58
  void *nativeWebView = nullptr;
@@ -793,15 +816,7 @@ Window Window::create(void *windowHandle, const WindowConfig &config) {
793
816
 
794
817
  // Inject scrollbar hiding CSS if disabled
795
818
  if (!pImpl->config.scrollbars) {
796
- std::string scrollbarScript = R"(
797
- (function() {
798
- var css = 'html, body { overflow: hidden !important; margin: 0 !important; padding: 0 !important; } ::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }';
799
- var style = document.createElement('style');
800
- style.type = 'text/css';
801
- style.appendChild(document.createTextNode(css));
802
- (document.head || document.documentElement).appendChild(style);
803
- })();
804
- )";
819
+ std::string scrollbarScript = kHideScrollbarsScript;
805
820
  pImpl->webview->AddScriptToExecuteOnDocumentCreated(
806
821
  std::wstring(scrollbarScript.begin(),
807
822
  scrollbarScript.end())
@@ -1183,13 +1198,7 @@ Window Window::create(void *windowHandle, const WindowConfig &config) {
1183
1198
 
1184
1199
  // Hide scrollbars if disabled
1185
1200
  if (!win.pImpl->config.scrollbars) {
1186
- NSString *scrollbarScript = @"(function() {"
1187
- "var css = 'html, body { overflow: hidden !important; margin: 0 !important; padding: 0 !important; } ::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }';"
1188
- "var style = document.createElement('style');"
1189
- "style.type = 'text/css';"
1190
- "style.appendChild(document.createTextNode(css));"
1191
- "(document.head || document.documentElement).appendChild(style);"
1192
- "})();";
1201
+ NSString *scrollbarScript = [NSString stringWithUTF8String:kHideScrollbarsScript];
1193
1202
 
1194
1203
  WKUserScript *scrollScript = [[WKUserScript alloc]
1195
1204
  initWithSource:scrollbarScript
@@ -1293,16 +1302,7 @@ void Window::navigate(const std::string &url) {
1293
1302
 
1294
1303
  // Apply scrollbar hiding CSS if configured
1295
1304
  if (!pImpl->config.scrollbars) {
1296
- std::string hideScrollbars = R"(
1297
- (function() {
1298
- document.documentElement.style.overflow = 'hidden';
1299
- document.documentElement.style.margin = '0';
1300
- document.documentElement.style.padding = '0';
1301
- document.body.style.overflow = 'hidden';
1302
- document.body.style.margin = '0';
1303
- document.body.style.padding = '0';
1304
- })();
1305
- )";
1305
+ std::string hideScrollbars = kHideScrollbarsScript;
1306
1306
  // Schedule this to run after a short delay to ensure DOM is ready
1307
1307
  #ifdef _WIN32
1308
1308
  if (pImpl->ready && pImpl->webview) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plusui-native-core",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "description": "PlusUI Core framework (frontend + backend implementations)",
5
5
  "type": "module",
6
6
  "files": [