Skip to content

Conversation

@junsikshim
Copy link
Collaborator

Based on @mcyph 's work, I restructured the code into a monorepo and added Storybook for the examples.

There are 3 packages.

  • core: the mxGraph source code
  • html: the vanilla-js examples using the 'core' as a dependency
  • react: React examples with react wrappers.

Currently, only two html examples are converted to stories(HelloWorld and Grid), but I think it'll still show what it's capable of.
Since this change affects so many files, I decided not to wait until every examples are converted.

Also, there were lots of circular dependencies going on, so I divided mxUtils into multiple files and shuffled things around. Some of them are temporarily fixes that may need to be modified later.

The instruction for setting up is in Readme.md.

Thanks!

jgadsden and others added 3 commits April 15, 2021 13:11
@junsikshim
Copy link
Collaborator Author

I've added Prettier and its config, but haven't run it. It felt like we didn't have much discussion about code-styling. It'd be nice to gather opinions about it.

@mcyph
Copy link
Collaborator

mcyph commented Apr 15, 2021

I actually was using Prettier via https://github.com/ijsto/eslint-config. I don't know what the best style for mxGraph is either, I figured the defaults looked pretty good even though it's not the styles I'd normally use and that they're pretty close to what I've seen in many JS projects like mapbox-gl etc. Should we add a hook so that it auto-cleans up to that style on commit?

I notice you've started converting some classes to functions too in mxEvents/mxUtils - looks much cleaner. I kept meaning to do it but to be honest knew the automatic typed-mxgraph documentation/types transfer scripts I was writing would depend on the code being in a class style convention. That's basically all done now, that script can be thrown away as far as I'm concerned and it's good to see them in there at last 😃

@mcyph
Copy link
Collaborator

mcyph commented Apr 15, 2021

I see you've commented out some lines like

 import('../../../serialization/mxStylesheetCodec');

It's not ideal having these as "on-demand" loaders, but the reason for these kinds of lines being after the classes was because of circular imports with the XML encode/decode serializers (formerly in the io directory).

They used to be in the codecs themselves, but if importing the codecs with all of those encoders/decoders effectively tree-shaking isn't possible because the serializers depend on the original class and vice-versa.

There should be a better solution for this, so would be interested if anyone knows of one. I might ask this as an issue together with a note to check the xml serialization/deserialization example works and re-enable it when it does because at last check it went in an endless recursive loop.

@junsikshim
Copy link
Collaborator Author

the serializers depend on the original class and vice-versa.

I haven't yet tried, but if each codec gets registered into mxCodecRegistry wrapped in a function to be executed later, we might be able to dodge this circular dependency problem.

Other than codecs, mxUtils is importing too many classes and that created circular dependencies, so I splitted them a bit and also deleted some functions like eval, alert and so on.

I'm writing this outside based on my memory, so the names might be wrong ;)

Copy link
Collaborator

@mcyph mcyph left a comment

Choose a reason for hiding this comment

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

Looks good to me. There was a previous eslint/Prettier config and need to check how they both interact, and there are some issues which need to be later worked out with the serializers, but can work these out after merging.

@mcyph mcyph merged commit 233b1fe into development Apr 16, 2021
@junsikshim junsikshim deleted the monorepo branch April 16, 2021 05:44
@tbouffard tbouffard added the chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...) label Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants