From 05f8692d1abd039771c33e757776e937840b3c88 Mon Sep 17 00:00:00 2001 From: Aaron Boodman Date: Sat, 12 Nov 2022 17:31:14 -1000 Subject: [PATCH 1/2] Revert "Switch from relying directly on Replicache to an interface. (#35)" This reverts commit 3ee3fbedc1e342aabe1bd4dc40a52db1298ce15e. I'm putting this back the way it was. In retrospect, this way of doing it seems more consistent with the JS ecosystem. The package should specify the versions it has been tested and known to work with explicitly. --- package-lock.json | 10 ++++++++-- package.json | 11 ++++++++--- src/index.ts | 4 +--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index efe275e..3bcc13b 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": ">= 10.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 || >7.0.0-beta <7.0.0 || >8.0.0-beta <8.0.0 || >9.0.0-beta <9.0.0 || >10.0.0-alpha <10.0.0 || >10.0.0-beta <10.0.0" + }, + "peerDependenciesMeta": { + "replicache": { + "optional": true + } } }, "node_modules/@babel/code-frame": { diff --git a/package.json b/package.json index e18f71d..4ce85ca 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 || >7.0.0-beta <7.0.0 || >8.0.0-beta <8.0.0 || >9.0.0-beta <9.0.0 || >10.0.0-alpha <10.0.0 || >10.0.0-beta <10.0.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": ">= 10.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 = [], From adfc19a4ed2998c820215925eccc1acf2783dace Mon Sep 17 00:00:00 2001 From: Aaron Boodman Date: Sat, 12 Nov 2022 17:45:31 -1000 Subject: [PATCH 2/2] Rely on Replicache 11.* for unit tests. Clean up old no-longer supported beta versions in peer deps. It will install even if there isn't a direct match so I think it's fine to leave these out for convenience. --- package-lock.json | 19 +++++++++++-------- package.json | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3bcc13b..6c018c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,14 +23,14 @@ "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", - "replicache": ">=4.0.1 <12.0 || >7.0.0-beta <7.0.0 || >8.0.0-beta <8.0.0 || >9.0.0-beta <9.0.0 || >10.0.0-alpha <10.0.0 || >10.0.0-beta <10.0.0" + "replicache": ">=4.0.1 <12.0" }, "peerDependenciesMeta": { "replicache": { @@ -6331,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": { @@ -12717,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 4ce85ca..68a3b13 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "peerDependencies": { "react": ">=16.0 <19.0", "react-dom": ">=16.0 <19.0", - "replicache": ">=4.0.1 <12.0 || >7.0.0-beta <7.0.0 || >8.0.0-beta <8.0.0 || >9.0.0-beta <9.0.0 || >10.0.0-alpha <10.0.0 || >10.0.0-beta <10.0.0" + "replicache": ">=4.0.1 <12.0" }, "peerDependenciesMeta": { "replicache": { @@ -42,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" },