@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,220 @@
1
+ // This test cannot use imports because it needs to run in non-strict mode.
2
+
3
+ function assert(actual, expected, message) {
4
+ if (arguments.length == 1)
5
+ expected = true;
6
+
7
+ if (actual === expected)
8
+ return;
9
+
10
+ if (actual !== null && expected !== null
11
+ && typeof actual == 'object' && typeof expected == 'object'
12
+ && actual.toString() === expected.toString())
13
+ return;
14
+
15
+ throw Error("assertion failed: got |" + actual + "|" +
16
+ ", expected |" + expected + "|" +
17
+ (message ? " (" + message + ")" : ""));
18
+ }
19
+
20
+ /*----------------*/
21
+
22
+ var log_str = "";
23
+
24
+ function log(str)
25
+ {
26
+ log_str += str + ",";
27
+ }
28
+
29
+ function f(a, b, c)
30
+ {
31
+ var x = 10;
32
+ log("a="+a);
33
+ function g(d) {
34
+ function h() {
35
+ log("d=" + d);
36
+ log("x=" + x);
37
+ }
38
+ log("b=" + b);
39
+ log("c=" + c);
40
+ h();
41
+ }
42
+ g(4);
43
+ return g;
44
+ }
45
+
46
+ var g1 = f(1, 2, 3);
47
+ g1(5);
48
+
49
+ assert(log_str, "a=1,b=2,c=3,d=4,x=10,b=2,c=3,d=5,x=10,", "closure1");
50
+
51
+ function test_closure1()
52
+ {
53
+ function f2()
54
+ {
55
+ var val = 1;
56
+
57
+ function set(a) {
58
+ val = a;
59
+ }
60
+ function get(a) {
61
+ return val;
62
+ }
63
+ return { "set": set, "get": get };
64
+ }
65
+
66
+ var obj = f2();
67
+ obj.set(10);
68
+ var r;
69
+ r = obj.get();
70
+ assert(r, 10, "closure2");
71
+ }
72
+
73
+ function test_closure2()
74
+ {
75
+ var expr_func = function myfunc1(n) {
76
+ function myfunc2(n) {
77
+ return myfunc1(n - 1);
78
+ }
79
+ if (n == 0)
80
+ return 0;
81
+ else
82
+ return myfunc2(n);
83
+ };
84
+ var r;
85
+ r = expr_func(1);
86
+ assert(r, 0, "expr_func");
87
+ }
88
+
89
+ function test_closure3()
90
+ {
91
+ function fib(n)
92
+ {
93
+ if (n <= 0)
94
+ return 0;
95
+ else if (n == 1)
96
+ return 1;
97
+ else
98
+ return fib(n - 1) + fib(n - 2);
99
+ }
100
+
101
+ var fib_func = function fib1(n)
102
+ {
103
+ if (n <= 0)
104
+ return 0;
105
+ else if (n == 1)
106
+ return 1;
107
+ else
108
+ return fib1(n - 1) + fib1(n - 2);
109
+ };
110
+
111
+ assert(fib(6), 8, "fib");
112
+ assert(fib_func(6), 8, "fib_func");
113
+ }
114
+
115
+ function test_arrow_function()
116
+ {
117
+ "use strict";
118
+
119
+ function f1() {
120
+ return (() => arguments)();
121
+ }
122
+ function f2() {
123
+ return (() => this)();
124
+ }
125
+ function f3() {
126
+ return (() => eval("this"))();
127
+ }
128
+ function f4() {
129
+ return (() => eval("new.target"))();
130
+ }
131
+ var a;
132
+
133
+ a = f1(1, 2);
134
+ assert(a.length, 2);
135
+ assert(a[0] === 1 && a[1] === 2);
136
+
137
+ assert(f2.call("this_val"), "this_val");
138
+ assert(f3.call("this_val"), "this_val");
139
+ assert(new f4(), f4);
140
+
141
+ var o1 = { f() { return this; } };
142
+ var o2 = { f() {
143
+ return (() => eval("super.f()"))();
144
+ } };
145
+ o2.__proto__ = o1;
146
+
147
+ assert(o2.f(), o2);
148
+ }
149
+
150
+ function test_with()
151
+ {
152
+ var o1 = { x: "o1", y: "o1" };
153
+ var x = "local";
154
+ eval('var z="var_obj";');
155
+ assert(z, "var_obj");
156
+ with (o1) {
157
+ assert(x, "o1");
158
+ assert(eval("x"), "o1");
159
+ var f = function () {
160
+ o2 = { x: "o2" };
161
+ with (o2) {
162
+ assert(x, "o2");
163
+ assert(y, "o1");
164
+ assert(z, "var_obj");
165
+ assert(eval("x"), "o2");
166
+ assert(eval("y"), "o1");
167
+ assert(eval("z"), "var_obj");
168
+ assert(eval('eval("x")'), "o2");
169
+ }
170
+ };
171
+ f();
172
+ }
173
+ }
174
+
175
+ function test_eval_closure()
176
+ {
177
+ var tab;
178
+
179
+ tab = [];
180
+ for(let i = 0; i < 3; i++) {
181
+ eval("tab.push(function g1() { return i; })");
182
+ }
183
+ for(let i = 0; i < 3; i++) {
184
+ assert(tab[i](), i);
185
+ }
186
+
187
+ tab = [];
188
+ for(let i = 0; i < 3; i++) {
189
+ let f = function f() {
190
+ eval("tab.push(function g2() { return i; })");
191
+ };
192
+ f();
193
+ }
194
+ for(let i = 0; i < 3; i++) {
195
+ assert(tab[i](), i);
196
+ }
197
+ }
198
+
199
+ function test_eval_const()
200
+ {
201
+ const a = 1;
202
+ var success = false;
203
+ var f = function () {
204
+ eval("a = 1");
205
+ };
206
+ try {
207
+ f();
208
+ } catch(e) {
209
+ success = (e instanceof TypeError);
210
+ }
211
+ assert(success);
212
+ }
213
+
214
+ test_closure1();
215
+ test_closure2();
216
+ test_closure3();
217
+ test_arrow_function();
218
+ test_with();
219
+ test_eval_closure();
220
+ test_eval_const();
@@ -0,0 +1,12 @@
1
+ /*---
2
+ negative:
3
+ phase: resolution
4
+ type: SyntaxError
5
+ ---*/
6
+ // FIXME(bnoordhuis) shouldn't throw SyntaxError but that's still better
7
+ // than segfaulting, see https://github.com/quickjs-ng/quickjs/issues/567
8
+ import {assert} from "./assert.js"
9
+ import {f} from "./fixture_cyclic_import.js"
10
+ export {f}
11
+ export function g(x) { return x + 1 }
12
+ assert(f(1), 4)
@@ -0,0 +1,35 @@
1
+ import { assert, assertThrows } from "./assert.js";
2
+
3
+ function test_code() {
4
+ let ex = new DOMException();
5
+ assert(ex.code, 0);
6
+ ex = new DOMException("", "HierarchyRequestError\0test");
7
+ assert(ex.code, 0);
8
+ ex = new DOMException("test", "HierarchyRequestError");
9
+ assert(ex.code, 3);
10
+ assert(ex.code, ex.HIERARCHY_REQUEST_ERR);
11
+ assert(ex.code, DOMException.HIERARCHY_REQUEST_ERR);
12
+ ex = new DOMException("", "DataCloneError");
13
+ assert(ex.code, ex.DATA_CLONE_ERR);
14
+ assert(ex.code, 25);
15
+ ex = new DOMException("", "IndexSizeError");
16
+ assert(ex.code, ex.INDEX_SIZE_ERR);
17
+ assert(ex.code, 1);
18
+ }
19
+
20
+ function test_properties() {
21
+ let ex = new DOMException("test");
22
+ assert(ex.message, "test");
23
+ assert(ex.name, "Error");
24
+ ex = new DOMException("test", "InvalidCharacterError");
25
+ assert(ex.name, "InvalidCharacterError");
26
+ assertThrows(TypeError, () => ex.message = "");
27
+ assertThrows(TypeError, () => ex.name = "test");
28
+ assert(ex.__proto__, DOMException.prototype);
29
+ /* Note: browsers set "stack" on the prototype, not the object.
30
+ * This follows node. */
31
+ assert(Object.getOwnPropertyNames(ex), ["stack"]);
32
+ }
33
+
34
+ test_code();
35
+ test_properties();