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

Breaking changes in v4 #396

Closed
24 tasks done
cocopon opened this issue Apr 18, 2022 · 4 comments
Closed
24 tasks done

Breaking changes in v4 #396

cocopon opened this issue Apr 18, 2022 · 4 comments
Milestone

Comments

@cocopon
Copy link
Owner

cocopon commented Apr 18, 2022

WIP
https://github.com/cocopon/tweakpane/tree/v4

@cocopon cocopon added this to the 4.0.0 milestone Apr 18, 2022
@cocopon cocopon pinned this issue Jan 30, 2023
@cocopon
Copy link
Owner Author

cocopon commented Feb 6, 2023

Changelog (WIP)

For users

Breaking changes

  • Migrated to ES modules (Support import as ES module type #209)
    • Use <script type="module"> to use the package
  • Unified methods to add bindings (Unify addInput() and addMonitor() #486)
    • Use addBinding() to add input bindings (former addInput())
    • Use addBinding() with {readonly: true} to add monitor bindings (former addMonitor())
  • Changed a event name for monitor bindings
    • Use change event for handling monitor updates instead of update
  • Replaced a preset with a blade state
    • Use importState() and exportState() instead of importPreset() and exportPreset()
  • Changed an option name for changing visual height of monitors
    • lineCount -> rows
  • Changed a way to get a binding key in event handlers
    • Use TpChangeEvent.target.key instead of TpChangeEvent.key
  • Renamed classes
    • ListApi -> ListBindingApi
    • SliderApi -> SliderBladeApi
    • TextApi -> TextBladeApi
  • Renamed fields
    • SliderApi.maxValue -> SliderBladeApi.max
    • SliderApi.minValue -> SliderBladeApi.min

New features

For plugin developers

Diff of Essentials plugin (TODO) can be useful to know how to migrate your plugin to v4.

Breaking changes

  • Added core field to all types of plugins for checking compatibility. Use createPlugin() to add the core version.
  • Added id field to plugin bundle.
  • Moved css field from plugin to plugin bundle.
  • Changed a core style file for plugins
    • @import '../../node_modules/@tweakpane/core/lib/sass/plugin'; -> @use '../../node_modules/@tweakpane/core/lib/sass/tp';
  • Added a namespace and a prefix tp to mixins, functions, and variables
    • .#{$prefix}-some -> .#{tp.$prefix}-some
      • @extend %input -> @extend %tp-input

New features

  • Added a way to provide a custom API for binding controllers (More specific API for input bindings #455)
    • InputBindingPlugin.api()
    • MonitorBindingPlugin.api()
  • Added more stable way to access internal CSS variables
    • var(--in-bg) -> tp.cssVar('input-bg')
    • Refer _defs.scss to see the list of variables
  • Added more stable way to access CSS modifiers
    • &.#{$prefix}-v-disabled -> &#{tp.$disabled}

@cocopon
Copy link
Owner Author

cocopon commented Apr 28, 2023

Migration guide: for plugin developers

  • Migrate your package to ES modules
    • Upgrade rollup.config.js
    • Add .js postfix to all import statements
  • Add id to TpPluginBundle
  • Change TpPlugin.css to TpPluginBundle.css
  • Update rollup.config.js
    • Change entries[0].replacement for @rollup/plugin-alias to ./node_modules/@tweakpane/core/dist/index.js
  • LabeledValueController -> LabeledValueBladeController
  • parseParams -> parseRecord
  • ParamsParser -> MicroParser
  • LabelController drops blade field
    • Implement an own blade controller if your plugin directly uses LabelController

@cocopon
Copy link
Owner Author

cocopon commented Apr 29, 2023

Just released 4.0.0-alpha.0. Checking plugins' compatibility...

@kitschpatrol
Copy link
Contributor

kitschpatrol commented Nov 4, 2023

I know this is closed, but in case it's helpful to anyone else I've ported a bunch of community plugins to Tweakpane 4.

I have PRs open on all of the original repos, but if anyone needs a Tweakpane 4 compatible plugin right away, the forks are on NPM:

@kitschpatrol/tweakpane-image-plugin
@kitschpatrol/tweakpane-plugin-profiler PR merged 👍
@kitschpatrol/tweakpane-plugin-rotation PR merged 👍
@kitschpatrol/tweakpane-plugin-thumbnail-list
@kitschpatrol/tweakpane-plugin-waveform PR merged 👍
@kitschpatrol/tweakpane-textarea-plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants