rust_widgets 2.5.2

Pure Rust cross-platform native GUI library with hardware-adaptive rendering, 180 widgets, touch/gesture support, i18n, and SVG-pipeline-accurate output
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
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
[package]
name = "rust_widgets"
version = "2.5.2"
edition = "2021"
description = "Pure Rust cross-platform native GUI library with hardware-adaptive rendering, 180 widgets, touch/gesture support, i18n, and SVG-pipeline-accurate output"
license = "MIT"
keywords = ["gui", "widget", "cross-platform", "mobile", "wasm"]
categories = ["gui", "rendering", "graphics", "embedded", "wasm"]
authors = ["Mike Li <mikewolfli@163.com>"]
readme = "README.md"
homepage = "https://github.com/mikewolfli/rust-widgets"
repository = "https://github.com/mikewolfli/rust-widgets"
rust-version = "1.87"
include = [
    "build.rs",
    "src/**/*",
    "tests/**/*",
    "benches/**/*",
    "examples/**/*",
    "include/**/*",
    "language/**/*",
    # Both files under `tools/` are *declared* as Cargo targets below, so they must
    # ship: a target whose path is absent from the package makes `cargo package`
    # warn `ignoring test \`view_platform_gate_probe\` as
    # `tools/view_platform_gate_probe.rs` is not included in the published package`,
    # and a consumer building from the tarball then has no such target at all.
    # The rest of `tools/` is gates and generators that are not part of the crate's
    # build surface and stays excluded.
    "tools/widget_gallery.rs",
    "tools/view_platform_gate_probe.rs",
    # The designer's generation entry point (D7-b-3). Declared as an example below, so
    # it must ship for the same reason: without it, a consumer who takes the crate from
    # the tarball has the `designer` feature and the `designer_generate` binary it
    # documents, but not the target that writes a project's committed sources.
    "tools/designer_generate.rs",
    "LICENSE",
    "README.md",
    "README.zh-CN.md",
    "CHANGELOG.md",
    "clippy.toml",
    "rustfmt.toml",
]

[lints.rust]
# `target_os = "ohos"` (HarmonyOS NEXT) is not yet in rustc's built-in
# known target_os list; declare it explicitly so the check stays meaningful.
unexpected_cfgs = { level = "warn", check-cfg = [
    'cfg(target_os, values("ohos"))',
    'cfg(feature, values("cargo-clippy"))',
] }

[lib]
crate-type = ["lib", "cdylib"]

# ═══════════════════════════════════════════════════════════════════════
# Feature System — three independent axes (pick one from each):
#   1. Device Profile (pick ONE)
#   2. OS Backend    (pick ONE or auto)
#   3. Capability    (arbitrary composition)
# ═══════════════════════════════════════════════════════════════════════

[features]
# ── Default is full desktop ──
default = ["desktop"]

# ── Axis 1: DEVICE PROFILES (mutually exclusive) ──

## Full desktop: native platform, GPU, touch, i18n, chart, print, PDF, A11y.
##
## NOTE: `audio-output`, `symphonia-codecs`, and `video-codecs`
## are NOT enabled by default because they pull in large system-library
## dependencies (ALSA, FFmpeg, symphonia). Enable them explicitly:
##   cargo build --features "desktop,audio-output,symphonia-codecs,video-codecs"
## Or use the `full` meta-feature for everything.
##
## `webkit-engine` used to be listed here. It was removed in BLUE20 layer 5 (ruling W1,
## 2026-09-21) together with the 76-line WebKitGTK wrapper it gated: the wrapper never
## displayed a page, so the feature advertised a capability the library did not have.
desktop = [
    "os-auto",
    "cocoa-legacy",
    "desktop-runtime",
    "wgpu",
    "touch",
    "i18n",
    "chart",
    "print",
    "pdf",
    "a11y",
    "quality-management",
    "advanced-widgets",
    "controls-native",
    "controls-custom",
    "image",
    "video",
    "audio",
    "pdf-encryption",
    "js-engine",
    # The designer's code generator (mode 2). On by default for `desktop` only,
    # because `desktop` is the profile a designer **host** runs on: it is the
    # profile that has a window, a filesystem and an editor beside it.
    #
    # `tablet`/`mobile` deliberately do not enable it. They are **targets** of a
    # generation, not hosts (BLUE19 §5.3.4), and linking a code generator and its
    # artifact writer into a shipping application is the weight mode 2 exists to
    # remove. A caller who wants it there can ask: `--features tablet,designer`.
    "designer",
    "dep:chrono",
    "serde",
    "serde_json",
]

## Tablet: touch-first, GPU, native controls, no desktop extras.
##
## Shares the desktop UI-compilation surface (JSON, i18n hot-reload watcher,
## chrono-backed widgets, serde) minus print/pdf/chart/a11y/js extras.
tablet = [
    "os-auto",
    "wgpu",
    "touch",
    "i18n",
    "desktop-runtime",
    "serde",
    "serde_json",
    "dep:chrono",
    "quality-management",
    "controls-native",
    "controls-custom",
    "image",
]

## Mobile: touch, GPU, mobile API, native controls.
mobile = [
    "os-auto",
    "wgpu",
    "touch",
    "i18n",
    "desktop-runtime",
    "serde",
    "serde_json",
    "dep:chrono",
    "quality-management",
    "mobile-api",
    "controls-native",
    "controls-custom",
    "image",
]

## Embedded: software raster, no GPU, no touch, low memory.
embedded = ["software", "controls-custom"]

## LVGL-style mini: ~15 core widgets, software raster, no alloc-heavy deps.
mini = [
    "software",
    "controls-custom",
    "dep:heapless",
    "dep:hashbrown",
    "dep:spin",
    "dep:bumpalo",
]


# ── Axis 3: CAPABILITY OPT-OUTS ──

## Turn off the declarative view layer on a device profile.
##
## `rust_widgets::view` (the declarative-retained view layer) is **compiled by
## default** on `desktop`, `tablet` and `mobile`. It is never compiled on `mini`
## or `embedded`, which is a property of those profiles rather than a choice.
##
## Enabling this feature takes `crate::view` out of a device build. Use it when
## the layer's cost is not wanted — a headless tool, a size-constrained device
## build, or a program that only ever uses `add_child`:
##
##   cargo build --no-default-features --features desktop,no-declarative-view
##
## `tools/check_view_platform_gate.sh` asserts both states: the layer is present
## by default and absent when this feature is on.
##
## NOTE: the feature is deliberately *opt-out* rather than an `declarative-view`
## opt-in. A Cargo feature list cannot express "on unless named", so an opt-in
## spelling would require every existing caller to add a feature to keep working —
## a breaking change for a capability that is on today.
no-declarative-view = []

# ── Axis 2: OS BACKENDS (composable) ──
#
# Backend selection is performed by `cfg(target_os)` / `cfg(target_env)` arms in
# `src/platform/runtime.rs` and `src/platform/profile.rs` — a compile-time fact that
# Cargo features cannot express (a feature cannot say "whichever OS this target is").
#
# There used to be an `os-auto = []` feature here, documented as "picks by target_os",
# which `desktop`/`tablet`/`mobile` all enabled. Nothing anywhere read it: grepping
# for `feature = "os-auto"` over `src/` and `tools/` matched only the exclusion list in
# `check_capability_feature_gates.sh`. It is an empty name asserting a gate that does
# not exist (principle #47), so it is kept only as a documented no-op alias for build
# scripts that still pass it.
#
# Legacy no-op alias: does NOT select a backend. Kept so `--features os-auto` in an
# existing build script keeps working; new builds should name the backend feature
# (`macos`, `linux-gtk`, `ios`, `android`, `harmony`, `wasm`) or the device profile.
os-auto = []
macos = [
    "dep:objc2",
    "dep:objc2-foundation",
    "dep:objc2-app-kit",
    "dep:objc2-core-graphics",
    # The objc2 backend's handle types derive Serialize/Deserialize and its state
    # snapshot returns `serde_json::Error`, so these are hard requirements rather
    # than optional extras. They were previously inherited from `desktop`, which
    # made `--features macos` alone fail to compile.
    "serde",
    "serde_json",
]
macos-legacy = ["cocoa-legacy"]
ios = [
    "dep:objc2",
    "dep:objc2-foundation",
    "dep:objc2-core-foundation",
    "dep:objc2-core-graphics",
    "dep:objc2-ui-kit",
]
windows = []
linux-gtk = ["dep:gtk"]
linux-wayland = [
    "dep:wayland-client",
    "dep:wayland-protocols",
    "dep:wayland-cursor",
    "dep:libc",
]
linux-a11y = ["dep:zbus", "dep:pollster"]
android = ["dep:jni"]
# Explicit `jni` feature name so `--features jni` (documented by
# `src/bindings/java_jni.rs`) and `cfg(feature = "jni")` work; mirrors the
# `serde`/`dep:serde` pattern.
jni = ["dep:jni"]
wasm = ["dep:wasm-bindgen", "dep:web-sys", "dep:js-sys", "serde"]
harmony = []


# ── Axis 3: CAPABILITIES (arbitrary composition) ──

touch = []
gpu = ["dep:wgpu"]
wgpu = ["gpu"]
software = []
i18n = ["dep:notify", "dep:crossbeam-channel", "dep:serde", "dep:serde_json"]
chart = []
print = []
pdf = []
a11y = []

## The designer's code generator and artifact writer (BLUE19 D7-b-3).
##
## Turns a project document into Rust source and writes it into `src/generated/`.
## It is a **development-time** tool: a shipping application has no use for it, and
## leaving it on would link a generator plus file writing into every build.
##
## `desktop` enables it (the designer runs on a desktop host); every other profile
## leaves it off and opts in explicitly when needed:
##   cargo build --features "tablet,designer"
##
## It needs `serde_json`, because generating requires *parsing* the project, and the
## `designer_tooling` alias in `build.rs` requires a device profile on top of this.
## Declaring the dependency here rather than in each profile keeps the alias honest:
## `--features tablet,designer` fails with a clear missing-dependency error instead
## of compiling a module that cannot read its input.
designer = ["serde_json"]

image = ["dep:miniz_oxide", "image-codecs", "svg-rasterizer"]
image-codecs = ["dep:image-codecs"]
svg-rasterizer = ["dep:resvg"]
# Video frames reuse the image format types (DecodedImage/ImageFormat).
video = ["dep:jpeg-decoder", "image"]
audio = ["dep:minimp3_fixed"]
holographic = []
projection = []


# ── INTERNAL FEATURES (used by profiles, not user-facing) ──

desktop-runtime = ["dep:notify", "dep:crossbeam-channel"]
quality-management = []
mobile-api = []
controls-native = []
controls-custom = []
advanced-widgets = ["dep:dirs"]
# Internal runtime-profile selector referenced by `runtime_profile_name()`
# (`src/lib.rs`); selects the "embedded-mini" profile combination.
profile-embedded-mini = []

# New capability features
# Note: pdf-encryption, audio-output, js-engine are cross-platform (Pure Rust / system-agnostic).
# video-codecs is cross-platform when system FFmpeg is installed.
# `webkit-engine` was here (Linux-only, gating a wrapper over webkit2gtk). Deleted by
# BLUE20 layer 5 (ruling W1) because the wrapper never displayed a page; the feature
# promised a rendering engine the library did not have.
pdf-encryption = ["aes", "sha2", "cbc"]
audio-output = ["cpal"]
js-engine = ["boa_engine"]
video-codecs = ["dep:ffmpeg-next"]
web-http = ["dep:ureq"]

# Explicit feature flag so `cfg(feature = "serde")` works with `dep:serde`.
serde = ["dep:serde"]
serde_json = ["dep:serde_json"]

unstable-pipeline-routing = []
unstable-special-widgets = []


# ── AUDIO CODEC FEATURES ──

## Real audio codecs via symphonia (FLAC, OGG Vorbis, AAC, Opus).
## Enables actual PCM decoding instead of synthetic fallback data.
symphonia-codecs = ["symphonia"]


# ── BACKWARD-COMPAT ALIASES ──
# Old feature names used in #[cfg(feature = "...")] throughout the codebase.
# These forward to the new names above.

# Old OS backends
objc2-macos = ["macos"]

# `cocoa-legacy` is the name the macOS backend modules are gated on
# (`#[cfg(feature = "cocoa-legacy")]` in `src/platform/macos/`), so it is the one
# that must carry the cocoa/objc dependencies. `macos-legacy` is the documented
# user-facing alias and forwards to it.
#
# The alias used to point the other way (`cocoa-legacy = ["macos-legacy"]`), which
# meant `--features macos-legacy` pulled in the crate but never activated the gate
# the backend modules are written against: the backend was never compiled, and the
# build failed on a missing type instead of using the legacy backend it had asked
# for. Direction matters, because a Cargo feature alias is not symmetric.
#
# `serde`/`serde_json` are hard requirements here for the same reason documented on
# `macos` above: enabling `cocoa-legacy` also compiles `src/platform/macos_objc2/`
# (both backends ship behind the Apple gate), whose handle types derive
# Serialize/Deserialize and whose state snapshot returns `serde_json::Error`.
# Only `macos` used to carry them, so `--features cocoa-legacy` alone failed with
# `unresolved import serde` — the identical defect the `macos` line was patched for.
cocoa-legacy = ["dep:cocoa", "dep:objc", "serde", "serde_json"]
ios-uikit-ffi = ["ios"]
gtk-native = ["linux-gtk"]
wayland-native = ["linux-wayland"]
android-jni = ["android", "jni"]

# Old capability names
gpu-wgpu = ["gpu", "dep:pollster"]


# ── META FEATURES ──

## Everything (not for production — pick a specific device profile).
full = [
    "desktop",
    "macos",
    "macos-legacy",
    "ios",
    "linux-gtk",
    "linux-wayland",
    "linux-a11y",
    "android",
    "wasm",
    "harmony",
    "holographic",
    "projection",
    "unstable-pipeline-routing",
    "unstable-special-widgets",
    "pdf-encryption",
    "symphonia-codecs",
    "audio-output",
    "js-engine",
    "video-codecs",
]


# ═══════════════════════════════════════════════════════════════════════
# DEPENDENCIES
# ═══════════════════════════════════════════════════════════════════════

[dependencies]
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }
crossbeam-channel = { version = "0.5", optional = true }
font8x8 = "0.2.7"
pollster = { version = "0.4", optional = true }
chrono = { version = "0.4", optional = true }
notify = { version = "7.0", optional = true }
dirs = { version = "6.0", optional = true }
log = "0.4"
minimp3_fixed = { version = "0.5", optional = true }
miniz_oxide = { version = "0.8", optional = true }
# NOTE: AVIF uses the pure-Rust `avif` codec (ravif), not `avif-native`.
# `avif-native` pulls in `dav1d-sys`, a system C library that requires a
# pkg-config cross sysroot. That made every cross target (Android/iOS/wasm)
# fail to compile for the `mobile`/`tablet`/`desktop` profiles. The pure-Rust
# codec keeps AVIF support while remaining cross-compilable everywhere.
image-codecs = { package = "image", version = "0.25.10", optional = true, default-features = false, features = [
    "gif",
    "webp",
    "tiff",
    "avif",
    "ico",
] }
resvg = { version = "0.48.1", optional = true }
jpeg-decoder = { version = "0.3", optional = true }
ureq = { version = "3.0", optional = true, features = [] }
symphonia = { version = "0.5", default-features = false, features = [
    "all",
], optional = true }


# Audio/video codecs
aes = { version = "0.8", optional = true }
sha2 = { version = "0.10", optional = true }
cbc = { version = "0.1", optional = true }
# Note: On Linux, requires `libasound2-dev` package for ALSA backend.
# On macOS, uses CoreAudio; on Windows, uses WASAPI.
cpal = { version = "0.15", optional = true }
boa_engine = { version = "0.19", optional = true }

wgpu = { version = "30.0.1", optional = true }

wasm-bindgen = { version = "0.2", optional = true }
js-sys = { version = "0.3", optional = true }
# Cross-platform FFmpeg (system lib). On Linux: apt install libav*-dev,
# macOS: brew install ffmpeg, Windows: vcpkg install ffmpeg.
ffmpeg-next = { version = "9.0", optional = true }

web-sys = { version = "0.3", features = [
    "Window",
    "Document",
    "Element",
    "HtmlElement",
    "Node",
    "Event",
    "EventTarget",
    "MouseEvent",
    "KeyboardEvent",
    "console",
    "HtmlCanvasElement",
    "CanvasRenderingContext2d",
    "Clipboard",
    "Navigator",
    "Location",
    "ResizeObserver",
    "ResizeObserverEntry",
    "ResizeObserverSize",
    "DomRectReadOnly",
], optional = true }

jni = { version = "0.21", features = ["invocation"], optional = true }

heapless = { version = "0.8", optional = true }
hashbrown = { version = "0.15", optional = true, default-features = false, features = [
    "alloc",
] }
spin = { version = "0.9", optional = true }
bumpalo = { version = "3.17", optional = true, default-features = false }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = [
    "winuser",
    "commctrl",
    "commdlg",
    "winbase",
    "synchapi",
    "wingdi",
    "shellapi",
    "ole2",
    "combaseapi",
    "objbase",
    "knownfolders",
    "shlobj",
    "shobjidl",
    "winerror",
    "errhandlingapi",
    "libloaderapi",
    # `GlobalMemoryStatusEx` (sysinfoapi) and `GetProcessMemoryInfo` (psapi)
    # back `Platform::total_memory_mb` / `Platform::process_memory_utilization`
    # in the Windows backend.
    "sysinfoapi",
    "psapi",
] }

[target.'cfg(target_os = "macos")'.dependencies]
objc = { version = "0.2", optional = true }
objc2 = { version = "0.6", optional = true }
objc2-foundation = { version = "0.3", optional = true }
objc2-app-kit = { version = "0.3", optional = true }
objc2-core-graphics = { version = "0.3", optional = true }
cocoa = { version = "0.25", optional = true }
# Backs `Platform::total_memory_mb` in `src/platform/darwin_probes.rs`
# (`sysconf(_SC_PHYS_PAGES)`). Not optional: the probe is always compiled on this
# target, and an optional dep behind no feature is a compile error waiting to happen.
libc = "0.2"

[target.'cfg(target_os = "ios")'.dependencies]
objc2 = { version = "0.6", optional = true }
objc2-foundation = { version = "0.3", optional = true }
objc2-core-foundation = { version = "0.3", optional = true }
objc2-core-graphics = { version = "0.3", optional = true }
objc2-ui-kit = { version = "0.3", optional = true }
# Same probe as macOS: iOS does not mount `/proc/meminfo`.
libc = "0.2"

[target.'cfg(target_os = "linux")'.dependencies]
gtk = { version = "0.18", optional = true }
# Used by the Wayland backend to poll() the compositor socket in the native
# event loop (the crate is already in the dependency graph transitively).
libc = { version = "0.2", optional = true }
wayland-client = { version = "0.31", optional = true }
wayland-protocols = { version = "0.32", features = [
    "staging",
    "client",
], optional = true }
wayland-cursor = { version = "0.31", optional = true }
zbus = { version = "5", optional = true }

# `webkit2gtk` was a dependency here, gated by the `webkit-engine` feature. Both were
# removed by BLUE20 layer 5 (ruling W1, 2026-09-21): the wrapper never displayed a page,
# so the dependency pulled in GTK+WebKit system libraries for no observable behaviour.

# NOTE: there is deliberately no `[target.'cfg(target_os = "harmony")'.dependencies]`
# section. OpenHarmony targets are spelled `*-unknown-linux-ohos` and rustc reports
# `target_os = "linux"` / `target_env = "ohos"` for them, so such a section could
# never match — it was an empty, permanently-dead block. The OpenHarmony backend
# needs no extra crates: the NDK libraries it links against (e.g.
# `libtime_service_ndk.so`, pulled in by `time`) are resolved by the toolchain's
# sysroot, which `cargo ohos` points at. See `tools/check_harmony_cross.sh` and
# `src/platform/harmony/status.md` for the working recipe.

# `wasm32-unknown-unknown` has no OS entropy source, so `getrandom` refuses to
# build unless its `js` feature is on. The dependency reaches us transitively
# through the JavaScript engine (`boa_engine` -> `rand` 0.8 -> `rand_core` 0.6 ->
# `getrandom` 0.2), so the fix has to be applied from the top of the graph: the
# `js` feature below is unified with whatever `boa_engine` requests, which is what
# unlocks the wasm32 backend.
#
# This is a pure build-configuration fix — no source change — matching the
# existing note above the `dev-dependencies` section, where the same constraint
# is why criterion/tempfile/proptest are gated off wasm32.
[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom02 = { package = "getrandom", version = "0.2", features = ["js"] }

# `getrandom` 0.3 removed the browser backend from the default build and renamed
# the opt-in feature: 0.2's `js` became 0.3's `wasm_js` (verified in the crate's
# own manifest, not assumed). It arrives via `rand` 0.9 in the dev-dependency
# tree, so declaring it keeps `--all-features --target wasm32` compiling too.
getrandom03 = { package = "getrandom", version = "0.3", features = ["wasm_js"] }

[dev-dependencies]
# NOTE: criterion (benchmark harness), tempfile (filesystem tests) and proptest
# (property tests) do not support wasm32 (no OS/FS/threads and their transitive
# deps — wait-timeout, getrandom — cannot compile there). They are therefore
# gated off the wasm32 targets; the tests that use them carry matching
# `#[cfg(not(target_arch = "wasm32"))]` gates.

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
criterion = "0.8.2"
tempfile = "3.14"
proptest = "1.6"

[package.metadata.docs.rs]
features = ["full", "touch", "holographic", "projection"]
rustc-args = ["--cfg", "docsrs"]

[badges]
maintenance = { status = "actively-developed" }

[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1

[profile.release-embedded]
inherits = "release"
opt-level = "s"
lto = true
codegen-units = 1
strip = true
panic = "abort"

[profile.release-mini]
inherits = "release"
opt-level = "z"
lto = true
codegen-units = 1
strip = true
panic = "abort"

[[bench]]
name = "render_bench"
harness = false

[[bench]]
name = "signal_bench"
harness = false

# Demonstrates the declarative-retained loop end to end (BLUE18 Phase F-1): change
# state, and the engine reports the single patch it applied rather than rebuilding
# the tree. Needs no window — `ViewEngine` takes its constructor as an injected
# closure — so it runs on a headless CI host. Gated on the same expression
# `crate::view` uses, which is why a stripped profile skips it instead of failing.
[[example]]
name = "view_counter"
path = "examples/view_counter.rs"

# BLUE20 layer 1 — the rendering census probe.
#
# `required-features = ["desktop"]` rather than a crate-level `#![cfg]` on its own: an
# example whose body is removed by an inner `cfg` still needs *a* `main` for cargo to link
# it, so `cargo check --all-targets` on `mini` failed with `E0601: main function not found`.
# Declaring the requirement excludes the target from those builds outright, which is the
# accurate statement — this probe has nothing to measure in a stripped profile — instead of
# asking it to compile into a `main` that cannot use the widget registry it needs.
[[example]]
name = "control_rendering_census"
path = "examples/control_rendering_census.rs"
required-features = ["desktop"]

# BLUE20 layer 3 — writes `snapshots/svg/<name>.svg` for every published control.
# `required-features` for the same reason as the census probe above, and because the
# snapshots themselves need the theme module that only a device profile has.
[[example]]
name = "export_control_svgs"
path = "examples/export_control_svgs.rs"
required-features = ["desktop"]

# Compile-time probe for the declarative-layer platform gate.
#
# `tools/check_view_platform_gate.sh` (BLUE18 rules #92/#94) asserts that
# `crate::view` is compiled on desktop/tablet/mobile and ABSENT on
# mini/embedded. Its criterion is executable: it compiles a probe that names
# `rust_widgets::view::VIEW_GATE_PROBE`, so the probe resolving *is* the
# module being in the compilation unit.
#
# The path is under `tools/`, not `tests/`, so cargo's test auto-discovery
# never picks it up. That matters: an auto-discovered test naming that constant
# would be built by `cargo check --all-targets` on mini/embedded, fail to
# resolve the path, and report the very condition this gate exists to detect.
# The file is committed (so this entry never dangles) and is a no-op unless
# the gate compiles it.
#
# No `required-features`: the gate must compile this target under *every*
# profile, because the absent-profile steps are the ones asserting the build
# fails. Restricting it to a device profile would make those steps untestable.
#
# It is also excluded from `check_profiles.sh`'s `--all-targets` runs by
# carrying no assertions of its own on a stripped profile: the `use` is
# `cfg`-gated, so building it on mini/embedded succeeds trivially.
[[test]]
name = "view_platform_gate_probe"
path = "tools/view_platform_gate_probe.rs"

[[bench]]
name = "layout_bench"
harness = false

[[bench]]
name = "json_bench"
harness = false

[[bench]]
name = "event_bench"
harness = false

[[example]]
name = "widget_gallery"
path = "tools/widget_gallery.rs"

# `menu_shortcut_runtime` drives `rust_widgets::app` (macOS AppKit main-thread
# probe). The `app` module is gated on `full_widgets` — a device profile without
# `mini`/`embedded` — so the example must declare that requirement. Without this,
# `--all-targets` on a stripped profile tries to build it and fails on the
# missing `app` module instead of simply skipping it.
[[example]]
name = "menu_shortcut_runtime"
required-features = ["desktop"]

# `control_property_uniform` drives `rust_widgets::app` and the platform
# singleton, both of which require a device profile with a real backend. Declare
# the requirement so a stripped profile skips it instead of failing to build it.
[[example]]
name = "control_property_uniform"
required-features = ["desktop"]

# Measurement probe for the macOS window-state async contract; needs a real
# backend and the `app` module, so it is gated the same way.
[[example]]
name = "macos_window_state_async_probe"
required-features = ["desktop"]

# Runtime proof that the host creates no controls and one creation mechanism
# exists. Needs the `app` module and a real backend, so it is gated like the other
# desktop probes. Replaces `macos_created_controls_are_usable`, whose subject (the
# native control path) no longer exists.
[[example]]
name = "control_creation_is_single_mechanism"
required-features = ["desktop"]

# Emits the factory's resolved widget names as JSON so
# `tools/check_widget_registration_fidelity.sh` classifies every `WidgetKind`
# against the live registry rather than a source grep. Needs `serde_json` to
# print the report, which the device profiles carry.
[[example]]
name = "widget_reachability"
required-features = ["desktop", "serde_json"]

# Prints what the active theme resolves to for each control kind the control demo
# places. Answers "why is every control the same grey?" with values rather than a
# reading of the theme merger, so it needs a device profile and the `app` module.
[[example]]
name = "theme_resolve_dump"
required-features = ["desktop"]

# Reads back the style a **created** control carries, to decide whether a control that
# renders grey is missing the theme or ignoring it. Needs a device profile and the
# `app` module, like the other probes.

# The executable companion to the cookbook's embedded chapter. Declared with **no**
# `required-features` on purpose: it is supposed to compile on every profile
# (`desktop`, `tablet`, `mobile`, `mini`, `embedded`), which is what keeps the
# chapter's code honest. `tests/cookbook_embedded_paths_test.rs` asserts this file
# still exists so the chapter cannot point at a deleted example.
# The designer's generation entry point (BLUE19 D7-b-3): writes the committed
# generated sources that `tools/check_generated_sources.sh` regenerates and compares.
#
# Gated on `desktop` for the same reason `crate::designer` is `full_widgets`:
# generating requires *parsing* the project, and the parser needs `serde_json`.
# A `mini`/`embedded` build is the **target** of a generation, not its host.
[[example]]
name = "designer_generate"
path = "tools/designer_generate.rs"
required-features = ["designer"]

[[example]]
name = "embedded_host"
path = "examples/embedded_host.rs"

# Diagnostic probes kept as regression evidence for the "controls render invisibly"
# defect (log-20260921-1.md §3): `style_probe4` prints the pixel colours a window's
# tree produces, `style_probe3` does the same for a single control. Both are how the
# coordinate-space mismatch was located, and both are re-runnable on any host.
[[example]]
name = "style_probe3"
required-features = ["desktop"]

[[example]]
name = "style_probe4"
required-features = ["desktop"]

[[example]]
name = "style_probe6"
required-features = ["desktop"]

[[example]]
name = "style_probe7"
required-features = ["desktop"]