@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,9 @@
|
|
|
1
|
+
// AUTO-GENERATED FILE. DO NOT EDIT.
|
|
2
|
+
// Source of truth: `packages/bootstrap/src/backend.ts`
|
|
3
|
+
// Generated: `2026-03-22T07:58:05.469Z`
|
|
4
|
+
|
|
5
|
+
raw {
|
|
6
|
+
const char* zapp_darwin_backend_bootstrap_script(void) {
|
|
7
|
+
return "(()=>{var{defineProperty:W,getOwnPropertyNames:q,getOwnPropertyDescriptor:k}=Object,C=Object.prototype.hasOwnProperty;var j=new WeakMap,m=(F)=>{var G=j.get(F),J;if(G)return G;if(G=W({},\"__esModule\",{value:!0}),F&&typeof F===\"object\"||typeof F===\"function\")q(F).map((K)=>!C.call(G,K)&&W(G,K,{get:()=>F[K],enumerable:!(J=k(F,K))||J.enumerable}));return j.set(F,G),G};var l={},Q=globalThis,X=Q.__zappBridge?\?{};try{delete Q.__zappBridge}catch{}var{syncWait:f,syncNotify:v,syncCancel:S}=X,y=(F)=>{if(typeof F===\"string\")return F;try{return String(F)}catch{return\"unknown error\"}},b=(F)=>{try{let G=F instanceof Error?F.message:y(F);X.reportError?.(G)}catch{try{X.reportError?.(\"Backend error\")}catch{}}};try{Object.defineProperty(Q,Symbol.for(\"zapp.context\"),{value:\"backend\",enumerable:!1,configurable:!1,writable:!1})}catch{Q[Symbol.for(\"zapp.context\")]=\"backend\"}var w=Q.__zappConfig,_=w?{...w}:{name:\"Zapp App\",applicationShouldTerminateAfterLastWindowClosed:!1,webContentInspectable:!0};try{delete Q.__zappConfig}catch{}X.getConfig=()=>({..._});X.mergeConfig=(F)=>{if(F&&typeof F===\"object\"){if(typeof F.name===\"string\")_.name=F.name;if(typeof F.applicationShouldTerminateAfterLastWindowClosed===\"boolean\")_.applicationShouldTerminateAfterLastWindowClosed=F.applicationShouldTerminateAfterLastWindowClosed;if(typeof F.webContentInspectable===\"boolean\")_.webContentInspectable=F.webContentInspectable;if(typeof F.maxWorkers===\"number\")_.maxWorkers=F.maxWorkers}};if(typeof Q.Event!==\"function\")Q.Event=function(G,J){if(this.type=String(G?\?\"\"),this.defaultPrevented=!1,J)for(let K of Object.keys(J))this[K]=J[K]};if(typeof Q.MessageEvent!==\"function\"){let F=Q.Event;Q.MessageEvent=function(J,K){F.call(this,J,K),this.data=K?.data,this.ports=K?.ports?\?[]}}if(typeof Q.AbortSignal!==\"function\"){let F=function(){this.aborted=!1,this.reason=void 0,this._listeners=[]};F.prototype.addEventListener=function(G,J){if(G===\"abort\"&&typeof J===\"function\")this._listeners.push(J)},F.prototype.removeEventListener=function(G,J){if(G===\"abort\")this._listeners=this._listeners.filter((K)=>K!==J)},Q.AbortSignal=F}if(typeof Q.AbortController!==\"function\"){let F=Q.AbortSignal;Q.AbortController=function(){this.signal=new F},Q.AbortController.prototype.abort=function(G){let J=this.signal;if(J.aborted)return;J.aborted=!0,J.reason=G;let K=(J._listeners?\?[]).slice();J._listeners=[];for(let O of K)try{O()}catch{}}}if(typeof Q.CustomEvent!==\"function\"){let F=Q.Event;Q.CustomEvent=function(J,K){F.call(this,J,K),this.detail=K?.detail?\?null},Q.CustomEvent.prototype=Object.create(Q.Event.prototype)}if(typeof Q.TextEncoder!==\"function\"){let F=X.textEncode;Q.TextEncoder=function(){},Q.TextEncoder.prototype.encoding=\"utf-8\",Q.TextEncoder.prototype.encode=function(G){if(!G)return new Uint8Array(0);if(F)return F(String(G));let J=String(G),K=[];for(let O=0;O<J.length;O++){let Y=J.charCodeAt(O);if(Y<128)K.push(Y);else if(Y<2048)K.push(192|Y>>6,128|Y&63);else if(Y>=55296&&Y<=56319&&O+1<J.length){let T=J.charCodeAt(++O);Y=65536+(Y-55296<<10)+(T-56320),K.push(240|Y>>18,128|Y>>12&63,128|Y>>6&63,128|Y&63)}else K.push(224|Y>>12,128|Y>>6&63,128|Y&63)}return new Uint8Array(K)},Q.TextEncoder.prototype.encodeInto=function(G,J){let K=Q.TextEncoder.prototype.encode(G),O=Math.min(K.length,J.length);return J.set(K.subarray(0,O)),{read:G.length,written:O}}}if(typeof Q.TextDecoder!==\"function\"){let F=X.textDecode;Q.TextDecoder=function(){},Q.TextDecoder.prototype.encoding=\"utf-8\",Q.TextDecoder.prototype.decode=function(G){if(!G)return\"\";if(F)return F(G);let J=G instanceof Uint8Array?G:new Uint8Array(G),K=[],O=0;while(O<J.length){let Y=J[O];if(Y<128)K.push(String.fromCharCode(Y)),O++;else if((Y&224)===192)K.push(String.fromCharCode((Y&31)<<6|J[O+1]&63)),O+=2;else if((Y&240)===224)K.push(String.fromCharCode((Y&15)<<12|(J[O+1]&63)<<6|J[O+2]&63)),O+=3;else if((Y&248)===240){let $=((Y&7)<<18|(J[O+1]&63)<<12|(J[O+2]&63)<<6|J[O+3]&63)-65536;K.push(String.fromCharCode(55296+($>>10),56320+($&1023))),O+=4}else K.push(\"�\"),O++}return K.join(\"\")}}if(typeof Q.URL!==\"function\"){let G=function(J,K){let O=F?.(String(J),K!=null?String(K):void 0);if(!O)throw TypeError(`Invalid URL: ${J}`);this.href=O.href,this.protocol=O.protocol,this.host=O.host,this.hostname=O.hostname,this.port=O.port,this.pathname=O.pathname,this.search=O.search,this.hash=O.hash,this.origin=O.origin,this.username=O.username,this.password=O.password},F=X.urlParse;G.prototype.toString=function(){return this.href},G.prototype.toJSON=function(){return this.href},Q.URL=G}if(typeof Q.atob!==\"function\"){let F=X.atob;Q.atob=(G)=>{if(F)return F(String(G));throw Error(\"atob not available\")}}if(typeof Q.btoa!==\"function\"){let F=X.btoa;Q.btoa=(G)=>{if(F)return F(String(G));throw Error(\"btoa not available\")}}if(typeof Q.Headers!==\"function\"){let F=function(G){let J={};if(Array.isArray(G))for(let[K,O]of G)J[String(K).toLowerCase()]=String(O);else if(G&&typeof G===\"object\")for(let K of Object.keys(G))J[K.toLowerCase()]=String(G[K]);this._map=J};F.prototype.get=function(G){return this._map[String(G).toLowerCase()]?\?null},F.prototype.set=function(G,J){this._map[String(G).toLowerCase()]=String(J)},F.prototype.has=function(G){return String(G).toLowerCase()in this._map},F.prototype.delete=function(G){delete this._map[String(G).toLowerCase()]},F.prototype.forEach=function(G){let J=this._map;for(let K of Object.keys(J))G(J[K],K)},F.prototype.entries=function*(){let G=this._map;for(let J of Object.keys(G))yield[J,G[J]]},F.prototype[Symbol.iterator]=F.prototype.entries,Q.Headers=F}if(typeof Q.WebSocket!==\"function\"){let $=function(D,N){let V=this;V.url=String(D),V.readyState=0,V.bufferedAmount=0,V.extensions=\"\",V.protocol=\"\",V.binaryType=\"arraybuffer\",V.onopen=null,V.onmessage=null,V.onerror=null,V.onclose=null;let Z={};V.addEventListener=(R,z)=>{(Z[R]?\?=[]).push(z)},V.removeEventListener=(R,z)=>{Z[R]=(Z[R]?\?[]).filter((U)=>U!==z)},V.dispatchEvent=(R)=>{let z=String(R?.type?\?\"\"),U=V[`on${z}`];if(typeof U===\"function\")try{U(R)}catch{}for(let L of(Z[z]?\?[]).slice())try{L(R)}catch{}return!0};let M=N==null?void 0:typeof N===\"string\"?[N]:N;if(!F){Q.setTimeout(()=>{V.readyState=3;let R=typeof Q.Event===\"function\"?new Q.Event(\"error\"):{type:\"error\"};V.dispatchEvent(R)},0);return}let E=F(String(D),M,(R)=>{let z=String(R.type?\?\"\");if(z===\"open\"){V.readyState=1;let U=typeof Q.Event===\"function\"?new Q.Event(\"open\"):{type:\"open\"};V.dispatchEvent(U)}else if(z===\"message\"){if(V.readyState!==1)return;let U=R.data;if(R.binary===!0&&Array.isArray(U))U=new Uint8Array(U).buffer;let h=typeof Q.MessageEvent===\"function\"?new Q.MessageEvent(\"message\",{data:U}):{type:\"message\",data:U};V.dispatchEvent(h)}else if(z===\"error\"){let U=typeof Q.Event===\"function\"?new Q.Event(\"error\"):{type:\"error\"};V.dispatchEvent(U)}else if(z===\"close\"){V.readyState=3;let U={type:\"close\",code:R.code?\?1000,reason:R.reason?\?\"\",wasClean:R.wasClean?\?!0};V.dispatchEvent(U)}});V._wsId=E},F=X.wsConnect,G=X.wsSend,J=X.wsClose,K=0,O=1,Y=2,T=3;$.prototype.send=function(D){if(this.readyState!==1)throw Error(\"WebSocket is not open\");let N=this._wsId;if(D instanceof ArrayBuffer||D instanceof Uint8Array){let Z=D instanceof Uint8Array?D:new Uint8Array(D);G?.(N,Z,!0)}else G?.(N,String(D),!1)},$.prototype.close=function(D,N){if(this.readyState===3||this.readyState===2)return;this.readyState=2;let V=this._wsId;J?.(V,D,N)},$.CONNECTING=0,$.OPEN=1,$.CLOSING=2,$.CLOSED=3,$.prototype.CONNECTING=0,$.prototype.OPEN=1,$.prototype.CLOSING=2,$.prototype.CLOSED=3,Q.WebSocket=$}Q.setTimeout=(F,G,...J)=>{if(typeof F!==\"function\")return 0;return X.setTimer?.(()=>F(...J),Number(G?\?0),!1)?\?0};Q.clearTimeout=(F)=>{if(typeof F===\"number\")X.clearTimer?.(F)};Q.setInterval=(F,G,...J)=>{if(typeof F!==\"function\")return 0;return X.setTimer?.(()=>F(...J),Number(G?\?0),!0)?\?0};Q.clearInterval=Q.clearTimeout;if(typeof Q.crypto>\"u\")Q.crypto={getRandomValues:(F)=>X.getRandomValues?.(F)?\?F,randomUUID:()=>X.randomUUID?.()?\?\"00000000-0000-0000-0000-000000000000\"};{let{Headers:F,TextEncoder:G}=Q,J=(K,O,Y,T)=>{let $=F?new F(T):T,D=!1,N=()=>{if(D)throw TypeError(\"Body already consumed\");return D=!0,K};return{ok:O>=200&&O<300,status:O,statusText:Y,headers:$,url:\"\",redirected:!1,type:\"basic\",bodyUsed:!1,text:()=>{let V=N();return Promise.resolve(V)},json:()=>{let V=N();return Promise.resolve(JSON.parse(V))},arrayBuffer:()=>{let V=N();if(G){let E=new G;return Promise.resolve(E.encode(V).buffer)}let Z=new ArrayBuffer(V.length),M=new Uint8Array(Z);for(let E=0;E<V.length;E++)M[E]=V.charCodeAt(E)&255;return Promise.resolve(Z)},blob:()=>Promise.reject(Error(\"Blob not supported in this context\")),clone:()=>J(K,O,Y,T)}};if(typeof Q.fetch>\"u\")Q.fetch=(K,O)=>new Promise((Y,T)=>{let $=\"\",D=\"GET\",N={},V;if(typeof K===\"string\")$=K;else if(K&&typeof K===\"object\"){let Z=K;if(typeof Z.url===\"string\")$=Z.url,D=Z.method||\"GET\",V=Z.body;else if(typeof Z.href===\"string\")$=Z.href}if(O){if(O.method)D=O.method;if(O.body)if(typeof O.body===\"string\")V=O.body;else if(O.body instanceof ArrayBuffer||O.body instanceof Uint8Array){let Z=O.body instanceof Uint8Array?O.body:new Uint8Array(O.body),M=Q.TextDecoder;V=M?new M().decode(Z):String.fromCharCode(...Z)}else V=JSON.stringify(O.body);if(O.headers&&typeof O.headers===\"object\")if(typeof O.headers.forEach===\"function\")O.headers.forEach((Z,M)=>{N[M]=String(Z)});else for(let[Z,M]of Object.entries(O.headers))N[Z]=String(M)}if(!X.fetch)return T(Error(\"fetch not available\"));X.fetch($,{method:D,headers:N,body:V},(Z)=>{let M=Z.body?\?\"\";if(Z.body_base64&&typeof Q.atob===\"function\")try{M=Q.atob(Z.body_base64)}catch{}Y(J(M,Z.status,Z.statusText,Z.headers))},(Z)=>T(Error(Z)))})}{let F=(G)=>(...J)=>{let K=J.map((O)=>{if(typeof O===\"string\")return O;try{return JSON.stringify(O)}catch{return String(O)}}).join(\" \");X.consoleLog?.(G,K)};Q.console={log:F(\"log\"),info:F(\"info\"),warn:F(\"warn\"),error:F(\"error\"),debug:F(\"debug\")}}var A={},c=0,H=`backend-${Date.now()}-${Math.random().toString(36).slice(2)}`,x=()=>\"__zapp_backend__\",I=Object.freeze({emit:(F,G)=>{return X.emitToHost?.(F,G),!0},invoke:(F,G)=>{return X.invokeToHost?.(F,G),!0},on:(F,G)=>{let J=++c;return(A[F]?\?=[]).push({id:J,fn:G}),()=>{A[F]=(A[F]?\?[]).filter((K)=>K.id!==J)}}});try{Object.defineProperty(Q,\"__zapp\",{value:I,enumerable:!0,configurable:!1,writable:!1})}catch{Q.__zapp=I}var P={};X.syncWait=(F)=>new Promise((G,J)=>{let K=typeof F?.key===\"string\"?F.key.trim():\"\";if(!K){J(Error(\"Sync key must be a non-empty string.\"));return}if(F?.signal?.aborted){J(Error(\"Sync wait aborted.\"));return}let O=`${H}:sync-${Date.now()}-${Math.random().toString(36).slice(2)}`,Y=F?.timeoutMs==null?null:Math.max(1,Math.min(300000,Math.floor(Number(F.timeoutMs)))),T=Y==null?void 0:Q.setTimeout(()=>{delete P[O],J(Error(\"Sync wait transport timed out.\"))},Y+5000);if(P[O]={resolve:G,reject:J,timer:T},f?.({id:O,key:K,timeoutMs:Y,targetWorkerId:x()}),F?.signal?.addEventListener)F.signal.addEventListener(\"abort\",()=>{let $=P[O];if(!$)return;if($.timer)Q.clearTimeout($.timer);delete P[O],S?.({id:O,targetWorkerId:x()}),J(Error(\"Sync wait aborted.\"))})});X.syncNotify=(F)=>{let G=typeof F?.key===\"string\"?F.key.trim():\"\";if(!G)return!1;return v?.({key:G,count:Math.max(1,Math.min(65535,Math.floor(Number(F?.count?\?1)))),targetWorkerId:x()})?\?!1};X.syncCancel=(F)=>{let G=typeof F?.id===\"string\"?F.id.trim():\"\";if(!G)return!1;return S?.({id:G,targetWorkerId:x()})?\?!1};var B={},u=0;X.windowCreate=(F)=>new Promise((G,J)=>{let K=`${H}:win-${++u}`,O=Q.setTimeout(()=>{delete B[K],J(Error(\"Window creation timed out.\"))},15000);B[K]={resolve:G,reject:J,timer:O},X.emitToHost?.(\"__zapp_window_create\",JSON.stringify({requestId:K,options:F}))});X.windowAction=(F,G,J)=>{X.emitToHost?.(\"__zapp_window_action\",JSON.stringify({windowId:F,action:G,...J}))};X.appAction=(F)=>{X.emitToHost?.(\"__zapp_app_action\",JSON.stringify({action:F}))};X.appConfigure=(F)=>{if(!F||typeof F!==\"object\")return;X.emitToHost?.(\"__zapp_app_configure\",JSON.stringify(F))};X.dispatchWindowResult=(F)=>{let G=F;if(typeof G===\"string\")try{G=JSON.parse(G)}catch{return}if(!G||typeof G!==\"object\")return;let J=G;if(typeof J.requestId!==\"string\")return;let K=B[J.requestId];if(!K)return;if(K.timer)Q.clearTimeout(K.timer);if(delete B[J.requestId],J.ok===!1)K.reject(Error(J.error?\?\"Window creation failed.\"));else K.resolve({id:J.id?\?\"\"})};try{Object.defineProperty(Q,Symbol.for(\"zapp.bridge\"),{value:X,enumerable:!1,configurable:!0,writable:!1})}catch{Q[Symbol.for(\"zapp.bridge\")]=X}X.dispatchSyncResult=(F)=>{let G=F;if(typeof G===\"string\")try{G=JSON.parse(G)}catch{return}if(!G||typeof G!==\"object\")return;let J=G;if(typeof J.id!==\"string\"||!J.id)return;let K=P[J.id];if(!K)return;if(K.timer)Q.clearTimeout(K.timer);if(delete P[J.id],!J.ok){K.reject(Error(\"Sync wait failed.\"));return}if(J.status===\"cancelled\"){K.reject(Error(\"Sync wait aborted.\"));return}K.resolve(J.status===\"timed-out\"?\"timed-out\":\"notified\")};X.deliverEvent=(F,G)=>{let J=A[F];if(!J||J.length===0)return;let K=G;if(typeof K===\"string\")try{K=JSON.parse(K)}catch{}if(K&&typeof K===\"object\"){let O=K;if(O.__zapp_internal_meta){if(O.__zapp_internal_meta.sourceCtxId===H)return;K=O.data}}for(let O of J.slice())try{O.fn(K)}catch(Y){b(Y)}};})();\n";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// AUTO-GENERATED FILE. DO NOT EDIT.
|
|
2
|
+
// Source of truth: `packages/bootstrap/src/worker.ts`
|
|
3
|
+
// Generated: `2026-03-22T07:58:05.466Z`
|
|
4
|
+
|
|
5
|
+
raw {
|
|
6
|
+
const char* zapp_darwin_worker_bootstrap_script(void) {
|
|
7
|
+
return "(()=>{var{defineProperty:S,getOwnPropertyNames:f,getOwnPropertyDescriptor:h}=Object,C=Object.prototype.hasOwnProperty;var L=new WeakMap,m=(J)=>{var G=L.get(J),K;if(G)return G;if(G=S({},\"__esModule\",{value:!0}),J&&typeof J===\"object\"||typeof J===\"function\")f(J).map((O)=>!C.call(G,O)&&S(G,O,{get:()=>J[O],enumerable:!(K=h(J,O))||K.enumerable}));return L.set(J,G),G};var l={},Q=globalThis,Y=Q.__zappBridge?\?{};try{delete Q.__zappBridge}catch{}var{syncWait:v,syncNotify:y,syncCancel:q}=Y,b=(J)=>{if(typeof J===\"string\")return J;try{return String(J)}catch{return\"unknown error\"}},j=(J)=>{try{let G=J instanceof Error?J.message:b(J);Y.reportError?.(G)}catch{try{Y.reportError?.(\"Worker error\")}catch{}}};{let J=Y.consoleLog;if(J){let G=typeof Q.console===\"object\"&&Q.console?Q.console:null,K=(...V)=>V.map((X)=>{if(typeof X===\"string\")return X;try{return JSON.stringify(X)}catch{return String(X)}}).join(\" \"),O=(V)=>{let X=G?.[V];return(...N)=>{if(J(V,K(...N)),typeof X===\"function\")try{X.apply(G,N)}catch{}}};Q.console={log:O(\"log\"),info:O(\"info\"),warn:O(\"warn\"),error:O(\"error\"),debug:O(\"debug\"),trace:O(\"trace\"),dir:O(\"dir\"),assert:(V,...X)=>{if(!V){if(J(\"assert\",\"Assertion failed: \"+K(...X)),typeof G?.assert===\"function\")try{G.assert.call(G,V,...X)}catch{}}},time:G?.time?\?(()=>{}),timeEnd:G?.timeEnd?\?(()=>{}),timeLog:G?.timeLog?\?(()=>{}),group:G?.group?\?(()=>{}),groupEnd:G?.groupEnd?\?(()=>{}),groupCollapsed:G?.groupCollapsed?\?(()=>{}),clear:G?.clear?\?(()=>{}),count:G?.count?\?(()=>{}),countReset:G?.countReset?\?(()=>{}),table:O(\"table\")}}}if(typeof Q.Event!==\"function\")Q.Event=function(G,K){if(this.type=String(G?\?\"\"),this.defaultPrevented=!1,K)for(let O of Object.keys(K))this[O]=K[O]};if(typeof Q.MessageEvent!==\"function\"){let J=Q.Event;Q.MessageEvent=function(K,O){J.call(this,K,O),this.data=O?.data,this.ports=O?.ports?\?[]}}if(typeof Q.AbortSignal!==\"function\"){let J=function(){this.aborted=!1,this.reason=void 0,this._listeners=[]};J.prototype.addEventListener=function(G,K){if(G===\"abort\"&&typeof K===\"function\")this._listeners.push(K)},J.prototype.removeEventListener=function(G,K){if(G===\"abort\")this._listeners=this._listeners.filter((O)=>O!==K)},Q.AbortSignal=J}if(typeof Q.AbortController!==\"function\"){let J=Q.AbortSignal;Q.AbortController=function(){this.signal=new J},Q.AbortController.prototype.abort=function(G){let K=this.signal;if(K.aborted)return;K.aborted=!0,K.reason=G;let O=(K._listeners?\?[]).slice();K._listeners=[];for(let V of O)try{V()}catch{}}}if(typeof Q.CustomEvent!==\"function\"){let J=Q.Event;Q.CustomEvent=function(K,O){J.call(this,K,O),this.detail=O?.detail?\?null},Q.CustomEvent.prototype=Object.create(Q.Event.prototype)}if(typeof Q.TextEncoder!==\"function\"){let J=Y.textEncode;Q.TextEncoder=function(){},Q.TextEncoder.prototype.encoding=\"utf-8\",Q.TextEncoder.prototype.encode=function(G){if(!G)return new Uint8Array(0);if(J)return J(String(G));let K=String(G),O=[];for(let V=0;V<K.length;V++){let X=K.charCodeAt(V);if(X<128)O.push(X);else if(X<2048)O.push(192|X>>6,128|X&63);else if(X>=55296&&X<=56319&&V+1<K.length){let N=K.charCodeAt(++V);X=65536+(X-55296<<10)+(N-56320),O.push(240|X>>18,128|X>>12&63,128|X>>6&63,128|X&63)}else O.push(224|X>>12,128|X>>6&63,128|X&63)}return new Uint8Array(O)},Q.TextEncoder.prototype.encodeInto=function(G,K){let O=Q.TextEncoder.prototype.encode(G),V=Math.min(O.length,K.length);return K.set(O.subarray(0,V)),{read:G.length,written:V}}}if(typeof Q.TextDecoder!==\"function\"){let J=Y.textDecode;Q.TextDecoder=function(){},Q.TextDecoder.prototype.encoding=\"utf-8\",Q.TextDecoder.prototype.decode=function(G){if(!G)return\"\";if(J)return J(G);let K=G instanceof Uint8Array?G:new Uint8Array(G),O=[],V=0;while(V<K.length){let X=K[V];if(X<128)O.push(String.fromCharCode(X)),V++;else if((X&224)===192)O.push(String.fromCharCode((X&31)<<6|K[V+1]&63)),V+=2;else if((X&240)===224)O.push(String.fromCharCode((X&15)<<12|(K[V+1]&63)<<6|K[V+2]&63)),V+=3;else if((X&248)===240){let F=((X&7)<<18|(K[V+1]&63)<<12|(K[V+2]&63)<<6|K[V+3]&63)-65536;O.push(String.fromCharCode(55296+(F>>10),56320+(F&1023))),V+=4}else O.push(\"�\"),V++}return O.join(\"\")}}if(typeof Q.URL!==\"function\"){let G=function(K,O){let V=J?.(String(K),O!=null?String(O):void 0);if(!V)throw TypeError(`Invalid URL: ${K}`);this.href=V.href,this.protocol=V.protocol,this.host=V.host,this.hostname=V.hostname,this.port=V.port,this.pathname=V.pathname,this.search=V.search,this.hash=V.hash,this.origin=V.origin,this.username=V.username,this.password=V.password},J=Y.urlParse;G.prototype.toString=function(){return this.href},G.prototype.toJSON=function(){return this.href},Q.URL=G}if(typeof Q.atob!==\"function\"){let J=Y.atob;Q.atob=(G)=>{if(J)return J(String(G));throw Error(\"atob not available\")}}if(typeof Q.btoa!==\"function\"){let J=Y.btoa;Q.btoa=(G)=>{if(J)return J(String(G));throw Error(\"btoa not available\")}}if(typeof Q.Headers!==\"function\"){let J=function(G){let K={};if(Array.isArray(G))for(let[O,V]of G)K[String(O).toLowerCase()]=String(V);else if(G&&typeof G===\"object\")for(let O of Object.keys(G))K[O.toLowerCase()]=String(G[O]);this._map=K};J.prototype.get=function(G){return this._map[String(G).toLowerCase()]?\?null},J.prototype.set=function(G,K){this._map[String(G).toLowerCase()]=String(K)},J.prototype.has=function(G){return String(G).toLowerCase()in this._map},J.prototype.delete=function(G){delete this._map[String(G).toLowerCase()]},J.prototype.forEach=function(G){let K=this._map;for(let O of Object.keys(K))G(K[O],O)},J.prototype.entries=function*(){let G=this._map;for(let K of Object.keys(G))yield[K,G[K]]},J.prototype[Symbol.iterator]=J.prototype.entries,Q.Headers=J}if(typeof Q.WebSocket!==\"function\"){let F=function(R,U){let Z=this;Z.url=String(R),Z.readyState=0,Z.bufferedAmount=0,Z.extensions=\"\",Z.protocol=\"\",Z.binaryType=\"arraybuffer\",Z.onopen=null,Z.onmessage=null,Z.onerror=null,Z.onclose=null;let $={};Z.addEventListener=(B,T)=>{($[B]?\?=[]).push(T)},Z.removeEventListener=(B,T)=>{$[B]=($[B]?\?[]).filter((D)=>D!==T)},Z.dispatchEvent=(B)=>{let T=String(B?.type?\?\"\"),D=Z[`on${T}`];if(typeof D===\"function\")try{D(B)}catch{}for(let w of($[T]?\?[]).slice())try{w(B)}catch{}return!0};let M=U==null?void 0:typeof U===\"string\"?[U]:U;if(!J){Q.setTimeout(()=>{Z.readyState=3;let B=typeof Q.Event===\"function\"?new Q.Event(\"error\"):{type:\"error\"};Z.dispatchEvent(B)},0);return}let P=J(String(R),M,(B)=>{let T=String(B.type?\?\"\");if(T===\"open\"){Z.readyState=1;let D=typeof Q.Event===\"function\"?new Q.Event(\"open\"):{type:\"open\"};Z.dispatchEvent(D)}else if(T===\"message\"){if(Z.readyState!==1)return;let D=B.data;if(B.binary===!0&&Array.isArray(D))D=new Uint8Array(D).buffer;let k=typeof Q.MessageEvent===\"function\"?new Q.MessageEvent(\"message\",{data:D}):{type:\"message\",data:D};Z.dispatchEvent(k)}else if(T===\"error\"){let D=typeof Q.Event===\"function\"?new Q.Event(\"error\"):{type:\"error\"};Z.dispatchEvent(D)}else if(T===\"close\"){Z.readyState=3;let D={type:\"close\",code:B.code?\?1000,reason:B.reason?\?\"\",wasClean:B.wasClean?\?!0};Z.dispatchEvent(D)}});Z._wsId=P},J=Y.wsConnect,G=Y.wsSend,K=Y.wsClose,O=0,V=1,X=2,N=3;F.prototype.send=function(R){if(this.readyState!==1)throw Error(\"WebSocket is not open\");let U=this._wsId;if(R instanceof ArrayBuffer||R instanceof Uint8Array){let $=R instanceof Uint8Array?R:new Uint8Array(R);G?.(U,$,!0)}else G?.(U,String(R),!1)},F.prototype.close=function(R,U){if(this.readyState===3||this.readyState===2)return;this.readyState=2;let Z=this._wsId;K?.(Z,R,U)},F.CONNECTING=0,F.OPEN=1,F.CLOSING=2,F.CLOSED=3,F.prototype.CONNECTING=0,F.prototype.OPEN=1,F.prototype.CLOSING=2,F.prototype.CLOSED=3,Q.WebSocket=F}Q.setTimeout=(J,G,...K)=>{if(typeof J!==\"function\")return 0;return Y.setTimer?.(()=>J(...K),Number(G?\?0),!1)?\?0};Q.clearTimeout=(J)=>{if(typeof J===\"number\")Y.clearTimer?.(J)};Q.setInterval=(J,G,...K)=>{if(typeof J!==\"function\")return 0;return Y.setTimer?.(()=>J(...K),Number(G?\?0),!0)?\?0};Q.clearInterval=Q.clearTimeout;Q.postMessage=(J)=>{Y.postMessage?.(J)};Q.close=()=>{Y.closeWorker?.()};if(typeof Q.crypto>\"u\")Q.crypto={getRandomValues:(J)=>Y.getRandomValues?.(J)?\?J,randomUUID:()=>Y.randomUUID?.()?\?\"00000000-0000-0000-0000-000000000000\"};{let{Headers:J,TextEncoder:G}=Q,K=(O,V,X,N)=>{let F=J?new J(N):N,R=!1,U=()=>{if(R)throw TypeError(\"Body already consumed\");return R=!0,O};return{ok:V>=200&&V<300,status:V,statusText:X,headers:F,url:\"\",redirected:!1,type:\"basic\",bodyUsed:!1,text:()=>{let Z=U();return Promise.resolve(Z)},json:()=>{let Z=U();return Promise.resolve(JSON.parse(Z))},arrayBuffer:()=>{let Z=U();if(G){let P=new G;return Promise.resolve(P.encode(Z).buffer)}let $=new ArrayBuffer(Z.length),M=new Uint8Array($);for(let P=0;P<Z.length;P++)M[P]=Z.charCodeAt(P)&255;return Promise.resolve($)},blob:()=>Promise.reject(Error(\"Blob not supported in this context\")),clone:()=>K(O,V,X,N)}};if(typeof Q.fetch>\"u\")Q.fetch=(O,V)=>new Promise((X,N)=>{let F=\"\",R=\"GET\",U={},Z;if(typeof O===\"string\")F=O;else if(O&&typeof O===\"object\"){let $=O;if(typeof $.url===\"string\")F=$.url,R=$.method||\"GET\",Z=$.body;else if(typeof $.href===\"string\")F=$.href}if(V){if(V.method)R=V.method;if(V.body)if(typeof V.body===\"string\")Z=V.body;else if(V.body instanceof ArrayBuffer||V.body instanceof Uint8Array){let $=V.body instanceof Uint8Array?V.body:new Uint8Array(V.body),M=Q.TextDecoder;Z=M?new M().decode($):String.fromCharCode(...$)}else Z=JSON.stringify(V.body);if(V.headers&&typeof V.headers===\"object\")if(typeof V.headers.forEach===\"function\")V.headers.forEach(($,M)=>{U[M]=String($)});else for(let[$,M]of Object.entries(V.headers))U[$]=String(M)}if(!Y.fetch)return N(Error(\"fetch not available\"));Y.fetch(F,{method:R,headers:U,body:Z},($)=>{let M=$.body?\?\"\";if($.body_base64&&typeof Q.atob===\"function\")try{M=Q.atob($.body_base64)}catch{}X(K(M,$.status,$.statusText,$.headers))},($)=>N(Error($)))})}var z={},u=0,W=`ctx-${Date.now()}-${Math.random().toString(36).slice(2)}`,E=()=>String(Q.__zappWorkerDispatchId?\?\"\"),I=Object.freeze({emit:(J,G)=>{return Y.emitToHost?.(J,G),!0},invoke:(J,G)=>{return Y.invokeToHost?.(J,G),!0},on:(J,G)=>{let K=++u;return(z[J]?\?=[]).push({id:K,fn:G}),()=>{z[J]=(z[J]?\?[]).filter((O)=>O.id!==K)}}});try{Object.defineProperty(Q,\"__zapp\",{value:I,enumerable:!0,configurable:!1,writable:!1})}catch{Q.__zapp=I}var A={};Q.send=(J,G)=>{Q.postMessage({__zapp_channel:J,data:G})};Q.receive=(J,G)=>{return(A[J]?\?=[]).push(G),()=>{A[J]=(A[J]?\?[]).filter((K)=>K!==G)}};var _={};Y.syncWait=(J)=>new Promise((G,K)=>{let O=typeof J?.key===\"string\"?J.key.trim():\"\";if(!O){K(Error(\"Sync key must be a non-empty string.\"));return}if(J?.signal?.aborted){K(Error(\"Sync wait aborted.\"));return}let V=`${W}:sync-${Date.now()}-${Math.random().toString(36).slice(2)}`,X=J?.timeoutMs==null?null:Math.max(1,Math.min(300000,Math.floor(Number(J.timeoutMs)))),N=X==null?void 0:Q.setTimeout(()=>{delete _[V],K(Error(\"Sync wait transport timed out.\"))},X+5000);if(_[V]={resolve:G,reject:K,timer:N},v?.({id:V,key:O,timeoutMs:X,targetWorkerId:E()}),J?.signal?.addEventListener)J.signal.addEventListener(\"abort\",()=>{let F=_[V];if(!F)return;if(F.timer)Q.clearTimeout(F.timer);delete _[V],q?.({id:V,targetWorkerId:E()}),K(Error(\"Sync wait aborted.\"))})});Y.syncNotify=(J)=>{let G=typeof J?.key===\"string\"?J.key.trim():\"\";if(!G)return!1;return y?.({key:G,count:Math.max(1,Math.min(65535,Math.floor(Number(J?.count?\?1)))),targetWorkerId:E()})?\?!1};Y.syncCancel=(J)=>{let G=typeof J?.id===\"string\"?J.id.trim():\"\";if(!G)return!1;return q?.({id:G,targetWorkerId:E()})?\?!1};var x={},c=0;Y.windowCreate=(J)=>new Promise((G,K)=>{let O=`${W}:win-${++c}`,V=Q.setTimeout(()=>{delete x[O],K(Error(\"Window creation timed out.\"))},15000);x[O]={resolve:G,reject:K,timer:V},Y.emitToHost?.(\"__zapp_window_create\",JSON.stringify({requestId:O,options:J}))});Y.windowAction=(J,G,K)=>{Y.emitToHost?.(\"__zapp_window_action\",JSON.stringify({windowId:J,action:G,...K}))};Y.appAction=(J)=>{Y.emitToHost?.(\"__zapp_app_action\",JSON.stringify({action:J}))};Y.dispatchWindowResult=(J)=>{let G=J;if(typeof G===\"string\")try{G=JSON.parse(G)}catch{return}if(!G||typeof G!==\"object\")return;let K=G;if(typeof K.requestId!==\"string\")return;let O=x[K.requestId];if(!O)return;if(O.timer)Q.clearTimeout(O.timer);if(delete x[K.requestId],K.ok===!1)O.reject(Error(K.error?\?\"Window creation failed.\"));else O.resolve({id:K.id?\?\"\"})};try{Object.defineProperty(Q,Symbol.for(\"zapp.bridge\"),{value:Y,enumerable:!1,configurable:!0,writable:!1})}catch{Q[Symbol.for(\"zapp.bridge\")]=Y}var H=new Map;Y.dispatchMessage=(J,G)=>{if(J&&typeof J===\"object\"&&J.__zapp_channel){let{__zapp_channel:O,data:V}=J,X=(N,F)=>{if(G)Y.postMessage?.({__zapp_channel:N,data:F},G);else Q.postMessage({__zapp_channel:N,data:F})};for(let N of(A[O]?\?[]).slice())try{N(V,X)}catch{}return}let K=typeof Q.MessageEvent===\"function\"?new Q.MessageEvent(\"message\",{data:J}):{type:\"message\",data:J};if(typeof Q.onmessage===\"function\")try{Q.onmessage(K)}catch(O){j(O)}};Y.dispatchConnect=(J)=>{let G={_id:J,postMessage:(O)=>Y.postMessage?.(O,J),onmessage:null,onclose:null,start(){},close(){}};H.set(J,G);let K=typeof Q.MessageEvent===\"function\"?new Q.MessageEvent(\"connect\",{ports:[G]}):{type:\"connect\",ports:[G]};if(typeof Q.onconnect===\"function\")try{Q.onconnect(K)}catch(O){j(O)}};Y.dispatchDisconnect=(J)=>{let G=H.get(J);if(G){if(G.onclose)try{G.onclose({type:\"close\"})}catch{}H.delete(J)}};Y.dispatchSyncResult=(J)=>{let G=J;if(typeof G===\"string\")try{G=JSON.parse(G)}catch{return}if(!G||typeof G!==\"object\")return;let K=G;if(typeof K.id!==\"string\"||!K.id)return;let O=_[K.id];if(!O)return;if(O.timer)Q.clearTimeout(O.timer);if(delete _[K.id],!K.ok){O.reject(Error(\"Sync wait failed.\"));return}if(K.status===\"cancelled\"){O.reject(Error(\"Sync wait aborted.\"));return}O.resolve(K.status===\"timed-out\"?\"timed-out\":\"notified\")};Y.deliverEvent=(J,G)=>{let K=z[J];if(!K||K.length===0)return;let O=G;if(typeof O===\"string\")try{O=JSON.parse(O)}catch{}if(O&&typeof O===\"object\"){let V=O;if(V.__zapp_internal_meta){if(V.__zapp_internal_meta.sourceCtxId===W)return;O=V.data}}for(let V of K.slice())try{V.fn(O)}catch(X){j(X)}};})();\n";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Engine adapter for JSC: context lifecycle + eval. Backend (jsc) calls these.
|
|
2
|
+
// See WORKERS.md "Where to start implementation" and WORKERS_PROTOCOL.md §4.
|
|
3
|
+
|
|
4
|
+
//> macos: framework: JavaScriptCore
|
|
5
|
+
//> macos: framework: Cocoa
|
|
6
|
+
|
|
7
|
+
struct EngineJsc {}
|
|
8
|
+
|
|
9
|
+
raw {
|
|
10
|
+
#if !defined(ZAPP_WORKER_ENGINE_QJS)
|
|
11
|
+
#ifdef __APPLE__
|
|
12
|
+
#include <Cocoa/Cocoa.h>
|
|
13
|
+
#include <JavaScriptCore/JavaScriptCore.h>
|
|
14
|
+
#include <dispatch/dispatch.h>
|
|
15
|
+
#include <string.h>
|
|
16
|
+
|
|
17
|
+
static NSString* g_engine_jsc_last_exception_message = nil;
|
|
18
|
+
|
|
19
|
+
void* engine_jsc_create_ctx(void* vm, const char* name) {
|
|
20
|
+
if (!vm) return NULL;
|
|
21
|
+
JSVirtualMachine* jvm = (__bridge JSVirtualMachine*)vm;
|
|
22
|
+
JSContext* ctx = [[JSContext alloc] initWithVirtualMachine:jvm];
|
|
23
|
+
if (!ctx) return NULL;
|
|
24
|
+
if (name && name[0]) {
|
|
25
|
+
ctx.name = [NSString stringWithUTF8String:name];
|
|
26
|
+
}
|
|
27
|
+
return (__bridge_retained void*)ctx;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
int engine_jsc_eval(void* ctx_opaque, const char* utf8, size_t len, const char* filename) {
|
|
31
|
+
if (!ctx_opaque || !utf8) return -1;
|
|
32
|
+
g_engine_jsc_last_exception_message = nil;
|
|
33
|
+
JSContext* ctx = (__bridge JSContext*)ctx_opaque;
|
|
34
|
+
NSString* source = [[NSString alloc] initWithBytes:utf8 length:len encoding:NSUTF8StringEncoding];
|
|
35
|
+
if (!source) {
|
|
36
|
+
g_engine_jsc_last_exception_message = @"SyntaxError: invalid UTF-8 sequence";
|
|
37
|
+
return -1;
|
|
38
|
+
}
|
|
39
|
+
NSURL* url = filename && filename[0] ? [NSURL URLWithString:[NSString stringWithUTF8String:filename]] : nil;
|
|
40
|
+
if (url) {
|
|
41
|
+
[ctx evaluateScript:source withSourceURL:url];
|
|
42
|
+
} else {
|
|
43
|
+
[ctx evaluateScript:source];
|
|
44
|
+
}
|
|
45
|
+
if (ctx.exception) {
|
|
46
|
+
g_engine_jsc_last_exception_message = [ctx.exception toString];
|
|
47
|
+
return -1;
|
|
48
|
+
}
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const char* engine_jsc_get_exception_message(void* ctx_opaque) {
|
|
53
|
+
(void)ctx_opaque;
|
|
54
|
+
if (!g_engine_jsc_last_exception_message) return NULL;
|
|
55
|
+
return [g_engine_jsc_last_exception_message UTF8String];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void engine_jsc_free_ctx(void* ctx_opaque, void* vm_opaque, const char* new_name) {
|
|
59
|
+
if (!ctx_opaque) return;
|
|
60
|
+
JSContext* ctx = (__bridge_transfer JSContext*)ctx_opaque;
|
|
61
|
+
ctx.exceptionHandler = nil;
|
|
62
|
+
[ctx evaluateScript:@"\
|
|
63
|
+
delete globalThis[Symbol.for('zapp.bridge')];\
|
|
64
|
+
delete globalThis.__zappBridge;\
|
|
65
|
+
delete globalThis.__zappWorkerDispatchId;\
|
|
66
|
+
"];
|
|
67
|
+
ctx[@"__zappBridge"] = [NSNull null];
|
|
68
|
+
ctx[@"self"] = [NSNull null];
|
|
69
|
+
ctx[@"globalThis"] = [NSNull null];
|
|
70
|
+
if (new_name && new_name[0]) {
|
|
71
|
+
ctx.name = [NSString stringWithUTF8String:new_name];
|
|
72
|
+
}
|
|
73
|
+
if (@available(macOS 13.3, *)) {
|
|
74
|
+
ctx.inspectable = NO;
|
|
75
|
+
}
|
|
76
|
+
JSGarbageCollect(ctx.JSGlobalContextRef);
|
|
77
|
+
if (vm_opaque) {
|
|
78
|
+
JSVirtualMachine* jvm = (__bridge JSVirtualMachine*)vm_opaque;
|
|
79
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
80
|
+
[jvm performSelector:@selector(garbageCollect) withObject:nil afterDelay:0.1];
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
#endif /* __APPLE__ */
|
|
85
|
+
#endif
|
|
86
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Engine adapter for QJS: context lifecycle + eval. Backend (qjs) calls
|
|
2
|
+
// these. See WORKERS.md "Where to start implementation" and WORKERS_PROTOCOL.md
|
|
3
|
+
// §4.
|
|
4
|
+
|
|
5
|
+
struct EngineQjs {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
raw {
|
|
9
|
+
#ifdef __APPLE__
|
|
10
|
+
#ifdef ZAPP_WORKER_ENGINE_QJS
|
|
11
|
+
/* Rename QuickJS types to avoid conflict with JavaScriptCore (Cocoa/WebKit) in
|
|
12
|
+
* same translation unit */
|
|
13
|
+
#define JSContext QJSContext
|
|
14
|
+
#define JSRuntime QJSRuntime
|
|
15
|
+
#define JSValue QJSValue
|
|
16
|
+
#define JSClassID QJSClassID
|
|
17
|
+
#define JSClassDef QJSClassDef
|
|
18
|
+
#define JSClassEx QJSClassEx
|
|
19
|
+
#define JSValueConst QJSValueConst
|
|
20
|
+
#define JSPropertyEnum QJSPropertyEnum
|
|
21
|
+
#define JSPropertyDescriptor QJSPropertyDescriptor
|
|
22
|
+
#include "quickjs.h"
|
|
23
|
+
#include "quickjs-libc.h"
|
|
24
|
+
#undef JSContext
|
|
25
|
+
#undef JSRuntime
|
|
26
|
+
#undef JSValue
|
|
27
|
+
#undef JSClassID
|
|
28
|
+
#undef JSClassDef
|
|
29
|
+
#undef JSClassEx
|
|
30
|
+
#undef JSValueConst
|
|
31
|
+
#undef JSPropertyEnum
|
|
32
|
+
#undef JSPropertyDescriptor
|
|
33
|
+
#include <string.h>
|
|
34
|
+
|
|
35
|
+
#define ENGINE_QJS_MSG_MAX 4096
|
|
36
|
+
static char g_engine_qjs_last_message[ENGINE_QJS_MSG_MAX] = {0};
|
|
37
|
+
|
|
38
|
+
void *engine_qjs_create_ctx(void *rt) {
|
|
39
|
+
if (!rt)
|
|
40
|
+
return NULL;
|
|
41
|
+
QJSRuntime *qrt = (QJSRuntime *)rt;
|
|
42
|
+
QJSContext *ctx = JS_NewContext(qrt);
|
|
43
|
+
if (!ctx)
|
|
44
|
+
return NULL;
|
|
45
|
+
js_std_add_helpers(ctx, 0, NULL);
|
|
46
|
+
js_init_module_std(ctx, "std");
|
|
47
|
+
js_init_module_os(ctx, "os");
|
|
48
|
+
return (void *)ctx;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
int engine_qjs_eval(void *ctx_opaque, const char *utf8, size_t len,
|
|
52
|
+
const char *filename) {
|
|
53
|
+
if (!ctx_opaque || !utf8)
|
|
54
|
+
return -1;
|
|
55
|
+
g_engine_qjs_last_message[0] = '\0';
|
|
56
|
+
QJSContext *ctx = (QJSContext *)ctx_opaque;
|
|
57
|
+
QJSValue ret =
|
|
58
|
+
JS_Eval(ctx, utf8, (int)(len > 0x7fffffff ? 0x7fffffff : len),
|
|
59
|
+
filename ? filename : "<script>", JS_EVAL_TYPE_GLOBAL);
|
|
60
|
+
if (JS_IsException(ret)) {
|
|
61
|
+
QJSValue exc = JS_GetException(ctx);
|
|
62
|
+
const char *str = JS_ToCString(ctx, exc);
|
|
63
|
+
if (str) {
|
|
64
|
+
size_t n = strlen(str);
|
|
65
|
+
if (n >= ENGINE_QJS_MSG_MAX)
|
|
66
|
+
n = ENGINE_QJS_MSG_MAX - 1;
|
|
67
|
+
memcpy(g_engine_qjs_last_message, str, n);
|
|
68
|
+
g_engine_qjs_last_message[n] = '\0';
|
|
69
|
+
JS_FreeCString(ctx, str);
|
|
70
|
+
}
|
|
71
|
+
JS_FreeValue(ctx, exc);
|
|
72
|
+
JS_FreeValue(ctx, ret);
|
|
73
|
+
return -1;
|
|
74
|
+
}
|
|
75
|
+
JS_FreeValue(ctx, ret);
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const char *engine_qjs_get_exception_message(void *ctx_opaque) {
|
|
80
|
+
(void)ctx_opaque;
|
|
81
|
+
return g_engine_qjs_last_message[0] ? g_engine_qjs_last_message : NULL;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
void engine_qjs_free_ctx(void *ctx_opaque) {
|
|
85
|
+
if (!ctx_opaque)
|
|
86
|
+
return;
|
|
87
|
+
QJSContext *ctx = (QJSContext *)ctx_opaque;
|
|
88
|
+
JS_FreeContext(ctx);
|
|
89
|
+
}
|
|
90
|
+
#endif
|
|
91
|
+
#endif
|
|
92
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import "../platform.zc";
|
|
2
|
+
import "./worker/dispatch.zc";
|
|
3
|
+
import "./backend.zc";
|
|
4
|
+
|
|
5
|
+
// --- Baseline macOS Directives ---
|
|
6
|
+
//> macos: framework: Cocoa
|
|
7
|
+
//> macos: framework: WebKit
|
|
8
|
+
//> macos: framework: Foundation
|
|
9
|
+
//> macos: cflags: -fobjc-arc
|
|
10
|
+
// ---------------------------------
|
|
11
|
+
|
|
12
|
+
// Worker API: worker.zc selects JSC (default) or QuickJS implementation
|
|
13
|
+
import "./worker/mod.zc";
|
|
14
|
+
|
|
15
|
+
fn app_get_config(app_ptr: App*) -> AppConfig;
|
|
16
|
+
fn app_should_quit() -> bool;
|
|
17
|
+
|
|
18
|
+
raw {
|
|
19
|
+
#ifdef __APPLE__
|
|
20
|
+
extern bool app_should_quit(void);
|
|
21
|
+
static BOOL zapp_should_terminate_after_last_window_closed = NO;
|
|
22
|
+
static void zapp_set_should_terminate_after_last_window_closed(BOOL value) {
|
|
23
|
+
zapp_should_terminate_after_last_window_closed = value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@interface ZappAppDelegate : NSObject <NSApplicationDelegate>
|
|
27
|
+
@end
|
|
28
|
+
|
|
29
|
+
@implementation ZappAppDelegate
|
|
30
|
+
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)sender {
|
|
31
|
+
(void)sender;
|
|
32
|
+
if (!zapp_should_terminate_after_last_window_closed) return NO;
|
|
33
|
+
return app_should_quit() ? YES : NO;
|
|
34
|
+
}
|
|
35
|
+
@end
|
|
36
|
+
|
|
37
|
+
static id zapp_app_delegate = nil;
|
|
38
|
+
|
|
39
|
+
static void zapp_create_default_menu(void) {
|
|
40
|
+
NSMenu* mainMenu = [[NSMenu alloc] init];
|
|
41
|
+
|
|
42
|
+
// App menu
|
|
43
|
+
NSMenuItem* appMenuItem = [[NSMenuItem alloc] init];
|
|
44
|
+
NSMenu* appMenu = [[NSMenu alloc] init];
|
|
45
|
+
extern char* app_get_bootstrap_name(void);
|
|
46
|
+
const char* nameC = app_get_bootstrap_name();
|
|
47
|
+
NSString* appName = nameC ? [NSString stringWithUTF8String:nameC] : @"Zapp";
|
|
48
|
+
|
|
49
|
+
[appMenu addItemWithTitle:[NSString stringWithFormat:@"About %@", appName]
|
|
50
|
+
action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
|
|
51
|
+
[appMenu addItem:[NSMenuItem separatorItem]];
|
|
52
|
+
[appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", appName]
|
|
53
|
+
action:@selector(hide:) keyEquivalent:@"h"];
|
|
54
|
+
NSMenuItem* hideOthers = [appMenu addItemWithTitle:@"Hide Others"
|
|
55
|
+
action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
|
|
56
|
+
[hideOthers setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand];
|
|
57
|
+
[appMenu addItemWithTitle:@"Show All"
|
|
58
|
+
action:@selector(unhideAllApplications:) keyEquivalent:@""];
|
|
59
|
+
[appMenu addItem:[NSMenuItem separatorItem]];
|
|
60
|
+
[appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %@", appName]
|
|
61
|
+
action:@selector(terminate:) keyEquivalent:@"q"];
|
|
62
|
+
[appMenuItem setSubmenu:appMenu];
|
|
63
|
+
[mainMenu addItem:appMenuItem];
|
|
64
|
+
|
|
65
|
+
// Edit menu
|
|
66
|
+
NSMenuItem* editMenuItem = [[NSMenuItem alloc] init];
|
|
67
|
+
NSMenu* editMenu = [[NSMenu alloc] initWithTitle:@"Edit"];
|
|
68
|
+
[editMenu addItemWithTitle:@"Undo" action:@selector(undo:) keyEquivalent:@"z"];
|
|
69
|
+
[editMenu addItemWithTitle:@"Redo" action:@selector(redo:) keyEquivalent:@"Z"];
|
|
70
|
+
[editMenu addItem:[NSMenuItem separatorItem]];
|
|
71
|
+
[editMenu addItemWithTitle:@"Cut" action:@selector(cut:) keyEquivalent:@"x"];
|
|
72
|
+
[editMenu addItemWithTitle:@"Copy" action:@selector(copy:) keyEquivalent:@"c"];
|
|
73
|
+
[editMenu addItemWithTitle:@"Paste" action:@selector(paste:) keyEquivalent:@"v"];
|
|
74
|
+
[editMenu addItemWithTitle:@"Select All" action:@selector(selectAll:) keyEquivalent:@"a"];
|
|
75
|
+
[editMenuItem setSubmenu:editMenu];
|
|
76
|
+
[mainMenu addItem:editMenuItem];
|
|
77
|
+
|
|
78
|
+
// View menu
|
|
79
|
+
NSMenuItem* viewMenuItem = [[NSMenuItem alloc] init];
|
|
80
|
+
NSMenu* viewMenu = [[NSMenu alloc] initWithTitle:@"View"];
|
|
81
|
+
NSMenuItem* fullScreenItem = [viewMenu addItemWithTitle:@"Enter Full Screen"
|
|
82
|
+
action:@selector(toggleFullScreen:) keyEquivalent:@"f"];
|
|
83
|
+
[fullScreenItem setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
|
|
84
|
+
[viewMenuItem setSubmenu:viewMenu];
|
|
85
|
+
[mainMenu addItem:viewMenuItem];
|
|
86
|
+
|
|
87
|
+
// Window menu
|
|
88
|
+
NSMenuItem* windowMenuItem = [[NSMenuItem alloc] init];
|
|
89
|
+
NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
|
|
90
|
+
[windowMenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
|
|
91
|
+
[windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
|
|
92
|
+
[windowMenu addItem:[NSMenuItem separatorItem]];
|
|
93
|
+
[windowMenu addItemWithTitle:@"Close Window" action:@selector(performClose:) keyEquivalent:@"w"];
|
|
94
|
+
[windowMenuItem setSubmenu:windowMenu];
|
|
95
|
+
[mainMenu addItem:windowMenuItem];
|
|
96
|
+
[NSApp setWindowsMenu:windowMenu];
|
|
97
|
+
|
|
98
|
+
[NSApp setMainMenu:mainMenu];
|
|
99
|
+
}
|
|
100
|
+
#endif
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
struct CocoaPlatform {
|
|
104
|
+
initialized: bool;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
impl Platform for CocoaPlatform {
|
|
108
|
+
fn init(self) -> void {
|
|
109
|
+
if self.initialized {
|
|
110
|
+
println "NSApplication already initialized";
|
|
111
|
+
} else {
|
|
112
|
+
raw {
|
|
113
|
+
#ifdef __APPLE__
|
|
114
|
+
NSApplication* nsApp = [NSApplication sharedApplication];
|
|
115
|
+
[nsApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
|
116
|
+
if (zapp_app_delegate == nil) {
|
|
117
|
+
zapp_app_delegate = [ZappAppDelegate new];
|
|
118
|
+
}
|
|
119
|
+
[nsApp setDelegate:zapp_app_delegate];
|
|
120
|
+
zapp_create_default_menu();
|
|
121
|
+
#endif
|
|
122
|
+
}
|
|
123
|
+
self.initialized = true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
fn run(self, app: App*) -> int {
|
|
128
|
+
self.init();
|
|
129
|
+
let cfg = app_get_config(app);
|
|
130
|
+
raw {
|
|
131
|
+
#ifdef __APPLE__
|
|
132
|
+
#include <stdlib.h>
|
|
133
|
+
#include <signal.h>
|
|
134
|
+
|
|
135
|
+
static dispatch_source_t zapp_sigint_source = nil;
|
|
136
|
+
if (zapp_sigint_source == nil) {
|
|
137
|
+
signal(SIGINT, SIG_IGN);
|
|
138
|
+
zapp_sigint_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGINT, 0, dispatch_get_main_queue());
|
|
139
|
+
dispatch_source_set_event_handler(zapp_sigint_source, ^{
|
|
140
|
+
if (app_should_quit()) {
|
|
141
|
+
exit(0);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
dispatch_resume(zapp_sigint_source);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
zapp_set_should_terminate_after_last_window_closed(
|
|
148
|
+
cfg.applicationShouldTerminateAfterLastWindowClosed ? YES : NO
|
|
149
|
+
);
|
|
150
|
+
[NSApp activateIgnoringOtherApps:YES];
|
|
151
|
+
[NSApp run];
|
|
152
|
+
#endif
|
|
153
|
+
}
|
|
154
|
+
return 0;
|
|
155
|
+
}
|
|
156
|
+
}
|