@isograph/react 0.2.0 → 0.3.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.
Files changed (151) hide show
  1. package/.turbo/turbo-compile-typescript.log +4 -0
  2. package/dist/core/FragmentReference.d.ts +25 -6
  3. package/dist/core/FragmentReference.d.ts.map +1 -0
  4. package/dist/core/FragmentReference.js +3 -13
  5. package/dist/core/IsographEnvironment.d.ts +34 -26
  6. package/dist/core/IsographEnvironment.d.ts.map +1 -0
  7. package/dist/core/IsographEnvironment.js +19 -22
  8. package/dist/core/PromiseWrapper.d.ts +4 -4
  9. package/dist/core/PromiseWrapper.d.ts.map +1 -0
  10. package/dist/core/PromiseWrapper.js +9 -9
  11. package/dist/core/areEqualWithDeepComparison.d.ts +5 -3
  12. package/dist/core/areEqualWithDeepComparison.d.ts.map +1 -0
  13. package/dist/core/areEqualWithDeepComparison.js +89 -39
  14. package/dist/core/cache.d.ts +20 -13
  15. package/dist/core/cache.d.ts.map +1 -0
  16. package/dist/core/cache.js +205 -128
  17. package/dist/core/check.d.ts +22 -0
  18. package/dist/core/check.d.ts.map +1 -0
  19. package/dist/core/check.js +127 -0
  20. package/dist/core/componentCache.d.ts +2 -2
  21. package/dist/core/componentCache.d.ts.map +1 -0
  22. package/dist/core/componentCache.js +28 -32
  23. package/dist/core/entrypoint.d.ts +31 -15
  24. package/dist/core/entrypoint.d.ts.map +1 -0
  25. package/dist/core/entrypoint.js +1 -2
  26. package/dist/core/garbageCollection.d.ts +6 -5
  27. package/dist/core/garbageCollection.d.ts.map +1 -0
  28. package/dist/core/garbageCollection.js +49 -16
  29. package/dist/core/logging.d.ts +68 -0
  30. package/dist/core/logging.d.ts.map +1 -0
  31. package/dist/core/logging.js +22 -0
  32. package/dist/core/makeNetworkRequest.d.ts +6 -3
  33. package/dist/core/makeNetworkRequest.d.ts.map +1 -0
  34. package/dist/core/makeNetworkRequest.js +160 -19
  35. package/dist/core/read.d.ts +25 -5
  36. package/dist/core/read.d.ts.map +1 -0
  37. package/dist/core/read.js +416 -259
  38. package/dist/core/reader.d.ts +31 -15
  39. package/dist/core/reader.d.ts.map +1 -0
  40. package/dist/core/startUpdate.d.ts +5 -0
  41. package/dist/core/startUpdate.d.ts.map +1 -0
  42. package/dist/core/startUpdate.js +15 -0
  43. package/dist/core/util.d.ts +5 -0
  44. package/dist/core/util.d.ts.map +1 -0
  45. package/dist/index.d.ts +19 -14
  46. package/dist/index.d.ts.map +1 -0
  47. package/dist/index.js +11 -2
  48. package/dist/loadable-hooks/useClientSideDefer.d.ts +9 -3
  49. package/dist/loadable-hooks/useClientSideDefer.d.ts.map +1 -0
  50. package/dist/loadable-hooks/useClientSideDefer.js +6 -8
  51. package/dist/loadable-hooks/useConnectionSpecPagination.d.ts +27 -0
  52. package/dist/loadable-hooks/useConnectionSpecPagination.d.ts.map +1 -0
  53. package/dist/loadable-hooks/useConnectionSpecPagination.js +162 -0
  54. package/dist/loadable-hooks/useImperativeExposedMutationField.d.ts +2 -2
  55. package/dist/loadable-hooks/useImperativeExposedMutationField.d.ts.map +1 -0
  56. package/dist/loadable-hooks/useImperativeExposedMutationField.js +1 -2
  57. package/dist/loadable-hooks/useImperativeLoadableField.d.ts +13 -7
  58. package/dist/loadable-hooks/useImperativeLoadableField.d.ts.map +1 -0
  59. package/dist/loadable-hooks/useImperativeLoadableField.js +4 -5
  60. package/dist/loadable-hooks/useSkipLimitPagination.d.ts +13 -26
  61. package/dist/loadable-hooks/useSkipLimitPagination.d.ts.map +1 -0
  62. package/dist/loadable-hooks/useSkipLimitPagination.js +93 -47
  63. package/dist/react/FragmentReader.d.ts +6 -4
  64. package/dist/react/FragmentReader.d.ts.map +1 -0
  65. package/dist/react/FragmentReader.js +4 -2
  66. package/dist/react/IsographEnvironmentProvider.d.ts +1 -0
  67. package/dist/react/IsographEnvironmentProvider.d.ts.map +1 -0
  68. package/dist/react/IsographEnvironmentProvider.js +3 -3
  69. package/dist/react/RenderAfterCommit__DO_NOT_USE.d.ts +10 -0
  70. package/dist/react/RenderAfterCommit__DO_NOT_USE.d.ts.map +1 -0
  71. package/dist/react/RenderAfterCommit__DO_NOT_USE.js +15 -0
  72. package/dist/react/useImperativeReference.d.ts +8 -6
  73. package/dist/react/useImperativeReference.d.ts.map +1 -0
  74. package/dist/react/useImperativeReference.js +6 -8
  75. package/dist/react/useLazyReference.d.ts +5 -3
  76. package/dist/react/useLazyReference.d.ts.map +1 -0
  77. package/dist/react/useLazyReference.js +34 -6
  78. package/dist/react/useReadAndSubscribe.d.ts +6 -3
  79. package/dist/react/useReadAndSubscribe.d.ts.map +1 -0
  80. package/dist/react/useReadAndSubscribe.js +13 -10
  81. package/dist/react/useRerenderOnChange.d.ts +7 -2
  82. package/dist/react/useRerenderOnChange.d.ts.map +1 -0
  83. package/dist/react/useRerenderOnChange.js +3 -4
  84. package/dist/react/useResult.d.ts +4 -3
  85. package/dist/react/useResult.d.ts.map +1 -0
  86. package/dist/react/useResult.js +14 -9
  87. package/isograph.config.json +8 -0
  88. package/package.json +14 -9
  89. package/{src/tests/schema.graphql → schema.graphql} +1 -0
  90. package/src/core/FragmentReference.ts +44 -17
  91. package/src/core/IsographEnvironment.ts +67 -50
  92. package/src/core/PromiseWrapper.ts +3 -3
  93. package/src/core/areEqualWithDeepComparison.ts +95 -41
  94. package/src/core/cache.ts +316 -169
  95. package/src/core/check.ts +212 -0
  96. package/src/core/componentCache.ts +40 -46
  97. package/src/core/entrypoint.ts +41 -16
  98. package/src/core/garbageCollection.ts +77 -26
  99. package/src/core/logging.ts +118 -0
  100. package/src/core/makeNetworkRequest.ts +249 -20
  101. package/src/core/read.ts +658 -368
  102. package/src/core/reader.ts +61 -21
  103. package/src/core/startUpdate.ts +28 -0
  104. package/src/core/util.ts +8 -0
  105. package/src/index.ts +94 -8
  106. package/src/loadable-hooks/useClientSideDefer.ts +48 -17
  107. package/src/loadable-hooks/useConnectionSpecPagination.ts +344 -0
  108. package/src/loadable-hooks/useImperativeExposedMutationField.ts +1 -1
  109. package/src/loadable-hooks/useImperativeLoadableField.ts +36 -12
  110. package/src/loadable-hooks/useSkipLimitPagination.ts +253 -94
  111. package/src/react/FragmentReader.tsx +15 -6
  112. package/src/react/IsographEnvironmentProvider.tsx +1 -1
  113. package/src/react/RenderAfterCommit__DO_NOT_USE.tsx +17 -0
  114. package/src/react/useImperativeReference.ts +50 -18
  115. package/src/react/useLazyReference.ts +79 -11
  116. package/src/react/useReadAndSubscribe.ts +33 -10
  117. package/src/react/useRerenderOnChange.ts +7 -2
  118. package/src/react/useResult.ts +30 -9
  119. package/src/tests/__isograph/Query/meName/entrypoint.ts +10 -29
  120. package/src/tests/__isograph/Query/meName/normalization_ast.ts +25 -0
  121. package/src/tests/__isograph/Query/meName/param_type.ts +5 -2
  122. package/src/tests/__isograph/Query/meName/query_text.ts +6 -0
  123. package/src/tests/__isograph/Query/meName/resolver_reader.ts +5 -0
  124. package/src/tests/__isograph/Query/meNameSuccessor/entrypoint.ts +10 -65
  125. package/src/tests/__isograph/Query/meNameSuccessor/normalization_ast.ts +56 -0
  126. package/src/tests/__isograph/Query/meNameSuccessor/param_type.ts +9 -6
  127. package/src/tests/__isograph/Query/meNameSuccessor/query_text.ts +13 -0
  128. package/src/tests/__isograph/Query/meNameSuccessor/resolver_reader.ts +10 -0
  129. package/src/tests/__isograph/Query/nodeField/entrypoint.ts +10 -28
  130. package/src/tests/__isograph/Query/nodeField/normalization_ast.ts +30 -0
  131. package/src/tests/__isograph/Query/nodeField/param_type.ts +7 -3
  132. package/src/tests/__isograph/Query/nodeField/parameters_type.ts +3 -0
  133. package/src/tests/__isograph/Query/nodeField/query_text.ts +6 -0
  134. package/src/tests/__isograph/Query/nodeField/resolver_reader.ts +5 -0
  135. package/src/tests/__isograph/Query/subquery/entrypoint.ts +28 -0
  136. package/src/tests/__isograph/Query/subquery/normalization_ast.ts +38 -0
  137. package/src/tests/__isograph/Query/subquery/output_type.ts +3 -0
  138. package/src/tests/__isograph/Query/subquery/param_type.ts +12 -0
  139. package/src/tests/__isograph/Query/subquery/parameters_type.ts +3 -0
  140. package/src/tests/__isograph/Query/subquery/query_text.ts +8 -0
  141. package/src/tests/__isograph/Query/subquery/resolver_reader.ts +52 -0
  142. package/src/tests/__isograph/iso.ts +24 -12
  143. package/src/tests/garbageCollection.test.ts +53 -45
  144. package/src/tests/meNameSuccessor.ts +8 -3
  145. package/src/tests/nodeQuery.ts +7 -4
  146. package/src/tests/normalizeData.test.ts +120 -0
  147. package/src/tests/tsconfig.json +3 -3
  148. package/tsconfig.json +2 -2
  149. package/tsconfig.pkg.json +7 -3
  150. package/vitest.config.ts +20 -0
  151. package/src/tests/isograph.config.json +0 -7
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_SHOULD_FETCH_VALUE = void 0;
4
+ exports.check = check;
5
+ const cache_1 = require("./cache");
6
+ const IsographEnvironment_1 = require("./IsographEnvironment");
7
+ const logging_1 = require("./logging");
8
+ exports.DEFAULT_SHOULD_FETCH_VALUE = 'IfNecessary';
9
+ function check(environment, normalizationAst, variables, root) {
10
+ var _a, _b;
11
+ var _c, _d, _e;
12
+ const recordsById = ((_a = (_c = environment.store)[_d = root.__typename]) !== null && _a !== void 0 ? _a : (_c[_d] = {}));
13
+ const newStoreRecord = ((_b = recordsById[_e = root.__link]) !== null && _b !== void 0 ? _b : (recordsById[_e] = {}));
14
+ const checkResult = checkFromRecord(environment, normalizationAst, variables, newStoreRecord, root);
15
+ (0, logging_1.logMessage)(environment, () => ({
16
+ kind: 'EnvironmentCheck',
17
+ result: checkResult,
18
+ }));
19
+ return checkResult;
20
+ }
21
+ function checkFromRecord(environment, normalizationAst, variables, record, recordLink) {
22
+ var _a, _b;
23
+ normalizationAstLoop: for (const normalizationAstNode of normalizationAst) {
24
+ switch (normalizationAstNode.kind) {
25
+ case 'Scalar': {
26
+ const parentRecordKey = (0, cache_1.getParentRecordKey)(normalizationAstNode, variables);
27
+ const scalarValue = record[parentRecordKey];
28
+ // null means the value is known to be missing, so it must
29
+ // be exactly undefined
30
+ if (scalarValue === undefined) {
31
+ return {
32
+ kind: 'MissingData',
33
+ record: recordLink,
34
+ };
35
+ }
36
+ continue normalizationAstLoop;
37
+ }
38
+ case 'Linked': {
39
+ const parentRecordKey = (0, cache_1.getParentRecordKey)(normalizationAstNode, variables);
40
+ const linkedValue = record[parentRecordKey];
41
+ if (linkedValue === undefined) {
42
+ return {
43
+ kind: 'MissingData',
44
+ record: recordLink,
45
+ };
46
+ }
47
+ else if (linkedValue === null) {
48
+ continue;
49
+ }
50
+ else if (Array.isArray(linkedValue)) {
51
+ arrayItemsLoop: for (const item of linkedValue) {
52
+ const link = (0, IsographEnvironment_1.getLink)(item);
53
+ if (link === null) {
54
+ throw new Error('Unexpected non-link in the Isograph store. ' +
55
+ 'This is indicative of a bug in Isograph.');
56
+ }
57
+ const linkedRecord = (_a = environment.store[link.__typename]) === null || _a === void 0 ? void 0 : _a[link.__link];
58
+ if (linkedRecord === undefined) {
59
+ return {
60
+ kind: 'MissingData',
61
+ record: link,
62
+ };
63
+ }
64
+ else if (linkedRecord === null) {
65
+ continue arrayItemsLoop;
66
+ }
67
+ else {
68
+ // TODO in __DEV__ assert linkedRecord is an object
69
+ const result = checkFromRecord(environment, normalizationAstNode.selections, variables, linkedRecord, link);
70
+ if (result.kind === 'MissingData') {
71
+ return result;
72
+ }
73
+ }
74
+ }
75
+ }
76
+ else {
77
+ const link = (0, IsographEnvironment_1.getLink)(linkedValue);
78
+ if (link === null) {
79
+ throw new Error('Unexpected non-link in the Isograph store. ' +
80
+ 'This is indicative of a bug in Isograph.');
81
+ }
82
+ const linkedRecord = (_b = environment.store[link.__typename]) === null || _b === void 0 ? void 0 : _b[link.__link];
83
+ if (linkedRecord === undefined) {
84
+ return {
85
+ kind: 'MissingData',
86
+ record: link,
87
+ };
88
+ }
89
+ else if (linkedRecord === null) {
90
+ continue normalizationAstLoop;
91
+ }
92
+ else {
93
+ // TODO in __DEV__ assert linkedRecord is an object
94
+ const result = checkFromRecord(environment, normalizationAstNode.selections, variables, linkedRecord, link);
95
+ if (result.kind === 'MissingData') {
96
+ return result;
97
+ }
98
+ }
99
+ }
100
+ continue normalizationAstLoop;
101
+ }
102
+ case 'InlineFragment': {
103
+ const existingRecordTypename = record['__typename'];
104
+ if (existingRecordTypename == null ||
105
+ existingRecordTypename !== normalizationAstNode.type) {
106
+ return {
107
+ kind: 'MissingData',
108
+ record: recordLink,
109
+ };
110
+ }
111
+ const result = checkFromRecord(environment, normalizationAstNode.selections, variables, record, recordLink);
112
+ if (result.kind === 'MissingData') {
113
+ return result;
114
+ }
115
+ continue normalizationAstLoop;
116
+ }
117
+ default: {
118
+ let _ = normalizationAstNode;
119
+ _;
120
+ throw new Error('Unexpected case. This is indicative of a bug in Isograph.');
121
+ }
122
+ }
123
+ }
124
+ return {
125
+ kind: 'EnoughData',
126
+ };
127
+ }
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
- import { IsographEnvironment } from './IsographEnvironment';
3
1
  import { FragmentReference } from './FragmentReference';
2
+ import { IsographEnvironment } from './IsographEnvironment';
4
3
  import { NetworkRequestReaderOptions } from './read';
5
4
  export declare function getOrCreateCachedComponent(environment: IsographEnvironment, componentName: string, fragmentReference: FragmentReference<any, any>, networkRequestOptions: NetworkRequestReaderOptions): React.FC<any>;
5
+ //# sourceMappingURL=componentCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentCache.d.ts","sourceRoot":"","sources":["../../src/core/componentCache.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,QAAQ,CAAC;AAGrD,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,mBAAmB,EAChC,aAAa,EAAE,MAAM,EACrB,iBAAiB,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,EAC9C,qBAAqB,EAAE,2BAA2B,GACjD,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAsCf"}
@@ -1,38 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOrCreateCachedComponent = void 0;
4
- const cache_1 = require("./cache");
3
+ exports.getOrCreateCachedComponent = getOrCreateCachedComponent;
5
4
  const useReadAndSubscribe_1 = require("../react/useReadAndSubscribe");
5
+ const FragmentReference_1 = require("./FragmentReference");
6
+ const logging_1 = require("./logging");
6
7
  const PromiseWrapper_1 = require("./PromiseWrapper");
8
+ const startUpdate_1 = require("./startUpdate");
7
9
  function getOrCreateCachedComponent(environment, componentName, fragmentReference, networkRequestOptions) {
8
- var _a, _b, _c;
9
- // cachedComponentsById is a three layer cache: id, then component name, then
10
- // stringified args. These three, together, uniquely identify a read at a given
11
- // time.
12
- const cachedComponentsById = environment.componentCache;
13
- cachedComponentsById[fragmentReference.root] =
14
- (_a = cachedComponentsById[fragmentReference.root]) !== null && _a !== void 0 ? _a : {};
15
- const componentsByName = cachedComponentsById[fragmentReference.root];
16
- componentsByName[componentName] = (_b = componentsByName[componentName]) !== null && _b !== void 0 ? _b : {};
17
- const byArgs = componentsByName[componentName];
18
- const stringifiedArgs = JSON.stringify((0, cache_1.stableCopy)(fragmentReference.variables));
19
- byArgs[stringifiedArgs] =
20
- (_c = byArgs[stringifiedArgs]) !== null && _c !== void 0 ? _c : (() => {
21
- function Component(additionalRuntimeProps) {
22
- const data = (0, useReadAndSubscribe_1.useReadAndSubscribe)(fragmentReference, networkRequestOptions);
23
- // @ts-expect-error
24
- if (typeof window !== 'undefined' && window.__LOG) {
25
- console.log('Component re-rendered: ' +
26
- componentName +
27
- ' ' +
28
- fragmentReference.root);
29
- }
30
- const readerWithRefetchQueries = (0, PromiseWrapper_1.readPromise)(fragmentReference.readerWithRefetchQueries);
31
- return readerWithRefetchQueries.readerArtifact.resolver(data, additionalRuntimeProps);
32
- }
33
- Component.displayName = `${componentName} (id: ${fragmentReference.root}) @component`;
34
- return Component;
35
- })();
36
- return byArgs[stringifiedArgs];
10
+ var _a;
11
+ var _b, _c;
12
+ // We create startUpdate outside of component to make it stable
13
+ const startUpdate = (0, startUpdate_1.createStartUpdate)(environment, fragmentReference);
14
+ return ((_a = (_b = environment.componentCache)[_c = (0, FragmentReference_1.stableIdForFragmentReference)(fragmentReference, componentName)]) !== null && _a !== void 0 ? _a : (_b[_c] = (() => {
15
+ function Component(additionalRuntimeProps) {
16
+ const readerWithRefetchQueries = (0, PromiseWrapper_1.readPromise)(fragmentReference.readerWithRefetchQueries);
17
+ const data = (0, useReadAndSubscribe_1.useReadAndSubscribe)(fragmentReference, networkRequestOptions, readerWithRefetchQueries.readerArtifact.readerAst);
18
+ (0, logging_1.logMessage)(environment, () => ({
19
+ kind: 'ComponentRerendered',
20
+ componentName,
21
+ rootLink: fragmentReference.root,
22
+ }));
23
+ return readerWithRefetchQueries.readerArtifact.resolver({
24
+ data,
25
+ parameters: fragmentReference.variables,
26
+ startUpdate: readerWithRefetchQueries.readerArtifact.hasUpdatable
27
+ ? startUpdate
28
+ : undefined,
29
+ }, additionalRuntimeProps);
30
+ }
31
+ Component.displayName = `${componentName} (id: ${fragmentReference.root}) @component`;
32
+ return Component;
33
+ })()));
37
34
  }
38
- exports.getOrCreateCachedComponent = getOrCreateCachedComponent;
@@ -1,24 +1,38 @@
1
- /// <reference types="react" />
1
+ import type { UnknownTReadFromStore } from './FragmentReference';
2
+ import type { TypeName } from './IsographEnvironment';
2
3
  import { TopLevelReaderArtifact } from './reader';
3
4
  import { Arguments } from './util';
4
- export type ReaderWithRefetchQueries<TReadFromStore extends Object, TClientFieldValue> = {
5
+ export type ReaderWithRefetchQueries<TReadFromStore extends UnknownTReadFromStore, TClientFieldValue> = {
5
6
  readonly kind: 'ReaderWithRefetchQueries';
6
7
  readonly readerArtifact: TopLevelReaderArtifact<TReadFromStore, TClientFieldValue, any>;
7
8
  readonly nestedRefetchQueries: RefetchQueryNormalizationArtifactWrapper[];
8
9
  };
9
- export type IsographEntrypoint<TReadFromStore extends Object, TClientFieldValue> = {
10
- readonly kind: 'Entrypoint';
10
+ export type NetworkRequestInfo<TNormalizationAst> = {
11
+ readonly kind: 'NetworkRequestInfo';
11
12
  readonly queryText: string;
12
- readonly normalizationAst: NormalizationAst;
13
+ readonly normalizationAst: TNormalizationAst;
14
+ };
15
+ export type IsographEntrypoint<TReadFromStore extends UnknownTReadFromStore, TClientFieldValue, TNormalizationAst extends NormalizationAst | NormalizationAstLoader> = {
16
+ readonly kind: 'Entrypoint';
17
+ readonly networkRequestInfo: NetworkRequestInfo<TNormalizationAst>;
13
18
  readonly readerWithRefetchQueries: ReaderWithRefetchQueries<TReadFromStore, TClientFieldValue>;
19
+ readonly concreteType: TypeName;
14
20
  };
15
- export type IsographEntrypointLoader<TReadFromStore extends Object, TClientFieldValue> = {
21
+ export type IsographEntrypointLoader<TReadFromStore extends UnknownTReadFromStore, TClientFieldValue> = {
16
22
  readonly kind: 'EntrypointLoader';
17
23
  readonly typeAndField: string;
18
- readonly loader: () => Promise<IsographEntrypoint<TReadFromStore, TClientFieldValue>>;
24
+ readonly loader: () => Promise<IsographEntrypoint<TReadFromStore, TClientFieldValue, NormalizationAst>>;
19
25
  };
20
26
  export type NormalizationAstNode = NormalizationScalarField | NormalizationLinkedField | NormalizationInlineFragment;
21
- export type NormalizationAst = ReadonlyArray<NormalizationAstNode>;
27
+ export type NormalizationAstNodes = ReadonlyArray<NormalizationAstNode>;
28
+ export type NormalizationAst = {
29
+ readonly kind: 'NormalizationAst';
30
+ readonly selections: NormalizationAstNodes;
31
+ };
32
+ export type NormalizationAstLoader = {
33
+ readonly kind: 'NormalizationAstLoader';
34
+ readonly loader: () => Promise<NormalizationAst>;
35
+ };
22
36
  export type NormalizationScalarField = {
23
37
  readonly kind: 'Scalar';
24
38
  readonly fieldName: string;
@@ -28,23 +42,25 @@ export type NormalizationLinkedField = {
28
42
  readonly kind: 'Linked';
29
43
  readonly fieldName: string;
30
44
  readonly arguments: Arguments | null;
31
- readonly selections: NormalizationAst;
45
+ readonly selections: NormalizationAstNodes;
46
+ readonly concreteType: TypeName | null;
32
47
  };
33
48
  export type NormalizationInlineFragment = {
34
49
  readonly kind: 'InlineFragment';
35
50
  readonly type: string;
36
- readonly selections: NormalizationAst;
51
+ readonly selections: NormalizationAstNodes;
37
52
  };
38
53
  export type RefetchQueryNormalizationArtifact = {
39
54
  readonly kind: 'RefetchQuery';
40
- readonly queryText: string;
41
- readonly normalizationAst: NormalizationAst;
55
+ readonly networkRequestInfo: NetworkRequestInfo<NormalizationAst>;
56
+ readonly concreteType: TypeName;
42
57
  };
43
58
  export type RefetchQueryNormalizationArtifactWrapper = {
44
59
  readonly artifact: RefetchQueryNormalizationArtifact;
45
60
  readonly allowedVariables: string[];
46
61
  };
47
- export declare function assertIsEntrypoint<TReadFromStore extends Object, TClientFieldValue>(value: IsographEntrypoint<TReadFromStore, TClientFieldValue> | ((_: any) => any) | any): asserts value is IsographEntrypoint<TReadFromStore, TClientFieldValue>;
48
- export type ExtractReadFromStore<Type> = Type extends IsographEntrypoint<infer X, any> ? X : never;
49
- export type ExtractResolverResult<Type> = Type extends IsographEntrypoint<any, infer X> ? X : never;
62
+ export declare function assertIsEntrypoint<TReadFromStore extends UnknownTReadFromStore, TClientFieldValue, TNormalizationAst extends NormalizationAst | NormalizationAstLoader>(value: IsographEntrypoint<TReadFromStore, TClientFieldValue, TNormalizationAst> | ((_: any) => any) | any): asserts value is IsographEntrypoint<TReadFromStore, TClientFieldValue, TNormalizationAst>;
63
+ export type ExtractReadFromStore<Type> = Type extends IsographEntrypoint<infer X, any, any> ? X : never;
64
+ export type ExtractResolverResult<Type> = Type extends IsographEntrypoint<any, infer X, any> ? X : never;
50
65
  export type ExtractProps<Type> = Type extends React.FC<infer X> ? X : never;
66
+ //# sourceMappingURL=entrypoint.d.ts.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ty(exports, "__esModule", { value: true });
3
- exports.assertIsEntrypoint = void 0;
3
+ exports.assertIsEntrypoint = assertIsEntrypoint;
4
4
  function assertIsEntrypoint(value) {
5
5
  if (typeof value === 'function')
6
6
  throw new Error('Not a string');
7
7
  }
8
- exports.assertIsEntrypoint = assertIsEntrypoint;
@@ -1,11 +1,12 @@
1
- import { IsographEnvironment } from './IsographEnvironment';
2
- import { NormalizationAst } from './entrypoint';
1
+ import { NormalizationAstNodes } from './entrypoint';
2
+ import { IsographEnvironment, type Link } from './IsographEnvironment';
3
3
  export type RetainedQuery = {
4
- readonly normalizationAst: NormalizationAst;
4
+ readonly normalizationAst: NormalizationAstNodes;
5
5
  readonly variables: {};
6
+ readonly root: Link;
6
7
  };
7
- type DidUnretainSomeQuery = boolean;
8
+ export type DidUnretainSomeQuery = boolean;
8
9
  export declare function unretainQuery(environment: IsographEnvironment, retainedQuery: RetainedQuery): DidUnretainSomeQuery;
9
10
  export declare function retainQuery(environment: IsographEnvironment, queryToRetain: RetainedQuery): void;
10
11
  export declare function garbageCollectEnvironment(environment: IsographEnvironment): void;
11
- export {};
12
+ //# sourceMappingURL=garbageCollection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"garbageCollection.d.ts","sourceRoot":"","sources":["../../src/core/garbageCollection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAGL,mBAAmB,EAGnB,KAAK,IAAI,EAEV,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,gBAAgB,EAAE,qBAAqB,CAAC;IACjD,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAC3C,wBAAgB,aAAa,CAC3B,WAAW,EAAE,mBAAmB,EAChC,aAAa,EAAE,aAAa,GAC3B,oBAAoB,CAUtB;AAED,wBAAgB,WAAW,CACzB,WAAW,EAAE,mBAAmB,EAChC,aAAa,EAAE,aAAa,QAM7B;AAED,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,mBAAmB,QA+BzE"}
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.garbageCollectEnvironment = exports.retainQuery = exports.unretainQuery = void 0;
4
- const IsographEnvironment_1 = require("./IsographEnvironment");
3
+ exports.unretainQuery = unretainQuery;
4
+ exports.retainQuery = retainQuery;
5
+ exports.garbageCollectEnvironment = garbageCollectEnvironment;
5
6
  const cache_1 = require("./cache");
7
+ const IsographEnvironment_1 = require("./IsographEnvironment");
6
8
  function unretainQuery(environment, retainedQuery) {
7
9
  environment.retainedQueries.delete(retainedQuery);
8
10
  environment.gcBuffer.push(retainedQuery);
@@ -12,57 +14,88 @@ function unretainQuery(environment, retainedQuery) {
12
14
  }
13
15
  return false;
14
16
  }
15
- exports.unretainQuery = unretainQuery;
16
17
  function retainQuery(environment, queryToRetain) {
17
18
  environment.retainedQueries.add(queryToRetain);
18
19
  // TODO can we remove this query from the buffer somehow?
19
20
  // We are relying on === equality, but we really should be comparing
20
21
  // id + variables
21
22
  }
22
- exports.retainQuery = retainQuery;
23
23
  function garbageCollectEnvironment(environment) {
24
- const retainedIds = new Set([IsographEnvironment_1.ROOT_ID]);
24
+ const retainedIds = {};
25
25
  for (const query of environment.retainedQueries) {
26
26
  recordReachableIds(environment.store, query, retainedIds);
27
27
  }
28
28
  for (const query of environment.gcBuffer) {
29
29
  recordReachableIds(environment.store, query, retainedIds);
30
30
  }
31
- for (const dataId in environment.store) {
32
- if (!retainedIds.has(dataId)) {
33
- delete environment.store[dataId];
31
+ for (const typeName in environment.store) {
32
+ const dataById = environment.store[typeName];
33
+ if (dataById == null)
34
+ continue;
35
+ const retainedTypeIds = retainedIds[typeName];
36
+ // delete all objects
37
+ if (retainedTypeIds == undefined || retainedTypeIds.size == 0) {
38
+ delete environment.store[typeName];
39
+ continue;
40
+ }
41
+ for (const dataId in dataById) {
42
+ if (!retainedTypeIds.has(dataId)) {
43
+ delete dataById[dataId];
44
+ }
45
+ }
46
+ if (Object.keys(dataById).length === 0) {
47
+ delete environment.store[typeName];
34
48
  }
35
49
  }
36
50
  }
37
- exports.garbageCollectEnvironment = garbageCollectEnvironment;
38
51
  function recordReachableIds(store, retainedQuery, mutableRetainedIds) {
39
- recordReachableIdsFromRecord(store, store[IsographEnvironment_1.ROOT_ID], mutableRetainedIds, retainedQuery.normalizationAst, retainedQuery.variables);
52
+ var _a, _b;
53
+ var _c;
54
+ const record = (_a = store[retainedQuery.root.__typename]) === null || _a === void 0 ? void 0 : _a[retainedQuery.root.__link];
55
+ const retainedRecordsIds = ((_b = mutableRetainedIds[_c = retainedQuery.root.__typename]) !== null && _b !== void 0 ? _b : (mutableRetainedIds[_c] = new Set()));
56
+ retainedRecordsIds.add(retainedQuery.root.__link);
57
+ if (record) {
58
+ recordReachableIdsFromRecord(store, record, mutableRetainedIds, retainedQuery.normalizationAst, retainedQuery.variables);
59
+ }
40
60
  }
41
61
  function recordReachableIdsFromRecord(store, currentRecord, mutableRetainedIds, selections, variables) {
62
+ var _a;
42
63
  for (const selection of selections) {
43
64
  switch (selection.kind) {
44
65
  case 'Linked':
45
66
  const linkKey = (0, cache_1.getParentRecordKey)(selection, variables !== null && variables !== void 0 ? variables : {});
46
67
  const linkedFieldOrFields = currentRecord[linkKey];
47
- const ids = [];
68
+ const links = [];
48
69
  if (Array.isArray(linkedFieldOrFields)) {
49
70
  for (const maybeLink of linkedFieldOrFields) {
50
71
  const link = (0, IsographEnvironment_1.assertLink)(maybeLink);
51
72
  if (link != null) {
52
- ids.push(link.__link);
73
+ links.push(link);
53
74
  }
54
75
  }
55
76
  }
56
77
  else {
57
78
  const link = (0, IsographEnvironment_1.assertLink)(linkedFieldOrFields);
58
79
  if (link != null) {
59
- ids.push(link.__link);
80
+ links.push(link);
60
81
  }
61
82
  }
62
- for (const nextRecordId of ids) {
63
- const nextRecord = store[nextRecordId];
83
+ let typeStore = selection.concreteType !== null
84
+ ? store[selection.concreteType]
85
+ : null;
86
+ if (typeStore == null && selection.concreteType !== null) {
87
+ continue;
88
+ }
89
+ for (const nextRecordLink of links) {
90
+ let __typename = nextRecordLink.__typename;
91
+ const resolvedTypeStore = typeStore !== null && typeStore !== void 0 ? typeStore : store[__typename];
92
+ if (resolvedTypeStore == null) {
93
+ continue;
94
+ }
95
+ const nextRecord = resolvedTypeStore[nextRecordLink.__link];
64
96
  if (nextRecord != null) {
65
- mutableRetainedIds.add(nextRecordId);
97
+ const retainedRecordsIds = ((_a = mutableRetainedIds[__typename]) !== null && _a !== void 0 ? _a : (mutableRetainedIds[__typename] = new Set()));
98
+ retainedRecordsIds.add(nextRecordLink.__link);
66
99
  recordReachableIdsFromRecord(store, nextRecord, mutableRetainedIds, selection.selections, variables);
67
100
  }
68
101
  }
@@ -0,0 +1,68 @@
1
+ import { CleanupFn } from '@isograph/disposable-types';
2
+ import { NetworkResponseObject, type EncounteredIds } from './cache';
3
+ import { CheckResult } from './check';
4
+ import { IsographEntrypoint, RefetchQueryNormalizationArtifact, type NormalizationAstNodes } from './entrypoint';
5
+ import { FragmentReference, Variables } from './FragmentReference';
6
+ import { IsographEnvironment, IsographStore, StoreRecord, type Link } from './IsographEnvironment';
7
+ import { ReadDataResult } from './read';
8
+ import { Arguments } from './util';
9
+ export type LogMessage = {
10
+ kind: 'AboutToNormalize';
11
+ normalizationAst: NormalizationAstNodes;
12
+ networkResponse: NetworkResponseObject;
13
+ variables: Variables;
14
+ } | {
15
+ kind: 'AfterNormalization';
16
+ store: IsographStore;
17
+ encounteredIds: EncounteredIds;
18
+ } | {
19
+ kind: 'DeepEqualityCheck';
20
+ fragmentReference: FragmentReference<any, any>;
21
+ old: object;
22
+ new: object;
23
+ deeplyEqual: boolean;
24
+ } | {
25
+ kind: 'ComponentRerendered';
26
+ componentName: string;
27
+ rootLink: Link;
28
+ } | {
29
+ kind: 'MakeNetworkRequest';
30
+ artifact: RefetchQueryNormalizationArtifact | IsographEntrypoint<any, any, any>;
31
+ variables: Variables;
32
+ networkRequestId: string;
33
+ } | {
34
+ kind: 'ReceivedNetworkResponse';
35
+ networkResponse: any;
36
+ networkRequestId: string;
37
+ } | {
38
+ kind: 'ReceivedNetworkError';
39
+ error: any;
40
+ networkRequestId: string;
41
+ } | {
42
+ kind: 'MissingFieldHandlerCalled';
43
+ root: Link;
44
+ storeRecord: StoreRecord;
45
+ fieldName: string;
46
+ arguments: Arguments | null;
47
+ variables: Variables;
48
+ } | {
49
+ kind: 'DoneReading';
50
+ response: ReadDataResult<any>;
51
+ fieldName: string;
52
+ root: Link;
53
+ } | {
54
+ kind: 'NonEntrypointReceived';
55
+ entrypoint: any;
56
+ } | {
57
+ kind: 'EnvironmentCheck';
58
+ result: CheckResult;
59
+ } | {
60
+ kind: 'EnvironmentCreated';
61
+ };
62
+ export type LogFunction = (logMessage: LogMessage) => void;
63
+ export type WrappedLogFunction = {
64
+ log: LogFunction;
65
+ };
66
+ export declare function logMessage(environment: IsographEnvironment, getMessage: () => LogMessage): void;
67
+ export declare function registerLogger(environment: IsographEnvironment, log: LogFunction): CleanupFn;
68
+ //# sourceMappingURL=logging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/core/logging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EACL,kBAAkB,EAClB,iCAAiC,EACjC,KAAK,qBAAqB,EAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACnE,O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;IACX,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,SAAS,CAAC;CACtB,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC;CACZ,GACD;IACE,IAAI,EAAE,uBAAuB,CAAC;IAC9B,UAAU,EAAE,GAAG,CAAC;CACjB,GACD;IACE,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,WAAW,CAAC;CACrB,GACD;IACE,IAAI,EAAE,oBAAoB,CAAC;CAC5B,CAAC;AAEN,MAAM,MAAM,WAAW,GAAG,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;AAG3D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,WAAW,CAAC;CAClB,CAAC;AAEF,wBAAgB,UAAU,CACxB,WAAW,EAAE,mBAAmB,EAChC,UAAU,EAAE,MAAM,UAAU,QAU7B;AAED,wBAAgB,cAAc,CAC5B,WAAW,EAAE,mBAAmB,EAChC,GAAG,EAAE,WAAW,GACf,SAAS,CAMX"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logMessage = logMessage;
4
+ exports.registerLogger = registerLogger;
5
+ function logMessage(environment, getMessage) {
6
+ if (environment.loggers.size > 0) {
7
+ const message = getMessage();
8
+ for (const logger of environment.loggers) {
9
+ try {
10
+ logger.log(message);
11
+ }
12
+ catch (_a) { }
13
+ }
14
+ }
15
+ }
16
+ function registerLogger(environment, log) {
17
+ const wrapped = { log };
18
+ environment.loggers.add(wrapped);
19
+ return () => {
20
+ environment.loggers.delete(wrapped);
21
+ };
22
+ }
@@ -1,6 +1,9 @@
1
1
  import { ItemCleanupPair } from '@isograph/disposable-types';
2
- import { IsographEntrypoint, RefetchQueryNormalizationArtifact } from './entrypoint';
3
- import { Variables } from './FragmentReference';
2
+ import { FetchOptions } from './check';
3
+ import { IsographEntrypoint, RefetchQueryNormalizationArtifact, type NormalizationAst, type NormalizationAstLoader } from './entrypoint';
4
+ import { ExtractParameters, type UnknownTReadFromStore } from './FragmentReference';
4
5
  import { IsographEnvironment } from './IsographEnvironment';
5
6
  import { AnyError, PromiseWrapper } from './PromiseWrapper';
6
- export declare function makeNetworkRequest(environment: IsographEnvironment, artifact: RefetchQueryNormalizationArtifact | IsographEntrypoint<any, any>, variables: Variables): ItemCleanupPair<PromiseWrapper<void, AnyError>>;
7
+ export declare function maybeMakeNetworkRequest<TReadFromStore extends UnknownTReadFromStore, TClientFieldValue, TNormalizationAst extends NormalizationAst | NormalizationAstLoader>(environment: IsographEnvironment, artifact: RefetchQueryNormalizationArtifact | IsographEntrypoint<TReadFromStore, TClientFieldValue, TNormalizationAst>, variables: ExtractParameters<TReadFromStore>, fetchOptions?: FetchOptions<TClientFieldValue>): ItemCleanupPair<PromiseWrapper<void, AnyError>>;
8
+ export declare function makeNetworkRequest<TReadFromStore extends UnknownTReadFromStore, TClientFieldValue, TNormalizationAst extends NormalizationAst | NormalizationAstLoader>(environment: IsographEnvironment, artifact: RefetchQueryNormalizationArtifact | IsographEntrypoint<TReadFromStore, TClientFieldValue, TNormalizationAst>, variables: ExtractParameters<TReadFromStore>, fetchOptions?: FetchOptions<TClientFieldValue>): ItemCleanupPair<PromiseWrapper<void, AnyError>>;
9
+ //# sourceMappingURL=makeNetworkRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"makeNetworkRequest.d.ts","sourceRoot":"","sources":["../../src/core/makeNetworkRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAqC,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,EACL,kBAAkB,EAClB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