gdscript_scene/lib.rs
1//! `gdscript-scene` — a `.tscn`/`.tres` **text** parser for scene-aware analysis (Phase 4).
2//!
3//! Godot's text scene format is INI-like: bracketed section headers (`[node …]`, `[ext_resource …]`,
4//! …) followed by `key = value` property lines. This crate parses that structure — node names,
5//! types, parent paths, attached scripts, `unique_name_in_owner`, and instanced sub-scenes — into a
6//! [`SceneModel`] **with byte spans**, so the type layer (Phase-4 M1+) can resolve `$Path` /
7//! `%Unique` / `get_node("…")` to a node's real `Control`/`Node` subclass instead of bare `Node` —
8//! intelligence the Godot editor's own LSP produces only in-editor and never flows into inference.
9//!
10//! **M0 scope:** the pure, wasm-clean [`parse_scene`] (`&str -> SceneModel`) + the model + byte
11//! spans. It **records** the typing inputs (`type=`/`script=`/`instance=`); it does **not** resolve
12//! a `Ty` (M1), recurse into instanced sub-scenes, build the project-wide script↔scene index, or
13//! cache via salsa (M1+). See `plans/PHASE-4-M0-PLAYBOOK.md`.
14//!
15//! **Invariant:** the parser is strictly additive and **never fails** — every binary/malformed/
16//! unknown form degrades to an empty-or-partial model + a [`SceneProblem`], never a panic or `Err`.
17//! The floor is always parity with the engine's `Node`-everywhere baseline.
18//!
19//! **Portability:** a core crate — wasm32-clean (no `std::fs`, no `Instant`, no threads); `.tscn`
20//! text is injected via the VFS exactly like `.gd`.
21#![cfg_attr(docsrs, feature(doc_cfg))]
22
23mod model;
24mod parse;
25
26pub use model::{
27 ExtId, ExtResource, NodeIdx, NodePathResolution, SceneKind, SceneModel, SceneNode,
28 SceneProblem, SubResource,
29};
30pub use parse::parse_scene;
31
32#[cfg(test)]
33mod tests;