Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoregister images #909

Merged
merged 12 commits into from
Jan 9, 2025
Merged

Autoregister images #909

merged 12 commits into from
Jan 9, 2025

Conversation

BrtqKr
Copy link
Collaborator

@BrtqKr BrtqKr commented Jan 7, 2025

@BrtqKr BrtqKr requested a review from wkozyra95 January 7, 2025 14:59
@BrtqKr BrtqKr self-assigned this Jan 7, 2025
@@ -182,6 +183,25 @@ class OutputContext implements CompositorOutputContext {
{}
);
}
public async registerImage(imageId: number, imageSpec: any) {
const imageRef = {
type: 'image-local',
Copy link
Member

Choose a reason for hiding this comment

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

output-local in inputs means that this "input" is local/scoped/limited/assigned to that specific output, so with this naming output-local would make sense.

I guess we could use output-local-input and output-local-image to make sure they ae different, or maybe output-specific

@@ -35,7 +35,7 @@ class LocallySpawnedInstance implements CompositorManager {
this.port = opts.port;
this.workingdir = opts.workingdir ?? path.join(os.tmpdir(), `live-compositor-${uuidv4()}`);
this.executablePath = opts.executablePath;
this.enableWebRenderer = opts.enableWebRenderer;
this.enableWebRenderer = true;
Copy link
Member

Choose a reason for hiding this comment

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

?

};
}, [props.source]);

if (!isImageRegistered) return createElement(View, {});
Copy link
Member

Choose a reason for hiding this comment

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

don't use if statements without {} it is very easy to add new line and introduce wierd bugs


export type ImageProps = Omit<ComponentBaseProps, 'children'> &
(
| {
Copy link
Member

Choose a reason for hiding this comment

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

I would add runtime check to make sure only one is provided

return createElement(View, {});
}

type ImageSceneBuliderProps = Omit<ImageProps, 'imageId'> & { imageId: string };
Copy link
Member

Choose a reason for hiding this comment

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

maybe move that up? above first use

const ctx = useContext(LiveCompositorContext);
const [imageId, setImageId] = useState(0);
const [isImageRegistered, setIsImageRegistered] = useState(!!props.imageId);

Copy link
Member

Choose a reason for hiding this comment

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

you need to handle when component props change between imageId and source e.g. reset isImageRegistered to false

@BrtqKr BrtqKr requested a review from wkozyra95 January 8, 2025 14:20

function Image(props: ImageProps) {
const ctx = useContext(LiveCompositorContext);
const [imageId, setImageId] = useState(0);
Copy link
Member

Choose a reason for hiding this comment

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

maybe internalImageId or autoImageId because it is confusing to distinguish this id from props one


void (async () => {
try {
if (!assetType) {
Copy link
Member

Choose a reason for hiding this comment

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

I would move that outside this async function

@BrtqKr BrtqKr enabled auto-merge (squash) January 8, 2025 15:03
@BrtqKr BrtqKr merged commit 4178579 into master Jan 9, 2025
5 checks passed
@BrtqKr BrtqKr deleted the @BrtqKr/autoregister-image branch January 9, 2025 11:04
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