@comapeo/core-react 9.0.1 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +1 -1
  2. package/dist/commonjs/contexts/ClientApi.d.ts +1 -3
  3. package/dist/commonjs/contexts/ClientApi.js +2 -2
  4. package/dist/commonjs/hooks/client.d.ts +74 -33
  5. package/dist/commonjs/hooks/client.js +40 -11
  6. package/dist/commonjs/hooks/documents.d.ts +41 -429
  7. package/dist/commonjs/hooks/documents.js +101 -51
  8. package/dist/commonjs/hooks/invites.d.ts +153 -55
  9. package/dist/commonjs/hooks/invites.js +69 -20
  10. package/dist/commonjs/hooks/maps.d.ts +98 -219
  11. package/dist/commonjs/hooks/maps.js +104 -37
  12. package/dist/commonjs/hooks/projects.d.ts +666 -223
  13. package/dist/commonjs/hooks/projects.js +264 -131
  14. package/dist/commonjs/index.d.ts +2 -2
  15. package/dist/commonjs/lib/map-shares-stores.d.ts +1 -1
  16. package/dist/commonjs/lib/map-shares-stores.js +2 -2
  17. package/dist/commonjs/lib/presets.d.ts +1 -3
  18. package/dist/commonjs/lib/react-query.d.ts +103 -0
  19. package/dist/commonjs/lib/react-query.js +187 -0
  20. package/dist/commonjs/lib/sync.d.ts +2 -5
  21. package/dist/commonjs/lib/sync.js +0 -1
  22. package/dist/commonjs/lib/types.d.ts +4 -6
  23. package/dist/esm/contexts/ClientApi.d.ts +1 -3
  24. package/dist/esm/contexts/ClientApi.js +1 -1
  25. package/dist/esm/hooks/client.d.ts +74 -33
  26. package/dist/esm/hooks/client.js +40 -11
  27. package/dist/esm/hooks/documents.d.ts +41 -429
  28. package/dist/esm/hooks/documents.js +101 -51
  29. package/dist/esm/hooks/invites.d.ts +153 -55
  30. package/dist/esm/hooks/invites.js +69 -20
  31. package/dist/esm/hooks/maps.d.ts +98 -219
  32. package/dist/esm/hooks/maps.js +105 -38
  33. package/dist/esm/hooks/projects.d.ts +666 -223
  34. package/dist/esm/hooks/projects.js +262 -129
  35. package/dist/esm/index.d.ts +2 -2
  36. package/dist/esm/lib/map-shares-stores.d.ts +1 -1
  37. package/dist/esm/lib/map-shares-stores.js +1 -1
  38. package/dist/esm/lib/presets.d.ts +1 -3
  39. package/dist/esm/lib/react-query.d.ts +103 -0
  40. package/dist/esm/lib/react-query.js +162 -0
  41. package/dist/esm/lib/sync.d.ts +2 -5
  42. package/dist/esm/lib/sync.js +1 -1
  43. package/dist/esm/lib/types.d.ts +4 -6
  44. package/docs/API.md +137 -81
  45. package/package.json +39 -35
  46. package/dist/commonjs/lib/react-query/client.d.ts +0 -65
  47. package/dist/commonjs/lib/react-query/client.js +0 -68
  48. package/dist/commonjs/lib/react-query/documents.d.ts +0 -1484
  49. package/dist/commonjs/lib/react-query/documents.js +0 -149
  50. package/dist/commonjs/lib/react-query/invites.d.ts +0 -88
  51. package/dist/commonjs/lib/react-query/invites.js +0 -95
  52. package/dist/commonjs/lib/react-query/maps.d.ts +0 -72
  53. package/dist/commonjs/lib/react-query/maps.js +0 -129
  54. package/dist/commonjs/lib/react-query/mutation-result.d.ts +0 -8
  55. package/dist/commonjs/lib/react-query/mutation-result.js +0 -22
  56. package/dist/commonjs/lib/react-query/projects.d.ts +0 -316
  57. package/dist/commonjs/lib/react-query/projects.js +0 -359
  58. package/dist/commonjs/lib/react-query/shared.d.ts +0 -9
  59. package/dist/commonjs/lib/react-query/shared.js +0 -23
  60. package/dist/esm/lib/react-query/client.d.ts +0 -65
  61. package/dist/esm/lib/react-query/client.js +0 -59
  62. package/dist/esm/lib/react-query/documents.d.ts +0 -1484
  63. package/dist/esm/lib/react-query/documents.js +0 -137
  64. package/dist/esm/lib/react-query/invites.d.ts +0 -88
  65. package/dist/esm/lib/react-query/invites.js +0 -85
  66. package/dist/esm/lib/react-query/maps.d.ts +0 -72
  67. package/dist/esm/lib/react-query/maps.js +0 -119
  68. package/dist/esm/lib/react-query/mutation-result.d.ts +0 -8
  69. package/dist/esm/lib/react-query/mutation-result.js +0 -19
  70. package/dist/esm/lib/react-query/projects.d.ts +0 -316
  71. package/dist/esm/lib/react-query/projects.js +0 -324
  72. package/dist/esm/lib/react-query/shared.d.ts +0 -9
  73. package/dist/esm/lib/react-query/shared.js +0 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comapeo/core-react",
3
- "version": "9.0.1",
3
+ "version": "10.0.0",
4
4
  "description": "React wrapper for working with @comapeo/core",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,6 +34,13 @@
34
34
  "main": "./dist/commonjs/index.js",
35
35
  "types": "./dist/commonjs/index.d.ts",
36
36
  "module": "./dist/esm/index.js",
37
+ "devEngines": {
38
+ "runtime": {
39
+ "name": "node",
40
+ "version": "^24",
41
+ "onFail": "warn"
42
+ }
43
+ },
37
44
  "files": [
38
45
  "dist/",
39
46
  "docs/API.md"
@@ -56,59 +63,56 @@
56
63
  "test": "vitest run",
57
64
  "types": "tsc"
58
65
  },
66
+ "dependencies": {
67
+ "@comapeo/map-server": "1.0.1",
68
+ "ensure-error": "5.0.0",
69
+ "eventsource-client": "1.2.0",
70
+ "type-fest": "5.4.4"
71
+ },
59
72
  "peerDependencies": {
60
- "@comapeo/core": "^5.5.0",
61
- "@comapeo/ipc": "^6.0.2",
62
- "@comapeo/schema": "*",
73
+ "@comapeo/core": "^6.0.2",
74
+ "@comapeo/ipc": "^7.0.0",
63
75
  "@tanstack/react-query": "^5",
64
76
  "react": "^18 || ^19"
65
77
  },
66
78
  "devDependencies": {
67
- "@comapeo/core": "5.5.0",
68
- "@comapeo/ipc": "6.0.2",
69
- "@comapeo/schema": "2.2.0",
70
- "@eslint/compat": "2.0.0",
71
- "@eslint/js": "9.39.2",
72
- "@ianvs/prettier-plugin-sort-imports": "4.7.0",
79
+ "@comapeo/core": "6.0.2",
80
+ "@comapeo/ipc": "7.0.0",
81
+ "@eslint/compat": "2.0.3",
82
+ "@eslint/js": "9.39.4",
83
+ "@ianvs/prettier-plugin-sort-imports": "4.7.1",
73
84
  "@mapeo/crypto": "1.0.0-alpha.10",
74
85
  "@mapeo/default-config": "6.0.0",
75
86
  "@mapeo/mock-data": "5.0.0",
76
- "@tanstack/eslint-plugin-query": "5.91.2",
77
- "@tanstack/react-query": "5.90.12",
87
+ "@tanstack/eslint-plugin-query": "5.91.4",
88
+ "@tanstack/react-query": "5.90.21",
78
89
  "@testing-library/dom": "10.4.1",
79
- "@testing-library/react": "16.3.1",
80
- "@types/jsdom": "27.0.0",
81
- "@types/node": "22.19.3",
82
- "@types/react": "19.2.7",
90
+ "@testing-library/react": "16.3.2",
91
+ "@types/jsdom": "28.0.0",
92
+ "@types/node": "24.12.0",
93
+ "@types/react": "19.2.14",
83
94
  "@types/react-dom": "19.2.3",
84
- "@vitest/eslint-plugin": "1.5.2",
85
- "eslint": "9.39.2",
95
+ "@vitest/eslint-plugin": "1.6.12",
96
+ "eslint": "9.39.4",
86
97
  "eslint-plugin-react-hooks": "7.0.1",
87
- "eslint-plugin-testing-library": "7.14.0",
98
+ "eslint-plugin-testing-library": "7.16.0",
88
99
  "fastify": "4.29.1",
89
- "globals": "16.5.0",
90
- "happy-dom": "20.0.11",
100
+ "globals": "17.4.0",
91
101
  "husky": "9.1.7",
92
- "jsdom": "28.0.0",
102
+ "jsdom": "29.0.0",
93
103
  "ky": "1.14.3",
94
- "lint-staged": "16.2.7",
104
+ "lint-staged": "16.4.0",
95
105
  "npm-run-all2": "8.0.4",
96
- "prettier": "3.7.4",
106
+ "prettier": "3.8.1",
97
107
  "random-access-memory": "6.2.1",
98
- "react": "19.2.3",
99
- "react-dom": "19.2.3",
108
+ "react": "19.2.4",
109
+ "react-dom": "19.2.4",
100
110
  "secret-stream-http": "1.0.1",
101
111
  "tsdoc-markdown": "1.4.1",
102
- "tshy": "3.1.0",
112
+ "tshy": "3.3.2",
103
113
  "typescript": "5.9.3",
104
- "typescript-eslint": "8.49.0",
114
+ "typescript-eslint": "8.57.1",
105
115
  "uint8array-extras": "1.5.0",
106
- "vitest": "4.0.15"
107
- },
108
- "dependencies": {
109
- "@comapeo/map-server": "1.0.0",
110
- "ensure-error": "5.0.0",
111
- "eventsource-client": "1.2.0",
112
- "type-fest": "5.4.4"
116
+ "vitest": "4.1.0"
113
117
  }
114
118
  }
@@ -1,65 +0,0 @@
1
- import type { MapeoClientApi } from '@comapeo/ipc' with {
2
- 'resolution-mode': 'import'
3
- };
4
- import type { DeviceInfo } from '@comapeo/schema' with {
5
- 'resolution-mode': 'import'
6
- };
7
- import { type QueryClient } from '@tanstack/react-query';
8
- export declare function getClientQueryKey(): readonly ["@comapeo/core-react", "client"];
9
- export declare function getDeviceInfoQueryKey(): readonly ["@comapeo/core-react", "client", "device_info"];
10
- export declare function getIsArchiveDeviceQueryKey(): readonly ["@comapeo/core-react", "client", "is_archive_device"];
11
- export declare function deviceInfoQueryOptions({ clientApi, }: {
12
- clientApi: MapeoClientApi;
13
- }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
14
- deviceId: string;
15
- deviceType: import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam["deviceType"];
16
- } & Partial<import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam>, Error, {
17
- deviceId: string;
18
- deviceType: import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam["deviceType"];
19
- } & Partial<import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam>, readonly ["@comapeo/core-react", "client", "device_info"]>, "queryFn"> & {
20
- queryFn?: import("@tanstack/react-query").QueryFunction<{
21
- deviceId: string;
22
- deviceType: import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam["deviceType"];
23
- } & Partial<import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam>, readonly ["@comapeo/core-react", "client", "device_info"], never> | undefined;
24
- } & {
25
- queryKey: readonly ["@comapeo/core-react", "client", "device_info"] & {
26
- [dataTagSymbol]: {
27
- deviceId: string;
28
- deviceType: import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam["deviceType"];
29
- } & Partial<import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam>;
30
- [dataTagErrorSymbol]: Error;
31
- };
32
- };
33
- export declare function isArchiveDeviceQueryOptions({ clientApi, }: {
34
- clientApi: MapeoClientApi;
35
- }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<boolean, Error, boolean, readonly ["@comapeo/core-react", "client", "is_archive_device"]>, "queryFn"> & {
36
- queryFn?: import("@tanstack/react-query").QueryFunction<boolean, readonly ["@comapeo/core-react", "client", "is_archive_device"], never> | undefined;
37
- } & {
38
- queryKey: readonly ["@comapeo/core-react", "client", "is_archive_device"] & {
39
- [dataTagSymbol]: boolean;
40
- [dataTagErrorSymbol]: Error;
41
- };
42
- };
43
- export declare function setOwnDeviceInfoMutationOptions({ clientApi, queryClient, }: {
44
- clientApi: MapeoClientApi;
45
- queryClient: QueryClient;
46
- }): {
47
- mutationFn: ({ name, deviceType }: {
48
- name: string;
49
- deviceType: DeviceInfo["deviceType"];
50
- }) => Promise<void>;
51
- onSuccess: () => void;
52
- networkMode: "always";
53
- retry: false;
54
- };
55
- export declare function setIsArchiveDeviceMutationOptions({ clientApi, queryClient, }: {
56
- clientApi: MapeoClientApi;
57
- queryClient: QueryClient;
58
- }): {
59
- mutationFn: ({ isArchiveDevice }: {
60
- isArchiveDevice: boolean;
61
- }) => Promise<void>;
62
- onSuccess: () => void;
63
- networkMode: "always";
64
- retry: false;
65
- };
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getClientQueryKey = getClientQueryKey;
4
- exports.getDeviceInfoQueryKey = getDeviceInfoQueryKey;
5
- exports.getIsArchiveDeviceQueryKey = getIsArchiveDeviceQueryKey;
6
- exports.deviceInfoQueryOptions = deviceInfoQueryOptions;
7
- exports.isArchiveDeviceQueryOptions = isArchiveDeviceQueryOptions;
8
- exports.setOwnDeviceInfoMutationOptions = setOwnDeviceInfoMutationOptions;
9
- exports.setIsArchiveDeviceMutationOptions = setIsArchiveDeviceMutationOptions;
10
- const react_query_1 = require("@tanstack/react-query");
11
- const projects_js_1 = require("./projects.js");
12
- const shared_js_1 = require("./shared.js");
13
- function getClientQueryKey() {
14
- return [shared_js_1.ROOT_QUERY_KEY, 'client'];
15
- }
16
- function getDeviceInfoQueryKey() {
17
- return [shared_js_1.ROOT_QUERY_KEY, 'client', 'device_info'];
18
- }
19
- function getIsArchiveDeviceQueryKey() {
20
- return [shared_js_1.ROOT_QUERY_KEY, 'client', 'is_archive_device'];
21
- }
22
- function deviceInfoQueryOptions({ clientApi, }) {
23
- return (0, react_query_1.queryOptions)({
24
- ...(0, shared_js_1.baseQueryOptions)(),
25
- queryKey: getDeviceInfoQueryKey(),
26
- queryFn: async () => {
27
- return clientApi.getDeviceInfo();
28
- },
29
- });
30
- }
31
- function isArchiveDeviceQueryOptions({ clientApi, }) {
32
- return (0, react_query_1.queryOptions)({
33
- ...(0, shared_js_1.baseQueryOptions)(),
34
- queryKey: getIsArchiveDeviceQueryKey(),
35
- queryFn: async () => {
36
- return clientApi.getIsArchiveDevice();
37
- },
38
- });
39
- }
40
- function setOwnDeviceInfoMutationOptions({ clientApi, queryClient, }) {
41
- return {
42
- ...(0, shared_js_1.baseMutationOptions)(),
43
- mutationFn: async ({ name, deviceType }) => {
44
- return clientApi.setDeviceInfo({ name, deviceType });
45
- },
46
- onSuccess: () => {
47
- queryClient.invalidateQueries({
48
- queryKey: getDeviceInfoQueryKey(),
49
- });
50
- queryClient.invalidateQueries({
51
- queryKey: (0, projects_js_1.getProjectsQueryKey)(),
52
- });
53
- },
54
- };
55
- }
56
- function setIsArchiveDeviceMutationOptions({ clientApi, queryClient, }) {
57
- return {
58
- ...(0, shared_js_1.baseMutationOptions)(),
59
- mutationFn: async ({ isArchiveDevice }) => {
60
- return clientApi.setIsArchiveDevice(isArchiveDevice);
61
- },
62
- onSuccess: () => {
63
- queryClient.invalidateQueries({
64
- queryKey: getIsArchiveDeviceQueryKey(),
65
- });
66
- },
67
- };
68
- }