Skip to content

Commit 16310ca

Browse files
authored
Merge pull request #886 from gadget-inc/react-19
add react 19 support
2 parents f1b6d5d + 536e14c commit 16310ca

File tree

72 files changed

+3902
-2952
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3902
-2952
lines changed

.github/actions/setup-test-env/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ runs:
77
steps:
88
- uses: cachix/install-nix-action@v18
99
with:
10-
install_url: https://releases.nixos.org/nix/nix-2.11.1/install
10+
install_url: https://releases.nixos.org/nix/nix-2.31.1/install
1111
- run: |
1212
source <(nix print-dev-env --show-trace)
1313
output_file="nix-env.txt"

flake.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,24 @@
22
description = "Gadget js-clients development environment";
33

44
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
56
flake-utils.url = "github:numtide/flake-utils";
6-
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
77
};
88

9-
outputs = { self, flake-utils, nixpkgs }:
10-
(flake-utils.lib.eachSystem [
11-
"x86_64-linux"
12-
"x86_64-darwin"
13-
"aarch64-darwin"
14-
]
15-
(system: nixpkgs.lib.fix (flake:
16-
let
17-
pkgs = nixpkgs.legacyPackages.${system};
18-
in
19-
rec {
20-
packages = rec {
21-
nodejs = pkgs.nodejs_18;
22-
corepack = pkgs.corepack;
9+
outputs = { self, nixpkgs, flake-utils }:
10+
flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ] (system:
11+
let
12+
pkgs = import nixpkgs { inherit system; };
13+
node = pkgs.nodejs_22;
14+
in {
15+
packages = {
16+
nodejs = node;
17+
corepack = pkgs.corepack;
18+
git = pkgs.git;
19+
};
2320

24-
git = pkgs.git;
25-
};
26-
27-
devShell = pkgs.mkShell {
28-
packages = builtins.attrValues self.packages.${system};
29-
};
30-
}
31-
)));
21+
devShells.default = pkgs.mkShell {
22+
packages = with pkgs; [ node corepack git ];
23+
};
24+
});
3225
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@swc/core": "^1.3.90",
4141
"@swc/jest": "^0.2.36",
4242
"@types/jest": "^29.5.12",
43-
"@types/node": "^16.11.7",
43+
"@types/node": "^22.13.14",
4444
"@types/semver": "^7.5.8",
4545
"eslint": "^8.57.0",
4646
"execa": "^5.1.1",

packages/api-client-core/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@
4545
"ws": "^8.18.2"
4646
},
4747
"devDependencies": {
48-
"@types/node": "^16.11.7",
48+
"@types/node": "^22.13.14",
4949
"conditional-type-checks": "^1.0.6",
5050
"globby": "^11.0.4",
5151
"gql-tag": "^1.0.1",
5252
"nock": "^13.5.4",
5353
"p-retry": "^4.5.0",
54-
"react": "^18.2.0",
55-
"react-dom": "^18.2.0",
54+
"react": "^19.1.1",
55+
"react-dom": "^19.1.1",
5656
"typescript": "5.4.5"
5757
}
5858
}

packages/api-client-core/spec/mockUrqlClient.ts

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { SubscribePayload, Client as SubscriptionClient, Sink as Subscripti
66
import type { FunctionLike } from "jest-mock";
77
import { defaults, find, findLast } from "lodash-es";
88
import pRetry from "p-retry";
9-
import { act } from "react-dom/test-utils";
9+
import { act } from "react";
1010
import type { Sink, Source, Subject } from "wonka";
1111
import { filter, makeSubject, pipe, subscribe, take, toPromise } from "wonka";
1212
import { $gadgetConnection } from "../src/GadgetConnection.js";
@@ -49,7 +49,7 @@ export type MockOperationFn<F extends FunctionLike> = jest.Mock<(...args: any[])
4949
export type MockFetchFn = jest.Mock & {
5050
requests: { args: any[]; resolve: (response: Response) => void; reject: (error: Error) => void }[];
5151
pushResponse: (response: Response) => Promise<void>;
52-
reportAbort: () => Promise<void>;
52+
waitForRequest: (options?: pRetry.Options) => Promise<void>;
5353
};
5454

5555
export interface MockUrqlClient extends Client {
@@ -150,11 +150,25 @@ const newMockFetchFn = () => {
150150

151151
const fn = jest.fn((...args) => {
152152
return new Promise<Response>((resolve, reject) => {
153-
requests.push({
153+
const signal = (args[1] as any)?.signal;
154+
155+
const request = {
154156
args,
155157
resolve,
156158
reject,
157-
});
159+
};
160+
161+
if (signal) {
162+
signal.addEventListener("abort", () => {
163+
const idx = requests.findIndex((r) => r === request);
164+
if (idx !== -1) {
165+
request.reject(new Error("AbortError: The user aborted a request."));
166+
requests.splice(idx, 1);
167+
}
168+
});
169+
}
170+
171+
requests.push(request);
158172
});
159173
}) as unknown as MockFetchFn;
160174

@@ -173,20 +187,23 @@ const newMockFetchFn = () => {
173187
await request.resolve(response);
174188
});
175189
};
176-
fn.reportAbort = async () => {
190+
191+
fn.waitForRequest = async (options?: pRetry.Options) => {
192+
const requestCount = requests.length;
177193
await act(async () => {
178-
const request = requests.shift();
179-
if (!request) {
180-
throw new Error("no requests started for response pushing");
181-
}
182-
const signal = request.args[1]?.signal;
183-
if (!signal) {
184-
throw new Error("no signal on request, can't report an abort that has happened");
185-
}
186-
if (!signal.aborted) {
187-
throw new Error("signal on request has not been aborted, can't report an abort that has happened");
188-
}
189-
await request.reject(new Error("AbortError: The user aborted a request."));
194+
await pRetry(
195+
async () => {
196+
if (requests.length > requestCount) {
197+
return;
198+
}
199+
throw new Error("request not found");
200+
},
201+
defaults(options, {
202+
attempts: 20,
203+
minTimeout: 10,
204+
maxTimeout: 250,
205+
})
206+
);
190207
});
191208
};
192209

packages/blog-example/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
"dependencies": {
2020
"@gadget-client/blog": "^1.49.0",
2121
"@gadgetinc/react": "workspace:*",
22-
"react": "^18.2.0",
23-
"react-dom": "^18.2.0"
22+
"react": "^19.1.1",
23+
"react-dom": "^19.1.1"
2424
},
2525
"devDependencies": {
26-
"@types/react": "^18.2.79",
27-
"@types/react-dom": "^18.3.1",
28-
"@vitejs/plugin-react-swc": "^3.6.0",
26+
"@types/react": "^19.1.1",
27+
"@types/react-dom": "^19.1.1",
28+
"@vitejs/plugin-react-swc": "^3.11.0",
2929
"typescript": "5.4.5",
30-
"vite": "^4.5.13"
30+
"vite": "^7.1.4"
3131
}
3232
}

packages/react-bigcommerce/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gadgetinc/react-bigcommerce",
3-
"version": "0.3.3",
3+
"version": "0.4.0",
44
"files": [
55
"README.md",
66
"dist/**/*"
@@ -32,15 +32,15 @@
3232
"devDependencies": {
3333
"@gadgetinc/api-client-core": "workspace:*",
3434
"@gadgetinc/react": "workspace:*",
35-
"@types/react": "^18.2.79",
36-
"@types/react-dom": "^18.3.1",
35+
"@types/react": "^19.1.1",
36+
"@types/react-dom": "^19.1.1",
3737
"conditional-type-checks": "^1.0.6",
38-
"react": "^18.2.0",
39-
"react-dom": "^18.2.0"
38+
"react": "^19.1.1",
39+
"react-dom": "^19.1.1"
4040
},
4141
"peerDependencies": {
42-
"react": "^18.0.0",
43-
"react-dom": "^18.0.0",
44-
"@gadgetinc/react": "^0.21.4"
42+
"react": "^19.0.0",
43+
"react-dom": "^19.0.0",
44+
"@gadgetinc/react": "^0.22.0"
4545
}
4646
}

packages/react-shopify-app-bridge/package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gadgetinc/react-shopify-app-bridge",
3-
"version": "0.18.8",
3+
"version": "0.19.0",
44
"files": [
55
"README.md",
66
"dist/**/*"
@@ -34,20 +34,20 @@
3434
"devDependencies": {
3535
"@gadgetinc/api-client-core": "workspace:*",
3636
"@gadgetinc/react": "workspace:*",
37-
"@shopify/app-bridge-react": "^4.0.0",
37+
"@shopify/app-bridge-react": "^4.2.0",
3838
"@types/crypto-js": "^4.2.2",
39-
"@types/node": "^16.11.7",
40-
"@types/react": "^18.2.79",
41-
"@types/react-dom": "^18.3.1",
39+
"@types/node": "^22.13.14",
40+
"@types/react": "^19.1.1",
41+
"@types/react-dom": "^19.1.1",
4242
"conditional-type-checks": "^1.0.6",
4343
"nock": "^13.5.4",
44-
"react": "^18.2.0",
45-
"react-dom": "^18.2.0"
44+
"react": "^19.1.1",
45+
"react-dom": "^19.1.1"
4646
},
4747
"peerDependencies": {
48-
"@gadgetinc/react": "^0.21.4",
49-
"@shopify/app-bridge-react": "^4.0.0",
50-
"react": "^18.0.0",
51-
"react-dom": "^18.0.0"
48+
"@gadgetinc/react": "^0.22.0",
49+
"@shopify/app-bridge-react": "^4.2.0",
50+
"react": "^19.0.0",
51+
"react-dom": "^19.0.0"
5252
}
5353
}

packages/react-shopify-app-bridge/spec/Provider.spec.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { jest } from "@jest/globals";
44
import "@testing-library/jest-dom";
55
import { render } from "@testing-library/react";
66
import { CombinedError } from "@urql/core";
7-
import React from "react";
8-
import { act } from "react-dom/test-utils";
7+
import React, { act } from "react";
98
import { mockUrqlClient } from "../../api-client-core/spec/mockUrqlClient.js";
109
import { AppType, Provider } from "../src/Provider.js";
1110

0 commit comments

Comments
 (0)