Migrating from v1 -> v2

Hi there! I have a pretty big project that is in OneJS v1, and you might've seen my posts recently about various issues I've been grappling with it, as well as some perf concerns. I'd like to see if I can migrate it to v2, but that's been a pretty thorny task that has come with its own set of problems. So I'm creating this forum thread to both ask for help along the way, and also document exactly what has changed for me. Some context from me: * Even with v1, I was using a custom esbuild setup to create a minified JS file to use * I use hookstate as my main state management system. This requires a full preact-compat, so I have a custom version vendored in. So far, in attempting to work with v2, I have 1. interop between my existing C# and TS seem fine, and I appreciate the new generated typedefs 2. DOTween also seems to include fine without errors. 3. It builds Nothing shows up ingame at the moment though! There's still a whole slew of errors to work through first.
2 Replies
amorphous
amorphous4d ago
Open Questions So Far 1. OneJS's preact (or its types?) seems to be incomplete compared to what we had in v1. The most prominent is the import { Style } from "preact/jsx" definition, which was a part of Scriptlib. Is that available in v2? (Other missing definitions include Fragment and a lot of the pieces of JSXInternal. 2. Do the onejs/comps components still exist? (I can probably vendor them in if needed, but was curious) 3. Typescript complains if we reach into a C# class and use nested variables or functions; is there something I'm missing there? I generated the type defs from the ScriptEngine object. 4. I asked 5 months ago (?!) about how to handle actions, and got https://discord.com/channels/971959898655051806/971963260704260146/1231847737620697088 as an answer. Is this still the case?
Singtaa
Singtaa17h ago
1. The def for Fragment was rencently added. But yeah, to get full npm and esbuild workflow working, I had to manually pull in and check every single declaration for onejs-preact and had to leave out some typings that had conflicts at the time. Feel free to PR https://github.com/DragonGround/onejs-preact to get missing typings in. 2. It's been on my mind, but I haven't gotten around to these yet for V2. 3. Nested classes? Those can be tricky when translating them from C# to TS. Half of time, they'll require some manual adjustment, especially when combined with explicit interfaces. 4. Reading over your code again, I think you might have something else that's triggering the delegate bridge error. Do you still get the error if your event is Action<float> instead of Action<bool>? Because it just seem weird that Action<float> works fine and Action<bool> doesn't. The former is being used in both the Ul Meter tutorial and the fortnite UI sample. I didn't need to explicitly declare UsingAction<float> for these. oh for Style, you can use Partial<CS.OneJS.Dom.DomStyle> in most cases I will start migrating the headless comps from v1 to v2 https://github.com/Singtaa/onejs-comps Just a slider right now (needed that one for something Yesterday)
Want results from more Discord servers?
Add your server