@zappdev/cli 0.5.0-alpha.0 → 0.5.0-alpha.2
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/native/app/app.zc +45 -6
- package/native/build.zc +2 -1
- package/package.json +1 -1
- package/src/init.ts +6 -6
- package/src/native.ts +28 -8
package/native/app/app.zc
CHANGED
|
@@ -38,7 +38,12 @@ fn app_get_bootstrap_name() -> string {
|
|
|
38
38
|
|
|
39
39
|
fn app_get_bootstrap_web_content_inspectable() -> bool {
|
|
40
40
|
let app = (App*)app_get_active();
|
|
41
|
-
if app
|
|
41
|
+
if app == NULL { return false; }
|
|
42
|
+
match app.config.inspectable {
|
|
43
|
+
ZappInspectable::On => { return true; },
|
|
44
|
+
ZappInspectable::Off => { return false; },
|
|
45
|
+
ZappInspectable::Auto => { return zapp_build_dev_tools_default() > 0; },
|
|
46
|
+
}
|
|
42
47
|
return false;
|
|
43
48
|
}
|
|
44
49
|
|
|
@@ -161,15 +166,47 @@ fn zapp_handle_message_from_window(app_ptr: void*, msg: string, window_id: int)
|
|
|
161
166
|
|
|
162
167
|
// Service bindings — provided by service/service.zc (imported via router.zc)
|
|
163
168
|
|
|
169
|
+
// Whether the webview inspector (devtools) is available.
|
|
170
|
+
// Auto — inherit from build mode (dev → on, prod → off)
|
|
171
|
+
// On — always available (useful for debugging)
|
|
172
|
+
// Off — never available (hardened production)
|
|
173
|
+
enum ZappInspectable {
|
|
174
|
+
Auto,
|
|
175
|
+
On,
|
|
176
|
+
Off,
|
|
177
|
+
}
|
|
178
|
+
|
|
164
179
|
struct AppConfig {
|
|
165
180
|
name: string;
|
|
166
181
|
applicationShouldTerminateAfterLastWindowClosed: bool;
|
|
167
|
-
|
|
182
|
+
inspectable: ZappInspectable;
|
|
168
183
|
maxWorkers: int;
|
|
169
184
|
qjsStackSize: int;
|
|
170
185
|
backend: bool; // enable backend worker (src/backend.ts)
|
|
171
186
|
}
|
|
172
187
|
|
|
188
|
+
// ---------------------------------------------------------------------------
|
|
189
|
+
// Zapp namespace — convenience accessors for framework enums and values.
|
|
190
|
+
//
|
|
191
|
+
// Usage:
|
|
192
|
+
// inspectable: Zapp::inspectable_auto(),
|
|
193
|
+
// inspectable: Zapp::inspectable_on(),
|
|
194
|
+
// inspectable: Zapp::inspectable_off(),
|
|
195
|
+
//
|
|
196
|
+
// These return the proper enum type so you get match exhaustiveness and
|
|
197
|
+
// type checking. The enum constructors also work directly if you prefer:
|
|
198
|
+
// inspectable: ZappInspectable::Auto(),
|
|
199
|
+
//
|
|
200
|
+
// As Zapp adds more framework-level options (log levels, security modes,
|
|
201
|
+
// etc.), new accessors will appear here under the same Zapp:: namespace.
|
|
202
|
+
// ---------------------------------------------------------------------------
|
|
203
|
+
struct Zapp {}
|
|
204
|
+
impl Zapp {
|
|
205
|
+
fn inspectable_auto() -> ZappInspectable { return ZappInspectable::Auto(); }
|
|
206
|
+
fn inspectable_on() -> ZappInspectable { return ZappInspectable::On(); }
|
|
207
|
+
fn inspectable_off() -> ZappInspectable { return ZappInspectable::Off(); }
|
|
208
|
+
}
|
|
209
|
+
|
|
173
210
|
struct App {
|
|
174
211
|
config: AppConfig;
|
|
175
212
|
window: WindowManager;
|
|
@@ -184,10 +221,12 @@ struct App {
|
|
|
184
221
|
impl App {
|
|
185
222
|
fn new(config: AppConfig) -> App {
|
|
186
223
|
let wm = WindowManager::new();
|
|
187
|
-
|
|
188
|
-
wm.webContentInspectable = true;
|
|
189
|
-
|
|
190
|
-
|
|
224
|
+
match config.inspectable {
|
|
225
|
+
ZappInspectable::On => { wm.webContentInspectable = true; },
|
|
226
|
+
ZappInspectable::Off => { wm.webContentInspectable = false; },
|
|
227
|
+
ZappInspectable::Auto => {
|
|
228
|
+
wm.webContentInspectable = zapp_build_dev_tools_default() > 0;
|
|
229
|
+
},
|
|
191
230
|
}
|
|
192
231
|
|
|
193
232
|
platform_init(config.name);
|
package/native/build.zc
CHANGED
|
@@ -53,9 +53,10 @@ fn main() -> int {
|
|
|
53
53
|
let config = AppConfig{
|
|
54
54
|
name: "Zapp v2 Test",
|
|
55
55
|
applicationShouldTerminateAfterLastWindowClosed: true,
|
|
56
|
-
|
|
56
|
+
inspectable: Zapp::inspectable_on(),
|
|
57
57
|
maxWorkers: 0,
|
|
58
58
|
qjsStackSize: 0,
|
|
59
|
+
backend: false,
|
|
59
60
|
};
|
|
60
61
|
let app = App::new(config);
|
|
61
62
|
|
package/package.json
CHANGED
package/src/init.ts
CHANGED
|
@@ -39,8 +39,8 @@ export async function runInit(opts: InitOptions) {
|
|
|
39
39
|
|
|
40
40
|
await Bun.write(path.join(zappDir, "app.zc"), `import "app/app.zc";
|
|
41
41
|
|
|
42
|
-
fn greet(_app: App*,
|
|
43
|
-
return
|
|
42
|
+
fn greet(_app: App*, _args: JsonValue*) -> string {
|
|
43
|
+
return "Hello from Zapp!";
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
fn on_ready(_id: int, _handle: void*) -> void {
|
|
@@ -51,7 +51,7 @@ fn run_app() -> int {
|
|
|
51
51
|
let config = AppConfig{
|
|
52
52
|
name: "${name}",
|
|
53
53
|
applicationShouldTerminateAfterLastWindowClosed: true,
|
|
54
|
-
|
|
54
|
+
inspectable: Zapp::inspectable_auto(),
|
|
55
55
|
maxWorkers: 0,
|
|
56
56
|
qjsStackSize: 0,
|
|
57
57
|
backend: false,
|
|
@@ -122,12 +122,12 @@ fn main() -> int {
|
|
|
122
122
|
|
|
123
123
|
pkgObj.dependencies = {
|
|
124
124
|
...(pkgObj.dependencies ?? {}),
|
|
125
|
-
"@zappdev/runtime": "
|
|
125
|
+
"@zappdev/runtime": "^0.5.0",
|
|
126
126
|
};
|
|
127
127
|
pkgObj.devDependencies = {
|
|
128
128
|
...(pkgObj.devDependencies ?? {}),
|
|
129
|
-
"@zappdev/cli": "
|
|
130
|
-
"@zappdev/vite": "
|
|
129
|
+
"@zappdev/cli": "^0.5.0",
|
|
130
|
+
"@zappdev/vite": "^0.5.0",
|
|
131
131
|
};
|
|
132
132
|
|
|
133
133
|
await Bun.write(pkgPath, JSON.stringify(pkgObj, null, 2));
|
package/src/native.ts
CHANGED
|
@@ -103,6 +103,8 @@ export async function compileNative(opts: CompileOptions): Promise<void> {
|
|
|
103
103
|
const { generatePlatformConfig } = await import("./build-config");
|
|
104
104
|
const platformFile = await generatePlatformConfig(root);
|
|
105
105
|
|
|
106
|
+
const verbose = process.argv.includes("--verbose") || process.argv.includes("-v");
|
|
107
|
+
|
|
106
108
|
const zcArgs = [
|
|
107
109
|
"build",
|
|
108
110
|
buildFile,
|
|
@@ -112,21 +114,39 @@ export async function compileNative(opts: CompileOptions): Promise<void> {
|
|
|
112
114
|
...(assetsFile ? [assetsFile] : []),
|
|
113
115
|
"-I", nativeDir,
|
|
114
116
|
"-o", output,
|
|
117
|
+
// Suppress C compiler warnings by default. The framework and zc stdlib
|
|
118
|
+
// generate ~200 warnings (parentheses-equality, incompatible-pointer-types,
|
|
119
|
+
// etc.) that are pure noise for end users and bury any actual error.
|
|
120
|
+
// Pass --verbose to see them.
|
|
121
|
+
...(verbose ? [] : ["-w"]),
|
|
115
122
|
];
|
|
116
123
|
|
|
117
|
-
// Size optimizations deferred for v2 baseline.
|
|
118
|
-
// When re-introduced: -Oz, -flto, --no-debug, strip
|
|
119
|
-
|
|
120
|
-
// Debug: uncomment to see zc invocation
|
|
121
|
-
// process.stderr.write(`[zapp] zc ${zcArgs.join(" ")}\n`);
|
|
122
124
|
const proc = Bun.spawn(["zc", ...zcArgs], {
|
|
123
125
|
cwd: root,
|
|
124
|
-
stdout: "inherit",
|
|
125
|
-
stderr: "
|
|
126
|
+
stdout: verbose ? "inherit" : "pipe",
|
|
127
|
+
stderr: "pipe",
|
|
126
128
|
});
|
|
129
|
+
|
|
130
|
+
const [stdoutText, stderrText] = await Promise.all([
|
|
131
|
+
verbose ? "" : new Response(proc.stdout).text(),
|
|
132
|
+
new Response(proc.stderr).text(),
|
|
133
|
+
]);
|
|
134
|
+
|
|
127
135
|
const exitCode = await proc.exited;
|
|
128
136
|
if (exitCode !== 0) {
|
|
129
|
-
|
|
137
|
+
// Show only error lines (not warnings) unless verbose.
|
|
138
|
+
if (!verbose && stderrText) {
|
|
139
|
+
const errors = stderrText.split("\n").filter(
|
|
140
|
+
line => line.includes("error:") || line.includes("error :") || line.startsWith(" ")
|
|
141
|
+
);
|
|
142
|
+
if (errors.length > 0) {
|
|
143
|
+
process.stderr.write(errors.join("\n") + "\n");
|
|
144
|
+
} else {
|
|
145
|
+
// Fallback: show everything if we couldn't filter.
|
|
146
|
+
process.stderr.write(stderrText);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
throw new Error(`[zapp] compilation failed (exit ${exitCode}). Run with --verbose for full output.`);
|
|
130
150
|
}
|
|
131
151
|
|
|
132
152
|
// Strip deferred for v2 baseline
|