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

Plugin refactor #1236

Merged
merged 138 commits into from
Oct 24, 2022
Merged

Conversation

nerfZael
Copy link
Contributor

@nerfZael nerfZael commented Sep 15, 2022

Description:

The goal of this refactor is to remove plugins from the core-js, and client-js packages and improve their composability with resolvers
This PR introduces a new plugin-js package where the PluginWrapper and PluginPackage classes are located.

Features:

  • client-js
    • Polywrap Client now re-exports the config builder and uri-resolvers (in addition to core) packages. This is done to improve dev exp and remove the need for users to import those package themselves.
      • For users who do not need those package and are using noDefaults there will be a separate PR that refactor core client functionality into a core-client package that does not depend on the config builder and uri-resolvers packages, but has no defaults.
  • config-builder-js
    • Added addRedirects, addWrappers, addPackages methods to the ClientConfigBuilder, so users can add many items at once.
    • Added buildDefault to the ClientConfigBuilder which builds a ClientConfig using default resolvers.
  • plugin-js
    • New package for plugins
    • Can create plugin packages with PluginPackage.from
      • Accepts manifest and a PluginModule or an inline PluginModule
  • uri-resolvers-js
    • Added StaticResolver and StaticResolver.from to optimize building resolvers with IUriRedirect, IUriWrapper and IUriPackage.
  • schema-bind-js
    • In the module template, PluginModule is now imported fron plugin-js instead of core-js

Breaking changes:

  • client-js
    • The Polywrap Client with noDefaults: false no longer accepts a plugins field, but it accepts wrappers and packages.
      • resolver field has been replaced with resolvers, since with default client the resolver used is the RecursiveResolver with the PackageToWrapperCacheResolver.
    • The Polywrap Client with noDefaults: true, no longer accepts a plugins field. It is expected that devs using this option will manually configure their own resolver.
    • removed getPlugins and getPluginByUri. Will add getWrapper, getWrapperByUri, getPackage, getPackageByUri, in a follow up PR.
    • createPolywrapClient function has been deleted from the client-js package as it is unnecessary
  • config-builder-js
    • Now uses the CustomClientConfig which doesn't have plugins and a resolver, but now has wrappers, packages and resolvers
    • Calling build returns an instance of the CustomClientConfig, which can be used with defaults from the PolywrapClient, but can not be used if noDefaults: true is passed to the PolywrapClient constructor.
    • Removed addPlugin from the ClientConfigBuilder, users can now use addWrapper or addPackage where appropriate.
    • Renamed addUriRedirect to addRedirect to keep it inline with addWrapper and addPackage (IUriRedirect, IUriWrapper, IUriPackage)
  • core-js
    • Plugins are no longer a part of this package, they have been moved to the plugin-js package
    • Renamed UriRedirect to IUriRedirect to match IUriWrapper and IUriPackage
    • IUriRedirect, IUriWrapper and IUriPackage are now generic and their generic param implements Uri | string
    • Removed options argument from client.getManifest method since all wrappers have a deserialized manifest
  • react-js
    • Replaced plugins on the PolywrapProvider with wrappers and packages
  • uri-resolvers-js
    • Replaced helper func buildUriResolver with UriResolver.from
    • Constructors of built-in resolvers like RecursiveResolver and PackageToWrapperCacheResolver now accept a concrete IUriResolver while their static from methods accept a UriResolverLike
    • Remove PluginsResolver and PluginResolver, users can now use WrapperResolver or PackageResolver

@dOrgJelli dOrgJelli changed the base branch from origin-dev to origin-0.10-dev October 20, 2022 20:46
@nerfZael nerfZael linked an issue Oct 21, 2022 that may be closed by this pull request
@dOrgJelli dOrgJelli merged commit 4cd4089 into origin-0.10-dev Oct 24, 2022
@dOrgJelli dOrgJelli deleted the nerfzael-remove-plugins-from-core-and-client branch April 10, 2023 17:02
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.

Remove plugin types from client and core
4 participants