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

Add library syntax and testing #488

Merged
merged 14 commits into from
Oct 31, 2024
Merged

Add library syntax and testing #488

merged 14 commits into from
Oct 31, 2024

Conversation

JackWilb
Copy link
Contributor

@JackWilb JackWilb commented Oct 30, 2024

Does this PR close any open issues?

Prelim for #478

Give a longer description of what this PR addresses and why it's needed

This adds libraries, a reusable configuration of components and sequences that can enable sharing of larger component blocks without copy/pasting between configurations.

The LibraryConfig is a new JSON schema that represents library objects. The schema looks similar to the StudyConfig (and reuses lots of the types), but it allows for multiple sequence definitions so that components may be used in 1 sequence and not another. This new schema is documented using typedoc.

Provide pictures/videos of the behavior before and after these changes (optional)

New steps panel icon for library components.
Screenshot 2024-10-28 at 4 57 59 PM

Are there any additional TODOs before this PR is ready to go?

TODOs:

  • Update relevant documentation
  • Add a doc page to the docs repo
  • Open issues for other libraries that we'd like to add

@JackWilb JackWilb changed the title Add initial library work Add library syntax and testing Oct 30, 2024
Copy link
Contributor

@bbollen23 bbollen23 left a comment

Choose a reason for hiding this comment

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

Just want to comment on this so I can see if I understand:

You have a config in your library. This is not initially namespaced -- it is just as if the user added their own config they used for a study there (to my knowledge, there's currently no restriction on the library elements, so any config thats valid should be able to be placed there).

When a user specifies a library, it firsts generates a "new config" which takes all the components and sequence objects and adds them as baseComponents with the specified namespace name. For example, if there is a baseComponent called "test-baseComponent", then a new base component in this new config is created with the name $test.components.test-baseComponent". That way, when you are referencing a component in your config, it has something to reference. Its essentially "merging" the library config inside your own config, but namespaces the elements.

This also allows for inheriting the libraryData's components as components or as baseComponents.

So, couple questions:

  1. Whats the use of a base component in the library config? is it just so that the library config itself can use them? Since it doesnt seem like you're adding specific libraryBaseComponents to the baseComponents of the final config, you're inheriting inside the library first? In other words, you're first generating the full library config so that there are no more "baseComponents" -- each final component of the resulting library config will essentially have all the stand-alone information for that component. (So if a library component inherits a library base component, when the library component is added to the final config, its as if that single library component has all the contents of the library base component coming with it)
  1. Are there any checks in place for repeating library names in the library folder? Not sure how you'd handle this if you haven't already

Great work!! I like the namespace conventions you used

src/components/interface/StepsPanel.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@ZachCutler04 ZachCutler04 left a comment

Choose a reason for hiding this comment

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

One small potential change, otherwise looks great

src/parser/parser.ts Outdated Show resolved Hide resolved
@JackWilb JackWilb merged commit c81c7db into dev Oct 31, 2024
4 checks passed
@JackWilb JackWilb deleted the library-exploration branch October 31, 2024 22:48
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.

Plugin libraries
3 participants