@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.
- package/README.md +55 -0
- package/dist/zapp-cli.js +9471 -0
- package/native/src/app/app.zc +490 -0
- package/native/src/event/event.zc +24 -0
- package/native/src/event/events.zc +70 -0
- package/native/src/platform/darwin/backend.zc +923 -0
- package/native/src/platform/darwin/backend_bootstrap.zc +9 -0
- package/native/src/platform/darwin/bootstrap.zc +9 -0
- package/native/src/platform/darwin/engine_jsc.zc +86 -0
- package/native/src/platform/darwin/engine_qjs.zc +92 -0
- package/native/src/platform/darwin/platform.zc +156 -0
- package/native/src/platform/darwin/webview.zc +550 -0
- package/native/src/platform/darwin/webview_bootstrap.zc +9 -0
- package/native/src/platform/darwin/window.zc +1223 -0
- package/native/src/platform/darwin/worker/common.zc +223 -0
- package/native/src/platform/darwin/worker/core/base64_core.zc +29 -0
- package/native/src/platform/darwin/worker/core/crypto_core.zc +19 -0
- package/native/src/platform/darwin/worker/core/encoding_core.zc +32 -0
- package/native/src/platform/darwin/worker/core/fetch_core.zc +145 -0
- package/native/src/platform/darwin/worker/core/url_core.zc +69 -0
- package/native/src/platform/darwin/worker/core/websocket_core.zc +179 -0
- package/native/src/platform/darwin/worker/dispatch.zc +55 -0
- package/native/src/platform/darwin/worker/jsc/base64_jsc.zc +39 -0
- package/native/src/platform/darwin/worker/jsc/crypto_jsc.zc +49 -0
- package/native/src/platform/darwin/worker/jsc/encoding_jsc.zc +86 -0
- package/native/src/platform/darwin/worker/jsc/fetch_jsc.zc +149 -0
- package/native/src/platform/darwin/worker/jsc/url_jsc.zc +54 -0
- package/native/src/platform/darwin/worker/jsc/websocket_jsc.zc +127 -0
- package/native/src/platform/darwin/worker/jsc.zc +670 -0
- package/native/src/platform/darwin/worker/mod.zc +30 -0
- package/native/src/platform/darwin/worker/qjs/fetch_qjs.zc +233 -0
- package/native/src/platform/darwin/worker/qjs/qjs_macros.zc +23 -0
- package/native/src/platform/darwin/worker/qjs/websocket_qjs.zc +223 -0
- package/native/src/platform/darwin/worker/qjs.zc +1053 -0
- package/native/src/platform/darwin/worker/timers.zc +149 -0
- package/native/src/platform/darwin/worker/timers_qjs.zc +209 -0
- package/native/src/platform/platform.zc +64 -0
- package/native/src/platform/shared/log.zc +156 -0
- package/native/src/platform/shared/worker/qjs/base64_qjs.zc +38 -0
- package/native/src/platform/shared/worker/qjs/crypto_qjs.zc +44 -0
- package/native/src/platform/shared/worker/qjs/encoding_qjs.zc +95 -0
- package/native/src/platform/shared/worker/qjs/url_qjs.zc +65 -0
- package/native/src/platform/shared/worker_registry.zc +206 -0
- package/native/src/platform/window.zc +446 -0
- package/native/src/platform/windows/backend.zc +452 -0
- package/native/src/platform/windows/backend_bootstrap.zc +9 -0
- package/native/src/platform/windows/bootstrap.zc +9 -0
- package/native/src/platform/windows/engine_qjs.zc +60 -0
- package/native/src/platform/windows/platform.zc +387 -0
- package/native/src/platform/windows/webview.zc +1175 -0
- package/native/src/platform/windows/webview_bootstrap.zc +9 -0
- package/native/src/platform/windows/window.zc +1271 -0
- package/native/src/platform/windows/worker/common.zc +409 -0
- package/native/src/platform/windows/worker/core/base64_core.zc +52 -0
- package/native/src/platform/windows/worker/core/crypto_core.zc +34 -0
- package/native/src/platform/windows/worker/core/encoding_core.zc +60 -0
- package/native/src/platform/windows/worker/core/fetch_core.zc +274 -0
- package/native/src/platform/windows/worker/core/url_core.zc +216 -0
- package/native/src/platform/windows/worker/core/websocket_core.zc +343 -0
- package/native/src/platform/windows/worker/dispatch.zc +34 -0
- package/native/src/platform/windows/worker/mod.zc +46 -0
- package/native/src/platform/windows/worker/qjs/fetch_qjs.zc +255 -0
- package/native/src/platform/windows/worker/qjs/websocket_qjs.zc +263 -0
- package/native/src/platform/windows/worker/qjs.zc +1049 -0
- package/native/src/platform/windows/worker/timers_qjs.zc +288 -0
- package/native/src/platform/worker.zc +8 -0
- package/native/src/service/service.zc +228 -0
- package/native/vendor/quickjs-ng/.gitattributes +4 -0
- package/native/vendor/quickjs-ng/.github/dependabot.yml +7 -0
- package/native/vendor/quickjs-ng/.github/workflows/ci.yml +812 -0
- package/native/vendor/quickjs-ng/.github/workflows/docs.yml +49 -0
- package/native/vendor/quickjs-ng/.github/workflows/release.yml +162 -0
- package/native/vendor/quickjs-ng/.github/workflows/test-docs.yml +23 -0
- package/native/vendor/quickjs-ng/.github/workflows/tsan.yml +32 -0
- package/native/vendor/quickjs-ng/.github/workflows/valgrind.yml +33 -0
- package/native/vendor/quickjs-ng/.gitmodules +5 -0
- package/native/vendor/quickjs-ng/CMakeLists.txt +553 -0
- package/native/vendor/quickjs-ng/LICENSE +24 -0
- package/native/vendor/quickjs-ng/Makefile +149 -0
- package/native/vendor/quickjs-ng/amalgam.js +53 -0
- package/native/vendor/quickjs-ng/api-test.c +927 -0
- package/native/vendor/quickjs-ng/builtin-array-fromasync.h +119 -0
- package/native/vendor/quickjs-ng/builtin-array-fromasync.js +36 -0
- package/native/vendor/quickjs-ng/builtin-iterator-zip-keyed.h +332 -0
- package/native/vendor/quickjs-ng/builtin-iterator-zip-keyed.js +194 -0
- package/native/vendor/quickjs-ng/builtin-iterator-zip.h +337 -0
- package/native/vendor/quickjs-ng/builtin-iterator-zip.js +210 -0
- package/native/vendor/quickjs-ng/ctest.c +17 -0
- package/native/vendor/quickjs-ng/cutils.h +2013 -0
- package/native/vendor/quickjs-ng/cxxtest.cc +2 -0
- package/native/vendor/quickjs-ng/dtoa.c +1619 -0
- package/native/vendor/quickjs-ng/dtoa.h +87 -0
- package/native/vendor/quickjs-ng/examples/fib.c +67 -0
- package/native/vendor/quickjs-ng/examples/fib_module.js +10 -0
- package/native/vendor/quickjs-ng/examples/hello.js +1 -0
- package/native/vendor/quickjs-ng/examples/hello_module.js +6 -0
- package/native/vendor/quickjs-ng/examples/meson.build +17 -0
- package/native/vendor/quickjs-ng/examples/pi_bigint.js +118 -0
- package/native/vendor/quickjs-ng/examples/point.c +154 -0
- package/native/vendor/quickjs-ng/examples/test_fib.js +8 -0
- package/native/vendor/quickjs-ng/examples/test_point.js +43 -0
- package/native/vendor/quickjs-ng/fuzz.c +51 -0
- package/native/vendor/quickjs-ng/gen/function_source.c +81 -0
- package/native/vendor/quickjs-ng/gen/hello.c +53 -0
- package/native/vendor/quickjs-ng/gen/hello_module.c +106 -0
- package/native/vendor/quickjs-ng/gen/repl.c +3053 -0
- package/native/vendor/quickjs-ng/gen/standalone.c +324 -0
- package/native/vendor/quickjs-ng/gen/test_fib.c +81 -0
- package/native/vendor/quickjs-ng/libregexp-opcode.h +58 -0
- package/native/vendor/quickjs-ng/libregexp.c +2687 -0
- package/native/vendor/quickjs-ng/libregexp.h +98 -0
- package/native/vendor/quickjs-ng/libunicode-table.h +4707 -0
- package/native/vendor/quickjs-ng/libunicode.c +1746 -0
- package/native/vendor/quickjs-ng/libunicode.h +126 -0
- package/native/vendor/quickjs-ng/list.h +107 -0
- package/native/vendor/quickjs-ng/lre-test.c +73 -0
- package/native/vendor/quickjs-ng/meson.build +684 -0
- package/native/vendor/quickjs-ng/meson_options.txt +6 -0
- package/native/vendor/quickjs-ng/qjs-wasi-reactor.c +208 -0
- package/native/vendor/quickjs-ng/qjs.c +748 -0
- package/native/vendor/quickjs-ng/qjsc.c +673 -0
- package/native/vendor/quickjs-ng/quickjs-atom.h +267 -0
- package/native/vendor/quickjs-ng/quickjs-c-atomics.h +54 -0
- package/native/vendor/quickjs-ng/quickjs-libc.c +4986 -0
- package/native/vendor/quickjs-ng/quickjs-libc.h +79 -0
- package/native/vendor/quickjs-ng/quickjs-opcode.h +369 -0
- package/native/vendor/quickjs-ng/quickjs.c +60259 -0
- package/native/vendor/quickjs-ng/quickjs.h +1419 -0
- package/native/vendor/quickjs-ng/repl.js +1927 -0
- package/native/vendor/quickjs-ng/run-test262.c +2417 -0
- package/native/vendor/quickjs-ng/standalone.js +129 -0
- package/native/vendor/quickjs-ng/tests/assert.js +49 -0
- package/native/vendor/quickjs-ng/tests/bug1221.js +16 -0
- package/native/vendor/quickjs-ng/tests/bug1296.js +12 -0
- package/native/vendor/quickjs-ng/tests/bug1297.js +22 -0
- package/native/vendor/quickjs-ng/tests/bug1301.js +21 -0
- package/native/vendor/quickjs-ng/tests/bug1302.js +24 -0
- package/native/vendor/quickjs-ng/tests/bug1305.js +26 -0
- package/native/vendor/quickjs-ng/tests/bug1318.js +54 -0
- package/native/vendor/quickjs-ng/tests/bug1352.js +8 -0
- package/native/vendor/quickjs-ng/tests/bug1354.js +6 -0
- package/native/vendor/quickjs-ng/tests/bug1355.js +58 -0
- package/native/vendor/quickjs-ng/tests/bug1368.js +9 -0
- package/native/vendor/quickjs-ng/tests/bug39/1.js +6 -0
- package/native/vendor/quickjs-ng/tests/bug39/2.js +6 -0
- package/native/vendor/quickjs-ng/tests/bug39/3.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug488-upstream.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug633/0.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug633/1.js +4 -0
- package/native/vendor/quickjs-ng/tests/bug633/2.js +4 -0
- package/native/vendor/quickjs-ng/tests/bug633/3.js +4 -0
- package/native/vendor/quickjs-ng/tests/bug645/0.js +4 -0
- package/native/vendor/quickjs-ng/tests/bug645/1.js +9 -0
- package/native/vendor/quickjs-ng/tests/bug645/2.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug648.js +13 -0
- package/native/vendor/quickjs-ng/tests/bug652.js +4 -0
- package/native/vendor/quickjs-ng/tests/bug741.js +19 -0
- package/native/vendor/quickjs-ng/tests/bug775.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug776.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug832.js +2 -0
- package/native/vendor/quickjs-ng/tests/bug858.js +26 -0
- package/native/vendor/quickjs-ng/tests/bug904.js +6 -0
- package/native/vendor/quickjs-ng/tests/bug988.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug999.js +3 -0
- package/native/vendor/quickjs-ng/tests/destructured-export.js +8 -0
- package/native/vendor/quickjs-ng/tests/detect_module/0.js +1 -0
- package/native/vendor/quickjs-ng/tests/detect_module/1.js +2 -0
- package/native/vendor/quickjs-ng/tests/detect_module/2.js +1 -0
- package/native/vendor/quickjs-ng/tests/detect_module/3.js +8 -0
- package/native/vendor/quickjs-ng/tests/detect_module/4.js +3 -0
- package/native/vendor/quickjs-ng/tests/empty.js +0 -0
- package/native/vendor/quickjs-ng/tests/fixture_cyclic_import.js +2 -0
- package/native/vendor/quickjs-ng/tests/fixture_string_exports.js +12 -0
- package/native/vendor/quickjs-ng/tests/function_source.js +14 -0
- package/native/vendor/quickjs-ng/tests/microbench.js +1267 -0
- package/native/vendor/quickjs-ng/tests/null_or_undefined.js +38 -0
- package/native/vendor/quickjs-ng/tests/str-pad-leak.js +5 -0
- package/native/vendor/quickjs-ng/tests/test_bigint.js +107 -0
- package/native/vendor/quickjs-ng/tests/test_bjson.js +366 -0
- package/native/vendor/quickjs-ng/tests/test_builtin.js +1314 -0
- package/native/vendor/quickjs-ng/tests/test_closure.js +220 -0
- package/native/vendor/quickjs-ng/tests/test_cyclic_import.js +12 -0
- package/native/vendor/quickjs-ng/tests/test_domexception.js +35 -0
- package/native/vendor/quickjs-ng/tests/test_language.js +755 -0
- package/native/vendor/quickjs-ng/tests/test_loop.js +367 -0
- package/native/vendor/quickjs-ng/tests/test_queue_microtask.js +39 -0
- package/native/vendor/quickjs-ng/tests/test_std.js +340 -0
- package/native/vendor/quickjs-ng/tests/test_string_exports.js +25 -0
- package/native/vendor/quickjs-ng/tests/test_worker.js +43 -0
- package/native/vendor/quickjs-ng/tests/test_worker_module.js +30 -0
- package/native/vendor/quickjs-ng/tests.conf +14 -0
- package/native/vendor/quickjs-ng/unicode_download.sh +19 -0
- package/native/vendor/quickjs-ng/unicode_gen.c +3108 -0
- package/native/vendor/quickjs-ng/unicode_gen_def.h +310 -0
- package/native/vendor/quickjs-ng/update-version.sh +32 -0
- package/native/vendor/webview2/include/WebView2.h +60636 -0
- package/native/vendor/webview2/include/WebView2EnvironmentOptions.h +406 -0
- package/package.json +33 -0
- package/src/backend.ts +139 -0
- package/src/build-config.ts +87 -0
- package/src/build.ts +276 -0
- package/src/common.ts +195 -0
- package/src/config.ts +89 -0
- package/src/dev.ts +164 -0
- package/src/generate.ts +200 -0
- package/src/icons.ts +116 -0
- package/src/init.ts +190 -0
- package/src/package.ts +150 -0
- package/src/zapp-cli.ts +263 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// JSC wrapper for WebSocket. Delegates to core/websocket_core.zc.
|
|
2
|
+
|
|
3
|
+
//> macos: framework: JavaScriptCore
|
|
4
|
+
|
|
5
|
+
raw {
|
|
6
|
+
#ifdef __APPLE__
|
|
7
|
+
#include <Foundation/Foundation.h>
|
|
8
|
+
#include <JavaScriptCore/JavaScriptCore.h>
|
|
9
|
+
|
|
10
|
+
static char* zapp_core_ws_connect(const char* url_str, const char** protocols, int protocol_count,
|
|
11
|
+
zapp_ws_event_fn callback, void* user_data);
|
|
12
|
+
static void zapp_core_ws_send_text(const char* ws_id, const char* text);
|
|
13
|
+
static void zapp_core_ws_send_binary(const char* ws_id, const uint8_t* bytes, size_t len);
|
|
14
|
+
static void zapp_core_ws_close(const char* ws_id, int code, const char* reason);
|
|
15
|
+
static void zapp_core_ws_ensure_init(void);
|
|
16
|
+
|
|
17
|
+
// JSC WS callback: receives events from core and dispatches to JS.
|
|
18
|
+
// user_data holds a retained NSDictionary* with the JSContext and JS callback function.
|
|
19
|
+
static void zapp_jsc_ws_callback(const char* ws_id, const char* event_type, const char* json_payload, void* user_data) {
|
|
20
|
+
if (!user_data || !json_payload) return;
|
|
21
|
+
NSDictionary* info = (__bridge NSDictionary*)user_data;
|
|
22
|
+
JSContext* ctx = info[@"ctx"];
|
|
23
|
+
JSValue* callback = info[@"fn"];
|
|
24
|
+
if (ctx == nil || callback == nil || [callback isUndefined]) return;
|
|
25
|
+
|
|
26
|
+
NSData* jsonData = [[NSString stringWithUTF8String:json_payload] dataUsingEncoding:NSUTF8StringEncoding];
|
|
27
|
+
id parsed = jsonData ? [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil] : @{};
|
|
28
|
+
|
|
29
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
30
|
+
@try {
|
|
31
|
+
[callback callWithArguments:@[[JSValue valueWithObject:parsed inContext:ctx]]];
|
|
32
|
+
} @catch (NSException* e) {
|
|
33
|
+
NSLog(@"[zapp-ws] dispatch error: %@", e);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Per-context storage for callback info so ARC keeps it alive
|
|
39
|
+
static NSMutableDictionary<NSString*, NSDictionary*>* zapp_jsc_ws_refs = nil;
|
|
40
|
+
|
|
41
|
+
void zapp_darwin_worker_websocket_init(JSContext* ctx) {
|
|
42
|
+
zapp_core_ws_ensure_init();
|
|
43
|
+
if (zapp_jsc_ws_refs == nil) zapp_jsc_ws_refs = [NSMutableDictionary new];
|
|
44
|
+
|
|
45
|
+
JSValue* bridge = ctx[@"__zappBridge"];
|
|
46
|
+
if (bridge == nil || bridge.isUndefined) {
|
|
47
|
+
ctx[@"__zappBridge"] = [JSValue valueWithNewObjectInContext:ctx];
|
|
48
|
+
bridge = ctx[@"__zappBridge"];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
bridge[@"wsConnect"] = ^NSString*(JSValue* urlVal, JSValue* protocolsVal, JSValue* callbackVal) {
|
|
52
|
+
if (urlVal == nil || [urlVal isUndefined] || [urlVal isNull]) return @"";
|
|
53
|
+
NSString* urlStr = [urlVal toString];
|
|
54
|
+
if (urlStr == nil || [urlStr length] == 0) return @"";
|
|
55
|
+
|
|
56
|
+
// Extract protocols
|
|
57
|
+
const char** protos = NULL;
|
|
58
|
+
int protoCount = 0;
|
|
59
|
+
NSArray* protoArr = nil;
|
|
60
|
+
if (protocolsVal != nil && ![protocolsVal isUndefined] && ![protocolsVal isNull]) {
|
|
61
|
+
protoArr = [protocolsVal toArray];
|
|
62
|
+
protoCount = (int)[protoArr count];
|
|
63
|
+
if (protoCount > 0) {
|
|
64
|
+
protos = (const char**)malloc(sizeof(const char*) * protoCount);
|
|
65
|
+
for (int i = 0; i < protoCount; i++) {
|
|
66
|
+
protos[i] = [[protoArr[i] description] UTF8String];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Store context + callback for the event dispatcher
|
|
72
|
+
NSDictionary* info = @{@"ctx": ctx, @"fn": (callbackVal && ![callbackVal isUndefined]) ? callbackVal : [NSNull null]};
|
|
73
|
+
void* ud = (__bridge_retained void*)info;
|
|
74
|
+
|
|
75
|
+
char* wsIdC = zapp_core_ws_connect([urlStr UTF8String], protos, protoCount, zapp_jsc_ws_callback, ud);
|
|
76
|
+
free(protos);
|
|
77
|
+
|
|
78
|
+
if (!wsIdC) {
|
|
79
|
+
CFRelease(ud);
|
|
80
|
+
return @"";
|
|
81
|
+
}
|
|
82
|
+
NSString* wsId = [NSString stringWithUTF8String:wsIdC];
|
|
83
|
+
zapp_jsc_ws_refs[wsId] = info;
|
|
84
|
+
free(wsIdC);
|
|
85
|
+
return wsId;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
bridge[@"wsSend"] = ^(JSValue* wsIdVal, JSValue* dataVal, JSValue* isBinaryVal) {
|
|
89
|
+
if (wsIdVal == nil || [wsIdVal isUndefined]) return;
|
|
90
|
+
const char* wsId = [[wsIdVal toString] UTF8String];
|
|
91
|
+
BOOL isBinary = (isBinaryVal && ![isBinaryVal isUndefined]) ? [isBinaryVal toBool] : NO;
|
|
92
|
+
|
|
93
|
+
if (isBinary) {
|
|
94
|
+
JSContextRef ctxRef = ctx.JSGlobalContextRef;
|
|
95
|
+
JSValueRef valRef = dataVal.JSValueRef;
|
|
96
|
+
JSValueRef exception = NULL;
|
|
97
|
+
const uint8_t* bytes = NULL;
|
|
98
|
+
size_t len = 0;
|
|
99
|
+
|
|
100
|
+
JSTypedArrayType type = JSValueGetTypedArrayType(ctxRef, valRef, &exception);
|
|
101
|
+
if (type != kJSTypedArrayTypeNone && exception == NULL) {
|
|
102
|
+
bytes = (const uint8_t*)JSObjectGetTypedArrayBytesPtr(ctxRef, valRef, &exception);
|
|
103
|
+
len = JSObjectGetTypedArrayByteLength(ctxRef, valRef, &exception);
|
|
104
|
+
} else {
|
|
105
|
+
exception = NULL;
|
|
106
|
+
bytes = (const uint8_t*)JSObjectGetArrayBufferBytesPtr(ctxRef, valRef, &exception);
|
|
107
|
+
if (bytes && exception == NULL) len = JSObjectGetArrayBufferByteLength(ctxRef, valRef, &exception);
|
|
108
|
+
}
|
|
109
|
+
if (bytes && len > 0) zapp_core_ws_send_binary(wsId, bytes, len);
|
|
110
|
+
} else {
|
|
111
|
+
const char* text = [[dataVal toString] UTF8String];
|
|
112
|
+
zapp_core_ws_send_text(wsId, text ?: "");
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
bridge[@"wsClose"] = ^(JSValue* wsIdVal, JSValue* codeVal, JSValue* reasonVal) {
|
|
117
|
+
if (wsIdVal == nil || [wsIdVal isUndefined]) return;
|
|
118
|
+
NSString* wsId = [wsIdVal toString];
|
|
119
|
+
int code = (codeVal && ![codeVal isUndefined] && ![codeVal isNull]) ? [codeVal toInt32] : 1000;
|
|
120
|
+
const char* reason = (reasonVal && ![reasonVal isUndefined] && ![reasonVal isNull]) ? [[reasonVal toString] UTF8String] : NULL;
|
|
121
|
+
|
|
122
|
+
zapp_core_ws_close([wsId UTF8String], code, reason);
|
|
123
|
+
[zapp_jsc_ws_refs removeObjectForKey:wsId];
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
#endif
|
|
127
|
+
}
|