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

WIP next major #6382

Draft
wants to merge 37 commits into
base: master
Choose a base branch
from
Draft

WIP next major #6382

wants to merge 37 commits into from

Conversation

aymeric-giraudet
Copy link
Member

@aymeric-giraudet aymeric-giraudet commented Oct 8, 2024

Work in progress branch for the next major version of InstantSearch (and its dependent packages).

This includes:

  • Remove support for hogan.js templates (including bindEvent)
  • Change browser targets, support is now "chrome >= 60", "firefox >= 55", "safari >= 12.2"
  • Introduce a new instantsearch-core package, used as a dependency for InstantSearch.js, React InstantSearch and Vue InstantSearch. The last two no longer depend on InstantSearch.js
  • Remove deprecated widgets (places, answers, analytics, EXPERIMENTAL_configureRelatedItems, EXPERIMENTAL_dynamicWidgets)
  • Remove experimental functions (EXPERIMENTAL_use)
  • Remove deprecated helpers (insights, getInsightsAnonymousUserToken, highlight, reverseHighlight, snippet, reverseSnippet)
  • Remove deprecated options (insightsClient -> insights, searchFunction)
  • Remove deprecated options from connector renderers
  • Simplify connectRange
  • Remove deprecated functions in the helper
  • Remove code mods from InstantSearch.js (available from the instantsearch-codemods package)
  • Call client.search for both search and searchForFacetValues
  • emit error as an error instead of an object
  • remove getWidgetState (now getWidgetUiState)
  • remove searchMetadata
  • replace getLocation with getCurrentURL in history router
  • change persistHierarchicalRootCount (to true)
  • change preserveSharedStateOnUnmount (to true), remove the need for any cleanup code of parameters in connectors
  • replace helper with the value of mainHelper in InstantSearch.js

BREAKING CHANGE : Hogan.js and raw HTML templates will no longer work. `bindEvent` also removed.

---------

Co-authored-by: Haroen Viaene <[email protected]>
@Haroenv Haroenv added the 🚨 DO NOT MERGE for a pull request that is ready to review, but should not be merged yet label Oct 8, 2024
Copy link

codesandbox-ci bot commented Oct 8, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit bafb0cb:

Sandbox Source
example-instantsearch-getting-started Configuration
example-react-instantsearch-getting-started Configuration
example-react-instantsearch-next-app-dir-example Configuration
example-react-instantsearch-next-routing-example Configuration
example-vue-instantsearch-getting-started Configuration

@Haroenv Haroenv added this to the instantsearch.js v5 milestone Oct 18, 2024
* fix(widgets): remove analytics widget

The analytics widget has long been deprecated, and is removed with the insights middleware as alternative. You can use the `onEvent` hook to use a different service.

BREAKING CHANGE: the analytics widget no longer exists

* !fixup stories
@Haroenv Haroenv force-pushed the next branch 2 times, most recently from 16ac735 to 3840673 Compare October 18, 2024 13:38
The places widget has long been deprecated, and is removed without replacement as no places service exists anymore.

As a userland solution if you're using the places widget, copy the removed `places.ts` file inside your own project and import it locally.

BREAKING CHANGE: the places widget no longer exists
The answers widget has long been deprecated, and is removed without replacement as no answers service exists anymore.

As a userland solution if you're using the answers widget, copy the removed answers files inside your own project and import it locally.

BREAKING CHANGE: the answers widget no longer exists
BREAKING CHANGE: the findAnswers in the helper no longer exists
Instead you can use `use` to add a middleware

BREAKING CHANGE: EXPERIMENTAL_use function is replaced with use function
babel.config.js Outdated Show resolved Hide resolved
* fix(methods): remove addDisjunctiveRefine

BREAKING CHANGE: addDisjunctiveRefine is replaced with addDisjunctiveFacetRefinement

* fix(methods): remove removeDisjunctiveRefine

BREAKING CHANGE: removeDisjunctiveRefine is replaced with removeDisjunctiveFacetRefinement

* fix(methods): remove addRefine

BREAKING CHANGE: addRefine is replaced with addFacetRefinement

* fix(methods): remove addExclude

BREAKING CHANGE: addExclude is replaced with addFacetExclusion

* fix(methods): remove removeRefine

BREAKING CHANGE: removeRefine is replaced with removeFacetRefinement

* fix(methods): remove removeExclude

BREAKING CHANGE: removeExclude is replaced with removeFacetExclusion

* fix(methods): remove toggleExclude

BREAKING CHANGE: toggleExclude is replaced with toggleFacetExclusion

* fix(methods): remove toggleRefine

BREAKING CHANGE: toggleRefine is replaced with toggleFacetRefinement

* fix(methods): remove toggleRefinement

BREAKING CHANGE: toggleRefinement is replaced with toggleFacetRefinement

* fix(methods): remove isExcluded, isDisjunctiveRefined, hasTag, isTagRefined

These methods are available from the SearchParameters / helper.state instead

BREAKING CHANGE: replace helper.isExcluded with helper.state.isExcludeRefined
BREAKING CHANGE: replace helper.isDisjunctiveRefined with helper.state.isDisjunctiveFacetRefined
BREAKING CHANGE: replace helper.hasTag with helper.state.isTagRefined
BREAKING CHANGE: replace helper.isTagRefined with helper.state.isTagRefined

* fix(methods): remove setCurrentPage

BREAKING CHANGE: setCurrentPage is replaced with setPage

* fix(methods): remove getCurrentPage

BREAKING CHANGE: getCurrentPage is replaced with getPage

* fix(methods): remove getFacetByName

BREAKING CHANGE: getFacetByName (on search results) is replaced by calling results.xxxfacets.find(f => f.name === name) yourself (where xxxfacets is facets, disjunctiveFacets or hierarchicalFacets depending on your use case)

* fix(methods): remove containsRefinement

BREAKING CHANGE: containsRefinement is removed. Instead check the length of the arguments directly.
@Haroenv Haroenv force-pushed the next branch 2 times, most recently from c507965 to 47e48be Compare October 23, 2024 08:26
The widgets (and connectors) EXPERIMENTAL_dynamicWidgets, EXPERIMENTAL_configureRelatedItems are removed, and replaced with their non-experimental version.

If you want to keep using the experimental behaviour of configure related items, you can copy the files from here into your project and continue using them.

BREAKING CHANGE: experimental configure related items is replace with related products
BREAKING CHANGE: experimental dynamic widgets is replaced with dynamic widgets
They are already in place in the instantsearch-codemods package

BREAKING CHANGE: use codemods from `instantsearch-codemods` instead of instantsearch.js
BREAKING CHANGE: remove instantsearch.highlight, instantsearch.reverseHighlight, instantsearch.snippet, instantsearch.reverseSnippet. Instead use the `components` available from a template
BREAKING CHANGE: remove instantsearch.insights, instead use sendEvent
BREAKING CHANGE: remove instantsearch.getInsightsAnonymousUserToken
@Haroenv Haroenv force-pushed the next branch 4 times, most recently from ac63cc6 to 81599db Compare October 24, 2024 11:48
Co-authored-by: Dhaya <[email protected]>
Co-authored-by: Sarah Dayan <[email protected]>

---------

Co-authored-by: Haroen Viaene <[email protected]>
Co-authored-by: Dhaya <[email protected]>

refactor(react): replace instantsearch.js with instantsearch-core (#6439)

BREAKING CHANGE: if you are using any internal instantsearch.js functions, ensure to update to instantsearch-core to avoid duplication

refactor(vue): replace instantsearch.js with instantsearch-core (#6440)

[FX-3069]

BREAKING CHANGE: if you are using any internal instantsearch.js functions, ensure to update to instantsearch-core to avoid duplication

feat(core): migrate instantsearch.js to instantsearch-core (#6424)

BREAKING CHANGE: __hitIndex is no longer populated

refactor(js): remove duplicate files (#6493)

The files `connectors/*/connect*.ts` and `middlewares/create*Middleware.ts` files have the same name in instantsearch.js as in instantsearch-core, making file navigation annoying. This is now solved by re-exporting in the barrel file for those files only.

BREAKING CHANGE: import only from `instantsearch.js/es/{connectors,middleware}` or `instantsearch-core`, not from no longer existing child files
@Haroenv Haroenv force-pushed the next branch 2 times, most recently from b591f0f to 2823c40 Compare October 25, 2024 11:49
* feat(babel): upgrade and set newer browser targets

* fix @babel/traverse security issue

* remove unused babel plugin

* dedupe lockfile

* add babel to vue-instantsearch

* exclude helper docs from eslint rule

---------

Co-authored-by: Haroen Viaene <[email protected]>
* refactor: remove findIndex polyfill

* refactor: remove object spread polyfill

* refactor: remove find and findIndex polyfill

---------

Co-authored-by: Haroen Viaene <[email protected]>
We no longer document directly using the `query` for example in the ais-state-results component, read it either from state or results.

[FX-3194]

BREAKING CHANGE: connectStateResults is no longer exposed from Vue InstantSearch
BREAKING CHANGE: the slot in ais-state-results receives an object with `results`, `state`, `status` and `error`, no longer direct access to e.g. `query`
* fix(connectors): replace hits for items

In the past we have added an `items` alias for the previously added `hits`, so that all widgets are more consistent and the same widget would be usable between hits and relatedItems connectors for example. This is now continued with:
- hits render property removed
- infinite hits cache "write" receives `{ page, items }` instead of hits

[FX-3207]

BREAKING CHANGE: connectHits: `hits` property from render is replaced with `items`
BREAKING CHANGE: connectInfiniteHits: `hits` property from render is replaced with `items`
BREAKING CHANGE: infiniteHits: the cache.write function gets called with `{ page, items }` instead of `{ page, hits }`

* bim
With preserveSharedStateOnUnmount behavior, UI State is the source of truth, when a widget gets removed, the UI State is evaluated again and the parameters result out of that.

[FX-3192]

Not done in this PR yet:
- changed the signature of dispose (no more helper and state)
- implement a similar behavior for recommend

BREAKING CHANGE: The option `future.preserveSharedStateOnUnmount` is removed and now behaves as if it was set to `true`
@Haroenv Haroenv force-pushed the next branch 3 times, most recently from b37ba30 to 7ff6737 Compare December 26, 2024 16:21
Haroenv and others added 11 commits December 30, 2024 15:43
In the past, `canRefine` has been introduced as a consistent way to check if any widget can be refined. There were previous largely overlapping pieces of information exposed which were deprecated. These are now removed.

[FX-3195]

BREAKING CHANGE: clearRefinements: replace `hasRefinements` with `canRefine`
BREAKING CHANGE: hitsPerPage: replace `hasNoResults` with `!canRefine`
BREAKING CHANGE: numericMenu: replace `hasNoResults` with `!canRefine`
BREAKING CHANGE: ratingMenu: replace `hasNoResults` with `!canRefine`
BREAKING CHANGE: sortBy: replace `hasNoResults` with `!canRefine`
Before this PR `canRefine` was always true for searchable.

[FX-3190]

BREAKING CHANGE: `canRefine` is false if there are no results from searchable if there's a query.
* fix(instantsearch): remove addWidget, removeWidget methdos

BREAKING CHANGE: use removeWidgets, addWidgets instead of removeWidget, addWidget

* !fixup
* feat(routing): change default of cleanUrlOnDispose to false

In the vast majority of cases you're either never disposing InstantSearch, or the URL already gets cleared some other way (eg. through SPA navigation). This is why the new default for cleanUrlOnDispose is `false`.

You'd still want to set this option to `true` if you're rendering instantsearch in a modal that should have the url cleared when that modal is closed.

BREAKING CHANGE: default of cleanUrlOnDispose is false

[FX-3213]

* fix tests

* Update packages/instantsearch-core/src/routing/historyRouter.ts

Co-authored-by: Dhaya <[email protected]>

---------

Co-authored-by: Dhaya <[email protected]>
This option is deprecated and all use cases are possible with onStateChange or other methods too

[FX-3216]

BREAKING CHANGE: replace searchFunction usage with onStateChange
This is the cause of the UMD e2e failure in `next`.
…use (#6508)

BREAKING CHANGE: `start` is now called `currentRefinement` and its data structure and behavior are different
feat(connectors): rely entirely on gWSP and gUS for parameters in dispose

In `dispose`, we no longer have any logic other than clearing listeners and removing rendering. This causes a significant simplification in all connectors.

One side-effect of this is that `configure` no longer can be collaborating in ui state. If we'd want that, there's no way to distinguish between the ui state set for one configure or the one set for another. Therefore the configure widget is completely in charge of its parameters. If you want to synchronise configure with the URL, do that separately of the UI State.

Small side-effect of this PR is the deduplication of the test/mock createWidget files

BREAKING CHANGE: widgets no longer explicitly clean in dispose (handled in index widget automatically)
BREAKING CHANGE: configure no longer shows in ui state or routing.

[FX-3209]
* chore: remove no longer needed comments

- algolia/algoliasearch-helper-js#800 made the todo in numeric menu no longer needed
- template is generic

[FX-3215]

* number
…er" (#6516)

* refactor(instantsearch): remove "helper" in favor of "mainHelper"

[FX-3212]

* refactor(instantsearch): rename "mainHelper" to "helper"

[FX-3212]

BREAKING CHANGE: the value search.helper is what used to be search.mainHelper. search.mainHelper no longer exists. Use either search.helper now or search.mainIndex.getHelper()
refactor(routing): simplify historyRouter
@Haroenv Haroenv force-pushed the next branch 8 times, most recently from 569b70d to 68fabfe Compare January 22, 2025 12:40
@Haroenv Haroenv force-pushed the next branch 2 times, most recently from 226154c to bafb0cb Compare January 28, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 DO NOT MERGE for a pull request that is ready to review, but should not be merged yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants