diff --git a/package-lock.json b/package-lock.json index efe275e..6c018c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,13 +23,19 @@ "prettier": "^2.4.1", "react": ">=16.0 <18.0", "react-dom": ">=16.0 <18.0", - "replicache": "10.0.0", + "replicache": "^11.0.0", "snowpack": "^3.8.8", "typescript": "^4.4.3" }, "peerDependencies": { "react": ">=16.0 <19.0", - "react-dom": ">=16.0 <19.0" + "react-dom": ">=16.0 <19.0", + "replicache": ">=4.0.1 <12.0" + }, + "peerDependenciesMeta": { + "replicache": { + "optional": true + } } }, "node_modules/@babel/code-frame": { @@ -6325,12 +6331,15 @@ } }, "node_modules/replicache": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/replicache/-/replicache-10.0.0.tgz", - "integrity": "sha512-Y0su0q1ouOYOh20HO+RsfYxJimIFNGLrZqRMtrMg/LxC1ilAQE1gt9XEBmpSRmWs/dL4oWv8W476dIT1Dbc56w==", + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/replicache/-/replicache-11.2.0.tgz", + "integrity": "sha512-LK2wv3OIxNzAe4JNePC8mj9u4jC3+piSfxRTd/e+gTS7xSoSrI7eo5lDrFbS0NLgpD3nT8OoitIJUyE0wlLZ9g==", "dev": true, "bin": { "replicache": "out/cli.cjs" + }, + "engines": { + "node": ">=14.8.0" } }, "node_modules/request": { @@ -12711,9 +12720,9 @@ "dev": true }, "replicache": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/replicache/-/replicache-10.0.0.tgz", - "integrity": "sha512-Y0su0q1ouOYOh20HO+RsfYxJimIFNGLrZqRMtrMg/LxC1ilAQE1gt9XEBmpSRmWs/dL4oWv8W476dIT1Dbc56w==", + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/replicache/-/replicache-11.2.0.tgz", + "integrity": "sha512-LK2wv3OIxNzAe4JNePC8mj9u4jC3+piSfxRTd/e+gTS7xSoSrI7eo5lDrFbS0NLgpD3nT8OoitIJUyE0wlLZ9g==", "dev": true }, "request": { diff --git a/package.json b/package.json index e18f71d..68a3b13 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "homepage": "https://replicache.dev", "repository": "github:rocicorp/replicache-react", "main": "out/index.js", - "module": "out/index.mjs", "scripts": { "format": "prettier --write 'src/*.{js,jsx,json,ts,tsx,html,css,md}' '*.{cjs,js,jsx,json,ts,tsx,html,css,md}'", "check-format": "prettier --check 'src/*.{js,jsx,json,ts,tsx,html,css,md}' '*.{cjs,js,jsx,json,ts,tsx,html,css,md}'", @@ -20,7 +19,13 @@ "license": "ISC", "peerDependencies": { "react": ">=16.0 <19.0", - "react-dom": ">=16.0 <19.0" + "react-dom": ">=16.0 <19.0", + "replicache": ">=4.0.1 <12.0" + }, + "peerDependenciesMeta": { + "replicache": { + "optional": true + } }, "devDependencies": { "@esm-bundle/chai": "^4.3.4-fix.0", @@ -37,7 +42,7 @@ "prettier": "^2.4.1", "react": ">=16.0 <18.0", "react-dom": ">=16.0 <18.0", - "replicache": "10.0.0", + "replicache": "^11.0.0", "snowpack": "^3.8.8", "typescript": "^4.4.3" }, diff --git a/src/index.ts b/src/index.ts index 2a28130..2756927 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,8 +3,6 @@ import type {ReadonlyJSONValue, ReadTransaction} from 'replicache'; import {useEffect, useState} from 'react'; import {unstable_batchedUpdates} from 'react-dom'; -type Subscribable = Pick; - // We wrap all the callbacks in a `unstable_batchedUpdates` call to ensure that // we do not render things more than once over all of the changed subscriptions. @@ -23,7 +21,7 @@ function doCallback() { } export function useSubscribe( - rep: Subscribable | null | undefined, + rep: Replicache | null | undefined, query: (tx: ReadTransaction) => Promise, def: R, deps: Array = [],