bun_options_types 0.1.0

A Rust-native programmable browser runtime built on Servo and SpiderMonkey
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
// GENERATED: re-run peechy (src/api/schema.peechy) with .rs output
// source: src/options_types/schema.zig (3224 lines)
// PORT STATUS: skipped — generated file (see PORTING.md §Don't translate)
//
// Minimal hand-stubbed `api` namespace so Context.rs / BundleEnums.rs
// struct fields type-check. Full body arrives when peechy emits .rs.

/// Port of `schema.Writer(WritableStream)` (schema.zig:169) specialised to a
/// `Vec<u8>` sink — the only instantiation reachable from Rust today
/// (`js_parser::runtime::Base64FallbackMessage::fmt`). The full generic shape
/// arrives with the peechy-generated body.
pub struct Writer<'a> {
    writable: &'a mut Vec<u8>,
}

impl<'a> Writer<'a> {
    #[inline]
    pub fn new(writable: &'a mut Vec<u8>) -> Self {
        Self { writable }
    }
    #[inline]
    pub fn write(&mut self, bytes: &[u8]) {
        self.writable.extend_from_slice(bytes);
    }
    #[inline]
    pub fn write_byte(&mut self, byte: u8) {
        self.writable.push(byte);
    }
    /// Zig: `writeInt` — `std.mem.asBytes(&int)` is native-endian raw bytes.
    #[inline]
    pub fn write_int<I: Copy>(&mut self, int: I) {
        // SAFETY: `int` is a live stack local, so `&raw const int` is valid for reads of
        // `size_of::<I>()` initialized bytes; `u8` has align 1 so the cast pointer is always
        // aligned; the slice is consumed by `extend_from_slice` before `int` leaves scope.
        let bytes = unsafe {
            core::slice::from_raw_parts((&raw const int).cast::<u8>(), core::mem::size_of::<I>())
        };
        self.writable.extend_from_slice(bytes);
    }
    #[inline]
    pub fn write_field_id(&mut self, id: u8) {
        self.write_byte(id);
    }
    #[inline]
    pub fn write_enum<E: Copy>(&mut self, val: E) {
        self.write_int(val);
    }
    /// Zig: `writeArray(u8, slice)` — length-prefixed byte slice.
    #[inline]
    pub fn write_array_u8(&mut self, slice: &[u8]) {
        self.write_int(u32::try_from(slice.len()).unwrap());
        self.write(slice);
    }
    #[inline]
    pub fn end_message(&mut self) {
        self.write_byte(0);
    }
}

pub mod api {
    /// schema.zig:1172 — canonical definition lives in bun_dotenv (lower tier).
    pub use bun_dotenv::DotEnvBehavior;

    /// schema.zig:711 — `enum(u8)` (open). Kept closed.
    /// Variants PascalCased to match the only downstream writers
    /// (`jsc/config.rs`, `runtime/cli/Arguments.rs` → `api::ResolveMode::Lazy`).
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
    pub enum ResolveMode {
        #[default]
        _none = 0,
        Disable = 1,
        Lazy = 2,
        Dev = 3,
        Bundle = 4,
    }

    /// schema.zig:2295 — `enum(u32)` (open). Kept closed.
    /// PascalCased: `bun_ast::Kind::to_api` matches on `Err`/`Warn`/`Note`/`Debug`.
    #[repr(u32)]
    #[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
    pub enum MessageLevel {
        #[default]
        _none = 0,
        Err = 1,
        Warn = 2,
        Note = 3,
        Info = 4,
        Debug = 5,
    }

    /// schema.zig:1622 — `enum(u8)` (closed; not a peechy `smol`).
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
    pub enum UnhandledRejections {
        Strict = 0,
        Throw = 1,
        Warn = 2,
        None = 3,
        WarnWithErrorCode = 4,
        #[default]
        Bun = 5,
    }

    impl UnhandledRejections {
        /// `UnhandledRejections.map` — `bun.ComptimeStringMap` → `phf::Map`.
        /// Note: Zig deliberately omits `"bun"` (it's the implicit default).
        pub const MAP: phf::Map<&'static [u8], UnhandledRejections> = phf::phf_map! {
            b"strict" => UnhandledRejections::Strict,
            b"throw" => UnhandledRejections::Throw,
            b"warn" => UnhandledRejections::Warn,
            b"none" => UnhandledRejections::None,
            b"warn-with-error-code" => UnhandledRejections::WarnWithErrorCode,
        };
    }

    /// schema.zig:1639 — peechy `message TransformOptions`. Full field set,
    /// hand-expanded so `bundler::options::BundleOptions::from_api` and the
    /// bunfig/CLI parsers can un-gate. Field order mirrors the Zig struct
    /// exactly so side-by-side diff stays readable.
    ///
    /// Type map (matches the convention block below):
    ///   `?T`                  → `Option<T>`
    ///   `[]const u8`          → `Box<[u8]>`
    ///   `?[]const u8`         → `Option<Box<[u8]>>`
    ///   `[]const []const u8`  → `Vec<Box<[u8]>>`
    ///   `?[:0]const u8`       → `Option<Box<[u8]>>`   (sentinel re-derived
    ///                            at use-site; see Context.rs `// TODO(port):
    ///                            owned ZStr repr` precedent)
    ///
    /// `Default` ⇔ `std.mem.zeroes(TransformOptions)` — every Option `None`,
    /// every slice empty, every scalar `0`/`false`.
    ///
    /// LIFECYCLE: `BundleOptions::from_api` parks this in an `Arc` whose final ref
    /// lives on the process-lifetime `Transpiler` (LSan-rooted in build_command.rs).
    #[derive(Clone, Debug, Default)]
    pub struct TransformOptions {
        /// jsx
        pub jsx: Option<Jsx>,
        /// tsconfig_override
        pub tsconfig_override: Option<Box<[u8]>>,
        /// resolve
        pub resolve: Option<ResolveMode>,
        /// origin
        pub origin: Option<Box<[u8]>>,
        /// absolute_working_dir — Zig `?[:0]const u8`; sentinel dropped (see
        /// type-map note above).
        pub absolute_working_dir: Option<Box<[u8]>>,
        /// define
        pub define: Option<StringMap>,
        /// drop
        pub drop: Vec<Box<[u8]>>,
        /// feature_flags — DCE via `import { feature } from "bun:bundle"`
        pub feature_flags: Vec<Box<[u8]>>,
        /// preserve_symlinks
        pub preserve_symlinks: Option<bool>,
        /// entry_points
        pub entry_points: Vec<Box<[u8]>>,
        /// write
        pub write: Option<bool>,
        /// inject
        pub inject: Vec<Box<[u8]>>,
        /// output_dir
        pub output_dir: Option<Box<[u8]>>,
        /// external
        pub external: Vec<Box<[u8]>>,
        /// loaders
        pub loaders: Option<LoaderMap>,
        /// main_fields
        pub main_fields: Vec<Box<[u8]>>,
        /// target
        pub target: Option<Target>,
        /// serve
        pub serve: Option<bool>,
        /// env_files
        pub env_files: Vec<Box<[u8]>>,
        /// disable_default_env_files
        pub disable_default_env_files: bool,
        /// extension_order
        pub extension_order: Vec<Box<[u8]>>,
        /// no_summary
        pub no_summary: Option<bool>,
        /// disable_hmr
        pub disable_hmr: bool,
        /// port
        pub port: Option<u16>,
        /// logLevel
        pub log_level: Option<MessageLevel>,
        /// source_map
        pub source_map: Option<SourceMapMode>,
        /// conditions
        pub conditions: Vec<Box<[u8]>>,
        /// packages
        pub packages: Option<PackagesMode>,
        /// ignore_dce_annotations
        pub ignore_dce_annotations: bool,

        /// e.g. `[serve.static] plugins = ["tailwindcss"]`
        pub serve_plugins: Option<Vec<Box<[u8]>>>,
        pub serve_minify_syntax: Option<bool>,
        pub serve_minify_whitespace: Option<bool>,
        pub serve_minify_identifiers: Option<bool>,
        pub serve_env_behavior: DotEnvBehavior,
        pub serve_env_prefix: Option<Box<[u8]>>,
        pub serve_splitting: bool,
        pub serve_public_path: Option<Box<[u8]>>,
        pub serve_hmr: Option<bool>,
        pub serve_define: Option<StringMap>,

        /// from `--no-addons`. `None` == `true`.
        pub allow_addons: Option<bool>,
        /// from `--unhandled-rejections`; default is `Bun`.
        pub unhandled_rejections: Option<UnhandledRejections>,

        pub bunfig_path: Box<[u8]>,
    }

    // ─── BunInstall + supporting types ───────────────────────────────────────

    /// schema.zig:2807 — `api.NpmRegistry`.
    /// `Default` ⇔ `std.mem.zeroes(NpmRegistry)` (empty slices).
    #[derive(Clone, Debug, Default)]
    pub struct NpmRegistry {
        /// url
        pub url: Box<[u8]>,
        /// username
        pub username: Box<[u8]>,
        /// password
        pub password: Box<[u8]>,
        /// token
        pub token: Box<[u8]>,
        /// email
        pub email: Box<[u8]>,
    }

    impl NpmRegistry {
        /// `NpmRegistry.dupe(allocator)` — Zig packs all five strings into one
        /// contiguous allocation and reslices. Rust can't hand back five
        /// `Box<[u8]>` views into one buffer without leaking, so this is a
        /// plain field-wise clone. PERF(port): could pack into a single buffer.
        #[inline]
        pub fn dupe(&self) -> NpmRegistry {
            self.clone()
        }
    }

    /// schema.zig:2956 — `scopes: bun.StringArrayHashMapUnmanaged(NpmRegistry)`.
    #[derive(Default)]
    pub struct NpmRegistryMap {
        pub scopes: bun_collections::StringArrayHashMap<NpmRegistry>,
    }

    /// schema.zig:3041 — anonymous `?union(enum) { str, list }` field on
    /// `BunInstall.ca`; hoisted to a named type so callers can construct it.
    #[derive(Clone, Debug)]
    pub enum Ca {
        Str(Box<[u8]>),
        List(Box<[Box<[u8]>]>),
    }

    /// `NodeLinker` / `PnpmMatcher` are canonical in `bun_install_types`
    /// (lower crate). Re-export so `BunInstall.node_linker` /
    /// `BunInstall.hoist_pattern` and `bun_ini`'s callers all name the
    /// same type.
    pub use bun_install_types::NodeLinker::{NodeLinker, PnpmMatcher};

    /// schema.zig:2973 — `api.BunInstall`. Full field set, order-faithful.
    /// `Default` ⇔ `std.mem.zeroes(Api.BunInstall)` (every field `None`/empty).
    ///
    /// No `Debug`/`Clone` derive: `NpmRegistryMap` wraps `StringArrayHashMap`
    /// which currently provides neither.
    #[derive(Default)]
    pub struct BunInstall {
        /// default_registry
        pub default_registry: Option<NpmRegistry>,
        /// scoped
        pub scoped: Option<NpmRegistryMap>,
        /// lockfile_path
        pub lockfile_path: Option<Box<[u8]>>,
        /// save_lockfile_path
        pub save_lockfile_path: Option<Box<[u8]>>,
        /// cache_directory
        pub cache_directory: Option<Box<[u8]>>,
        /// dry_run
        pub dry_run: Option<bool>,
        /// force
        pub force: Option<bool>,
        /// save_dev
        pub save_dev: Option<bool>,
        /// save_optional
        pub save_optional: Option<bool>,
        /// save_peer
        pub save_peer: Option<bool>,
        /// save_lockfile
        pub save_lockfile: Option<bool>,
        /// production
        pub production: Option<bool>,
        /// save_yarn_lockfile
        pub save_yarn_lockfile: Option<bool>,
        /// native_bin_links
        pub native_bin_links: Vec<Box<[u8]>>,
        /// disable_cache
        pub disable_cache: Option<bool>,
        /// disable_manifest_cache
        pub disable_manifest_cache: Option<bool>,
        /// global_dir
        pub global_dir: Option<Box<[u8]>>,
        /// global_bin_dir
        pub global_bin_dir: Option<Box<[u8]>>,
        /// frozen_lockfile
        pub frozen_lockfile: Option<bool>,
        /// exact
        pub exact: Option<bool>,
        /// concurrent_scripts
        pub concurrent_scripts: Option<u32>,

        pub cafile: Option<Box<[u8]>>,
        pub save_text_lockfile: Option<bool>,
        pub ca: Option<Ca>,
        pub ignore_scripts: Option<bool>,
        pub link_workspace_packages: Option<bool>,
        pub node_linker: Option<NodeLinker>,
        pub global_store: Option<bool>,
        pub security_scanner: Option<Box<[u8]>>,
        pub minimum_release_age_ms: Option<f64>,
        pub minimum_release_age_excludes: Option<Vec<Box<[u8]>>>,
        pub public_hoist_pattern: Option<PnpmMatcher>,
        pub hoist_pattern: Option<PnpmMatcher>,
    }

    /// schema.zig:1967 — `enum(u8)` (open). Generated body emits `_` open
    /// variant; Rust side keeps it closed since callers exhaustively match
    /// only the four named tags (see bundler/options.rs `SourceMapOption`).
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
    pub enum SourceMapMode {
        #[default]
        None,
        Inline,
        External,
        Linked,
    }

    /// schema.zig:732 — `enum(u8)` (open). Kept closed; `BundleEnums::Target::from`
    /// guards the open tail with a `_ => Browser` arm.
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
    pub enum Target {
        #[default]
        _none = 0,
        browser = 1,
        node = 2,
        bun = 3,
        bun_macro = 4,
    }

    impl Target {
        // PascalCase aliases — `runtime/cli/Arguments.rs` writes
        // `api::Target::Bun` while the schema enum body keeps the peechy
        // snake_case tags above.
        pub const Browser: Self = Self::browser;
        pub const Node: Self = Self::node;
        pub const Bun: Self = Self::bun;
        pub const BunMacro: Self = Self::bun_macro;
    }

    /// Alias: `runtime/cli/Arguments.rs` spells the schema type both ways.
    pub type SourceMap = SourceMapMode;
    /// Alias: `runtime/cli/Arguments.rs` spells the schema type both ways.
    pub type Packages = PackagesMode;

    /// schema.zig:325 — `enum(u8)` (open), `_none = 254`. Kept closed;
    /// `BundleEnums::Loader::from_api` guards the open tail with `_ => File`.
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
    pub enum Loader {
        #[default]
        _none = 254,
        jsx = 1,
        js = 2,
        ts = 3,
        tsx = 4,
        css = 5,
        file = 6,
        json = 7,
        jsonc = 8,
        toml = 9,
        wasm = 10,
        napi = 11,
        base64 = 12,
        dataurl = 13,
        text = 14,
        bunsh = 15,
        sqlite = 16,
        sqlite_embedded = 17,
        html = 18,
        yaml = 19,
        json5 = 20,
        md = 21,
    }

    impl Loader {
        /// Zig `@enumFromInt` for the schema `Loader` (open `enum(u8)` in Zig).
        /// Unknown discriminants fall back to `_none`, matching how
        /// `BundleEnums::Loader::from_api` already guards the open tail.
        #[inline]
        pub const fn from_raw(n: u8) -> Loader {
            match n {
                1 => Loader::jsx,
                2 => Loader::js,
                3 => Loader::ts,
                4 => Loader::tsx,
                5 => Loader::css,
                6 => Loader::file,
                7 => Loader::json,
                8 => Loader::jsonc,
                9 => Loader::toml,
                10 => Loader::wasm,
                11 => Loader::napi,
                12 => Loader::base64,
                13 => Loader::dataurl,
                14 => Loader::text,
                15 => Loader::bunsh,
                16 => Loader::sqlite,
                17 => Loader::sqlite_embedded,
                18 => Loader::html,
                19 => Loader::yaml,
                20 => Loader::json5,
                21 => Loader::md,
                _ => Loader::_none,
            }
        }
    }

    /// schema.zig:2200 — `enum(u8)` (open). Kept closed.
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
    pub enum ImportKind {
        #[default]
        _none = 0,
        entry_point = 1,
        stmt = 2,
        require = 3,
        dynamic = 4,
        require_resolve = 5,
        at = 6,
        url = 7,
        internal = 8,
    }

    // ─── peechy batch 2: hand-expanded for downstream wfs ────────────────
    // Jsx / JsxRuntime / StringMap / EnvConfig / LoadedEnvConfig /
    // LoadedRouteConfig / RouteConfig / FrameworkEntryPoint{,Type,Map,Message} /
    // PackagesMode / CssInJsBehavior / LoaderMap / LoadedFramework.
    //
    // String mapping (matches Context.rs convention — proc-lifetime borrows
    // ported as owned heap):
    //   `[]const u8`          → `Box<[u8]>`
    //   `[]const []const u8`  → `Vec<Box<[u8]>>`  (or `Box<[Box<[u8]>]>` where
    //                            downstream `.clone()` target requires it)
    //
    // Enum variant names are PascalCase (idiomatic Rust, matches downstream
    // callers in bundler/options.rs + router/lib.rs); `_none` retained as the
    // zero-tag default where the Zig schema has it. Full peechy `.rs` emit
    // will replace this block wholesale.

    /// schema.zig:771 — `enum(u8)` (open). Kept closed.
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
    pub enum JsxRuntime {
        #[default]
        _none = 0,
        Automatic = 1,
        Classic = 2,
        Solid = 3,
    }

    /// schema.zig:789
    #[derive(Clone, Debug, Default)]
    pub struct Jsx {
        pub factory: Box<[u8]>,
        pub runtime: JsxRuntime,
        pub fragment: Box<[u8]>,
        pub development: bool,
        pub import_source: Box<[u8]>,
        pub side_effects: bool,
    }

    /// schema.zig:1130
    #[derive(Clone, Debug, Default)]
    pub struct StringMap {
        pub keys: Vec<Box<[u8]>>,
        pub values: Vec<Box<[u8]>>,
    }

    impl StringMap {
        pub const EMPTY: StringMap = StringMap {
            keys: Vec::new(),
            values: Vec::new(),
        };
    }

    /// schema.zig:1151
    #[derive(Clone, Debug, Default)]
    pub struct LoaderMap {
        pub extensions: Vec<Box<[u8]>>,
        pub loaders: Vec<Loader>,
    }

    /// schema.zig:1193 — peechy `message` (all fields optional)
    #[derive(Clone, Debug, Default)]
    pub struct EnvConfig {
        pub prefix: Option<Box<[u8]>>,
        pub defaults: Option<StringMap>,
    }

    /// schema.zig:1247
    #[derive(Clone, Debug, Default)]
    pub struct LoadedEnvConfig {
        pub dotenv: DotEnvBehavior,
        pub defaults: StringMap,
        pub prefix: Box<[u8]>,
    }

    /// schema.zig:355 — `enum(u8)` (open). Kept closed.
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
    pub enum FrameworkEntryPointType {
        #[default]
        _none = 0,
        Client = 1,
        Server = 2,
        Fallback = 3,
    }

    /// schema.zig:1365
    #[derive(Clone, Debug, Default)]
    pub struct FrameworkEntryPoint {
        pub kind: FrameworkEntryPointType,
        pub path: Box<[u8]>,
        pub env: LoadedEnvConfig,
    }

    /// schema.zig:1391 — peechy `message` (all fields optional)
    #[derive(Clone, Debug, Default)]
    pub struct FrameworkEntryPointMap {
        pub client: Option<FrameworkEntryPoint>,
        pub server: Option<FrameworkEntryPoint>,
        pub fallback: Option<FrameworkEntryPoint>,
    }

    /// schema.zig:1444 — peechy `message` (all fields optional)
    #[derive(Clone, Debug, Default)]
    pub struct FrameworkEntryPointMessage {
        pub path: Option<Box<[u8]>>,
        pub env: Option<EnvConfig>,
    }

    /// schema.zig:1528
    #[derive(Clone, Debug, Default)]
    pub struct LoadedRouteConfig {
        pub dir: Box<[u8]>,
        pub extensions: Box<[Box<[u8]>]>,
        pub static_dir: Box<[u8]>,
        pub asset_prefix: Box<[u8]>,
    }

    /// schema.zig:1559 — peechy `message` (array fields default empty,
    /// scalar fields optional)
    #[derive(Clone, Debug, Default)]
    pub struct RouteConfig {
        pub dir: Box<[Box<[u8]>]>,
        pub extensions: Box<[Box<[u8]>]>,
        pub static_dir: Option<Box<[u8]>>,
        pub asset_prefix: Option<Box<[u8]>>,
    }

    /// schema.zig:753 — `enum(u8)` (open). Kept closed.
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
    pub enum CssInJsBehavior {
        #[default]
        _none = 0,
        Facade = 1,
        FacadeOnimportcss = 2,
        AutoOnimportcss = 3,
    }

    /// schema.zig:1987 — `enum(u8)` (open, no `_none`). Kept closed.
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
    pub enum PackagesMode {
        #[default]
        Bundle = 0,
        External = 1,
    }

    // ── Fallback error-page wire types (schema.zig:548-708) ────────────────
    // Hand-stubbed subset so `js_parser::runtime::Fallback` un-gates. Full
    // bodies (with `decode`) arrive from the peechy generator.

    /// schema.zig:548 — `enum(u8)` (open).
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
    pub enum FallbackStep {
        #[default]
        _none = 0,
        ssr_disabled = 1,
        create_vm = 2,
        configure_router = 3,
        configure_defines = 4,
        resolve_entry_point = 5,
        load_entry_point = 6,
        eval_entry_point = 7,
        fetch_event_handler = 8,
    }

    /// schema.zig:612 — peechy `struct Router`.
    #[derive(Clone, Debug, Default)]
    pub struct Router {
        pub routes: StringMap,
        pub route: i32,
        pub params: StringMap,
    }
    impl Router {
        pub fn encode(&self, w: &mut super::Writer<'_>) {
            self.routes.encode(w);
            w.write_int(self.route);
            self.params.encode(w);
        }
    }

    /// schema.zig:581 — peechy `struct Problems`.
    #[derive(Clone, Debug, Default)]
    pub struct Problems {
        pub code: u16,
        pub name: Box<[u8]>,
        pub exceptions: Vec<JsException>,
        pub build: Log,
    }
    impl Problems {
        pub fn encode(&self, w: &mut super::Writer<'_>) {
            w.write_int(self.code);
            w.write_array_u8(&self.name);
            w.write_int(u32::try_from(self.exceptions.len()).unwrap());
            for ex in &self.exceptions {
                ex.encode(w);
            }
            self.build.encode(w);
        }
    }

    /// schema.zig:475 — peechy `message JsException` (all fields optional).
    #[derive(Clone, Debug, Default)]
    pub struct JsException {
        pub name: Option<Box<[u8]>>,
        pub message: Option<Box<[u8]>>,
        pub runtime_type: Option<u16>,
        pub code: Option<u8>,
        // `stack: ?StackTrace` — omitted until StackTrace is ported.
    }
    impl JsException {
        pub fn encode(&self, w: &mut super::Writer<'_>) {
            if let Some(ref v) = self.name {
                w.write_field_id(1);
                w.write_array_u8(v);
            }
            if let Some(ref v) = self.message {
                w.write_field_id(2);
                w.write_array_u8(v);
            }
            if let Some(v) = self.runtime_type {
                w.write_field_id(3);
                w.write_int(v);
            }
            if let Some(v) = self.code {
                w.write_field_id(4);
                w.write_int(v);
            }
            w.end_message();
        }
    }

    impl StringMap {
        pub fn encode(&self, w: &mut super::Writer<'_>) {
            w.write_int(u32::try_from(self.keys.len()).unwrap());
            for k in &self.keys {
                w.write_array_u8(k);
            }
            w.write_int(u32::try_from(self.values.len()).unwrap());
            for v in &self.values {
                w.write_array_u8(v);
            }
        }
    }

    /// schema.zig — peechy `struct Log` (minimal: `warnings`, `errors`, `msgs`).
    #[derive(Copy, Clone, Debug, Default)]
    pub struct Log {
        pub warnings: u32,
        pub errors: u32,
        // `msgs: []Message` — omitted until `Message` is ported.
    }
    impl Log {
        pub fn encode(self, w: &mut super::Writer<'_>) {
            w.write_int(self.warnings);
            w.write_int(self.errors);
            w.write_int(0u32); // msgs.len
        }
    }

    /// schema.zig:638 — peechy `message FallbackMessageContainer`.
    #[derive(Clone, Debug, Default)]
    pub struct FallbackMessageContainer {
        pub message: Option<Box<[u8]>>,
        pub router: Option<Router>,
        pub reason: Option<FallbackStep>,
        pub problems: Option<Problems>,
        pub cwd: Option<Box<[u8]>>,
    }
    impl FallbackMessageContainer {
        pub fn encode(&self, w: &mut super::Writer<'_>) {
            if let Some(ref message) = self.message {
                w.write_field_id(1);
                w.write_array_u8(message);
            }
            if let Some(ref router) = self.router {
                w.write_field_id(2);
                router.encode(w);
            }
            if let Some(reason) = self.reason {
                w.write_field_id(3);
                w.write_enum(reason);
            }
            if let Some(ref problems) = self.problems {
                w.write_field_id(4);
                problems.encode(w);
            }
            if let Some(ref cwd) = self.cwd {
                w.write_field_id(5);
                w.write_array_u8(cwd);
            }
            w.end_message();
        }
    }
}