@trpc/client 10.13.2 → 10.14.1
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/LICENSE +2 -2
- package/dist/getFetch.d.ts.map +1 -1
- package/dist/{httpUtils-d348a3ca.js → httpUtils-05eea0cb.js} +9 -5
- package/dist/{httpUtils-24d9ee59.mjs → httpUtils-9b676ab4.mjs} +9 -4
- package/dist/{httpUtils-ce40966a.js → httpUtils-b67e2601.js} +9 -4
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/links/httpBatchLink.js +1 -1
- package/dist/links/httpBatchLink.mjs +1 -1
- package/dist/links/httpLink.js +1 -1
- package/dist/links/httpLink.mjs +1 -1
- package/package.json +4 -4
- package/src/getFetch.ts +13 -7
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2023 Alex Johansson
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/dist/getFetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFetch.d.ts","sourceRoot":"","sources":["../src/getFetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"getFetch.d.ts","sourceRoot":"","sources":["../src/getFetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAWjE,wBAAgB,QAAQ,CACtB,eAAe,CAAC,EAAE,UAAU,GAAG,gBAAgB,GAC9C,UAAU,CAcZ"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
const isFunction = (fn) => typeof fn === 'function';
|
|
2
|
+
function _bind(fn, thisArg) {
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
4
|
+
return isFunction(fn.bind) ? fn.bind(thisArg) : fn;
|
|
5
|
+
}
|
|
1
6
|
function getFetch(customFetchImpl) {
|
|
2
7
|
if (customFetchImpl) {
|
|
3
8
|
return customFetchImpl;
|
|
4
9
|
}
|
|
5
|
-
if (typeof window !== 'undefined' &&
|
|
6
|
-
return window.fetch
|
|
10
|
+
if (typeof window !== 'undefined' && isFunction(window.fetch)) {
|
|
11
|
+
return _bind(window.fetch, window);
|
|
7
12
|
}
|
|
8
|
-
if (typeof globalThis !== 'undefined' &&
|
|
9
|
-
|
|
10
|
-
return globalThis.fetch.bind(globalThis);
|
|
13
|
+
if (typeof globalThis !== 'undefined' && isFunction(globalThis.fetch)) {
|
|
14
|
+
return _bind(globalThis.fetch, globalThis);
|
|
11
15
|
}
|
|
12
16
|
throw new Error('No fetch implementation found');
|
|
13
17
|
}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
const isFunction = (fn)=>typeof fn === 'function';
|
|
2
|
+
function _bind(fn, thisArg) {
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
4
|
+
return isFunction(fn.bind) ? fn.bind(thisArg) : fn;
|
|
5
|
+
}
|
|
1
6
|
function getFetch(customFetchImpl) {
|
|
2
7
|
if (customFetchImpl) {
|
|
3
8
|
return customFetchImpl;
|
|
4
9
|
}
|
|
5
|
-
if (typeof window !== 'undefined' &&
|
|
6
|
-
return window.fetch
|
|
10
|
+
if (typeof window !== 'undefined' && isFunction(window.fetch)) {
|
|
11
|
+
return _bind(window.fetch, window);
|
|
7
12
|
}
|
|
8
|
-
if (typeof globalThis !== 'undefined' &&
|
|
9
|
-
return globalThis.fetch
|
|
13
|
+
if (typeof globalThis !== 'undefined' && isFunction(globalThis.fetch)) {
|
|
14
|
+
return _bind(globalThis.fetch, globalThis);
|
|
10
15
|
}
|
|
11
16
|
throw new Error('No fetch implementation found');
|
|
12
17
|
}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const isFunction = (fn)=>typeof fn === 'function';
|
|
4
|
+
function _bind(fn, thisArg) {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
6
|
+
return isFunction(fn.bind) ? fn.bind(thisArg) : fn;
|
|
7
|
+
}
|
|
3
8
|
function getFetch(customFetchImpl) {
|
|
4
9
|
if (customFetchImpl) {
|
|
5
10
|
return customFetchImpl;
|
|
6
11
|
}
|
|
7
|
-
if (typeof window !== 'undefined' &&
|
|
8
|
-
return window.fetch
|
|
12
|
+
if (typeof window !== 'undefined' && isFunction(window.fetch)) {
|
|
13
|
+
return _bind(window.fetch, window);
|
|
9
14
|
}
|
|
10
|
-
if (typeof globalThis !== 'undefined' &&
|
|
11
|
-
return globalThis.fetch
|
|
15
|
+
if (typeof globalThis !== 'undefined' && isFunction(globalThis.fetch)) {
|
|
16
|
+
return _bind(globalThis.fetch, globalThis);
|
|
12
17
|
}
|
|
13
18
|
throw new Error('No fetch implementation found');
|
|
14
19
|
}
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var observable = require('@trpc/server/observable');
|
|
|
6
6
|
var transformResult = require('./transformResult-e7a1e69e.js');
|
|
7
7
|
var links_splitLink = require('./splitLink-f29e84be.js');
|
|
8
8
|
var shared = require('@trpc/server/shared');
|
|
9
|
-
var httpUtils = require('./httpUtils-
|
|
9
|
+
var httpUtils = require('./httpUtils-b67e2601.js');
|
|
10
10
|
var links_httpBatchLink = require('./links/httpBatchLink.js');
|
|
11
11
|
var links_httpLink = require('./links/httpLink.js');
|
|
12
12
|
var links_loggerLink = require('./links/loggerLink.js');
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ export { T as TRPCClientError } from './transformResult-6fb67924.mjs';
|
|
|
4
4
|
import { c as createChain } from './splitLink-4c75f7be.mjs';
|
|
5
5
|
export { s as splitLink } from './splitLink-4c75f7be.mjs';
|
|
6
6
|
import { createFlatProxy, createRecursiveProxy } from '@trpc/server/shared';
|
|
7
|
-
export { g as getFetch } from './httpUtils-
|
|
7
|
+
export { g as getFetch } from './httpUtils-9b676ab4.mjs';
|
|
8
8
|
export { httpBatchLink } from './links/httpBatchLink.mjs';
|
|
9
9
|
export { httpLink } from './links/httpLink.mjs';
|
|
10
10
|
export { loggerLink } from './links/loggerLink.mjs';
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var observable = require('@trpc/server/observable');
|
|
6
6
|
var transformResult = require('../transformResult-e7a1e69e.js');
|
|
7
|
-
var httpUtils = require('../httpUtils-
|
|
7
|
+
var httpUtils = require('../httpUtils-b67e2601.js');
|
|
8
8
|
|
|
9
9
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /**
|
|
10
10
|
* A function that should never be called unless we messed something up.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { observable } from '@trpc/server/observable';
|
|
2
2
|
import { t as transformResult, T as TRPCClientError } from '../transformResult-6fb67924.mjs';
|
|
3
|
-
import { r as resolveHTTPLinkOptions, a as getUrl, h as httpRequest } from '../httpUtils-
|
|
3
|
+
import { r as resolveHTTPLinkOptions, a as getUrl, h as httpRequest } from '../httpUtils-9b676ab4.mjs';
|
|
4
4
|
|
|
5
5
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /**
|
|
6
6
|
* A function that should never be called unless we messed something up.
|
package/dist/links/httpLink.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var observable = require('@trpc/server/observable');
|
|
6
6
|
var transformResult = require('../transformResult-e7a1e69e.js');
|
|
7
|
-
var httpUtils = require('../httpUtils-
|
|
7
|
+
var httpUtils = require('../httpUtils-b67e2601.js');
|
|
8
8
|
|
|
9
9
|
function httpLink(opts) {
|
|
10
10
|
const resolvedOpts = httpUtils.resolveHTTPLinkOptions(opts);
|
package/dist/links/httpLink.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { observable } from '@trpc/server/observable';
|
|
2
2
|
import { t as transformResult, T as TRPCClientError } from '../transformResult-6fb67924.mjs';
|
|
3
|
-
import { r as resolveHTTPLinkOptions, h as httpRequest } from '../httpUtils-
|
|
3
|
+
import { r as resolveHTTPLinkOptions, h as httpRequest } from '../httpUtils-9b676ab4.mjs';
|
|
4
4
|
|
|
5
5
|
function httpLink(opts) {
|
|
6
6
|
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/client",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.14.1",
|
|
4
4
|
"description": "tRPC Client lib",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -69,11 +69,11 @@
|
|
|
69
69
|
"links"
|
|
70
70
|
],
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@trpc/server": "10.
|
|
72
|
+
"@trpc/server": "10.14.1"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@testing-library/dom": "^9.0.0",
|
|
76
|
-
"@trpc/server": "10.
|
|
76
|
+
"@trpc/server": "10.14.1",
|
|
77
77
|
"@types/isomorphic-fetch": "^0.0.36",
|
|
78
78
|
"@types/node": "^18.7.20",
|
|
79
79
|
"eslint": "^8.30.0",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "c20c66596798ea772f7684f0319b0dffdde4af2a"
|
|
92
92
|
}
|
package/src/getFetch.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { FetchEsque, NativeFetchEsque } from './internals/types';
|
|
2
2
|
|
|
3
|
+
type AnyFn = (...args: any[]) => unknown;
|
|
4
|
+
|
|
5
|
+
const isFunction = (fn: unknown): fn is AnyFn => typeof fn === 'function';
|
|
6
|
+
|
|
7
|
+
function _bind(fn: AnyFn, thisArg: unknown): AnyFn {
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
9
|
+
return isFunction(fn.bind) ? fn.bind(thisArg) : fn;
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
export function getFetch(
|
|
4
13
|
customFetchImpl?: FetchEsque | NativeFetchEsque,
|
|
5
14
|
): FetchEsque {
|
|
@@ -7,15 +16,12 @@ export function getFetch(
|
|
|
7
16
|
return customFetchImpl as FetchEsque;
|
|
8
17
|
}
|
|
9
18
|
|
|
10
|
-
if (typeof window !== 'undefined' &&
|
|
11
|
-
return window.fetch
|
|
19
|
+
if (typeof window !== 'undefined' && isFunction(window.fetch)) {
|
|
20
|
+
return _bind(window.fetch, window) as FetchEsque;
|
|
12
21
|
}
|
|
13
22
|
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
typeof globalThis.fetch === 'function'
|
|
17
|
-
) {
|
|
18
|
-
return globalThis.fetch.bind(globalThis) as FetchEsque;
|
|
23
|
+
if (typeof globalThis !== 'undefined' && isFunction(globalThis.fetch)) {
|
|
24
|
+
return _bind(globalThis.fetch, globalThis) as FetchEsque;
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
throw new Error('No fetch implementation found');
|