windowpp 0.1.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 (88) hide show
  1. package/bin/windowpp.js +86 -0
  2. package/cmake/embed_assets.py +144 -0
  3. package/framework/CMakeLists.txt +176 -0
  4. package/framework/include/windowpp/windowpp.h +704 -0
  5. package/framework/src/AppData/API/AppData.ts +137 -0
  6. package/framework/src/AppData/appdata_bridge.h +138 -0
  7. package/framework/src/AppData/appdata_manager.cpp +126 -0
  8. package/framework/src/AppData/appdata_manager.h +3 -0
  9. package/framework/src/FileSystem/API/FileSystem.ts +389 -0
  10. package/framework/src/FileSystem/Linux/filesearch.cpp +148 -0
  11. package/framework/src/FileSystem/Linux/readfile.cpp +79 -0
  12. package/framework/src/FileSystem/Linux/savefile.cpp +333 -0
  13. package/framework/src/FileSystem/MacOS/filesearch.cpp +149 -0
  14. package/framework/src/FileSystem/MacOS/readfile.cpp +80 -0
  15. package/framework/src/FileSystem/MacOS/savefile.cpp +264 -0
  16. package/framework/src/FileSystem/Windows/filesearch.cpp +195 -0
  17. package/framework/src/FileSystem/Windows/readfile.cpp +122 -0
  18. package/framework/src/FileSystem/Windows/savefile.cpp +290 -0
  19. package/framework/src/FileSystem/file_index_service.cpp +262 -0
  20. package/framework/src/FileSystem/file_index_service.h +55 -0
  21. package/framework/src/FileSystem/filesystem_bridge.h +243 -0
  22. package/framework/src/FileSystem/filesystem_handler.h +93 -0
  23. package/framework/src/FileSystem/filesystem_json.h +241 -0
  24. package/framework/src/FileSystem/filesystem_search_service.cpp +414 -0
  25. package/framework/src/FileSystem/filesystem_search_service.h +94 -0
  26. package/framework/src/Input/API/Input.ts +161 -0
  27. package/framework/src/Input/Linux/linux_key_utils.h +135 -0
  28. package/framework/src/Input/MacOS/macos_key_utils.h +137 -0
  29. package/framework/src/Input/Windows/win32_key_utils.h +199 -0
  30. package/framework/src/Input/input_bridge.h +192 -0
  31. package/framework/src/Input/input_service.cpp +584 -0
  32. package/framework/src/Input/input_service.h +21 -0
  33. package/framework/src/application.cpp +29 -0
  34. package/framework/src/common/hit_test.cpp +40 -0
  35. package/framework/src/common/image_loader.cpp +24 -0
  36. package/framework/src/common/paths.cpp +75 -0
  37. package/framework/src/filedrop/filedrop.cpp +316 -0
  38. package/framework/src/filedrop/filedrop.css +421 -0
  39. package/framework/src/filedrop/filedrop.hpp +92 -0
  40. package/framework/src/filedrop/filedrop.ts +183 -0
  41. package/framework/src/platform/API/App.ts +156 -0
  42. package/framework/src/platform/API/Window.ts +249 -0
  43. package/framework/src/platform/linux/app_linux.cpp +256 -0
  44. package/framework/src/platform/linux/app_linux.h +64 -0
  45. package/framework/src/platform/linux/linux_helpers.cpp +26 -0
  46. package/framework/src/platform/linux/linux_helpers.h +19 -0
  47. package/framework/src/platform/linux/tray_linux.cpp +21 -0
  48. package/framework/src/platform/linux/tray_linux.h +26 -0
  49. package/framework/src/platform/linux/window_linux.cpp +256 -0
  50. package/framework/src/platform/linux/window_linux.h +70 -0
  51. package/framework/src/platform/macos/app_macos.h +59 -0
  52. package/framework/src/platform/macos/app_macos.mm +223 -0
  53. package/framework/src/platform/macos/macos_helpers.h +21 -0
  54. package/framework/src/platform/macos/tray_macos.h +22 -0
  55. package/framework/src/platform/macos/tray_macos.mm +53 -0
  56. package/framework/src/platform/macos/window_macos.h +74 -0
  57. package/framework/src/platform/macos/window_macos.mm +318 -0
  58. package/framework/src/platform/platform_bridge.h +514 -0
  59. package/framework/src/platform/platform_factory.cpp +33 -0
  60. package/framework/src/platform/platform_factory.h +19 -0
  61. package/framework/src/platform/win32/app_win32.cpp +572 -0
  62. package/framework/src/platform/win32/app_win32.h +83 -0
  63. package/framework/src/platform/win32/tray_win32.cpp +57 -0
  64. package/framework/src/platform/win32/tray_win32.h +30 -0
  65. package/framework/src/platform/win32/win32_helpers.h +61 -0
  66. package/framework/src/platform/win32/window_win32.cpp +267 -0
  67. package/framework/src/platform/win32/window_win32.h +79 -0
  68. package/framework/src/renderer/webgpu.h +128 -0
  69. package/framework/src/renderer/webview/include/WebView2.h +48014 -0
  70. package/framework/src/renderer/webview/include/WebView2EnvironmentOptions.h +342 -0
  71. package/framework/src/renderer/webview/webview.h +13 -0
  72. package/framework/src/renderer/webview/webview_linux.cpp +392 -0
  73. package/framework/src/renderer/webview/webview_macos.mm +388 -0
  74. package/framework/src/renderer/webview/webview_win32.cpp +688 -0
  75. package/framework/src/renderer/webview/x64/WebView2Loader.dll +0 -0
  76. package/framework/src/renderer/webview/x64/WebView2Loader.lib +0 -0
  77. package/framework/src/renderer/webview/x64/WebView2LoaderStatic.lib +0 -0
  78. package/lib/build.js +112 -0
  79. package/lib/create.js +283 -0
  80. package/lib/dev.js +155 -0
  81. package/package.json +24 -0
  82. package/scripts/publish.js +67 -0
  83. package/scripts/sync-framework.js +73 -0
  84. package/templates/solid/CMakeLists.txt +56 -0
  85. package/templates/solid/frontend/package.json +22 -0
  86. package/templates/solid/frontend/vite.config.ts +25 -0
  87. package/templates/solid/main.cpp +72 -0
  88. package/templates/solid/package.json +12 -0
@@ -0,0 +1,342 @@
1
+ // Copyright (C) Microsoft Corporation. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef __core_webview2_environment_options_h__
6
+ #define __core_webview2_environment_options_h__
7
+
8
+ #include <objbase.h>
9
+ #include <wrl/implements.h>
10
+
11
+ #include "webview2.h"
12
+ #define CORE_WEBVIEW_TARGET_PRODUCT_VERSION L"120.0.2210.55"
13
+
14
+ #define COREWEBVIEW2ENVIRONMENTOPTIONS_STRING_PROPERTY(p) \
15
+ public: \
16
+ HRESULT STDMETHODCALLTYPE get_##p(LPWSTR* value) override { \
17
+ if (!value) \
18
+ return E_POINTER; \
19
+ *value = m_##p.Copy(); \
20
+ if ((*value == nullptr) && (m_##p.Get() != nullptr)) \
21
+ return HRESULT_FROM_WIN32(GetLastError()); \
22
+ return S_OK; \
23
+ } \
24
+ HRESULT STDMETHODCALLTYPE put_##p(LPCWSTR value) override { \
25
+ LPCWSTR result = m_##p.Set(value); \
26
+ if ((result == nullptr) && (value != nullptr)) \
27
+ return HRESULT_FROM_WIN32(GetLastError()); \
28
+ return S_OK; \
29
+ } \
30
+ \
31
+ protected: \
32
+ AutoCoMemString m_##p;
33
+
34
+ #define COREWEBVIEW2ENVIRONMENTOPTIONS_BOOL_PROPERTY(p, defPVal) \
35
+ public: \
36
+ HRESULT STDMETHODCALLTYPE get_##p(BOOL* value) override { \
37
+ if (!value) \
38
+ return E_POINTER; \
39
+ *value = m_##p; \
40
+ return S_OK; \
41
+ } \
42
+ HRESULT STDMETHODCALLTYPE put_##p(BOOL value) override { \
43
+ m_##p = value; \
44
+ return S_OK; \
45
+ } \
46
+ \
47
+ protected: \
48
+ BOOL m_##p = defPVal ? TRUE : FALSE;
49
+
50
+ #define DEFINE_AUTO_COMEM_STRING() \
51
+ protected: \
52
+ class AutoCoMemString { \
53
+ public: \
54
+ AutoCoMemString() {} \
55
+ ~AutoCoMemString() { Release(); } \
56
+ void Release() { \
57
+ if (m_string) { \
58
+ deallocate_fn(m_string); \
59
+ m_string = nullptr; \
60
+ } \
61
+ } \
62
+ \
63
+ LPCWSTR Set(LPCWSTR str) { \
64
+ Release(); \
65
+ if (str) { \
66
+ m_string = MakeCoMemString(str); \
67
+ } \
68
+ return m_string; \
69
+ } \
70
+ LPCWSTR Get() { return m_string; } \
71
+ LPWSTR Copy() { \
72
+ if (m_string) \
73
+ return MakeCoMemString(m_string); \
74
+ return nullptr; \
75
+ } \
76
+ \
77
+ protected: \
78
+ LPWSTR MakeCoMemString(LPCWSTR source) { \
79
+ const size_t length = wcslen(source); \
80
+ const size_t bytes = (length + 1) * sizeof(*source); \
81
+ \
82
+ if (bytes <= length) { \
83
+ return nullptr; \
84
+ } \
85
+ \
86
+ wchar_t* result = reinterpret_cast<wchar_t*>(allocate_fn(bytes)); \
87
+ \
88
+ if (result) \
89
+ memcpy(result, source, bytes); \
90
+ return result; \
91
+ } \
92
+ LPWSTR m_string = nullptr; \
93
+ };
94
+
95
+ template <typename allocate_fn_t,
96
+ allocate_fn_t allocate_fn,
97
+ typename deallocate_fn_t,
98
+ deallocate_fn_t deallocate_fn>
99
+ class CoreWebView2CustomSchemeRegistrationBase
100
+ : public Microsoft::WRL::RuntimeClass<
101
+ Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
102
+ ICoreWebView2CustomSchemeRegistration> {
103
+ public:
104
+ CoreWebView2CustomSchemeRegistrationBase(LPCWSTR schemeName) {
105
+ m_schemeName.Set(schemeName);
106
+ }
107
+
108
+ CoreWebView2CustomSchemeRegistrationBase(
109
+ CoreWebView2CustomSchemeRegistrationBase&&) = default;
110
+ ~CoreWebView2CustomSchemeRegistrationBase() { ReleaseAllowedOrigins(); }
111
+
112
+ HRESULT STDMETHODCALLTYPE get_SchemeName(LPWSTR* schemeName) override {
113
+ if (!schemeName)
114
+ return E_POINTER;
115
+ *schemeName = m_schemeName.Copy();
116
+ if ((*schemeName == nullptr) && (m_schemeName.Get() != nullptr))
117
+ return HRESULT_FROM_WIN32(GetLastError());
118
+ return S_OK;
119
+ }
120
+
121
+ HRESULT STDMETHODCALLTYPE
122
+ GetAllowedOrigins(UINT32* allowedOriginsCount,
123
+ LPWSTR** allowedOrigins) override {
124
+ if (!allowedOrigins || !allowedOriginsCount) {
125
+ return E_POINTER;
126
+ }
127
+ *allowedOriginsCount = 0;
128
+ if (m_allowedOriginsCount == 0) {
129
+ *allowedOrigins = nullptr;
130
+ return S_OK;
131
+ } else {
132
+ *allowedOrigins = reinterpret_cast<LPWSTR*>(
133
+ allocate_fn(m_allowedOriginsCount * sizeof(LPWSTR)));
134
+ if (!(*allowedOrigins)) {
135
+ return HRESULT_FROM_WIN32(GetLastError());
136
+ }
137
+ ZeroMemory(*allowedOrigins, m_allowedOriginsCount * sizeof(LPWSTR));
138
+ for (UINT32 i = 0; i < m_allowedOriginsCount; i++) {
139
+ (*allowedOrigins)[i] = m_allowedOrigins[i].Copy();
140
+ if (!(*allowedOrigins)[i]) {
141
+ HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
142
+ for (UINT32 j = 0; j < i; j++) {
143
+ deallocate_fn((*allowedOrigins)[j]);
144
+ }
145
+ deallocate_fn(*allowedOrigins);
146
+ return hr;
147
+ }
148
+ }
149
+ *allowedOriginsCount = m_allowedOriginsCount;
150
+ return S_OK;
151
+ }
152
+ }
153
+
154
+ HRESULT STDMETHODCALLTYPE
155
+ SetAllowedOrigins(UINT32 allowedOriginsCount,
156
+ LPCWSTR* allowedOrigins) override {
157
+ ReleaseAllowedOrigins();
158
+ if (allowedOriginsCount == 0) {
159
+ return S_OK;
160
+ } else {
161
+ m_allowedOrigins = new AutoCoMemString[allowedOriginsCount];
162
+ if (!m_allowedOrigins) {
163
+ return HRESULT_FROM_WIN32(GetLastError());
164
+ }
165
+ for (UINT32 i = 0; i < allowedOriginsCount; i++) {
166
+ m_allowedOrigins[i].Set(allowedOrigins[i]);
167
+ if (!m_allowedOrigins[i].Get()) {
168
+ HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
169
+ for (UINT32 j = 0; j < i; j++) {
170
+ m_allowedOrigins[j].Release();
171
+ }
172
+ m_allowedOriginsCount = 0;
173
+ delete[] (m_allowedOrigins);
174
+ return hr;
175
+ }
176
+ }
177
+ m_allowedOriginsCount = allowedOriginsCount;
178
+ return S_OK;
179
+ }
180
+ }
181
+
182
+ protected:
183
+ DEFINE_AUTO_COMEM_STRING();
184
+
185
+ void ReleaseAllowedOrigins() {
186
+ if (m_allowedOrigins) {
187
+ delete[] (m_allowedOrigins);
188
+ m_allowedOrigins = nullptr;
189
+ }
190
+ }
191
+
192
+ AutoCoMemString m_schemeName;
193
+ COREWEBVIEW2ENVIRONMENTOPTIONS_BOOL_PROPERTY(TreatAsSecure, false);
194
+ COREWEBVIEW2ENVIRONMENTOPTIONS_BOOL_PROPERTY(HasAuthorityComponent, false);
195
+ AutoCoMemString* m_allowedOrigins = nullptr;
196
+ unsigned int m_allowedOriginsCount = 0;
197
+ };
198
+
199
+ // This is a base COM class that implements ICoreWebView2EnvironmentOptions.
200
+ template <typename allocate_fn_t,
201
+ allocate_fn_t allocate_fn,
202
+ typename deallocate_fn_t,
203
+ deallocate_fn_t deallocate_fn>
204
+ class CoreWebView2EnvironmentOptionsBase
205
+ : public Microsoft::WRL::Implements<
206
+ Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
207
+ ICoreWebView2EnvironmentOptions,
208
+ ICoreWebView2EnvironmentOptions2,
209
+ ICoreWebView2EnvironmentOptions3,
210
+ ICoreWebView2EnvironmentOptions4,
211
+ ICoreWebView2EnvironmentOptions5,
212
+ ICoreWebView2EnvironmentOptions6> {
213
+ public:
214
+ CoreWebView2EnvironmentOptionsBase() {
215
+ // Initialize the target compatible browser version value to the version
216
+ // of the browser binaries corresponding to this version of the SDK.
217
+ m_TargetCompatibleBrowserVersion.Set(CORE_WEBVIEW_TARGET_PRODUCT_VERSION);
218
+ }
219
+
220
+ protected:
221
+ ~CoreWebView2EnvironmentOptionsBase() { ReleaseCustomSchemeRegistrations(); };
222
+
223
+ void ReleaseCustomSchemeRegistrations() {
224
+ if (m_customSchemeRegistrations) {
225
+ for (UINT32 i = 0; i < m_customSchemeRegistrationsCount; i++) {
226
+ m_customSchemeRegistrations[i]->Release();
227
+ }
228
+ deallocate_fn(m_customSchemeRegistrations);
229
+ m_customSchemeRegistrations = nullptr;
230
+ m_customSchemeRegistrationsCount = 0;
231
+ }
232
+ }
233
+
234
+ private:
235
+ ICoreWebView2CustomSchemeRegistration** m_customSchemeRegistrations = nullptr;
236
+ unsigned int m_customSchemeRegistrationsCount = 0;
237
+
238
+ DEFINE_AUTO_COMEM_STRING();
239
+
240
+ public:
241
+ // ICoreWebView2EnvironmentOptions
242
+ COREWEBVIEW2ENVIRONMENTOPTIONS_STRING_PROPERTY(AdditionalBrowserArguments)
243
+ COREWEBVIEW2ENVIRONMENTOPTIONS_STRING_PROPERTY(Language)
244
+ COREWEBVIEW2ENVIRONMENTOPTIONS_STRING_PROPERTY(TargetCompatibleBrowserVersion)
245
+ COREWEBVIEW2ENVIRONMENTOPTIONS_BOOL_PROPERTY(
246
+ AllowSingleSignOnUsingOSPrimaryAccount,
247
+ false)
248
+
249
+ // ICoreWebView2EnvironmentOptions2
250
+ COREWEBVIEW2ENVIRONMENTOPTIONS_BOOL_PROPERTY(ExclusiveUserDataFolderAccess,
251
+ false)
252
+
253
+ // ICoreWebView2EnvironmentOptions3
254
+ COREWEBVIEW2ENVIRONMENTOPTIONS_BOOL_PROPERTY(IsCustomCrashReportingEnabled,
255
+ false)
256
+
257
+ // ICoreWebView2EnvironmentOptions4
258
+ public:
259
+ HRESULT STDMETHODCALLTYPE GetCustomSchemeRegistrations(
260
+ UINT32* count,
261
+ ICoreWebView2CustomSchemeRegistration*** schemeRegistrations) override {
262
+ if (!count || !schemeRegistrations) {
263
+ return E_POINTER;
264
+ }
265
+ *count = 0;
266
+ if (m_customSchemeRegistrationsCount == 0) {
267
+ *schemeRegistrations = nullptr;
268
+ return S_OK;
269
+ } else {
270
+ *schemeRegistrations =
271
+ reinterpret_cast<ICoreWebView2CustomSchemeRegistration**>(
272
+ allocate_fn(sizeof(ICoreWebView2CustomSchemeRegistration*) *
273
+ m_customSchemeRegistrationsCount));
274
+ if (!*schemeRegistrations) {
275
+ return HRESULT_FROM_WIN32(GetLastError());
276
+ }
277
+ for (UINT32 i = 0; i < m_customSchemeRegistrationsCount; i++) {
278
+ (*schemeRegistrations)[i] = m_customSchemeRegistrations[i];
279
+ (*schemeRegistrations)[i]->AddRef();
280
+ }
281
+ *count = m_customSchemeRegistrationsCount;
282
+ return S_OK;
283
+ }
284
+ }
285
+
286
+ HRESULT STDMETHODCALLTYPE SetCustomSchemeRegistrations(
287
+ UINT32 count,
288
+ ICoreWebView2CustomSchemeRegistration** schemeRegistrations) override {
289
+ ReleaseCustomSchemeRegistrations();
290
+ m_customSchemeRegistrations =
291
+ reinterpret_cast<ICoreWebView2CustomSchemeRegistration**>(allocate_fn(
292
+ sizeof(ICoreWebView2CustomSchemeRegistration*) * count));
293
+ if (!m_customSchemeRegistrations) {
294
+ return GetLastError();
295
+ }
296
+ for (UINT32 i = 0; i < count; i++) {
297
+ m_customSchemeRegistrations[i] = schemeRegistrations[i];
298
+ m_customSchemeRegistrations[i]->AddRef();
299
+ }
300
+ m_customSchemeRegistrationsCount = count;
301
+ return S_OK;
302
+ }
303
+
304
+ // ICoreWebView2EnvironmentOptions5
305
+ COREWEBVIEW2ENVIRONMENTOPTIONS_BOOL_PROPERTY(EnableTrackingPrevention, true)
306
+
307
+ // ICoreWebView2EnvironmentOptions6
308
+ COREWEBVIEW2ENVIRONMENTOPTIONS_BOOL_PROPERTY(AreBrowserExtensionsEnabled,
309
+ false)
310
+ };
311
+
312
+ template <typename allocate_fn_t,
313
+ allocate_fn_t allocate_fn,
314
+ typename deallocate_fn_t,
315
+ deallocate_fn_t deallocate_fn>
316
+ class CoreWebView2EnvironmentOptionsBaseClass
317
+ : public Microsoft::WRL::RuntimeClass<
318
+ Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
319
+ CoreWebView2EnvironmentOptionsBase<allocate_fn_t,
320
+ allocate_fn,
321
+ deallocate_fn_t,
322
+ deallocate_fn>> {
323
+ public:
324
+ CoreWebView2EnvironmentOptionsBaseClass() {}
325
+
326
+ protected:
327
+ ~CoreWebView2EnvironmentOptionsBaseClass() override {}
328
+ };
329
+
330
+ typedef CoreWebView2CustomSchemeRegistrationBase<decltype(&::CoTaskMemAlloc),
331
+ ::CoTaskMemAlloc,
332
+ decltype(&::CoTaskMemFree),
333
+ ::CoTaskMemFree>
334
+ CoreWebView2CustomSchemeRegistration;
335
+
336
+ typedef CoreWebView2EnvironmentOptionsBaseClass<decltype(&::CoTaskMemAlloc),
337
+ ::CoTaskMemAlloc,
338
+ decltype(&::CoTaskMemFree),
339
+ ::CoTaskMemFree>
340
+ CoreWebView2EnvironmentOptions;
341
+
342
+ #endif // __core_webview2_environment_options_h__
@@ -0,0 +1,13 @@
1
+ // ============================================================================
2
+ // webview.h — WebView factory and platform-specific creation
3
+ // ============================================================================
4
+
5
+ #pragma once
6
+
7
+ #include <windowpp/windowpp.h>
8
+
9
+ namespace wpp {
10
+
11
+ std::unique_ptr<WebView> create_webview(const WebViewConfig& config, void* native_handle);
12
+
13
+ } // namespace wpp