diff --git a/plugins/markdown/src/md/net_image.zig b/plugins/markdown/src/md/net_image.zig index 98b012868..bb1f6486f 100644 --- a/plugins/markdown/src/md/net_image.zig +++ b/plugins/markdown/src/md/net_image.zig @@ -26,10 +26,9 @@ const is_wasm = builtin.target.cpu.arch == .wasm32; pub const fetch_supported = true; /// The browser rasterizes SVG for us (the page reads its pixels, through the image proxy when -/// the host sends no CORS header). Native cannot — dvui's `svgToTvg` mangles every real badge — so -/// SVG -/// URLs are skipped there instead of fetched. The preview uses this to decide -/// *before* a fetch, so a `.svg` badge never becomes the "open" fallback link. +/// the host sends no CORS header). Native cannot — dvui's `svgToTvg` mangles every real badge — +/// so SVG URLs are skipped there instead of fetched. The preview uses this to decide *before* a +/// fetch, so a `.svg` badge never becomes the "open" fallback link. pub const rasterizes_svg = is_wasm; pub const Status = enum(u8) { fetching, ready, failed }; diff --git a/sdk/build.zig b/sdk/build.zig index cb697e20a..30542ca76 100644 --- a/sdk/build.zig +++ b/sdk/build.zig @@ -3,8 +3,8 @@ const std = @import("std"); // Build-time surface of this package, for the app as well as third-party plugins. The app consumes -// `sdk/` as a dependency and reaches these through it (`@import("fizzy_sdk").plugin`) rather than by -// relative path: a file may belong to only one module, and importing these from the root build +// `sdk/` as a dependency and reaches these through it (`@import("fizzy_sdk").plugin`) rather than +// by relative path: a file may belong to only one module, and importing these from the root build // scripts by path would claim them for the root's build module and make this package unusable as a // dependency of it. Going through the dependency is also what lets the app share this package's // dvui instead of pinning its own — see `build/sdk.zig`'s `dvuiDependency`. diff --git a/sdk/core_module.zig b/sdk/core_module.zig index 3ae03e8ff..a02841a0e 100644 --- a/sdk/core_module.zig +++ b/sdk/core_module.zig @@ -73,7 +73,9 @@ pub fn addImports( /// package — so the access check below picks whichever layout is present. pub fn repoPath(b: *std.Build, sub_path: []const u8) std.Build.LazyPath { b.root.access(b.graph.io, sub_path, .{}) catch { - return .{ .cwd_relative = b.root.joinString(b.allocator, b.pathJoin(&.{ "..", sub_path })) catch @panic("OOM") }; + return .{ + .cwd_relative = b.root.joinString(b.allocator, b.pathJoin(&.{ "..", sub_path })) catch @panic("OOM"), + }; }; return b.path(sub_path); } diff --git a/sdk/plugin_sdk.zig b/sdk/plugin_sdk.zig index 787a0f6d1..077523bf4 100644 --- a/sdk/plugin_sdk.zig +++ b/sdk/plugin_sdk.zig @@ -3,7 +3,8 @@ //! Required in your project (see `docs/PLUGINS.md` §2): //! - `plugin.zig` — `register(host)` + `Plugin` vtable; read `sdk.allocator()` / `sdk.host()`. //! This is the module root: everything under `src/` imports it via relative paths, and the -//! shared deps (`fizzy_sdk`/`core`/`dvui`/`proxy_bridge`) are named imports (`@import("fizzy_sdk")`, …). +//! shared deps (`fizzy_sdk`/`core`/`dvui`/`proxy_bridge`) are named imports +//! (`@import("fizzy_sdk")`, …). //! - `plugin.zig.zon` — identity only (`id`/`name`/`version`/`min_sdk_version`). Read //! at configure time by `create` below; also embedded verbatim into the dylib (`fizzy_plugin_ //! manifest_zon`) so a disabled/unloaded plugin's identity can still be probed. There is no @@ -89,9 +90,16 @@ pub fn readManifest(b: *std.Build) IdentityManifest { fn readManifestAt(b: *std.Build, rel_path: []const u8) IdentityManifest { b.dependOnFileContents(b.path(rel_path)); - const raw = std.Io.Dir.cwd().readFileAlloc(b.graph.io, b.root.joinString(b.allocator, rel_path) catch @panic("OOM"), b.allocator, std.Io.Limit.limited(256 * 1024)) catch |e| + const raw = std.Io.Dir.cwd().readFileAlloc( + b.graph.io, + b.root.joinString(b.allocator, rel_path) catch @panic("OOM"), + b.allocator, + std.Io.Limit.limited(256 * 1024), + ) catch |e| std.debug.panic( - "fizzy: could not read {s}: {}\nEvery plugin needs a `plugin.zig.zon` manifest at its root (id/name/version) — see docs/PLUGINS.md.", + "fizzy: could not read {s}: {}\n" ++ + "Every plugin needs a `plugin.zig.zon` manifest at its root (id/name/version) — " ++ + "see docs/PLUGINS.md.", .{ rel_path, e }, ); const src = b.allocator.dupeSentinel(u8, raw, 0) catch @panic("OOM"); @@ -103,13 +111,25 @@ fn readManifestAt(b: *std.Build, rel_path: []const u8) IdentityManifest { }; // The build's allocator is freed only when the build ends: the manifest is read into it. var diag: std.zon.parse.Diagnostics = undefined; - const parsed = std.zon.parse.fromSlice(Target, .{ .gpa = b.allocator, .arena = b.allocator, .source = src, .diagnostics = &diag, .ignore_unknown_fields = true }) catch |e| + const parsed = std.zon.parse.fromSlice(Target, .{ + .gpa = b.allocator, + .arena = b.allocator, + .source = src, + .diagnostics = &diag, + .ignore_unknown_fields = true, + }) catch |e| std.debug.panic("fizzy: failed to parse {s}: {}", .{ rel_path, e }); _ = std.SemanticVersion.parse(parsed.version) catch - std.debug.panic("fizzy: {s} .version \"{s}\" is not valid semver (expected e.g. 1.2.3)", .{ rel_path, parsed.version }); + std.debug.panic( + "fizzy: {s} .version \"{s}\" is not valid semver (expected e.g. 1.2.3)", + .{ rel_path, parsed.version }, + ); if (parsed.min_sdk_version.len > 0) { _ = std.SemanticVersion.parse(parsed.min_sdk_version) catch - std.debug.panic("fizzy: {s} .min_sdk_version \"{s}\" is not valid semver", .{ rel_path, parsed.min_sdk_version }); + std.debug.panic( + "fizzy: {s} .min_sdk_version \"{s}\" is not valid semver", + .{ rel_path, parsed.min_sdk_version }, + ); } return .{ .id = parsed.id, @@ -264,7 +284,13 @@ pub const InstallBesideOptions = struct { /// fizzy.plugin.installBeside(b, helper_exe, .{ .plugin = "agent" }); pub fn installBeside(b: *std.Build, artifact: *std.Build.Step.Compile, opts: InstallBesideOptions) void { if (artifact.rootModuleTarget().cpu.arch == .wasm32) return; - addDevInstall(b, artifact, opts.plugin, artifact.out_filename, b.fmt("install '{s}' beside plugin '{s}'", .{ artifact.out_filename, opts.plugin })); + addDevInstall( + b, + artifact, + opts.plugin, + artifact.out_filename, + b.fmt("install '{s}' beside plugin '{s}'", .{ artifact.out_filename, opts.plugin }), + ); } /// The helper `addDevInstall` runs, one per builder however many artifacts it installs. Debug: @@ -288,7 +314,13 @@ var dev_install_exes: std.AutoHashMapUnmanaged(*std.Build, *std.Build.Step.Compi /// Copy `artifact` to `{plugins}/{dir_name}/{file_name}` on every `zig build install`, through /// `plugin_sdk_install.zig`: Zig 0.17's build has no custom steps. -fn addDevInstall(b: *std.Build, artifact: *std.Build.Step.Compile, dir_name: []const u8, file_name: []const u8, step_name: []const u8) void { +fn addDevInstall( + b: *std.Build, + artifact: *std.Build.Step.Compile, + dir_name: []const u8, + file_name: []const u8, + step_name: []const u8, +) void { const dev = b.addRunArtifact(devInstallExe(b)); dev.setName(step_name); dev.addArtifactArg(artifact); @@ -345,7 +377,10 @@ fn addSdkMeta(b: *std.Build, lib: *std.Build.Step.Compile) *std.Build.Step { fn addSdkCheck(b: *std.Build) *std.Build.Step { if (b.top_level_steps.get("check")) |existing| return &existing.step; - const step = b.step("check", "Print pinned fizzy SDK version + abi fingerprint (and catch legacy release.yml drift)"); + const step = b.step( + "check", + "Print pinned fizzy SDK version + abi fingerprint (and catch legacy release.yml drift)", + ); const release_yml = ".github/workflows/release.yml"; dependOnPathExistence(b, release_yml); @@ -371,7 +406,11 @@ fn addSdkCheck(b: *std.Build) *std.Build.Step { /// without regard to the environment, so a variable read here would be seen once and then ignored. fn pluginUseLlvm(b: *std.Build) ?bool { const gop = plugin_use_llvm.getOrPut(b.allocator, b) catch @panic("OOM"); - if (!gop.found_existing) gop.value_ptr.* = b.option(bool, "plugin-use-llvm", "Force (true) or forbid (false) LLVM for plugin builds; unset, Zig chooses"); + if (!gop.found_existing) gop.value_ptr.* = b.option( + bool, + "plugin-use-llvm", + "Force (true) or forbid (false) LLVM for plugin builds; unset, Zig chooses", + ); return gop.value_ptr.*; } var plugin_use_llvm: std.AutoHashMapUnmanaged(*std.Build, ?bool) = .empty; @@ -561,7 +600,10 @@ pub fn create(b: *std.Build, opts: CreateOptions) PluginArtifact { .link_libc = opts.link_libc and opts.target.result.cpu.arch != .wasm32, }); static_module.addAnonymousImport("plugin_zon", .{ .root_source_file = b.path("plugin.zig.zon") }); - static_module.addOptions(plugin_options_import, pluginOptions(b, m.id, m.name, m.version, m.min_sdk_version, m.raw)); + static_module.addOptions( + plugin_options_import, + pluginOptions(b, m.id, m.name, m.version, m.min_sdk_version, m.raw), + ); return .{ .lib = lib, .module = plugin_module, .static = static_module }; } diff --git a/sdk/replay_module.zig b/sdk/replay_module.zig index 2304ba916..322c5d4f9 100644 --- a/sdk/replay_module.zig +++ b/sdk/replay_module.zig @@ -7,7 +7,9 @@ //! //! ```zig //! const sdk = b.dependency("fizzy_sdk", .{}); -//! const automation = @import("fizzy_sdk").replay.modules(b, sdk.builder, my_dvui_module, target, optimize); +//! const automation = @import("fizzy_sdk").replay.modules( +//! b, sdk.builder, my_dvui_module, target, optimize, +//! ); //! exe.root_module.addImport("tape", automation.tape); //! exe.root_module.addImport("replay", automation.replay); //! ```