@zappdev/cli 0.1.0

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 (209) hide show
  1. package/README.md +55 -0
  2. package/dist/zapp-cli.js +9471 -0
  3. package/native/src/app/app.zc +490 -0
  4. package/native/src/event/event.zc +24 -0
  5. package/native/src/event/events.zc +70 -0
  6. package/native/src/platform/darwin/backend.zc +923 -0
  7. package/native/src/platform/darwin/backend_bootstrap.zc +9 -0
  8. package/native/src/platform/darwin/bootstrap.zc +9 -0
  9. package/native/src/platform/darwin/engine_jsc.zc +86 -0
  10. package/native/src/platform/darwin/engine_qjs.zc +92 -0
  11. package/native/src/platform/darwin/platform.zc +156 -0
  12. package/native/src/platform/darwin/webview.zc +550 -0
  13. package/native/src/platform/darwin/webview_bootstrap.zc +9 -0
  14. package/native/src/platform/darwin/window.zc +1223 -0
  15. package/native/src/platform/darwin/worker/common.zc +223 -0
  16. package/native/src/platform/darwin/worker/core/base64_core.zc +29 -0
  17. package/native/src/platform/darwin/worker/core/crypto_core.zc +19 -0
  18. package/native/src/platform/darwin/worker/core/encoding_core.zc +32 -0
  19. package/native/src/platform/darwin/worker/core/fetch_core.zc +145 -0
  20. package/native/src/platform/darwin/worker/core/url_core.zc +69 -0
  21. package/native/src/platform/darwin/worker/core/websocket_core.zc +179 -0
  22. package/native/src/platform/darwin/worker/dispatch.zc +55 -0
  23. package/native/src/platform/darwin/worker/jsc/base64_jsc.zc +39 -0
  24. package/native/src/platform/darwin/worker/jsc/crypto_jsc.zc +49 -0
  25. package/native/src/platform/darwin/worker/jsc/encoding_jsc.zc +86 -0
  26. package/native/src/platform/darwin/worker/jsc/fetch_jsc.zc +149 -0
  27. package/native/src/platform/darwin/worker/jsc/url_jsc.zc +54 -0
  28. package/native/src/platform/darwin/worker/jsc/websocket_jsc.zc +127 -0
  29. package/native/src/platform/darwin/worker/jsc.zc +670 -0
  30. package/native/src/platform/darwin/worker/mod.zc +30 -0
  31. package/native/src/platform/darwin/worker/qjs/fetch_qjs.zc +233 -0
  32. package/native/src/platform/darwin/worker/qjs/qjs_macros.zc +23 -0
  33. package/native/src/platform/darwin/worker/qjs/websocket_qjs.zc +223 -0
  34. package/native/src/platform/darwin/worker/qjs.zc +1053 -0
  35. package/native/src/platform/darwin/worker/timers.zc +149 -0
  36. package/native/src/platform/darwin/worker/timers_qjs.zc +209 -0
  37. package/native/src/platform/platform.zc +64 -0
  38. package/native/src/platform/shared/log.zc +156 -0
  39. package/native/src/platform/shared/worker/qjs/base64_qjs.zc +38 -0
  40. package/native/src/platform/shared/worker/qjs/crypto_qjs.zc +44 -0
  41. package/native/src/platform/shared/worker/qjs/encoding_qjs.zc +95 -0
  42. package/native/src/platform/shared/worker/qjs/url_qjs.zc +65 -0
  43. package/native/src/platform/shared/worker_registry.zc +206 -0
  44. package/native/src/platform/window.zc +446 -0
  45. package/native/src/platform/windows/backend.zc +452 -0
  46. package/native/src/platform/windows/backend_bootstrap.zc +9 -0
  47. package/native/src/platform/windows/bootstrap.zc +9 -0
  48. package/native/src/platform/windows/engine_qjs.zc +60 -0
  49. package/native/src/platform/windows/platform.zc +387 -0
  50. package/native/src/platform/windows/webview.zc +1175 -0
  51. package/native/src/platform/windows/webview_bootstrap.zc +9 -0
  52. package/native/src/platform/windows/window.zc +1271 -0
  53. package/native/src/platform/windows/worker/common.zc +409 -0
  54. package/native/src/platform/windows/worker/core/base64_core.zc +52 -0
  55. package/native/src/platform/windows/worker/core/crypto_core.zc +34 -0
  56. package/native/src/platform/windows/worker/core/encoding_core.zc +60 -0
  57. package/native/src/platform/windows/worker/core/fetch_core.zc +274 -0
  58. package/native/src/platform/windows/worker/core/url_core.zc +216 -0
  59. package/native/src/platform/windows/worker/core/websocket_core.zc +343 -0
  60. package/native/src/platform/windows/worker/dispatch.zc +34 -0
  61. package/native/src/platform/windows/worker/mod.zc +46 -0
  62. package/native/src/platform/windows/worker/qjs/fetch_qjs.zc +255 -0
  63. package/native/src/platform/windows/worker/qjs/websocket_qjs.zc +263 -0
  64. package/native/src/platform/windows/worker/qjs.zc +1049 -0
  65. package/native/src/platform/windows/worker/timers_qjs.zc +288 -0
  66. package/native/src/platform/worker.zc +8 -0
  67. package/native/src/service/service.zc +228 -0
  68. package/native/vendor/quickjs-ng/.gitattributes +4 -0
  69. package/native/vendor/quickjs-ng/.github/dependabot.yml +7 -0
  70. package/native/vendor/quickjs-ng/.github/workflows/ci.yml +812 -0
  71. package/native/vendor/quickjs-ng/.github/workflows/docs.yml +49 -0
  72. package/native/vendor/quickjs-ng/.github/workflows/release.yml +162 -0
  73. package/native/vendor/quickjs-ng/.github/workflows/test-docs.yml +23 -0
  74. package/native/vendor/quickjs-ng/.github/workflows/tsan.yml +32 -0
  75. package/native/vendor/quickjs-ng/.github/workflows/valgrind.yml +33 -0
  76. package/native/vendor/quickjs-ng/.gitmodules +5 -0
  77. package/native/vendor/quickjs-ng/CMakeLists.txt +553 -0
  78. package/native/vendor/quickjs-ng/LICENSE +24 -0
  79. package/native/vendor/quickjs-ng/Makefile +149 -0
  80. package/native/vendor/quickjs-ng/amalgam.js +53 -0
  81. package/native/vendor/quickjs-ng/api-test.c +927 -0
  82. package/native/vendor/quickjs-ng/builtin-array-fromasync.h +119 -0
  83. package/native/vendor/quickjs-ng/builtin-array-fromasync.js +36 -0
  84. package/native/vendor/quickjs-ng/builtin-iterator-zip-keyed.h +332 -0
  85. package/native/vendor/quickjs-ng/builtin-iterator-zip-keyed.js +194 -0
  86. package/native/vendor/quickjs-ng/builtin-iterator-zip.h +337 -0
  87. package/native/vendor/quickjs-ng/builtin-iterator-zip.js +210 -0
  88. package/native/vendor/quickjs-ng/ctest.c +17 -0
  89. package/native/vendor/quickjs-ng/cutils.h +2013 -0
  90. package/native/vendor/quickjs-ng/cxxtest.cc +2 -0
  91. package/native/vendor/quickjs-ng/dtoa.c +1619 -0
  92. package/native/vendor/quickjs-ng/dtoa.h +87 -0
  93. package/native/vendor/quickjs-ng/examples/fib.c +67 -0
  94. package/native/vendor/quickjs-ng/examples/fib_module.js +10 -0
  95. package/native/vendor/quickjs-ng/examples/hello.js +1 -0
  96. package/native/vendor/quickjs-ng/examples/hello_module.js +6 -0
  97. package/native/vendor/quickjs-ng/examples/meson.build +17 -0
  98. package/native/vendor/quickjs-ng/examples/pi_bigint.js +118 -0
  99. package/native/vendor/quickjs-ng/examples/point.c +154 -0
  100. package/native/vendor/quickjs-ng/examples/test_fib.js +8 -0
  101. package/native/vendor/quickjs-ng/examples/test_point.js +43 -0
  102. package/native/vendor/quickjs-ng/fuzz.c +51 -0
  103. package/native/vendor/quickjs-ng/gen/function_source.c +81 -0
  104. package/native/vendor/quickjs-ng/gen/hello.c +53 -0
  105. package/native/vendor/quickjs-ng/gen/hello_module.c +106 -0
  106. package/native/vendor/quickjs-ng/gen/repl.c +3053 -0
  107. package/native/vendor/quickjs-ng/gen/standalone.c +324 -0
  108. package/native/vendor/quickjs-ng/gen/test_fib.c +81 -0
  109. package/native/vendor/quickjs-ng/libregexp-opcode.h +58 -0
  110. package/native/vendor/quickjs-ng/libregexp.c +2687 -0
  111. package/native/vendor/quickjs-ng/libregexp.h +98 -0
  112. package/native/vendor/quickjs-ng/libunicode-table.h +4707 -0
  113. package/native/vendor/quickjs-ng/libunicode.c +1746 -0
  114. package/native/vendor/quickjs-ng/libunicode.h +126 -0
  115. package/native/vendor/quickjs-ng/list.h +107 -0
  116. package/native/vendor/quickjs-ng/lre-test.c +73 -0
  117. package/native/vendor/quickjs-ng/meson.build +684 -0
  118. package/native/vendor/quickjs-ng/meson_options.txt +6 -0
  119. package/native/vendor/quickjs-ng/qjs-wasi-reactor.c +208 -0
  120. package/native/vendor/quickjs-ng/qjs.c +748 -0
  121. package/native/vendor/quickjs-ng/qjsc.c +673 -0
  122. package/native/vendor/quickjs-ng/quickjs-atom.h +267 -0
  123. package/native/vendor/quickjs-ng/quickjs-c-atomics.h +54 -0
  124. package/native/vendor/quickjs-ng/quickjs-libc.c +4986 -0
  125. package/native/vendor/quickjs-ng/quickjs-libc.h +79 -0
  126. package/native/vendor/quickjs-ng/quickjs-opcode.h +369 -0
  127. package/native/vendor/quickjs-ng/quickjs.c +60259 -0
  128. package/native/vendor/quickjs-ng/quickjs.h +1419 -0
  129. package/native/vendor/quickjs-ng/repl.js +1927 -0
  130. package/native/vendor/quickjs-ng/run-test262.c +2417 -0
  131. package/native/vendor/quickjs-ng/standalone.js +129 -0
  132. package/native/vendor/quickjs-ng/tests/assert.js +49 -0
  133. package/native/vendor/quickjs-ng/tests/bug1221.js +16 -0
  134. package/native/vendor/quickjs-ng/tests/bug1296.js +12 -0
  135. package/native/vendor/quickjs-ng/tests/bug1297.js +22 -0
  136. package/native/vendor/quickjs-ng/tests/bug1301.js +21 -0
  137. package/native/vendor/quickjs-ng/tests/bug1302.js +24 -0
  138. package/native/vendor/quickjs-ng/tests/bug1305.js +26 -0
  139. package/native/vendor/quickjs-ng/tests/bug1318.js +54 -0
  140. package/native/vendor/quickjs-ng/tests/bug1352.js +8 -0
  141. package/native/vendor/quickjs-ng/tests/bug1354.js +6 -0
  142. package/native/vendor/quickjs-ng/tests/bug1355.js +58 -0
  143. package/native/vendor/quickjs-ng/tests/bug1368.js +9 -0
  144. package/native/vendor/quickjs-ng/tests/bug39/1.js +6 -0
  145. package/native/vendor/quickjs-ng/tests/bug39/2.js +6 -0
  146. package/native/vendor/quickjs-ng/tests/bug39/3.js +7 -0
  147. package/native/vendor/quickjs-ng/tests/bug488-upstream.js +7 -0
  148. package/native/vendor/quickjs-ng/tests/bug633/0.js +7 -0
  149. package/native/vendor/quickjs-ng/tests/bug633/1.js +4 -0
  150. package/native/vendor/quickjs-ng/tests/bug633/2.js +4 -0
  151. package/native/vendor/quickjs-ng/tests/bug633/3.js +4 -0
  152. package/native/vendor/quickjs-ng/tests/bug645/0.js +4 -0
  153. package/native/vendor/quickjs-ng/tests/bug645/1.js +9 -0
  154. package/native/vendor/quickjs-ng/tests/bug645/2.js +7 -0
  155. package/native/vendor/quickjs-ng/tests/bug648.js +13 -0
  156. package/native/vendor/quickjs-ng/tests/bug652.js +4 -0
  157. package/native/vendor/quickjs-ng/tests/bug741.js +19 -0
  158. package/native/vendor/quickjs-ng/tests/bug775.js +7 -0
  159. package/native/vendor/quickjs-ng/tests/bug776.js +7 -0
  160. package/native/vendor/quickjs-ng/tests/bug832.js +2 -0
  161. package/native/vendor/quickjs-ng/tests/bug858.js +26 -0
  162. package/native/vendor/quickjs-ng/tests/bug904.js +6 -0
  163. package/native/vendor/quickjs-ng/tests/bug988.js +7 -0
  164. package/native/vendor/quickjs-ng/tests/bug999.js +3 -0
  165. package/native/vendor/quickjs-ng/tests/destructured-export.js +8 -0
  166. package/native/vendor/quickjs-ng/tests/detect_module/0.js +1 -0
  167. package/native/vendor/quickjs-ng/tests/detect_module/1.js +2 -0
  168. package/native/vendor/quickjs-ng/tests/detect_module/2.js +1 -0
  169. package/native/vendor/quickjs-ng/tests/detect_module/3.js +8 -0
  170. package/native/vendor/quickjs-ng/tests/detect_module/4.js +3 -0
  171. package/native/vendor/quickjs-ng/tests/empty.js +0 -0
  172. package/native/vendor/quickjs-ng/tests/fixture_cyclic_import.js +2 -0
  173. package/native/vendor/quickjs-ng/tests/fixture_string_exports.js +12 -0
  174. package/native/vendor/quickjs-ng/tests/function_source.js +14 -0
  175. package/native/vendor/quickjs-ng/tests/microbench.js +1267 -0
  176. package/native/vendor/quickjs-ng/tests/null_or_undefined.js +38 -0
  177. package/native/vendor/quickjs-ng/tests/str-pad-leak.js +5 -0
  178. package/native/vendor/quickjs-ng/tests/test_bigint.js +107 -0
  179. package/native/vendor/quickjs-ng/tests/test_bjson.js +366 -0
  180. package/native/vendor/quickjs-ng/tests/test_builtin.js +1314 -0
  181. package/native/vendor/quickjs-ng/tests/test_closure.js +220 -0
  182. package/native/vendor/quickjs-ng/tests/test_cyclic_import.js +12 -0
  183. package/native/vendor/quickjs-ng/tests/test_domexception.js +35 -0
  184. package/native/vendor/quickjs-ng/tests/test_language.js +755 -0
  185. package/native/vendor/quickjs-ng/tests/test_loop.js +367 -0
  186. package/native/vendor/quickjs-ng/tests/test_queue_microtask.js +39 -0
  187. package/native/vendor/quickjs-ng/tests/test_std.js +340 -0
  188. package/native/vendor/quickjs-ng/tests/test_string_exports.js +25 -0
  189. package/native/vendor/quickjs-ng/tests/test_worker.js +43 -0
  190. package/native/vendor/quickjs-ng/tests/test_worker_module.js +30 -0
  191. package/native/vendor/quickjs-ng/tests.conf +14 -0
  192. package/native/vendor/quickjs-ng/unicode_download.sh +19 -0
  193. package/native/vendor/quickjs-ng/unicode_gen.c +3108 -0
  194. package/native/vendor/quickjs-ng/unicode_gen_def.h +310 -0
  195. package/native/vendor/quickjs-ng/update-version.sh +32 -0
  196. package/native/vendor/webview2/include/WebView2.h +60636 -0
  197. package/native/vendor/webview2/include/WebView2EnvironmentOptions.h +406 -0
  198. package/package.json +33 -0
  199. package/src/backend.ts +139 -0
  200. package/src/build-config.ts +87 -0
  201. package/src/build.ts +276 -0
  202. package/src/common.ts +195 -0
  203. package/src/config.ts +89 -0
  204. package/src/dev.ts +164 -0
  205. package/src/generate.ts +200 -0
  206. package/src/icons.ts +116 -0
  207. package/src/init.ts +190 -0
  208. package/src/package.ts +150 -0
  209. package/src/zapp-cli.ts +263 -0
@@ -0,0 +1,406 @@
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"131.0.2903.40"
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
+ ICoreWebView2EnvironmentOptions7,
214
+ ICoreWebView2EnvironmentOptions8> {
215
+ public:
216
+ static const COREWEBVIEW2_RELEASE_CHANNELS kInternalChannel =
217
+ static_cast<COREWEBVIEW2_RELEASE_CHANNELS>(1 << 4);
218
+ static const COREWEBVIEW2_RELEASE_CHANNELS kAllChannels =
219
+ COREWEBVIEW2_RELEASE_CHANNELS_STABLE |
220
+ COREWEBVIEW2_RELEASE_CHANNELS_BETA | COREWEBVIEW2_RELEASE_CHANNELS_DEV |
221
+ COREWEBVIEW2_RELEASE_CHANNELS_CANARY | kInternalChannel;
222
+
223
+ CoreWebView2EnvironmentOptionsBase() {
224
+ // Initialize the target compatible browser version value to the version
225
+ // of the browser binaries corresponding to this version of the SDK.
226
+ m_TargetCompatibleBrowserVersion.Set(CORE_WEBVIEW_TARGET_PRODUCT_VERSION);
227
+ }
228
+
229
+ // ICoreWebView2EnvironmentOptions7
230
+ HRESULT STDMETHODCALLTYPE
231
+ get_ReleaseChannels(COREWEBVIEW2_RELEASE_CHANNELS* channels) override {
232
+ if (!channels) {
233
+ return E_POINTER;
234
+ }
235
+ *channels = m_releaseChannels;
236
+ return S_OK;
237
+ }
238
+
239
+ HRESULT STDMETHODCALLTYPE
240
+ put_ReleaseChannels(COREWEBVIEW2_RELEASE_CHANNELS channels) override {
241
+ m_releaseChannels = channels;
242
+ return S_OK;
243
+ }
244
+
245
+ HRESULT STDMETHODCALLTYPE
246
+ get_ChannelSearchKind(COREWEBVIEW2_CHANNEL_SEARCH_KIND* value) override {
247
+ if (!value) {
248
+ return E_POINTER;
249
+ }
250
+ *value = m_channelSearchKind;
251
+ return S_OK;
252
+ }
253
+
254
+ HRESULT STDMETHODCALLTYPE
255
+ put_ChannelSearchKind(COREWEBVIEW2_CHANNEL_SEARCH_KIND value) override {
256
+ m_channelSearchKind = value;
257
+ return S_OK;
258
+ }
259
+
260
+ // ICoreWebView2EnvironmentOptions8
261
+ HRESULT STDMETHODCALLTYPE
262
+ get_ScrollBarStyle(COREWEBVIEW2_SCROLLBAR_STYLE* style) override {
263
+ if (!style) {
264
+ return E_POINTER;
265
+ }
266
+ *style = m_scrollbarStyle;
267
+ return S_OK;
268
+ }
269
+
270
+ HRESULT STDMETHODCALLTYPE
271
+ put_ScrollBarStyle(COREWEBVIEW2_SCROLLBAR_STYLE style) override {
272
+ m_scrollbarStyle = style;
273
+ return S_OK;
274
+ }
275
+
276
+ protected:
277
+ ~CoreWebView2EnvironmentOptionsBase() { ReleaseCustomSchemeRegistrations(); };
278
+
279
+ void ReleaseCustomSchemeRegistrations() {
280
+ if (m_customSchemeRegistrations) {
281
+ for (UINT32 i = 0; i < m_customSchemeRegistrationsCount; i++) {
282
+ m_customSchemeRegistrations[i]->Release();
283
+ }
284
+ deallocate_fn(m_customSchemeRegistrations);
285
+ m_customSchemeRegistrations = nullptr;
286
+ m_customSchemeRegistrationsCount = 0;
287
+ }
288
+ }
289
+
290
+ private:
291
+ ICoreWebView2CustomSchemeRegistration** m_customSchemeRegistrations = nullptr;
292
+ unsigned int m_customSchemeRegistrationsCount = 0;
293
+
294
+ COREWEBVIEW2_RELEASE_CHANNELS m_releaseChannels = kAllChannels;
295
+ COREWEBVIEW2_CHANNEL_SEARCH_KIND m_channelSearchKind =
296
+ COREWEBVIEW2_CHANNEL_SEARCH_KIND_MOST_STABLE;
297
+
298
+ // ICoreWebView2EnvironmentOptions8
299
+ COREWEBVIEW2_SCROLLBAR_STYLE m_scrollbarStyle =
300
+ COREWEBVIEW2_SCROLLBAR_STYLE_DEFAULT;
301
+
302
+ DEFINE_AUTO_COMEM_STRING();
303
+
304
+ public:
305
+ // ICoreWebView2EnvironmentOptions
306
+ COREWEBVIEW2ENVIRONMENTOPTIONS_STRING_PROPERTY(AdditionalBrowserArguments)
307
+ COREWEBVIEW2ENVIRONMENTOPTIONS_STRING_PROPERTY(Language)
308
+ COREWEBVIEW2ENVIRONMENTOPTIONS_STRING_PROPERTY(TargetCompatibleBrowserVersion)
309
+ COREWEBVIEW2ENVIRONMENTOPTIONS_BOOL_PROPERTY(
310
+ AllowSingleSignOnUsingOSPrimaryAccount,
311
+ false)
312
+
313
+ // ICoreWebView2EnvironmentOptions2
314
+ COREWEBVIEW2ENVIRONMENTOPTIONS_BOOL_PROPERTY(ExclusiveUserDataFolderAccess,
315
+ false)
316
+
317
+ // ICoreWebView2EnvironmentOptions3
318
+ COREWEBVIEW2ENVIRONMENTOPTIONS_BOOL_PROPERTY(IsCustomCrashReportingEnabled,
319
+ false)
320
+
321
+ // ICoreWebView2EnvironmentOptions4
322
+ public:
323
+ HRESULT STDMETHODCALLTYPE GetCustomSchemeRegistrations(
324
+ UINT32* count,
325
+ ICoreWebView2CustomSchemeRegistration*** schemeRegistrations) override {
326
+ if (!count || !schemeRegistrations) {
327
+ return E_POINTER;
328
+ }
329
+ *count = 0;
330
+ if (m_customSchemeRegistrationsCount == 0) {
331
+ *schemeRegistrations = nullptr;
332
+ return S_OK;
333
+ } else {
334
+ *schemeRegistrations =
335
+ reinterpret_cast<ICoreWebView2CustomSchemeRegistration**>(
336
+ allocate_fn(sizeof(ICoreWebView2CustomSchemeRegistration*) *
337
+ m_customSchemeRegistrationsCount));
338
+ if (!*schemeRegistrations) {
339
+ return HRESULT_FROM_WIN32(GetLastError());
340
+ }
341
+ for (UINT32 i = 0; i < m_customSchemeRegistrationsCount; i++) {
342
+ (*schemeRegistrations)[i] = m_customSchemeRegistrations[i];
343
+ (*schemeRegistrations)[i]->AddRef();
344
+ }
345
+ *count = m_customSchemeRegistrationsCount;
346
+ return S_OK;
347
+ }
348
+ }
349
+
350
+ HRESULT STDMETHODCALLTYPE SetCustomSchemeRegistrations(
351
+ UINT32 count,
352
+ ICoreWebView2CustomSchemeRegistration** schemeRegistrations) override {
353
+ ReleaseCustomSchemeRegistrations();
354
+ m_customSchemeRegistrations =
355
+ reinterpret_cast<ICoreWebView2CustomSchemeRegistration**>(allocate_fn(
356
+ sizeof(ICoreWebView2CustomSchemeRegistration*) * count));
357
+ if (!m_customSchemeRegistrations) {
358
+ return GetLastError();
359
+ }
360
+ for (UINT32 i = 0; i < count; i++) {
361
+ m_customSchemeRegistrations[i] = schemeRegistrations[i];
362
+ m_customSchemeRegistrations[i]->AddRef();
363
+ }
364
+ m_customSchemeRegistrationsCount = count;
365
+ return S_OK;
366
+ }
367
+
368
+ // ICoreWebView2EnvironmentOptions5
369
+ COREWEBVIEW2ENVIRONMENTOPTIONS_BOOL_PROPERTY(EnableTrackingPrevention, true)
370
+
371
+ // ICoreWebView2EnvironmentOptions6
372
+ COREWEBVIEW2ENVIRONMENTOPTIONS_BOOL_PROPERTY(AreBrowserExtensionsEnabled,
373
+ false)
374
+ };
375
+
376
+ template <typename allocate_fn_t,
377
+ allocate_fn_t allocate_fn,
378
+ typename deallocate_fn_t,
379
+ deallocate_fn_t deallocate_fn>
380
+ class CoreWebView2EnvironmentOptionsBaseClass
381
+ : public Microsoft::WRL::RuntimeClass<
382
+ Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
383
+ CoreWebView2EnvironmentOptionsBase<allocate_fn_t,
384
+ allocate_fn,
385
+ deallocate_fn_t,
386
+ deallocate_fn>> {
387
+ public:
388
+ CoreWebView2EnvironmentOptionsBaseClass() {}
389
+
390
+ protected:
391
+ ~CoreWebView2EnvironmentOptionsBaseClass() override {}
392
+ };
393
+
394
+ typedef CoreWebView2CustomSchemeRegistrationBase<decltype(&::CoTaskMemAlloc),
395
+ ::CoTaskMemAlloc,
396
+ decltype(&::CoTaskMemFree),
397
+ ::CoTaskMemFree>
398
+ CoreWebView2CustomSchemeRegistration;
399
+
400
+ typedef CoreWebView2EnvironmentOptionsBaseClass<decltype(&::CoTaskMemAlloc),
401
+ ::CoTaskMemAlloc,
402
+ decltype(&::CoTaskMemFree),
403
+ ::CoTaskMemFree>
404
+ CoreWebView2EnvironmentOptions;
405
+
406
+ #endif // __core_webview2_environment_options_h__
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@zappdev/cli",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "CLI for building cross-platform desktop apps with Zapp",
6
+ "main": "dist/zapp-cli.js",
7
+ "bin": {
8
+ "zapp": "dist/zapp-cli.js"
9
+ },
10
+ "exports": {
11
+ ".": "./dist/zapp-cli.js",
12
+ "./config": "./src/config.ts"
13
+ },
14
+ "files": [
15
+ "dist/",
16
+ "native/",
17
+ "src/"
18
+ ],
19
+ "scripts": {
20
+ "build": "bun build ./src/zapp-cli.ts --outfile ./dist/zapp-cli.js --target bun --format esm"
21
+ },
22
+ "devDependencies": {
23
+ "@types/bun": "^1.3.10",
24
+ "@types/node": "^22.0.0",
25
+ "@types/yargs": "^17.0.35",
26
+ "esbuild": "^0.27.4",
27
+ "typescript": "^5.0.0"
28
+ },
29
+ "license": "MIT",
30
+ "dependencies": {
31
+ "yargs": "^18.0.0"
32
+ }
33
+ }
package/src/backend.ts ADDED
@@ -0,0 +1,139 @@
1
+ import path from "node:path";
2
+ import process from "node:process";
3
+ import { mkdir } from "node:fs/promises";
4
+ import { runCmd } from "./common";
5
+
6
+ const BACKEND_CONVENTIONS = ["zapp/backend.ts", "zapp/backend.js", "backend.ts", "backend.js"];
7
+
8
+ async function findBackendScript(root: string): Promise<string | null> {
9
+ for (const name of BACKEND_CONVENTIONS) {
10
+ const candidate = path.join(root, name);
11
+ if (await Bun.file(candidate).exists()) {
12
+ return candidate;
13
+ }
14
+ }
15
+ return null;
16
+ }
17
+
18
+ function resolveZappPackage(pkg: string, root: string): string | null {
19
+ try {
20
+ return require.resolve(pkg, { paths: [root] });
21
+ } catch {
22
+ // not found in node_modules
23
+ }
24
+
25
+ const monorepoFallbacks: Record<string, string> = {
26
+ "@zapp/runtime": "packages/runtime/index.ts",
27
+ "@zapp/backend": "packages/backend/index.ts",
28
+ };
29
+ const relative = monorepoFallbacks[pkg];
30
+ if (!relative) return null;
31
+
32
+ const candidate = path.resolve(root, relative);
33
+ try {
34
+ if (require("node:fs").existsSync(candidate)) return candidate;
35
+ } catch {}
36
+
37
+ return null;
38
+ }
39
+
40
+ export async function resolveAndBundleBackend({
41
+ root,
42
+ frontendDir,
43
+ backendScript,
44
+ }: {
45
+ root: string;
46
+ frontendDir: string;
47
+ backendScript?: string;
48
+ }): Promise<string | null> {
49
+ let entryPath: string | null = null;
50
+
51
+ if (backendScript) {
52
+ entryPath = path.resolve(root, backendScript);
53
+ if (!(await Bun.file(entryPath).exists())) {
54
+ process.stderr.write(`[zapp] backend script not found: ${entryPath}\n`);
55
+ return null;
56
+ }
57
+ } else {
58
+ entryPath = await findBackendScript(root);
59
+ }
60
+
61
+ if (!entryPath) return null;
62
+
63
+ process.stdout.write(`[zapp] bundling backend script: ${path.relative(root, entryPath)}\n`);
64
+
65
+ const buildDir = path.join(root, ".zapp");
66
+ await mkdir(buildDir, { recursive: true });
67
+
68
+ const outFile = path.join(buildDir, "backend.bundle.js");
69
+
70
+ const runtimePath = resolveZappPackage("@zapp/runtime", root);
71
+ const backendPath = resolveZappPackage("@zapp/backend", root);
72
+
73
+ if (!runtimePath || !backendPath) {
74
+ process.stderr.write(
75
+ `[zapp] could not resolve @zapp/runtime or @zapp/backend from ${root}\n` +
76
+ ` Install them: bun add @zapp/runtime @zapp/backend\n`
77
+ );
78
+ return null;
79
+ }
80
+
81
+ const hasBunBuild =
82
+ typeof (globalThis as any).Bun !== "undefined" &&
83
+ (globalThis as any).Bun != null &&
84
+ typeof (globalThis as any).Bun.build === "function";
85
+
86
+ if (hasBunBuild) {
87
+ const result = await (globalThis as any).Bun.build({
88
+ entrypoints: [entryPath],
89
+ outdir: buildDir,
90
+ naming: "backend.bundle.js",
91
+ target: "browser",
92
+ format: "esm",
93
+ sourcemap: "none",
94
+ minify: false,
95
+ plugins: [
96
+ {
97
+ name: "zapp-backend-alias",
98
+ setup(build: any) {
99
+ build.onResolve({ filter: /^@zapp\/backend$/ }, () => ({ path: backendPath }));
100
+ build.onResolve({ filter: /^@zapp\/backend\/(.*)/ }, (args: any) => ({
101
+ path: path.join(path.dirname(backendPath), args.path.slice("@zapp/backend/".length)),
102
+ }));
103
+ build.onResolve({ filter: /^@zapp\/runtime$/ }, () => ({ path: runtimePath }));
104
+ build.onResolve({ filter: /^@zapp\/runtime\/(.*)/ }, (args: any) => ({
105
+ path: path.join(path.dirname(runtimePath), args.path.slice("@zapp/runtime/".length)),
106
+ }));
107
+ },
108
+ },
109
+ ],
110
+ });
111
+
112
+ if (!result.success) {
113
+ const lines = (result.logs ?? [])
114
+ .map((log: any) => log?.message)
115
+ .filter(Boolean)
116
+ .join("\n");
117
+ process.stderr.write(`[zapp] backend bundle failed:\n${lines}\n`);
118
+ return null;
119
+ }
120
+ } else {
121
+ const { build: esbuild } = await import("esbuild");
122
+ await esbuild({
123
+ entryPoints: [entryPath],
124
+ bundle: true,
125
+ format: "esm",
126
+ platform: "browser",
127
+ target: "es2022",
128
+ sourcemap: false,
129
+ minify: false,
130
+ outfile: outFile,
131
+ alias: {
132
+ "@zapp/backend": backendPath,
133
+ "@zapp/runtime": runtimePath,
134
+ },
135
+ });
136
+ }
137
+
138
+ return outFile;
139
+ }
@@ -0,0 +1,87 @@
1
+ import path from "node:path";
2
+ import { mkdir } from "node:fs/promises";
3
+ import { runCmd } from "./common";
4
+
5
+ export type BuildMode = "dev" | "dev-embedded" | "prod" | "prod-embedded";
6
+
7
+ export type LogLevel = "error" | "warn" | "info" | "debug" | "trace";
8
+
9
+ const cString = (value: string): string => JSON.stringify(value.replace(/\\/g, "/"));
10
+
11
+ export const generateBuildConfigZc = async ({
12
+ root,
13
+ mode,
14
+ assetDir,
15
+ devUrl,
16
+ backendScriptPath,
17
+ logLevel,
18
+ csp,
19
+ enableDevTools,
20
+ }: {
21
+ root: string;
22
+ mode: BuildMode;
23
+ assetDir: string;
24
+ devUrl?: string;
25
+ backendScriptPath?: string | null;
26
+ logLevel?: LogLevel;
27
+ csp?: string;
28
+ enableDevTools?: boolean;
29
+ }) => {
30
+ const buildDir = path.join(root, ".zapp");
31
+ await mkdir(buildDir, { recursive: true });
32
+
33
+ const isDev = mode === "dev" || mode === "dev-embedded";
34
+ const useEmbeddedAssets = mode === "dev-embedded" || mode === "prod-embedded";
35
+ const isDarwin = process.platform === "darwin";
36
+ const prodUrl = isDarwin ? "zapp://index.html" : "https://app.localhost/index.html";
37
+ const initialUrl = mode === "dev" ? devUrl ?? "http://localhost:5173" : prodUrl;
38
+
39
+ // Default log levels: info for dev, warn for prod
40
+ const defaultLogLevel = isDev ? "info" : "warn";
41
+ const effectiveLogLevel = logLevel ?? defaultLogLevel;
42
+
43
+ const content = `// AUTO-GENERATED FILE. DO NOT EDIT.
44
+
45
+ raw {
46
+ const char* zapp_build_mode_name(void) {
47
+ return ${cString(mode)};
48
+ }
49
+
50
+ const char* zapp_build_asset_root(void) {
51
+ return ${cString(assetDir)};
52
+ }
53
+
54
+ const char* zapp_build_initial_url(void) {
55
+ return ${cString(initialUrl)};
56
+ }
57
+
58
+ int zapp_build_is_dev_mode(void) {
59
+ return ${isDev ? 1 : 0};
60
+ }
61
+
62
+ int zapp_build_use_embedded_assets(void) {
63
+ return ${useEmbeddedAssets ? 1 : 0};
64
+ }
65
+
66
+ const char* zapp_build_backend_script_path(void) {
67
+ return ${backendScriptPath ? cString(backendScriptPath) : '""'};
68
+ }
69
+
70
+ const char* zapp_build_log_level(void) {
71
+ return ${cString(effectiveLogLevel)};
72
+ }
73
+
74
+ int zapp_build_dev_tools_default(void) {
75
+ return ${enableDevTools ?? isDev ? 1 : 0};
76
+ }
77
+
78
+ const char* zapp_build_csp(void) {
79
+ return ${csp ? cString(csp) : '""'};
80
+ }
81
+ }
82
+ `;
83
+
84
+ const outPath = path.join(buildDir, "zapp_build_config.zc");
85
+ await Bun.write(outPath, content);
86
+ return outPath;
87
+ };