From 12d8b0a41535e02d01fe509989e93969f5fee88a Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Mon, 24 May 2021 17:08:21 +0200 Subject: [PATCH 01/23] feat(template): add widget template for react --- .../React InstantSearch widget/.eslintignore | 2 + .../React InstantSearch widget/.eslintrc.cjs | 13 ++++ .../React InstantSearch widget/.gitignore | 5 ++ .../React InstantSearch widget/.prettierrc | 5 ++ .../React InstantSearch widget/.template.js | 21 +++++ .../React InstantSearch widget/README.md | 56 ++++++++++++++ .../babel.config.cjs | 8 ++ .../React InstantSearch widget/index.html.hbs | 13 ++++ .../package.json.hbs | 77 +++++++++++++++++++ .../src/index.tsx.hbs | 3 + .../src/lib/__tests__/dummy-test.tsx.hbs | 40 ++++++++++ .../src/lib/component.tsx.hbs | 13 ++++ .../src/lib/connector.ts.hbs | 28 +++++++ .../src/lib/widget.tsx.hbs | 6 ++ .../src/main.tsx.hbs | 23 ++++++ .../React InstantSearch widget/src/shims.d.ts | 50 ++++++++++++ .../tsconfig.declaration.json | 10 +++ .../React InstantSearch widget/tsconfig.json | 20 +++++ .../React InstantSearch widget/vite.config.ts | 33 ++++++++ 19 files changed, 426 insertions(+) create mode 100644 src/templates/React InstantSearch widget/.eslintignore create mode 100644 src/templates/React InstantSearch widget/.eslintrc.cjs create mode 100644 src/templates/React InstantSearch widget/.gitignore create mode 100644 src/templates/React InstantSearch widget/.prettierrc create mode 100644 src/templates/React InstantSearch widget/.template.js create mode 100644 src/templates/React InstantSearch widget/README.md create mode 100644 src/templates/React InstantSearch widget/babel.config.cjs create mode 100644 src/templates/React InstantSearch widget/index.html.hbs create mode 100644 src/templates/React InstantSearch widget/package.json.hbs create mode 100644 src/templates/React InstantSearch widget/src/index.tsx.hbs create mode 100644 src/templates/React InstantSearch widget/src/lib/__tests__/dummy-test.tsx.hbs create mode 100644 src/templates/React InstantSearch widget/src/lib/component.tsx.hbs create mode 100644 src/templates/React InstantSearch widget/src/lib/connector.ts.hbs create mode 100644 src/templates/React InstantSearch widget/src/lib/widget.tsx.hbs create mode 100644 src/templates/React InstantSearch widget/src/main.tsx.hbs create mode 100644 src/templates/React InstantSearch widget/src/shims.d.ts create mode 100644 src/templates/React InstantSearch widget/tsconfig.declaration.json create mode 100644 src/templates/React InstantSearch widget/tsconfig.json create mode 100644 src/templates/React InstantSearch widget/vite.config.ts diff --git a/src/templates/React InstantSearch widget/.eslintignore b/src/templates/React InstantSearch widget/.eslintignore new file mode 100644 index 000000000..442f04bcc --- /dev/null +++ b/src/templates/React InstantSearch widget/.eslintignore @@ -0,0 +1,2 @@ +/dist +node_modules/ \ No newline at end of file diff --git a/src/templates/React InstantSearch widget/.eslintrc.cjs b/src/templates/React InstantSearch widget/.eslintrc.cjs new file mode 100644 index 000000000..90eff96ad --- /dev/null +++ b/src/templates/React InstantSearch widget/.eslintrc.cjs @@ -0,0 +1,13 @@ +// eslint-disable-next-line import/no-commonjs +module.exports = { + extends: ['algolia', 'algolia/jest', 'algolia/react', 'algolia/typescript'], + rules: { + '@typescript-eslint/explicit-function-return-type': 'off', + 'jest/expect-expect': 'off', + }, + settings: { + react: { + version: 'detect', + }, + }, +}; diff --git a/src/templates/React InstantSearch widget/.gitignore b/src/templates/React InstantSearch widget/.gitignore new file mode 100644 index 000000000..d451ff16c --- /dev/null +++ b/src/templates/React InstantSearch widget/.gitignore @@ -0,0 +1,5 @@ +node_modules +.DS_Store +dist +dist-ssr +*.local diff --git a/src/templates/React InstantSearch widget/.prettierrc b/src/templates/React InstantSearch widget/.prettierrc new file mode 100644 index 000000000..833f03b62 --- /dev/null +++ b/src/templates/React InstantSearch widget/.prettierrc @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "proseWrap": "never", + "trailingComma": "es5" +} diff --git a/src/templates/React InstantSearch widget/.template.js b/src/templates/React InstantSearch widget/.template.js new file mode 100644 index 000000000..3f1f1aabf --- /dev/null +++ b/src/templates/React InstantSearch widget/.template.js @@ -0,0 +1,21 @@ +const install = require('../../tasks/node/install'); +const teardown = require('../../tasks/node/teardown'); + +module.exports = { + category: 'Widget', + libraryName: 'react-instantsearch', + supportedVersion: '>= 6.0.0 < 7.0.0', + templateName: 'react-instantsearch widget', + appName: 'react-instantsearch-app', + keywords: [ + 'algolia', + 'InstantSearch', + 'React', + 'react-instantsearch', + 'widget', + ], + tasks: { + install, + teardown, + }, +}; diff --git a/src/templates/React InstantSearch widget/README.md b/src/templates/React InstantSearch widget/README.md new file mode 100644 index 000000000..71e35f2bf --- /dev/null +++ b/src/templates/React InstantSearch widget/README.md @@ -0,0 +1,56 @@ +# {{name}} + +_This project was generated with [create-instantsearch-app](https://github.com/algolia/create-instantsearch-app) by [Algolia](https://algolia.com)._ + +{{ description }} + +## Install + +```bash +npm install {{ packageName }} +# or +yarn add {{ packageName }} +``` + +## Widget + +### Usage + +```jsx +import instantsearch from 'instantsearch.js'; +import algoliasearch from 'algoliasearch/lite'; +import { {{ pascalCaseName }} } from '{{ packageName }}'; + +const searchClient = algoliasearch('appId', 'apiKey'); + +const App = () => ( + + <{{ pascalCaseName }} /> + +); +``` + +## Connector + +### Usage + +```jsx +import { connect{{ pascalCaseName }} } from '{{ packageName }}'; + +// 1. Create a render function +const Render{{ pascalCaseName }} = (renderOptions, isFirstRender) => { + // Rendering logic +}; + +// 2. Create the custom widget +const Custom{{ pascalCaseName }} = connect{{ pascalCaseName }}( + Render{{ pascalCaseName }} +); + +// 3. Instantiate +const App = () => ( + + + +); +``` diff --git a/src/templates/React InstantSearch widget/babel.config.cjs b/src/templates/React InstantSearch widget/babel.config.cjs new file mode 100644 index 000000000..bd1afc1f0 --- /dev/null +++ b/src/templates/React InstantSearch widget/babel.config.cjs @@ -0,0 +1,8 @@ +// eslint-disable-next-line import/no-commonjs +module.exports = { + presets: [ + ['@babel/preset-env', { targets: { node: 'current' } }], + '@babel/preset-react', + '@babel/preset-typescript', + ], +}; diff --git a/src/templates/React InstantSearch widget/index.html.hbs b/src/templates/React InstantSearch widget/index.html.hbs new file mode 100644 index 000000000..a2ee465f2 --- /dev/null +++ b/src/templates/React InstantSearch widget/index.html.hbs @@ -0,0 +1,13 @@ + + + + + + + {{ packageName }} | example + + +
+ + + diff --git a/src/templates/React InstantSearch widget/package.json.hbs b/src/templates/React InstantSearch widget/package.json.hbs new file mode 100644 index 000000000..0c44d8bb2 --- /dev/null +++ b/src/templates/React InstantSearch widget/package.json.hbs @@ -0,0 +1,77 @@ +{ + "name": "{{ packageName }}", + "version": "1.0.0", + "description": "{{ description }}", + "keywords": [ + "instantsearch-widget", + "instantsearch", + "react-instantsearch", + "widget", + "connector", + "algolia" + ], + "license": "MIT", + "main": "./dist/index.cjs.js", + "module": "./dist/index.es.js", + "exports": { + "import": "./dist/index.es.js", + "require": "./dist/index.cjs.js" + }, + "jsdelivr": "./dist/index.umd.js", + "unpkg": "./dist/index.umd.js", + "types": "./dist/index.d.ts", + "type": "module", + "files": [ + "dist" + ], + "scripts": { + "start": "vite", + "prebuild": "rm -rf dist", + "build": "vite build && npm run build:types", + "build:types": "tsc -p tsconfig.declaration.json", + "lint": "eslint --ext .js,.ts,.tsx .", + "lint:fix": "npm run lint --fix", + "test": "NODE_OPTIONS=--experimental-vm-modules jest", + "test:watch": "npm test -- --watch", + "test:types": "tsc", + "release": "standard-version" + }, + "dependencies": { + "algoliasearch": "^4.9.1", + "react": "^17.0.0", + "react-dom": "^17.0.0", + "react-instantsearch-dom": "^6.11.0" + }, + "devDependencies": { + "@babel/core": "7.14.3", + "@babel/preset-env": "7.14.2", + "@babel/preset-react": "7.13.13", + "@babel/preset-typescript": "7.13.0", + "@testing-library/react": "11.2.7", + "@types/jest": "26.0.23", + "@types/node": "15.3.0", + "@types/react": "17.0.0", + "@types/react-dom": "17.0.0", + "@typescript-eslint/eslint-plugin": "4.24.0", + "@typescript-eslint/parser": "4.24.0", + "@vitejs/plugin-react-refresh": "1.3.1", + "babel-eslint": "10.1.0", + "babel-jest": "26.6.3", + "eslint": "7.26.0", + "eslint-config-algolia": "18.0.0", + "eslint-config-prettier": "8.3.0", + "eslint-plugin-eslint-comments": "3.2.0", + "eslint-plugin-import": "2.23.2", + "eslint-plugin-jest": "24.3.6", + "eslint-plugin-jsdoc": "34.8.1", + "eslint-plugin-jsx-a11y": "6.4.1", + "eslint-plugin-prettier": "3.4.0", + "eslint-plugin-react": "7.23.2", + "eslint-plugin-react-hooks": "4.2.0", + "jest": "26.6.3", + "prettier": "2.3.0", + "standard-version": "9.3.0", + "typescript": "4.2.4", + "vite": "2.3.3" + } +} diff --git a/src/templates/React InstantSearch widget/src/index.tsx.hbs b/src/templates/React InstantSearch widget/src/index.tsx.hbs new file mode 100644 index 000000000..71bcdfd1c --- /dev/null +++ b/src/templates/React InstantSearch widget/src/index.tsx.hbs @@ -0,0 +1,3 @@ +export { connect{{ pascalCaseName }} } from './lib/connector'; +export { {{ pascalCaseName }}Component } from './lib/component'; +export { {{ pascalCaseName }} } from './lib/widget'; diff --git a/src/templates/React InstantSearch widget/src/lib/__tests__/dummy-test.tsx.hbs b/src/templates/React InstantSearch widget/src/lib/__tests__/dummy-test.tsx.hbs new file mode 100644 index 000000000..07aeb6d69 --- /dev/null +++ b/src/templates/React InstantSearch widget/src/lib/__tests__/dummy-test.tsx.hbs @@ -0,0 +1,40 @@ +import { render, fireEvent } from '@testing-library/react'; +import React from 'react'; +// @ts-expect-error +import { InstantSearch, Hits } from 'react-instantsearch-dom'; + +import { {{ pascalCaseName }} } from '../widget'; + +const runAllMicroTasks = (): Promise => new Promise(setImmediate); + +describe('nothing', () => { + it('tests nothing', async () => { + const searchClient = { + search(requests: any[]) { + return Promise.resolve({ + results: [ + { + hits: + [ + { + objectID: 'a', + name: 'test', + }, + ], + }, + ], + }); + }, + }; + + const { debug } = render( + + <{{ pascalCaseName }} /> + hit.name} /> + + ); + + await runAllMicroTasks(); + debug(); + }); +}); diff --git a/src/templates/React InstantSearch widget/src/lib/component.tsx.hbs b/src/templates/React InstantSearch widget/src/lib/component.tsx.hbs new file mode 100644 index 000000000..acc90c882 --- /dev/null +++ b/src/templates/React InstantSearch widget/src/lib/component.tsx.hbs @@ -0,0 +1,13 @@ +import React from 'react'; + +type Props = { + // TODO: this is the object returned by `getProvidedProps` from the connector. +}; + +export const {{ pascalCaseName }}Component = ({}: Props) => { + return ( +
+ {/* TODO: render something */} +
+ ); +}; diff --git a/src/templates/React InstantSearch widget/src/lib/connector.ts.hbs b/src/templates/React InstantSearch widget/src/lib/connector.ts.hbs new file mode 100644 index 000000000..84f315e0b --- /dev/null +++ b/src/templates/React InstantSearch widget/src/lib/connector.ts.hbs @@ -0,0 +1,28 @@ +import { createConnector } from 'react-instantsearch-dom'; + +export const connect{{ pascalCaseName }} = createConnector({ + displayName: '{{ pascalCaseName }}', + + getProvidedProps(props, searchState, searchResults) { + return { + // TODO: return a props for the component + }; + }, + + refine(props, searchState, nextRefinement) { + return { + // TODO: return a next searchState + }; + }, + + cleanUp(props, searchState, context) { + return { + // TODO: return a searchState where this widget is removed from the widget tree + }; + }, + + getSearchParameters(searchParameters, props, searchState) { + // TODO: update and return the searchParameters + return searchParameters; + }, +}); diff --git a/src/templates/React InstantSearch widget/src/lib/widget.tsx.hbs b/src/templates/React InstantSearch widget/src/lib/widget.tsx.hbs new file mode 100644 index 000000000..39f37bbde --- /dev/null +++ b/src/templates/React InstantSearch widget/src/lib/widget.tsx.hbs @@ -0,0 +1,6 @@ +import { {{ pascalCaseName }}Component } from './component'; +import { connect{{ pascalCaseName }} } from './connector'; + +export const {{ pascalCaseName }} = connect{{ pascalCaseName }}( + {{ pascalCaseName }}Component +); diff --git a/src/templates/React InstantSearch widget/src/main.tsx.hbs b/src/templates/React InstantSearch widget/src/main.tsx.hbs new file mode 100644 index 000000000..156bfb144 --- /dev/null +++ b/src/templates/React InstantSearch widget/src/main.tsx.hbs @@ -0,0 +1,23 @@ +import algoliasearch from 'algoliasearch/lite'; +import React from 'react'; +import ReactDOM from 'react-dom'; +// @ts-expect-error +import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom'; + +import { {{ pascalCaseName }} } from '.'; + +const searchClient = algoliasearch( + 'latency', + '6be0576ff61c053d5f9a3225e2a90f76' +); + +ReactDOM.render( + + + <{{ pascalCaseName }} /> + + + + , + document.getElementById('root') +); diff --git a/src/templates/React InstantSearch widget/src/shims.d.ts b/src/templates/React InstantSearch widget/src/shims.d.ts new file mode 100644 index 000000000..50bc62d43 --- /dev/null +++ b/src/templates/React InstantSearch widget/src/shims.d.ts @@ -0,0 +1,50 @@ +declare module 'react-instantsearch-dom' { + import type { ElementType } from 'react'; + + type ConnectorDescription = { + displayName: string; + /** + * A function to filter the local state. + */ + refine?: (props: any, searchState: any, searchResults: any) => any; + /** + * Function transforming the local state to a SearchParameters. + */ + getSearchParameters?: ( + searchParameters: any, + props: any, + searchState: any + ) => any; + /** + * Metadata of the widget (for current refinements). + */ + getMetadata?: (props: any, searchState: any) => any; + /** + * Hook after the state has changed. + */ + transitionState?: ( + props: any, + prevSearchState: any, + nextSearchState: any + ) => any; + /** + * Transform the state into props passed to the wrapped component. + * Receives (props, widgetStates, searchState, metadata) and returns the local state. + */ + getProvidedProps: (props: any, searchState: any, searchResults: any) => any; + /** + * Receives props and return the id that will be used to identify the widget. + */ + getId?: (...args: any[]) => string; + /** + * Hook when the widget will unmount. Receives (props, searchState) and return a cleaned state. + */ + cleanUp?: (props: any, searchState: any, context: any) => any; + searchForFacetValues?: (...args: any[]) => any; + shouldComponentUpdate?: (...args: any[]) => boolean; + }; + + export const createConnector: ( + connectorDesc: ConnectorDescription + ) => (component: ElementType) => ElementType; +} diff --git a/src/templates/React InstantSearch widget/tsconfig.declaration.json b/src/templates/React InstantSearch widget/tsconfig.declaration.json new file mode 100644 index 000000000..10539294d --- /dev/null +++ b/src/templates/React InstantSearch widget/tsconfig.declaration.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "outDir": "dist", + "noEmit": false, + "declaration": true, + "emitDeclarationOnly": true + }, + "exclude": ["./src/main.tsx", "**/__tests__"] +} diff --git a/src/templates/React InstantSearch widget/tsconfig.json b/src/templates/React InstantSearch widget/tsconfig.json new file mode 100644 index 000000000..6c6b05047 --- /dev/null +++ b/src/templates/React InstantSearch widget/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "ESNext", + "lib": ["DOM", "DOM.Iterable", "ESNext"], + "types": ["vite/client", "node", "jest"], + "allowJs": false, + "skipLibCheck": true, + "esModuleInterop": false, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "module": "ESNext", + "moduleResolution": "Node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react" + }, + "include": ["./src"] +} diff --git a/src/templates/React InstantSearch widget/vite.config.ts b/src/templates/React InstantSearch widget/vite.config.ts new file mode 100644 index 000000000..3ed486e2a --- /dev/null +++ b/src/templates/React InstantSearch widget/vite.config.ts @@ -0,0 +1,33 @@ +import path from 'path'; + +import reactRefresh from '@vitejs/plugin-react-refresh'; +import vite from 'vite'; + +// import { defineConfig } from 'vite' -> fails when type:module in package.json +// it seems related to https://github.com/vitejs/vite/issues/1560 +// so far this is the workaround. +const { defineConfig } = vite; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [reactRefresh()], + build: { + lib: { + entry: path.resolve(__dirname, 'src/index.tsx'), + name: 'SampleCustom', + fileName: 'index', + formats: ['es', 'cjs', 'umd'], + }, + rollupOptions: { + // make sure to externalize deps that shouldn't be bundled + // into your library + external: ['react', 'react-dom', 'react-instantsearch-dom'], + output: { + globals: { + react: 'React', + 'react-instantsearch-dom': 'ReactInstantSearchDOM', + }, + }, + }, + }, +}); From 5fc6445c09b0a4650db84b6db5a1767c69fc9fcd Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Mon, 24 May 2021 17:24:32 +0200 Subject: [PATCH 02/23] chore: update test case --- .../src/lib/__tests__/dummy-test.tsx.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/templates/React InstantSearch widget/src/lib/__tests__/dummy-test.tsx.hbs b/src/templates/React InstantSearch widget/src/lib/__tests__/dummy-test.tsx.hbs index 07aeb6d69..86de6b8d0 100644 --- a/src/templates/React InstantSearch widget/src/lib/__tests__/dummy-test.tsx.hbs +++ b/src/templates/React InstantSearch widget/src/lib/__tests__/dummy-test.tsx.hbs @@ -1,4 +1,4 @@ -import { render, fireEvent } from '@testing-library/react'; +import { render } from '@testing-library/react'; import React from 'react'; // @ts-expect-error import { InstantSearch, Hits } from 'react-instantsearch-dom'; @@ -10,7 +10,7 @@ const runAllMicroTasks = (): Promise => new Promise(setImmediate); describe('nothing', () => { it('tests nothing', async () => { const searchClient = { - search(requests: any[]) { + search(_requests: any[]) { return Promise.resolve({ results: [ { From 481e30c15dabbb10f7ce2dbc0caa07775e397093 Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Mon, 24 May 2021 17:39:32 +0200 Subject: [PATCH 03/23] docs: update README --- .../React InstantSearch widget/README.md | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/templates/React InstantSearch widget/README.md b/src/templates/React InstantSearch widget/README.md index 71e35f2bf..0d10a30c9 100644 --- a/src/templates/React InstantSearch widget/README.md +++ b/src/templates/React InstantSearch widget/README.md @@ -54,3 +54,35 @@ const App = () => ( ); ``` + +## Test + +```bash +npm test +# or +yarn test +``` + +## Release + +```bash +npm run release +# or +yarn release +``` + +### First Release + +```bash +npm run release -- --first-release +# or +yarn release --first-release +``` + +This will tag a release without bumping the version. + +When you are ready, push the git tag and run `npm publish`. + +If you want to publish it as a public scoped package, run `npm publish --access public`. + +[To know more about `standard-version`, read this →](https://github.com/conventional-changelog/standard-version#cli-usage) From 6758be8b571246d79dddebf3bf0e90d8ee5dc9c4 Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Tue, 25 May 2021 14:12:25 +0200 Subject: [PATCH 04/23] docs: add build section --- src/templates/React InstantSearch widget/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/templates/React InstantSearch widget/README.md b/src/templates/React InstantSearch widget/README.md index 0d10a30c9..e3324bd3a 100644 --- a/src/templates/React InstantSearch widget/README.md +++ b/src/templates/React InstantSearch widget/README.md @@ -63,6 +63,14 @@ npm test yarn test ``` +## Build + +```bash +npm run build +# or +yarn build +``` + ## Release ```bash From d1be4637f76bff1266ac0de2ac050dc788b38d81 Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Tue, 25 May 2021 16:08:14 +0200 Subject: [PATCH 05/23] chore: add type for widget --- .../src/lib/widget.tsx.hbs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/templates/React InstantSearch widget/src/lib/widget.tsx.hbs b/src/templates/React InstantSearch widget/src/lib/widget.tsx.hbs index 39f37bbde..f8251fb1b 100644 --- a/src/templates/React InstantSearch widget/src/lib/widget.tsx.hbs +++ b/src/templates/React InstantSearch widget/src/lib/widget.tsx.hbs @@ -1,6 +1,14 @@ import { {{ pascalCaseName }}Component } from './component'; import { connect{{ pascalCaseName }} } from './connector'; -export const {{ pascalCaseName }} = connect{{ pascalCaseName }}( - {{ pascalCaseName }}Component -); +import type { ElementType } from 'react'; + +type WidgetParams = { + /** + * Placeholder text for input element. + */ + placeholder?: string; +}; + +export const {{ pascalCaseName }}: ElementType = + connect{{ pascalCaseName }}({{ pascalCaseName }}Component); From c6c05480681bc08c9f2a1e8d5e83c8e2c2990d2c Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Tue, 25 May 2021 16:28:44 +0200 Subject: [PATCH 06/23] chore: update test snapshots --- src/api/__tests__/__snapshots__/index.test.js.snap | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/__tests__/__snapshots__/index.test.js.snap b/src/api/__tests__/__snapshots__/index.test.js.snap index 254a0b711..f45710d93 100644 --- a/src/api/__tests__/__snapshots__/index.test.js.snap +++ b/src/api/__tests__/__snapshots__/index.test.js.snap @@ -6,10 +6,10 @@ exports[`Options with invalid name throws 1`] = ` - name can only contain URL-friendly characters" `; -exports[`Options with unknown template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete.js, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, InstantSearch.js widget, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Native, Vue InstantSearch, Vue InstantSearch 1, Vue InstantSearch 2"`; +exports[`Options with unknown template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete.js, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, InstantSearch.js widget, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Native, React InstantSearch widget, Vue InstantSearch, Vue InstantSearch 1, Vue InstantSearch 2"`; -exports[`Options with wrong template path throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete.js, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, InstantSearch.js widget, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Native, Vue InstantSearch, Vue InstantSearch 1, Vue InstantSearch 2"`; +exports[`Options with wrong template path throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete.js, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, InstantSearch.js widget, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Native, React InstantSearch widget, Vue InstantSearch, Vue InstantSearch 1, Vue InstantSearch 2"`; exports[`Options without path throws 1`] = `"The option \`path\` is required."`; -exports[`Options without template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete.js, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, InstantSearch.js widget, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Native, Vue InstantSearch, Vue InstantSearch 1, Vue InstantSearch 2"`; +exports[`Options without template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete.js, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, InstantSearch.js widget, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Native, React InstantSearch widget, Vue InstantSearch, Vue InstantSearch 1, Vue InstantSearch 2"`; From 7c6a1cc3fffb349c4c5251f8fb88584f129d941b Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Tue, 25 May 2021 16:38:30 +0200 Subject: [PATCH 07/23] chore: update e2e test snapshot --- e2e/__snapshots__/templates.test.js.snap | 488 +++++++++++++++++++++++ 1 file changed, 488 insertions(+) diff --git a/e2e/__snapshots__/templates.test.js.snap b/e2e/__snapshots__/templates.test.js.snap index 300f7a0b6..3bf694f93 100644 --- a/e2e/__snapshots__/templates.test.js.snap +++ b/e2e/__snapshots__/templates.test.js.snap @@ -5536,6 +5536,494 @@ Array [ ] `; +exports[`Templates React InstantSearch widget File content: .eslintignore 1`] = ` +"/dist +node_modules/" +`; + +exports[`Templates React InstantSearch widget File content: .eslintrc.cjs 1`] = ` +"// eslint-disable-next-line import/no-commonjs +module.exports = { + extends: ['algolia', 'algolia/jest', 'algolia/react', 'algolia/typescript'], + rules: { + '@typescript-eslint/explicit-function-return-type': 'off', + 'jest/expect-expect': 'off', + }, + settings: { + react: { + version: 'detect', + }, + }, +};" +`; + +exports[`Templates React InstantSearch widget File content: .gitignore 1`] = ` +"node_modules +.DS_Store +dist +dist-ssr +*.local" +`; + +exports[`Templates React InstantSearch widget File content: .prettierrc 1`] = ` +"{ + \\"singleQuote\\": true, + \\"proseWrap\\": \\"never\\", + \\"trailingComma\\": \\"es5\\" +}" +`; + +exports[`Templates React InstantSearch widget File content: README.md 1`] = ` +"# react-instantsearch-app + +_This project was generated with [create-instantsearch-app](https://github.com/algolia/create-instantsearch-app) by [Algolia](https://algolia.com)._ + + + +## Install + +\`\`\`bash +npm install @algolia/react-instantsearch-app +# or +yarn add @algolia/react-instantsearch-app +\`\`\` + +## Widget + +### Usage + +\`\`\`jsx +import instantsearch from 'instantsearch.js'; +import algoliasearch from 'algoliasearch/lite'; +import { ReactInstantsearchApp } from '@algolia/react-instantsearch-app'; + +const searchClient = algoliasearch('appId', 'apiKey'); + +const App = () => ( + + + +); +\`\`\` + +## Connector + +### Usage + +\`\`\`jsx +import { connectReactInstantsearchApp } from '@algolia/react-instantsearch-app'; + +// 1. Create a render function +const RenderReactInstantsearchApp = (renderOptions, isFirstRender) => { + // Rendering logic +}; + +// 2. Create the custom widget +const CustomReactInstantsearchApp = connectReactInstantsearchApp( + RenderReactInstantsearchApp +); + +// 3. Instantiate +const App = () => ( + + + +); +\`\`\` + +## Test + +\`\`\`bash +npm test +# or +yarn test +\`\`\` + +## Build + +\`\`\`bash +npm run build +# or +yarn build +\`\`\` + +## Release + +\`\`\`bash +npm run release +# or +yarn release +\`\`\` + +### First Release + +\`\`\`bash +npm run release -- --first-release +# or +yarn release --first-release +\`\`\` + +This will tag a release without bumping the version. + +When you are ready, push the git tag and run \`npm publish\`. + +If you want to publish it as a public scoped package, run \`npm publish --access public\`. + +[To know more about \`standard-version\`, read this →](https://github.com/conventional-changelog/standard-version#cli-usage)" +`; + +exports[`Templates React InstantSearch widget File content: babel.config.cjs 1`] = ` +"// eslint-disable-next-line import/no-commonjs +module.exports = { + presets: [ + ['@babel/preset-env', { targets: { node: 'current' } }], + '@babel/preset-react', + '@babel/preset-typescript', + ], +};" +`; + +exports[`Templates React InstantSearch widget File content: index.html 1`] = ` +" + + + + + + @algolia/react-instantsearch-app | example + + +
+ + +" +`; + +exports[`Templates React InstantSearch widget File content: package.json 1`] = ` +"{ + \\"name\\": \\"@algolia/react-instantsearch-app\\", + \\"version\\": \\"1.0.0\\", + \\"description\\": \\"\\", + \\"keywords\\": [ + \\"instantsearch-widget\\", + \\"instantsearch\\", + \\"react-instantsearch\\", + \\"widget\\", + \\"connector\\", + \\"algolia\\" + ], + \\"license\\": \\"MIT\\", + \\"main\\": \\"./dist/index.cjs.js\\", + \\"module\\": \\"./dist/index.es.js\\", + \\"exports\\": { + \\"import\\": \\"./dist/index.es.js\\", + \\"require\\": \\"./dist/index.cjs.js\\" + }, + \\"jsdelivr\\": \\"./dist/index.umd.js\\", + \\"unpkg\\": \\"./dist/index.umd.js\\", + \\"types\\": \\"./dist/index.d.ts\\", + \\"type\\": \\"module\\", + \\"files\\": [ + \\"dist\\" + ], + \\"scripts\\": { + \\"start\\": \\"vite\\", + \\"prebuild\\": \\"rm -rf dist\\", + \\"build\\": \\"vite build && npm run build:types\\", + \\"build:types\\": \\"tsc -p tsconfig.declaration.json\\", + \\"lint\\": \\"eslint --ext .js,.ts,.tsx .\\", + \\"lint:fix\\": \\"npm run lint --fix\\", + \\"test\\": \\"NODE_OPTIONS=--experimental-vm-modules jest\\", + \\"test:watch\\": \\"npm test -- --watch\\", + \\"test:types\\": \\"tsc\\", + \\"release\\": \\"standard-version\\" + }, + \\"partialDependencies\\": {} +}" +`; + +exports[`Templates React InstantSearch widget File content: src/index.tsx 1`] = ` +"export { connectReactInstantsearchApp } from './lib/connector'; +export { ReactInstantsearchAppComponent } from './lib/component'; +export { ReactInstantsearchApp } from './lib/widget';" +`; + +exports[`Templates React InstantSearch widget File content: src/lib/__tests__/dummy-test.tsx 1`] = ` +"import { render } from '@testing-library/react'; +import React from 'react'; +// @ts-expect-error +import { InstantSearch, Hits } from 'react-instantsearch-dom'; + +import { ReactInstantsearchApp } from '../widget'; + +const runAllMicroTasks = (): Promise => new Promise(setImmediate); + +describe('nothing', () => { + it('tests nothing', async () => { + const searchClient = { + search(_requests: any[]) { + return Promise.resolve({ + results: [ + { + hits: [ + { + objectID: 'a', + name: 'test', + }, + ], + }, + ], + }); + }, + }; + + const { debug } = render( + + + hit.name} /> + + ); + + await runAllMicroTasks(); + debug(); + }); +});" +`; + +exports[`Templates React InstantSearch widget File content: src/lib/component.tsx 1`] = ` +"import React from 'react'; + +type Props = { + // TODO: this is the object returned by \`getProvidedProps\` from the connector. +}; + +export const ReactInstantsearchAppComponent = ({}: Props) => { + return
{/* TODO: render something */}
; +};" +`; + +exports[`Templates React InstantSearch widget File content: src/lib/connector.ts 1`] = ` +"import { createConnector } from 'react-instantsearch-dom'; + +export const connectReactInstantsearchApp = createConnector({ + displayName: 'ReactInstantsearchApp', + + getProvidedProps(props, searchState, searchResults) { + return { + // TODO: return a props for the component + }; + }, + + refine(props, searchState, nextRefinement) { + return { + // TODO: return a next searchState + }; + }, + + cleanUp(props, searchState, context) { + return { + // TODO: return a searchState where this widget is removed from the widget tree + }; + }, + + getSearchParameters(searchParameters, props, searchState) { + // TODO: update and return the searchParameters + return searchParameters; + }, +});" +`; + +exports[`Templates React InstantSearch widget File content: src/lib/widget.tsx 1`] = ` +"import { ReactInstantsearchAppComponent } from './component'; +import { connectReactInstantsearchApp } from './connector'; + +import type { ElementType } from 'react'; + +type WidgetParams = { + /** + * Placeholder text for input element. + */ + placeholder?: string; +}; + +export const ReactInstantsearchApp: ElementType = + connectReactInstantsearchApp(ReactInstantsearchAppComponent);" +`; + +exports[`Templates React InstantSearch widget File content: src/main.tsx 1`] = ` +"import algoliasearch from 'algoliasearch/lite'; +import React from 'react'; +import ReactDOM from 'react-dom'; +// @ts-expect-error +import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom'; + +import { ReactInstantsearchApp } from '.'; + +const searchClient = algoliasearch( + 'latency', + '6be0576ff61c053d5f9a3225e2a90f76' +); + +ReactDOM.render( + + + + + + + , + document.getElementById('root') +);" +`; + +exports[`Templates React InstantSearch widget File content: src/shims.d.ts 1`] = ` +"declare module 'react-instantsearch-dom' { + import type { ElementType } from 'react'; + + type ConnectorDescription = { + displayName: string; + /** + * A function to filter the local state. + */ + refine?: (props: any, searchState: any, searchResults: any) => any; + /** + * Function transforming the local state to a SearchParameters. + */ + getSearchParameters?: ( + searchParameters: any, + props: any, + searchState: any + ) => any; + /** + * Metadata of the widget (for current refinements). + */ + getMetadata?: (props: any, searchState: any) => any; + /** + * Hook after the state has changed. + */ + transitionState?: ( + props: any, + prevSearchState: any, + nextSearchState: any + ) => any; + /** + * Transform the state into props passed to the wrapped component. + * Receives (props, widgetStates, searchState, metadata) and returns the local state. + */ + getProvidedProps: (props: any, searchState: any, searchResults: any) => any; + /** + * Receives props and return the id that will be used to identify the widget. + */ + getId?: (...args: any[]) => string; + /** + * Hook when the widget will unmount. Receives (props, searchState) and return a cleaned state. + */ + cleanUp?: (props: any, searchState: any, context: any) => any; + searchForFacetValues?: (...args: any[]) => any; + shouldComponentUpdate?: (...args: any[]) => boolean; + }; + + export const createConnector: ( + connectorDesc: ConnectorDescription + ) => (component: ElementType) => ElementType; +}" +`; + +exports[`Templates React InstantSearch widget File content: tsconfig.declaration.json 1`] = ` +"{ + \\"extends\\": \\"./tsconfig\\", + \\"compilerOptions\\": { + \\"outDir\\": \\"dist\\", + \\"noEmit\\": false, + \\"declaration\\": true, + \\"emitDeclarationOnly\\": true + }, + \\"exclude\\": [\\"./src/main.tsx\\", \\"**/__tests__\\"] +}" +`; + +exports[`Templates React InstantSearch widget File content: tsconfig.json 1`] = ` +"{ + \\"compilerOptions\\": { + \\"target\\": \\"ESNext\\", + \\"lib\\": [\\"DOM\\", \\"DOM.Iterable\\", \\"ESNext\\"], + \\"types\\": [\\"vite/client\\", \\"node\\", \\"jest\\"], + \\"allowJs\\": false, + \\"skipLibCheck\\": true, + \\"esModuleInterop\\": false, + \\"allowSyntheticDefaultImports\\": true, + \\"strict\\": true, + \\"forceConsistentCasingInFileNames\\": true, + \\"module\\": \\"ESNext\\", + \\"moduleResolution\\": \\"Node\\", + \\"resolveJsonModule\\": true, + \\"isolatedModules\\": true, + \\"noEmit\\": true, + \\"jsx\\": \\"react\\" + }, + \\"include\\": [\\"./src\\"] +}" +`; + +exports[`Templates React InstantSearch widget File content: vite.config.ts 1`] = ` +"import path from 'path'; + +import reactRefresh from '@vitejs/plugin-react-refresh'; +import vite from 'vite'; + +// import { defineConfig } from 'vite' -> fails when type:module in package.json +// it seems related to https://github.com/vitejs/vite/issues/1560 +// so far this is the workaround. +const { defineConfig } = vite; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [reactRefresh()], + build: { + lib: { + entry: path.resolve(__dirname, 'src/index.tsx'), + name: 'SampleCustom', + fileName: 'index', + formats: ['es', 'cjs', 'umd'], + }, + rollupOptions: { + // make sure to externalize deps that shouldn't be bundled + // into your library + external: ['react', 'react-dom', 'react-instantsearch-dom'], + output: { + globals: { + react: 'React', + 'react-instantsearch-dom': 'ReactInstantSearchDOM', + }, + }, + }, + }, +});" +`; + +exports[`Templates React InstantSearch widget Folder structure: contains the right files 1`] = ` +Array [ + ".eslintignore", + ".eslintrc.cjs", + ".gitignore", + ".prettierrc", + "README.md", + "babel.config.cjs", + "index.html", + "package.json", + "src/index.tsx", + "src/lib/__tests__/dummy-test.tsx", + "src/lib/component.tsx", + "src/lib/connector.ts", + "src/lib/widget.tsx", + "src/main.tsx", + "src/shims.d.ts", + "tsconfig.declaration.json", + "tsconfig.json", + "vite.config.ts", +] +`; + exports[`Templates Vue InstantSearch 1 File content: .editorconfig 1`] = ` "root = true From 3a11e605722acd16dfa81b43918e64d77c125211 Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Tue, 25 May 2021 17:06:25 +0200 Subject: [PATCH 08/23] chore: build before release --- src/templates/React InstantSearch widget/package.json.hbs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/templates/React InstantSearch widget/package.json.hbs b/src/templates/React InstantSearch widget/package.json.hbs index 0c44d8bb2..79a0cdc20 100644 --- a/src/templates/React InstantSearch widget/package.json.hbs +++ b/src/templates/React InstantSearch widget/package.json.hbs @@ -34,6 +34,7 @@ "test": "NODE_OPTIONS=--experimental-vm-modules jest", "test:watch": "npm test -- --watch", "test:types": "tsc", + "prerelease": "npm run build", "release": "standard-version" }, "dependencies": { From 6403bfda0e621ec67ab2e2fc057f42cabef9232e Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Tue, 25 May 2021 17:16:56 +0200 Subject: [PATCH 09/23] chore: update e2e snapshot --- e2e/__snapshots__/templates.test.js.snap | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/__snapshots__/templates.test.js.snap b/e2e/__snapshots__/templates.test.js.snap index 3bf694f93..891a3a081 100644 --- a/e2e/__snapshots__/templates.test.js.snap +++ b/e2e/__snapshots__/templates.test.js.snap @@ -5736,6 +5736,7 @@ exports[`Templates React InstantSearch widget File content: package.json 1`] = ` \\"test\\": \\"NODE_OPTIONS=--experimental-vm-modules jest\\", \\"test:watch\\": \\"npm test -- --watch\\", \\"test:types\\": \\"tsc\\", + \\"prerelease\\": \\"npm run build\\", \\"release\\": \\"standard-version\\" }, \\"partialDependencies\\": {} From b541974ecb3d63c5e90eab434da5535b74dab322 Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Fri, 28 May 2021 14:42:44 +0200 Subject: [PATCH 10/23] chore: remove space from templateName --- src/templates/React InstantSearch widget/.template.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/React InstantSearch widget/.template.js b/src/templates/React InstantSearch widget/.template.js index 3f1f1aabf..baf8019a1 100644 --- a/src/templates/React InstantSearch widget/.template.js +++ b/src/templates/React InstantSearch widget/.template.js @@ -5,7 +5,7 @@ module.exports = { category: 'Widget', libraryName: 'react-instantsearch', supportedVersion: '>= 6.0.0 < 7.0.0', - templateName: 'react-instantsearch widget', + templateName: 'react-instantsearch-widget', appName: 'react-instantsearch-app', keywords: [ 'algolia', From f1f5105411c336f424af898077dbb4c7abc0315d Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Tue, 1 Jun 2021 16:38:27 +0200 Subject: [PATCH 11/23] add more keyword --- src/templates/React InstantSearch widget/package.json.hbs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/templates/React InstantSearch widget/package.json.hbs b/src/templates/React InstantSearch widget/package.json.hbs index 79a0cdc20..98361d2ab 100644 --- a/src/templates/React InstantSearch widget/package.json.hbs +++ b/src/templates/React InstantSearch widget/package.json.hbs @@ -6,6 +6,7 @@ "instantsearch-widget", "instantsearch", "react-instantsearch", + "react-instantsearch-widget-{{ packageName }}" "widget", "connector", "algolia" From db3b8e607450b8b1e60077418dcdbd311321f935 Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Tue, 1 Jun 2021 16:41:17 +0200 Subject: [PATCH 12/23] move example to /example folder --- .../React InstantSearch widget/{ => example}/index.html.hbs | 3 +-- .../{src/main.tsx.hbs => example/index.tsx.hbs} | 2 +- src/templates/React InstantSearch widget/package.json.hbs | 2 +- .../React InstantSearch widget/tsconfig.declaration.json | 2 +- src/templates/React InstantSearch widget/tsconfig.json | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) rename src/templates/React InstantSearch widget/{ => example}/index.html.hbs (67%) rename src/templates/React InstantSearch widget/{src/main.tsx.hbs => example/index.tsx.hbs} (92%) diff --git a/src/templates/React InstantSearch widget/index.html.hbs b/src/templates/React InstantSearch widget/example/index.html.hbs similarity index 67% rename from src/templates/React InstantSearch widget/index.html.hbs rename to src/templates/React InstantSearch widget/example/index.html.hbs index a2ee465f2..1d43b3dd1 100644 --- a/src/templates/React InstantSearch widget/index.html.hbs +++ b/src/templates/React InstantSearch widget/example/index.html.hbs @@ -2,12 +2,11 @@ - {{ packageName }} | example
- + diff --git a/src/templates/React InstantSearch widget/src/main.tsx.hbs b/src/templates/React InstantSearch widget/example/index.tsx.hbs similarity index 92% rename from src/templates/React InstantSearch widget/src/main.tsx.hbs rename to src/templates/React InstantSearch widget/example/index.tsx.hbs index 156bfb144..c07725792 100644 --- a/src/templates/React InstantSearch widget/src/main.tsx.hbs +++ b/src/templates/React InstantSearch widget/example/index.tsx.hbs @@ -4,7 +4,7 @@ import ReactDOM from 'react-dom'; // @ts-expect-error import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom'; -import { {{ pascalCaseName }} } from '.'; +import { {{ pascalCaseName }} } from '../src'; const searchClient = algoliasearch( 'latency', diff --git a/src/templates/React InstantSearch widget/package.json.hbs b/src/templates/React InstantSearch widget/package.json.hbs index 98361d2ab..c4626933b 100644 --- a/src/templates/React InstantSearch widget/package.json.hbs +++ b/src/templates/React InstantSearch widget/package.json.hbs @@ -26,7 +26,7 @@ "dist" ], "scripts": { - "start": "vite", + "start": "vite example", "prebuild": "rm -rf dist", "build": "vite build && npm run build:types", "build:types": "tsc -p tsconfig.declaration.json", diff --git a/src/templates/React InstantSearch widget/tsconfig.declaration.json b/src/templates/React InstantSearch widget/tsconfig.declaration.json index 10539294d..4469e2657 100644 --- a/src/templates/React InstantSearch widget/tsconfig.declaration.json +++ b/src/templates/React InstantSearch widget/tsconfig.declaration.json @@ -6,5 +6,5 @@ "declaration": true, "emitDeclarationOnly": true }, - "exclude": ["./src/main.tsx", "**/__tests__"] + "exclude": ["example/index.tsx", "**/__tests__"] } diff --git a/src/templates/React InstantSearch widget/tsconfig.json b/src/templates/React InstantSearch widget/tsconfig.json index 6c6b05047..116a34574 100644 --- a/src/templates/React InstantSearch widget/tsconfig.json +++ b/src/templates/React InstantSearch widget/tsconfig.json @@ -16,5 +16,5 @@ "noEmit": true, "jsx": "react" }, - "include": ["./src"] + "include": ["./src", "example/index.tsx"] } From 4375cf60e3d784bbf2921d7a79d42c1e93adff73 Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Tue, 1 Jun 2021 16:48:26 +0200 Subject: [PATCH 13/23] lower the react version to 16.8.0 --- src/templates/React InstantSearch widget/package.json.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/templates/React InstantSearch widget/package.json.hbs b/src/templates/React InstantSearch widget/package.json.hbs index c4626933b..d08b3fd41 100644 --- a/src/templates/React InstantSearch widget/package.json.hbs +++ b/src/templates/React InstantSearch widget/package.json.hbs @@ -40,8 +40,8 @@ }, "dependencies": { "algoliasearch": "^4.9.1", - "react": "^17.0.0", - "react-dom": "^17.0.0", + "react": "^16.8.0", + "react-dom": "^16.8.0", "react-instantsearch-dom": "^6.11.0" }, "devDependencies": { From 9856a5b7938e2ffc5787f86715714ff42e881a55 Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Tue, 1 Jun 2021 17:08:38 +0200 Subject: [PATCH 14/23] specify ReactDOM as globals --- src/templates/React InstantSearch widget/vite.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/templates/React InstantSearch widget/vite.config.ts b/src/templates/React InstantSearch widget/vite.config.ts index 3ed486e2a..a29da738d 100644 --- a/src/templates/React InstantSearch widget/vite.config.ts +++ b/src/templates/React InstantSearch widget/vite.config.ts @@ -25,6 +25,7 @@ export default defineConfig({ output: { globals: { react: 'React', + 'react-dom': 'ReactDOM', 'react-instantsearch-dom': 'ReactInstantSearchDOM', }, }, From 85c2ac821c1409dd0c3859a931ba954a78eb132f Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Wed, 2 Jun 2021 17:52:15 +0200 Subject: [PATCH 15/23] Apply suggestions from code review Co-authored-by: Haroen Viaene --- src/templates/React InstantSearch widget/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/React InstantSearch widget/README.md b/src/templates/React InstantSearch widget/README.md index e3324bd3a..9530927a6 100644 --- a/src/templates/React InstantSearch widget/README.md +++ b/src/templates/React InstantSearch widget/README.md @@ -91,6 +91,6 @@ This will tag a release without bumping the version. When you are ready, push the git tag and run `npm publish`. -If you want to publish it as a public scoped package, run `npm publish --access public`. +If you want to publish it as a public scoped package, run `npm publish --access public` the first time. [To know more about `standard-version`, read this →](https://github.com/conventional-changelog/standard-version#cli-usage) From c42f82506c991bf8235be3f10f3bc3b7eca36974 Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Wed, 2 Jun 2021 18:03:35 +0200 Subject: [PATCH 16/23] fix: add @types/react-instantsearch-dom and remove shims --- .../example/index.tsx.hbs | 1 - .../package.json.hbs | 1 + .../src/lib/__tests__/dummy-test.tsx.hbs | 1 - .../React InstantSearch widget/src/shims.d.ts | 50 ------------------- 4 files changed, 1 insertion(+), 52 deletions(-) delete mode 100644 src/templates/React InstantSearch widget/src/shims.d.ts diff --git a/src/templates/React InstantSearch widget/example/index.tsx.hbs b/src/templates/React InstantSearch widget/example/index.tsx.hbs index c07725792..801ad9a1f 100644 --- a/src/templates/React InstantSearch widget/example/index.tsx.hbs +++ b/src/templates/React InstantSearch widget/example/index.tsx.hbs @@ -1,7 +1,6 @@ import algoliasearch from 'algoliasearch/lite'; import React from 'react'; import ReactDOM from 'react-dom'; -// @ts-expect-error import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom'; import { {{ pascalCaseName }} } from '../src'; diff --git a/src/templates/React InstantSearch widget/package.json.hbs b/src/templates/React InstantSearch widget/package.json.hbs index d08b3fd41..29b079a4b 100644 --- a/src/templates/React InstantSearch widget/package.json.hbs +++ b/src/templates/React InstantSearch widget/package.json.hbs @@ -54,6 +54,7 @@ "@types/node": "15.3.0", "@types/react": "17.0.0", "@types/react-dom": "17.0.0", + "@types/react-instantsearch-dom": "6.10.0", "@typescript-eslint/eslint-plugin": "4.24.0", "@typescript-eslint/parser": "4.24.0", "@vitejs/plugin-react-refresh": "1.3.1", diff --git a/src/templates/React InstantSearch widget/src/lib/__tests__/dummy-test.tsx.hbs b/src/templates/React InstantSearch widget/src/lib/__tests__/dummy-test.tsx.hbs index 86de6b8d0..822fc68d4 100644 --- a/src/templates/React InstantSearch widget/src/lib/__tests__/dummy-test.tsx.hbs +++ b/src/templates/React InstantSearch widget/src/lib/__tests__/dummy-test.tsx.hbs @@ -1,6 +1,5 @@ import { render } from '@testing-library/react'; import React from 'react'; -// @ts-expect-error import { InstantSearch, Hits } from 'react-instantsearch-dom'; import { {{ pascalCaseName }} } from '../widget'; diff --git a/src/templates/React InstantSearch widget/src/shims.d.ts b/src/templates/React InstantSearch widget/src/shims.d.ts deleted file mode 100644 index 50bc62d43..000000000 --- a/src/templates/React InstantSearch widget/src/shims.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -declare module 'react-instantsearch-dom' { - import type { ElementType } from 'react'; - - type ConnectorDescription = { - displayName: string; - /** - * A function to filter the local state. - */ - refine?: (props: any, searchState: any, searchResults: any) => any; - /** - * Function transforming the local state to a SearchParameters. - */ - getSearchParameters?: ( - searchParameters: any, - props: any, - searchState: any - ) => any; - /** - * Metadata of the widget (for current refinements). - */ - getMetadata?: (props: any, searchState: any) => any; - /** - * Hook after the state has changed. - */ - transitionState?: ( - props: any, - prevSearchState: any, - nextSearchState: any - ) => any; - /** - * Transform the state into props passed to the wrapped component. - * Receives (props, widgetStates, searchState, metadata) and returns the local state. - */ - getProvidedProps: (props: any, searchState: any, searchResults: any) => any; - /** - * Receives props and return the id that will be used to identify the widget. - */ - getId?: (...args: any[]) => string; - /** - * Hook when the widget will unmount. Receives (props, searchState) and return a cleaned state. - */ - cleanUp?: (props: any, searchState: any, context: any) => any; - searchForFacetValues?: (...args: any[]) => any; - shouldComponentUpdate?: (...args: any[]) => boolean; - }; - - export const createConnector: ( - connectorDesc: ConnectorDescription - ) => (component: ElementType) => ElementType; -} From 83cfde94995700a39316fba41fb712f21df0770d Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Wed, 2 Jun 2021 18:10:03 +0200 Subject: [PATCH 17/23] fix: update e2e snapshots --- e2e/__snapshots__/templates.test.js.snap | 125 +++++------------- .../package.json.hbs | 2 +- 2 files changed, 36 insertions(+), 91 deletions(-) diff --git a/e2e/__snapshots__/templates.test.js.snap b/e2e/__snapshots__/templates.test.js.snap index 891a3a081..c0aa491c5 100644 --- a/e2e/__snapshots__/templates.test.js.snap +++ b/e2e/__snapshots__/templates.test.js.snap @@ -5667,7 +5667,7 @@ This will tag a release without bumping the version. When you are ready, push the git tag and run \`npm publish\`. -If you want to publish it as a public scoped package, run \`npm publish --access public\`. +If you want to publish it as a public scoped package, run \`npm publish --access public\` the first time. [To know more about \`standard-version\`, read this →](https://github.com/conventional-changelog/standard-version#cli-usage)" `; @@ -5683,22 +5683,46 @@ module.exports = { };" `; -exports[`Templates React InstantSearch widget File content: index.html 1`] = ` +exports[`Templates React InstantSearch widget File content: example/index.html 1`] = ` " - @algolia/react-instantsearch-app | example
- + " `; +exports[`Templates React InstantSearch widget File content: example/index.tsx 1`] = ` +"import algoliasearch from 'algoliasearch/lite'; +import React from 'react'; +import ReactDOM from 'react-dom'; +import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom'; + +import { ReactInstantsearchApp } from '../src'; + +const searchClient = algoliasearch( + 'latency', + '6be0576ff61c053d5f9a3225e2a90f76' +); + +ReactDOM.render( + + + + + + + , + document.getElementById('root') +);" +`; + exports[`Templates React InstantSearch widget File content: package.json 1`] = ` "{ \\"name\\": \\"@algolia/react-instantsearch-app\\", @@ -5708,6 +5732,7 @@ exports[`Templates React InstantSearch widget File content: package.json 1`] = ` \\"instantsearch-widget\\", \\"instantsearch\\", \\"react-instantsearch\\", + \\"react-instantsearch-widget-@algolia/react-instantsearch-app\\", \\"widget\\", \\"connector\\", \\"algolia\\" @@ -5727,7 +5752,7 @@ exports[`Templates React InstantSearch widget File content: package.json 1`] = ` \\"dist\\" ], \\"scripts\\": { - \\"start\\": \\"vite\\", + \\"start\\": \\"vite example\\", \\"prebuild\\": \\"rm -rf dist\\", \\"build\\": \\"vite build && npm run build:types\\", \\"build:types\\": \\"tsc -p tsconfig.declaration.json\\", @@ -5752,7 +5777,6 @@ export { ReactInstantsearchApp } from './lib/widget';" exports[`Templates React InstantSearch widget File content: src/lib/__tests__/dummy-test.tsx 1`] = ` "import { render } from '@testing-library/react'; import React from 'react'; -// @ts-expect-error import { InstantSearch, Hits } from 'react-instantsearch-dom'; import { ReactInstantsearchApp } from '../widget'; @@ -5851,85 +5875,6 @@ export const ReactInstantsearchApp: ElementType = connectReactInstantsearchApp(ReactInstantsearchAppComponent);" `; -exports[`Templates React InstantSearch widget File content: src/main.tsx 1`] = ` -"import algoliasearch from 'algoliasearch/lite'; -import React from 'react'; -import ReactDOM from 'react-dom'; -// @ts-expect-error -import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom'; - -import { ReactInstantsearchApp } from '.'; - -const searchClient = algoliasearch( - 'latency', - '6be0576ff61c053d5f9a3225e2a90f76' -); - -ReactDOM.render( - - - - - - - , - document.getElementById('root') -);" -`; - -exports[`Templates React InstantSearch widget File content: src/shims.d.ts 1`] = ` -"declare module 'react-instantsearch-dom' { - import type { ElementType } from 'react'; - - type ConnectorDescription = { - displayName: string; - /** - * A function to filter the local state. - */ - refine?: (props: any, searchState: any, searchResults: any) => any; - /** - * Function transforming the local state to a SearchParameters. - */ - getSearchParameters?: ( - searchParameters: any, - props: any, - searchState: any - ) => any; - /** - * Metadata of the widget (for current refinements). - */ - getMetadata?: (props: any, searchState: any) => any; - /** - * Hook after the state has changed. - */ - transitionState?: ( - props: any, - prevSearchState: any, - nextSearchState: any - ) => any; - /** - * Transform the state into props passed to the wrapped component. - * Receives (props, widgetStates, searchState, metadata) and returns the local state. - */ - getProvidedProps: (props: any, searchState: any, searchResults: any) => any; - /** - * Receives props and return the id that will be used to identify the widget. - */ - getId?: (...args: any[]) => string; - /** - * Hook when the widget will unmount. Receives (props, searchState) and return a cleaned state. - */ - cleanUp?: (props: any, searchState: any, context: any) => any; - searchForFacetValues?: (...args: any[]) => any; - shouldComponentUpdate?: (...args: any[]) => boolean; - }; - - export const createConnector: ( - connectorDesc: ConnectorDescription - ) => (component: ElementType) => ElementType; -}" -`; - exports[`Templates React InstantSearch widget File content: tsconfig.declaration.json 1`] = ` "{ \\"extends\\": \\"./tsconfig\\", @@ -5939,7 +5884,7 @@ exports[`Templates React InstantSearch widget File content: tsconfig.declaration \\"declaration\\": true, \\"emitDeclarationOnly\\": true }, - \\"exclude\\": [\\"./src/main.tsx\\", \\"**/__tests__\\"] + \\"exclude\\": [\\"example/index.tsx\\", \\"**/__tests__\\"] }" `; @@ -5962,7 +5907,7 @@ exports[`Templates React InstantSearch widget File content: tsconfig.json 1`] = \\"noEmit\\": true, \\"jsx\\": \\"react\\" }, - \\"include\\": [\\"./src\\"] + \\"include\\": [\\"./src\\", \\"example/index.tsx\\"] }" `; @@ -5994,6 +5939,7 @@ export default defineConfig({ output: { globals: { react: 'React', + 'react-dom': 'ReactDOM', 'react-instantsearch-dom': 'ReactInstantSearchDOM', }, }, @@ -6010,15 +5956,14 @@ Array [ ".prettierrc", "README.md", "babel.config.cjs", - "index.html", + "example/index.html", + "example/index.tsx", "package.json", "src/index.tsx", "src/lib/__tests__/dummy-test.tsx", "src/lib/component.tsx", "src/lib/connector.ts", "src/lib/widget.tsx", - "src/main.tsx", - "src/shims.d.ts", "tsconfig.declaration.json", "tsconfig.json", "vite.config.ts", diff --git a/src/templates/React InstantSearch widget/package.json.hbs b/src/templates/React InstantSearch widget/package.json.hbs index 29b079a4b..eb601b1b9 100644 --- a/src/templates/React InstantSearch widget/package.json.hbs +++ b/src/templates/React InstantSearch widget/package.json.hbs @@ -6,7 +6,7 @@ "instantsearch-widget", "instantsearch", "react-instantsearch", - "react-instantsearch-widget-{{ packageName }}" + "react-instantsearch-widget-{{ packageName }}", "widget", "connector", "algolia" From 2ea1b177f34bc052e154e2465ede363142aab10e Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Thu, 3 Jun 2021 10:22:34 +0200 Subject: [PATCH 18/23] fix: update keyword to use kebabCaseName --- src/templates/React InstantSearch widget/package.json.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/React InstantSearch widget/package.json.hbs b/src/templates/React InstantSearch widget/package.json.hbs index eb601b1b9..7697a833e 100644 --- a/src/templates/React InstantSearch widget/package.json.hbs +++ b/src/templates/React InstantSearch widget/package.json.hbs @@ -6,7 +6,7 @@ "instantsearch-widget", "instantsearch", "react-instantsearch", - "react-instantsearch-widget-{{ packageName }}", + "react-instantsearch-widget-{{ kebabCaseName }}", "widget", "connector", "algolia" From d9ca887f0633386eef54d7fd80190a750ecd40a5 Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Tue, 8 Jun 2021 16:47:05 +0200 Subject: [PATCH 19/23] fix: add kebabCaseName --- package.json | 1 + src/cli/getConfiguration.js | 2 ++ yarn.lock | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/package.json b/package.json index 158725dcb..9e887034f 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "latest-semver": "2.0.0", "load-json-file": "6.2.0", "lodash.camelcase": "4.3.0", + "lodash.kebabcase": "4.1.1", "metalsmith": "2.3.0", "metalsmith-ignore": "1.0.0", "metalsmith-in-place": "4.4.1", diff --git a/src/cli/getConfiguration.js b/src/cli/getConfiguration.js index 5c07f3563..0b6fa7c39 100644 --- a/src/cli/getConfiguration.js +++ b/src/cli/getConfiguration.js @@ -1,6 +1,7 @@ const latestSemver = require('latest-semver'); const loadJsonFile = require('load-json-file'); const camelCase = require('lodash.camelcase'); +const kebabCase = require('lodash.kebabcase'); const { fetchLibraryVersions } = require('../utils'); @@ -14,6 +15,7 @@ function createNameAlternatives({ organization, name }) { widgetType: `${organization}.${name}`, camelCaseName: camelCase(name), pascalCaseName: capitalize(camelCase(name)), + kebabCaseName: kebabCase(name), }; } diff --git a/yarn.lock b/yarn.lock index 368e5c8e3..b46e0a2f9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4550,6 +4550,11 @@ lodash.ismatch@^4.4.0: resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37" integrity sha1-dWy1FQyjum8RCFp4hJZF8Yj4Xzc= +lodash.kebabcase@4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz#8489b1cb0d29ff88195cceca448ff6d6cc295c36" + integrity sha1-hImxyw0p/4gZXM7KRI/21swpXDY= + lodash.set@^4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23" From dec9c2ad210b65ec1a11b714f74e78e1d343f755 Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Thu, 10 Jun 2021 11:18:31 +0200 Subject: [PATCH 20/23] fix: improve types for provided props --- .../React InstantSearch widget/src/lib/component.tsx.hbs | 6 ++++-- .../React InstantSearch widget/src/lib/connector.ts.hbs | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/templates/React InstantSearch widget/src/lib/component.tsx.hbs b/src/templates/React InstantSearch widget/src/lib/component.tsx.hbs index acc90c882..c8a3dcf57 100644 --- a/src/templates/React InstantSearch widget/src/lib/component.tsx.hbs +++ b/src/templates/React InstantSearch widget/src/lib/component.tsx.hbs @@ -1,7 +1,9 @@ import React from 'react'; -type Props = { - // TODO: this is the object returned by `getProvidedProps` from the connector. +import type { ProvidedProps } from './connector' + +type Props = ProvidedProps & { + refine: () => {} }; export const {{ pascalCaseName }}Component = ({}: Props) => { diff --git a/src/templates/React InstantSearch widget/src/lib/connector.ts.hbs b/src/templates/React InstantSearch widget/src/lib/connector.ts.hbs index 84f315e0b..964227b08 100644 --- a/src/templates/React InstantSearch widget/src/lib/connector.ts.hbs +++ b/src/templates/React InstantSearch widget/src/lib/connector.ts.hbs @@ -1,9 +1,13 @@ import { createConnector } from 'react-instantsearch-dom'; +export type ProvidedProps = { + // TODO: fill props that are returned by `getProvidedProps` +} + export const connect{{ pascalCaseName }} = createConnector({ displayName: '{{ pascalCaseName }}', - getProvidedProps(props, searchState, searchResults) { + getProvidedProps(props, searchState, searchResults): ProvidedProps { return { // TODO: return a props for the component }; From 160346348444af8c9bf9bec600b84a51ff573ee6 Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Thu, 10 Jun 2021 11:20:58 +0200 Subject: [PATCH 21/23] Revert "fix: add kebabCaseName" This reverts commit d9ca887f0633386eef54d7fd80190a750ecd40a5. --- package.json | 1 - src/cli/getConfiguration.js | 2 -- yarn.lock | 5 ----- 3 files changed, 8 deletions(-) diff --git a/package.json b/package.json index 9e887034f..158725dcb 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,6 @@ "latest-semver": "2.0.0", "load-json-file": "6.2.0", "lodash.camelcase": "4.3.0", - "lodash.kebabcase": "4.1.1", "metalsmith": "2.3.0", "metalsmith-ignore": "1.0.0", "metalsmith-in-place": "4.4.1", diff --git a/src/cli/getConfiguration.js b/src/cli/getConfiguration.js index 0b6fa7c39..5c07f3563 100644 --- a/src/cli/getConfiguration.js +++ b/src/cli/getConfiguration.js @@ -1,7 +1,6 @@ const latestSemver = require('latest-semver'); const loadJsonFile = require('load-json-file'); const camelCase = require('lodash.camelcase'); -const kebabCase = require('lodash.kebabcase'); const { fetchLibraryVersions } = require('../utils'); @@ -15,7 +14,6 @@ function createNameAlternatives({ organization, name }) { widgetType: `${organization}.${name}`, camelCaseName: camelCase(name), pascalCaseName: capitalize(camelCase(name)), - kebabCaseName: kebabCase(name), }; } diff --git a/yarn.lock b/yarn.lock index b46e0a2f9..368e5c8e3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4550,11 +4550,6 @@ lodash.ismatch@^4.4.0: resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37" integrity sha1-dWy1FQyjum8RCFp4hJZF8Yj4Xzc= -lodash.kebabcase@4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz#8489b1cb0d29ff88195cceca448ff6d6cc295c36" - integrity sha1-hImxyw0p/4gZXM7KRI/21swpXDY= - lodash.set@^4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23" From b37ad9465c105f34e9f0a923dc9290cdbc3f8a84 Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Thu, 10 Jun 2021 11:22:03 +0200 Subject: [PATCH 22/23] fix: update keywords in package.json --- src/templates/React InstantSearch widget/package.json.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/React InstantSearch widget/package.json.hbs b/src/templates/React InstantSearch widget/package.json.hbs index 7697a833e..47c653bf6 100644 --- a/src/templates/React InstantSearch widget/package.json.hbs +++ b/src/templates/React InstantSearch widget/package.json.hbs @@ -6,7 +6,7 @@ "instantsearch-widget", "instantsearch", "react-instantsearch", - "react-instantsearch-widget-{{ kebabCaseName }}", + "react-instantsearch-widget-{{ name }}", "widget", "connector", "algolia" From 7c67997d5103c7b98c54b6415733fec0b3cd4036 Mon Sep 17 00:00:00 2001 From: eunjae-lee Date: Thu, 10 Jun 2021 11:33:20 +0200 Subject: [PATCH 23/23] chore: update e2e snapshots --- e2e/__snapshots__/templates.test.js.snap | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/e2e/__snapshots__/templates.test.js.snap b/e2e/__snapshots__/templates.test.js.snap index c0aa491c5..8d9f17dfd 100644 --- a/e2e/__snapshots__/templates.test.js.snap +++ b/e2e/__snapshots__/templates.test.js.snap @@ -5732,7 +5732,7 @@ exports[`Templates React InstantSearch widget File content: package.json 1`] = ` \\"instantsearch-widget\\", \\"instantsearch\\", \\"react-instantsearch\\", - \\"react-instantsearch-widget-@algolia/react-instantsearch-app\\", + \\"react-instantsearch-widget-react-instantsearch-app\\", \\"widget\\", \\"connector\\", \\"algolia\\" @@ -5818,22 +5818,32 @@ describe('nothing', () => { exports[`Templates React InstantSearch widget File content: src/lib/component.tsx 1`] = ` "import React from 'react'; -type Props = { - // TODO: this is the object returned by \`getProvidedProps\` from the connector. +import type { ProvidedProps } from './connector' + +type Props = ProvidedProps & { + refine: () => {} }; export const ReactInstantsearchAppComponent = ({}: Props) => { - return
{/* TODO: render something */}
; + return ( +
+ {/* TODO: render something */} +
+ ); };" `; exports[`Templates React InstantSearch widget File content: src/lib/connector.ts 1`] = ` "import { createConnector } from 'react-instantsearch-dom'; +export type ProvidedProps = { + // TODO: fill props that are returned by \`getProvidedProps\` +}; + export const connectReactInstantsearchApp = createConnector({ displayName: 'ReactInstantsearchApp', - getProvidedProps(props, searchState, searchResults) { + getProvidedProps(props, searchState, searchResults): ProvidedProps { return { // TODO: return a props for the component };