Skip to content

Asset per file scheme, stage 1#69

Merged
Imberflur merged 14 commits intomainfrom
asset-per-file-fixes-and-additions
Feb 11, 2026
Merged

Asset per file scheme, stage 1#69
Imberflur merged 14 commits intomainfrom
asset-per-file-fixes-and-additions

Conversation

@Imberflur
Copy link
Contributor

This is "stage 1" in converting bauble to a file per top level asset scheme.

Additionally there are changes to support having our bauble editor work with local assets instead of inline assets.

Asset per file

If an object appears first in the file and its name matches the file's name, its path will now be simplified to the path of the file. Additionally, the object will be marked as top_level (via a new field on Object and as a property available on assets in PathReference).

Custom naming for additional objects

We add AdditionalUnspannedObjects::new_with_custom_namer. AdditionalUnspannedObjects is used when creating new values that need to also create additional objects that they reference. This new method allows custom names instead of creating all new referenced objects as inline sub-objects.

Misc changes

Removed newline at the beginning of display_formatted output and added a newline at the end. Now files generated with this will have a trailing newline.

Exposed constant used for the builtin Ref type's path so external code can reliably identify the builtin Ref type.

Comment on lines +405 to +406
/// naming logic. Note, a number representing the type id of the current subobject may be
/// appended to the parent object name.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When and why do we append that type id number?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done in here

TypePathElem::new(format!("{}&{}", meta.object_name, ty.inner()))
and here
let name = TypePathElem::new(format!("{}&{}", self.object_name, ty.inner())).unwrap();

The reasoning I have seen in documentation in our editor code is:

/// These sub-objects will have some path like `path::to::root::object&23&34@0`. The numbers are
/// there to give sub-objects more unique names to make hot-reloading assets better. And are based
/// on the types of the object. And the number `@0` at the end is there to make sure the name is unique.

I think it basically somewhat alleviates the issue that an array, optional field or similar, could effect the names of sub-objects in all following fields when an item is added/removed. I say "somewhat" because if the sub-objects across fields had common types then this would not change anything.

Co-authored-by: MavethGH <65792235+MavethGH@users.noreply.github.com>
@Imberflur Imberflur merged commit f2f68e7 into main Feb 11, 2026
1 check passed
@Imberflur Imberflur deleted the asset-per-file-fixes-and-additions branch February 11, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants