@isograph/react 0.0.0-main-54ebe831 → 0.0.0-main-6d83b6a2
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/dist/index.d.ts +1 -1
- package/dist/index.js +2 -13
- package/dist/iso.d.ts +1 -0
- package/dist/iso.js +16 -0
- package/package.json +3 -3
- package/src/index.tsx +2 -20
- package/src/iso.tsx +19 -0
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { DataId, StoreRecord, Link } from './cache';
|
2
2
|
export { setNetwork, makeNetworkRequest, subscribe, DataId, Link, StoreRecord, clearStore, } from './cache';
|
3
|
+
export { iso } from './iso';
|
3
4
|
export type IsographEntrypoint<TReadFromStore extends Object, TResolverProps, TResolverResult> = {
|
4
5
|
kind: 'Entrypoint';
|
5
6
|
queryText: string;
|
@@ -95,7 +96,6 @@ export type FragmentReference<TReadFromStore extends Object, TResolverProps, TRe
|
|
95
96
|
} | null;
|
96
97
|
nestedRefetchQueries: RefetchQueryArtifactWrapper[];
|
97
98
|
};
|
98
|
-
export declare function iso<TResolverParameter>(_queryText: TemplateStringsArray): <TResolverReturn>(x: (param: TResolverParameter) => TResolverReturn) => (param: TResolverParameter) => TResolverReturn;
|
99
99
|
type ExtractTReadFromStore<Type> = Type extends IsographEntrypoint<infer X, any, any> ? X : never;
|
100
100
|
type ExtractResolverProps<Type> = Type extends IsographEntrypoint<any, infer X, any> ? X : never;
|
101
101
|
type ExtractResolverResult<Type> = Type extends IsographEntrypoint<any, any, infer X> ? X : never;
|
package/dist/index.js
CHANGED
@@ -9,23 +9,12 @@ Object.defineProperty(exports, "setNetwork", { enumerable: true, get: function (
|
|
9
9
|
Object.defineProperty(exports, "makeNetworkRequest", { enumerable: true, get: function () { return cache_2.makeNetworkRequest; } });
|
10
10
|
Object.defineProperty(exports, "subscribe", { enumerable: true, get: function () { return cache_2.subscribe; } });
|
11
11
|
Object.defineProperty(exports, "clearStore", { enumerable: true, get: function () { return cache_2.clearStore; } });
|
12
|
+
var iso_1 = require("./iso");
|
13
|
+
Object.defineProperty(exports, "iso", { enumerable: true, get: function () { return iso_1.iso; } });
|
12
14
|
function assertIsEntrypoint(value) {
|
13
15
|
if (typeof value === 'function')
|
14
16
|
throw new Error('Not a string');
|
15
17
|
}
|
16
|
-
function iso(_queryText) {
|
17
|
-
// The name `identity` here is a bit of a double entendre.
|
18
|
-
// First, it is the identity function, constrained to operate
|
19
|
-
// on a very specific type. Thus, the value of b Declare`...`(
|
20
|
-
// someFunction) is someFunction. But furthermore, if one
|
21
|
-
// write b Declare`...` and passes no function, the resolver itself
|
22
|
-
// is the identity function. At that point, the types
|
23
|
-
// TResolverParameter and TResolverReturn must be identical.
|
24
|
-
return function identity(x) {
|
25
|
-
return x;
|
26
|
-
};
|
27
|
-
}
|
28
|
-
exports.iso = iso;
|
29
18
|
// Note: we cannot write TEntrypoint extends IsographEntrypoint<any, any, any>, or else
|
30
19
|
// if we do not explicitly pass a type, the read out type will be any.
|
31
20
|
// We cannot write TEntrypoint extends IsographEntrypoint<never, never, never>, or else
|
package/dist/iso.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export declare function iso<TResolverParameter>(_queryText: TemplateStringsArray): <TResolverReturn>(x: (param: TResolverParameter) => TResolverReturn) => (param: TResolverParameter) => TResolverReturn;
|
package/dist/iso.js
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.iso = void 0;
|
4
|
+
function iso(_queryText) {
|
5
|
+
// The name `identity` here is a bit of a double entendre.
|
6
|
+
// First, it is the identity function, constrained to operate
|
7
|
+
// on a very specific type. Thus, the value of b Declare`...`(
|
8
|
+
// someFunction) is someFunction. But furthermore, if one
|
9
|
+
// write b Declare`...` and passes no function, the resolver itself
|
10
|
+
// is the identity function. At that point, the types
|
11
|
+
// TResolverParameter and TResolverReturn must be identical.
|
12
|
+
return function identity(x) {
|
13
|
+
return x;
|
14
|
+
};
|
15
|
+
}
|
16
|
+
exports.iso = iso;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@isograph/react",
|
3
|
-
"version": "0.0.0-main-
|
3
|
+
"version": "0.0.0-main-6d83b6a2",
|
4
4
|
"description": "Use Isograph with React",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -15,8 +15,8 @@
|
|
15
15
|
"prepack": "yarn run test && yarn run compile"
|
16
16
|
},
|
17
17
|
"dependencies": {
|
18
|
-
"@isograph/disposable-types": "0.0.0-main-
|
19
|
-
"@isograph/react-disposable-state": "0.0.0-main-
|
18
|
+
"@isograph/disposable-types": "0.0.0-main-6d83b6a2",
|
19
|
+
"@isograph/react-disposable-state": "0.0.0-main-6d83b6a2",
|
20
20
|
"react": "^18.2.0"
|
21
21
|
},
|
22
22
|
"devDependencies": {
|
package/src/index.tsx
CHANGED
@@ -23,6 +23,8 @@ export {
|
|
23
23
|
clearStore,
|
24
24
|
} from './cache';
|
25
25
|
|
26
|
+
export { iso } from './iso';
|
27
|
+
|
26
28
|
// This type should be treated as an opaque type.
|
27
29
|
export type IsographEntrypoint<TReadFromStore extends Object, TResolverProps, TResolverResult> = {
|
28
30
|
kind: 'Entrypoint';
|
@@ -152,26 +154,6 @@ function assertIsEntrypoint<TReadFromStore extends Object, TResolverProps, TReso
|
|
152
154
|
if (typeof value === 'function') throw new Error('Not a string');
|
153
155
|
}
|
154
156
|
|
155
|
-
export function iso<TResolverParameter>(
|
156
|
-
_queryText: TemplateStringsArray,
|
157
|
-
): <TResolverReturn>(
|
158
|
-
x: (param: TResolverParameter) => TResolverReturn,
|
159
|
-
) => (param: TResolverParameter) => TResolverReturn {
|
160
|
-
// The name `identity` here is a bit of a double entendre.
|
161
|
-
// First, it is the identity function, constrained to operate
|
162
|
-
// on a very specific type. Thus, the value of b Declare`...`(
|
163
|
-
// someFunction) is someFunction. But furthermore, if one
|
164
|
-
// write b Declare`...` and passes no function, the resolver itself
|
165
|
-
// is the identity function. At that point, the types
|
166
|
-
// TResolverParameter and TResolverReturn must be identical.
|
167
|
-
|
168
|
-
return function identity<TResolverReturn>(
|
169
|
-
x: (param: TResolverParameter) => TResolverReturn,
|
170
|
-
): (param: TResolverParameter) => TResolverReturn {
|
171
|
-
return x;
|
172
|
-
};
|
173
|
-
}
|
174
|
-
|
175
157
|
type ExtractTReadFromStore<Type> = Type extends IsographEntrypoint<infer X, any, any> ? X : never;
|
176
158
|
type ExtractResolverProps<Type> = Type extends IsographEntrypoint<any, infer X, any> ? X : never;
|
177
159
|
type ExtractResolverResult<Type> = Type extends IsographEntrypoint<any, any, infer X> ? X : never;
|
package/src/iso.tsx
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
export function iso<TResolverParameter>(
|
2
|
+
_queryText: TemplateStringsArray,
|
3
|
+
): <TResolverReturn>(
|
4
|
+
x: (param: TResolverParameter) => TResolverReturn,
|
5
|
+
) => (param: TResolverParameter) => TResolverReturn {
|
6
|
+
// The name `identity` here is a bit of a double entendre.
|
7
|
+
// First, it is the identity function, constrained to operate
|
8
|
+
// on a very specific type. Thus, the value of b Declare`...`(
|
9
|
+
// someFunction) is someFunction. But furthermore, if one
|
10
|
+
// write b Declare`...` and passes no function, the resolver itself
|
11
|
+
// is the identity function. At that point, the types
|
12
|
+
// TResolverParameter and TResolverReturn must be identical.
|
13
|
+
|
14
|
+
return function identity<TResolverReturn>(
|
15
|
+
x: (param: TResolverParameter) => TResolverReturn,
|
16
|
+
): (param: TResolverParameter) => TResolverReturn {
|
17
|
+
return x;
|
18
|
+
};
|
19
|
+
}
|