@l.x/react-query 0.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.
- package/.depcheckrc +9 -0
- package/.eslintrc.js +20 -0
- package/LICENSE +122 -0
- package/README.md +3 -0
- package/package.json +32 -0
- package/project.json +18 -0
- package/src/createQueryClient.ts +57 -0
- package/src/index.ts +3 -0
- package/src/mergeDehydratedStates.ts +30 -0
- package/tsconfig.json +26 -0
- package/tsconfig.lint.json +8 -0
package/.depcheckrc
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ['@luxfi/eslint-config/lib'],
|
|
3
|
+
parserOptions: {
|
|
4
|
+
tsconfigRootDir: __dirname,
|
|
5
|
+
},
|
|
6
|
+
overrides: [
|
|
7
|
+
{
|
|
8
|
+
files: ['*.ts', '*.tsx'],
|
|
9
|
+
rules: {
|
|
10
|
+
'no-relative-import-paths/no-relative-import-paths': [
|
|
11
|
+
'error',
|
|
12
|
+
{
|
|
13
|
+
allowSameFolder: false,
|
|
14
|
+
prefix: '@luxexchange/react-query',
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Lux Ecosystem License
|
|
2
|
+
Version 1.2, December 2025
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2020-2025 Lux Industries Inc.
|
|
5
|
+
All rights reserved.
|
|
6
|
+
|
|
7
|
+
TECHNOLOGY PORTFOLIO - PATENT APPLICATIONS PLANNED
|
|
8
|
+
Contact: licensing@lux.network
|
|
9
|
+
|
|
10
|
+
================================================================================
|
|
11
|
+
TERMS AND CONDITIONS
|
|
12
|
+
================================================================================
|
|
13
|
+
|
|
14
|
+
1. DEFINITIONS
|
|
15
|
+
|
|
16
|
+
"Lux Primary Network" means the official Lux blockchain with Network ID=1
|
|
17
|
+
and EVM Chain ID=96369.
|
|
18
|
+
|
|
19
|
+
"Authorized Network" means the Lux Primary Network, official testnets/devnets,
|
|
20
|
+
and any L1/L2/L3 chain descending from the Lux Primary Network.
|
|
21
|
+
|
|
22
|
+
"Descending Chain" means an L1/L2/L3 chain built on, anchored to, or deriving
|
|
23
|
+
security from the Lux Primary Network or its authorized testnets.
|
|
24
|
+
|
|
25
|
+
"Research Use" means non-commercial academic research, education, personal
|
|
26
|
+
study, or evaluation purposes.
|
|
27
|
+
|
|
28
|
+
"Commercial Use" means any use in connection with a product or service
|
|
29
|
+
offered for sale or fee, internal use by a for-profit entity, or any use
|
|
30
|
+
to generate revenue.
|
|
31
|
+
|
|
32
|
+
2. GRANT OF LICENSE
|
|
33
|
+
|
|
34
|
+
Subject to these terms, Lux Industries Inc grants you a non-exclusive,
|
|
35
|
+
royalty-free license to:
|
|
36
|
+
|
|
37
|
+
(a) Use for Research Use without restriction;
|
|
38
|
+
|
|
39
|
+
(b) Operate on the Lux Primary Network (Network ID=1, EVM Chain ID=96369);
|
|
40
|
+
|
|
41
|
+
(c) Operate on official Lux testnets and devnets;
|
|
42
|
+
|
|
43
|
+
(d) Operate L1/L2/L3 chains descending from the Lux Primary Network;
|
|
44
|
+
|
|
45
|
+
(e) Build applications within the Lux ecosystem;
|
|
46
|
+
|
|
47
|
+
(f) Contribute improvements back to the original repositories.
|
|
48
|
+
|
|
49
|
+
3. RESTRICTIONS
|
|
50
|
+
|
|
51
|
+
Without a commercial license from Lux Industries Inc, you may NOT:
|
|
52
|
+
|
|
53
|
+
(a) Fork the Lux Network or any Lux software;
|
|
54
|
+
|
|
55
|
+
(b) Create competing networks not descending from Lux Primary Network;
|
|
56
|
+
|
|
57
|
+
(c) Use for Commercial Use outside the Lux ecosystem;
|
|
58
|
+
|
|
59
|
+
(d) Sublicense or transfer rights outside the Lux ecosystem;
|
|
60
|
+
|
|
61
|
+
(e) Use to create competing blockchain networks, exchanges, custody
|
|
62
|
+
services, or cryptographic systems outside the Lux ecosystem.
|
|
63
|
+
|
|
64
|
+
4. NO FORKS POLICY
|
|
65
|
+
|
|
66
|
+
Lux Industries Inc maintains ZERO TOLERANCE for unauthorized forks.
|
|
67
|
+
Any fork or deployment on an unauthorized network constitutes:
|
|
68
|
+
|
|
69
|
+
(a) Breach of this license;
|
|
70
|
+
(b) Grounds for immediate legal action.
|
|
71
|
+
|
|
72
|
+
5. RIGHTS RESERVATION
|
|
73
|
+
|
|
74
|
+
All rights not explicitly granted are reserved by Lux Industries Inc.
|
|
75
|
+
|
|
76
|
+
We plan to apply for patent protection for the technology in this
|
|
77
|
+
repository. Any implementation outside the Lux ecosystem may require
|
|
78
|
+
a separate commercial license.
|
|
79
|
+
|
|
80
|
+
6. DISCLAIMER OF WARRANTY
|
|
81
|
+
|
|
82
|
+
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
83
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
84
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
85
|
+
|
|
86
|
+
7. LIMITATION OF LIABILITY
|
|
87
|
+
|
|
88
|
+
IN NO EVENT SHALL LUX INDUSTRIES INC BE LIABLE FOR ANY CLAIM, DAMAGES
|
|
89
|
+
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
90
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE.
|
|
91
|
+
|
|
92
|
+
8. TERMINATION
|
|
93
|
+
|
|
94
|
+
This license terminates immediately upon any breach, including but not
|
|
95
|
+
limited to deployment on unauthorized networks or creation of forks.
|
|
96
|
+
|
|
97
|
+
9. GOVERNING LAW
|
|
98
|
+
|
|
99
|
+
This License shall be governed by the laws of the State of Delaware.
|
|
100
|
+
|
|
101
|
+
10. COMMERCIAL LICENSING
|
|
102
|
+
|
|
103
|
+
For commercial use outside the Lux ecosystem:
|
|
104
|
+
|
|
105
|
+
Lux Industries Inc.
|
|
106
|
+
Email: licensing@lux.network
|
|
107
|
+
Subject: Commercial License Request
|
|
108
|
+
|
|
109
|
+
================================================================================
|
|
110
|
+
TL;DR
|
|
111
|
+
================================================================================
|
|
112
|
+
|
|
113
|
+
- Research/academic use = OK
|
|
114
|
+
- Lux Primary Network (Network ID=1, Chain ID=96369) = OK
|
|
115
|
+
- L1/L2/L3 chains descending from Lux Primary Network = OK
|
|
116
|
+
- Commercial products outside Lux ecosystem = Contact licensing@lux.network
|
|
117
|
+
- Forks = Absolutely not
|
|
118
|
+
|
|
119
|
+
================================================================================
|
|
120
|
+
|
|
121
|
+
See LP-0012 for full licensing documentation:
|
|
122
|
+
https://github.com/luxfi/lps/blob/main/LPs/lp-0012-ecosystem-licensing.md
|
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@l.x/react-query",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@tanstack/react-query": "5.90.20"
|
|
6
|
+
},
|
|
7
|
+
"devDependencies": {
|
|
8
|
+
"@types/node": "22.13.1",
|
|
9
|
+
"@typescript/native-preview": "7.0.0-dev.20260311.1",
|
|
10
|
+
"depcheck": "1.4.7",
|
|
11
|
+
"eslint": "8.57.1",
|
|
12
|
+
"typescript": "5.8.3",
|
|
13
|
+
"@luxfi/eslint-config": "^1.0.5"
|
|
14
|
+
},
|
|
15
|
+
"nx": {
|
|
16
|
+
"includedScripts": []
|
|
17
|
+
},
|
|
18
|
+
"main": "src/index.ts",
|
|
19
|
+
"private": false,
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"scripts": {
|
|
22
|
+
"typecheck": "nx typecheck react-query",
|
|
23
|
+
"typecheck:tsgo": "nx typecheck:tsgo react-query",
|
|
24
|
+
"lint": "nx lint react-query",
|
|
25
|
+
"lint:fix": "nx lint:fix react-query",
|
|
26
|
+
"lint:biome": "nx lint:biome react-query",
|
|
27
|
+
"lint:biome:fix": "nx lint:biome:fix react-query",
|
|
28
|
+
"lint:eslint": "nx lint:eslint react-query",
|
|
29
|
+
"lint:eslint:fix": "nx lint:eslint:fix react-query",
|
|
30
|
+
"check:deps:usage": "nx check:deps:usage react-query"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@l.x/react-query",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "pkgs/react-query/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"targets": {
|
|
8
|
+
"typecheck": {},
|
|
9
|
+
"typecheck:tsgo": {},
|
|
10
|
+
"lint:biome": {},
|
|
11
|
+
"lint:biome:fix": {},
|
|
12
|
+
"lint:eslint": {},
|
|
13
|
+
"lint:eslint:fix": {},
|
|
14
|
+
"lint": {},
|
|
15
|
+
"lint:fix": {},
|
|
16
|
+
"check:deps:usage": {}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query'
|
|
2
|
+
|
|
3
|
+
export interface QueryClientConfig {
|
|
4
|
+
/** How long data is "fresh" before refetching (default: 30_000ms) */
|
|
5
|
+
staleTime?: number
|
|
6
|
+
/** How long unused data stays in cache (default: 24 hours) */
|
|
7
|
+
gcTime?: number
|
|
8
|
+
/** Refetch when window regains focus (default: true) */
|
|
9
|
+
refetchOnWindowFocus?: boolean
|
|
10
|
+
/** Refetch when component mounts (default: true) */
|
|
11
|
+
refetchOnMount?: boolean
|
|
12
|
+
/** Refetch when network reconnects (default: true) */
|
|
13
|
+
refetchOnReconnect?: boolean
|
|
14
|
+
/** Optional logger for retry warnings */
|
|
15
|
+
logger?: {
|
|
16
|
+
warn: (message: string, context?: Record<string, unknown>) => void
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new QueryClient with configurable defaults.
|
|
22
|
+
*/
|
|
23
|
+
export function createQueryClient(config?: QueryClientConfig): QueryClient {
|
|
24
|
+
const {
|
|
25
|
+
staleTime = 30_000,
|
|
26
|
+
gcTime = 24 * 60 * 60 * 1000,
|
|
27
|
+
refetchOnWindowFocus = true,
|
|
28
|
+
refetchOnMount = true,
|
|
29
|
+
refetchOnReconnect = true,
|
|
30
|
+
logger,
|
|
31
|
+
} = config ?? {}
|
|
32
|
+
|
|
33
|
+
return new QueryClient({
|
|
34
|
+
defaultOptions: {
|
|
35
|
+
queries: {
|
|
36
|
+
staleTime,
|
|
37
|
+
gcTime,
|
|
38
|
+
refetchOnWindowFocus,
|
|
39
|
+
refetchOnMount,
|
|
40
|
+
refetchOnReconnect,
|
|
41
|
+
retry: (failureCount, error): boolean => {
|
|
42
|
+
if (failureCount >= 2) {
|
|
43
|
+
return false
|
|
44
|
+
}
|
|
45
|
+
if (error instanceof Error && 'status' in error) {
|
|
46
|
+
const status = (error as { status: number }).status
|
|
47
|
+
if (status >= 500) {
|
|
48
|
+
logger?.warn('retrying request', { attempt: failureCount + 1, status })
|
|
49
|
+
return true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return false
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DehydratedState } from '@tanstack/react-query'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Merge multiple DehydratedState objects into one.
|
|
5
|
+
* Deduplicates queries by queryHash, mutations by stringified key.
|
|
6
|
+
*
|
|
7
|
+
* Used in SSR: nested routes each prefetch in their loaders,
|
|
8
|
+
* root merges all states into a single HydrationBoundary.
|
|
9
|
+
*/
|
|
10
|
+
export function mergeDehydratedStates(states: (DehydratedState | undefined | null)[]): DehydratedState {
|
|
11
|
+
const validStates = states.filter((s): s is DehydratedState => s != null)
|
|
12
|
+
|
|
13
|
+
const queriesMap = new Map<string, DehydratedState['queries'][number]>()
|
|
14
|
+
const mutationsMap = new Map<string, DehydratedState['mutations'][number]>()
|
|
15
|
+
|
|
16
|
+
for (const state of validStates) {
|
|
17
|
+
for (const query of state.queries) {
|
|
18
|
+
queriesMap.set(query.queryHash, query)
|
|
19
|
+
}
|
|
20
|
+
for (const mutation of state.mutations) {
|
|
21
|
+
const key = mutation.mutationKey ? JSON.stringify(mutation.mutationKey) : `mutation-${mutationsMap.size}`
|
|
22
|
+
mutationsMap.set(key, mutation)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
queries: Array.from(queriesMap.values()),
|
|
28
|
+
mutations: Array.from(mutationsMap.values()),
|
|
29
|
+
}
|
|
30
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../config/tsconfig/app.json",
|
|
3
|
+
"include": [
|
|
4
|
+
"src/**/*.ts",
|
|
5
|
+
"src/**/*.tsx",
|
|
6
|
+
"src/**/*.json",
|
|
7
|
+
"src/global.d.ts"
|
|
8
|
+
],
|
|
9
|
+
"exclude": [
|
|
10
|
+
"src/**/*.spec.ts",
|
|
11
|
+
"src/**/*.spec.tsx",
|
|
12
|
+
"src/**/*.test.ts",
|
|
13
|
+
"src/**/*.test.tsx"
|
|
14
|
+
],
|
|
15
|
+
"compilerOptions": {
|
|
16
|
+
"noEmit": false,
|
|
17
|
+
"emitDeclarationOnly": true,
|
|
18
|
+
"types": ["node"],
|
|
19
|
+
"paths": {}
|
|
20
|
+
},
|
|
21
|
+
"references": [
|
|
22
|
+
{
|
|
23
|
+
"path": "../eslint-config"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|