@isograph/react 0.0.0-main-e403ba82 → 0.0.0-main-82cbc3c0

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 (105) hide show
  1. package/.turbo/turbo-compile-libs.log +1 -1
  2. package/dist/core/FragmentReference.d.ts +1 -1
  3. package/dist/core/FragmentReference.d.ts.map +1 -1
  4. package/dist/core/FragmentReference.js +2 -2
  5. package/dist/core/IsographEnvironment.d.ts +7 -5
  6. package/dist/core/IsographEnvironment.d.ts.map +1 -1
  7. package/dist/core/IsographEnvironment.js +5 -4
  8. package/dist/core/areEqualWithDeepComparison.d.ts.map +1 -1
  9. package/dist/core/areEqualWithDeepComparison.js +2 -5
  10. package/dist/core/cache.d.ts +5 -18
  11. package/dist/core/cache.d.ts.map +1 -1
  12. package/dist/core/cache.js +10 -222
  13. package/dist/core/check.js +5 -5
  14. package/dist/core/componentCache.d.ts +2 -2
  15. package/dist/core/componentCache.d.ts.map +1 -1
  16. package/dist/core/componentCache.js +1 -26
  17. package/dist/core/entrypoint.d.ts +2 -2
  18. package/dist/core/entrypoint.d.ts.map +1 -1
  19. package/dist/core/garbageCollection.d.ts +2 -2
  20. package/dist/core/garbageCollection.d.ts.map +1 -1
  21. package/dist/core/garbageCollection.js +3 -3
  22. package/dist/core/getOrCreateCacheForArtifact.d.ts +8 -0
  23. package/dist/core/getOrCreateCacheForArtifact.d.ts.map +1 -0
  24. package/dist/core/getOrCreateCacheForArtifact.js +40 -0
  25. package/dist/core/logging.d.ts +8 -8
  26. package/dist/core/logging.d.ts.map +1 -1
  27. package/dist/core/makeNetworkRequest.d.ts +3 -3
  28. package/dist/core/makeNetworkRequest.d.ts.map +1 -1
  29. package/dist/core/makeNetworkRequest.js +3 -2
  30. package/dist/core/optimisticProxy.d.ts.map +1 -1
  31. package/dist/core/optimisticProxy.js +24 -22
  32. package/dist/core/read.d.ts +3 -3
  33. package/dist/core/read.d.ts.map +1 -1
  34. package/dist/core/read.js +4 -4
  35. package/dist/core/startUpdate.d.ts.map +1 -1
  36. package/dist/core/startUpdate.js +2 -1
  37. package/dist/core/subscribe.d.ts +8 -0
  38. package/dist/core/subscribe.d.ts.map +1 -0
  39. package/dist/core/subscribe.js +127 -0
  40. package/dist/core/util.d.ts +7 -0
  41. package/dist/core/util.d.ts.map +1 -1
  42. package/dist/core/util.js +26 -0
  43. package/dist/core/writeData.d.ts +7 -0
  44. package/dist/core/writeData.d.ts.map +1 -0
  45. package/dist/core/writeData.js +36 -0
  46. package/dist/index.d.ts +5 -2
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +8 -5
  49. package/dist/loadable-hooks/useConnectionSpecPagination.d.ts +3 -3
  50. package/dist/loadable-hooks/useConnectionSpecPagination.d.ts.map +1 -1
  51. package/dist/loadable-hooks/useConnectionSpecPagination.js +3 -3
  52. package/dist/loadable-hooks/useSkipLimitPagination.d.ts +3 -3
  53. package/dist/loadable-hooks/useSkipLimitPagination.d.ts.map +1 -1
  54. package/dist/loadable-hooks/useSkipLimitPagination.js +3 -3
  55. package/dist/react/createIsographEnvironment.d.ts +4 -0
  56. package/dist/react/createIsographEnvironment.d.ts.map +1 -0
  57. package/dist/react/createIsographEnvironment.js +8 -0
  58. package/dist/react/maybeUnwrapNetworkRequest.d.ts +4 -0
  59. package/dist/react/maybeUnwrapNetworkRequest.d.ts.map +1 -0
  60. package/dist/react/maybeUnwrapNetworkRequest.js +14 -0
  61. package/dist/react/useLazyReference.d.ts.map +1 -1
  62. package/dist/react/useLazyReference.js +2 -2
  63. package/dist/react/useReadAndSubscribe.d.ts +4 -2
  64. package/dist/react/useReadAndSubscribe.d.ts.map +1 -1
  65. package/dist/react/useReadAndSubscribe.js +31 -2
  66. package/dist/react/useRerenderOnChange.d.ts +2 -2
  67. package/dist/react/useRerenderOnChange.d.ts.map +1 -1
  68. package/dist/react/useRerenderOnChange.js +2 -2
  69. package/dist/react/useResult.d.ts +2 -4
  70. package/dist/react/useResult.d.ts.map +1 -1
  71. package/dist/react/useResult.js +3 -13
  72. package/package.json +4 -4
  73. package/src/core/FragmentReference.ts +2 -2
  74. package/src/core/IsographEnvironment.ts +26 -10
  75. package/src/core/areEqualWithDeepComparison.ts +2 -6
  76. package/src/core/cache.ts +18 -364
  77. package/src/core/check.ts +5 -5
  78. package/src/core/componentCache.ts +8 -43
  79. package/src/core/entrypoint.ts +2 -2
  80. package/src/core/garbageCollection.ts +8 -8
  81. package/src/core/getOrCreateCacheForArtifact.ts +86 -0
  82. package/src/core/logging.ts +10 -10
  83. package/src/core/makeNetworkRequest.ts +8 -8
  84. package/src/core/optimisticProxy.ts +27 -26
  85. package/src/core/read.ts +17 -17
  86. package/src/core/startUpdate.ts +1 -1
  87. package/src/core/subscribe.ts +195 -0
  88. package/src/core/util.ts +26 -0
  89. package/src/core/writeData.ts +79 -0
  90. package/src/index.ts +3 -4
  91. package/src/loadable-hooks/useConnectionSpecPagination.ts +6 -6
  92. package/src/loadable-hooks/useSkipLimitPagination.ts +6 -6
  93. package/src/react/createIsographEnvironment.ts +23 -0
  94. package/src/react/maybeUnwrapNetworkRequest.ts +17 -0
  95. package/src/react/useLazyReference.ts +2 -4
  96. package/src/react/useReadAndSubscribe.ts +53 -5
  97. package/src/react/useRerenderOnChange.ts +3 -3
  98. package/src/react/useResult.ts +6 -24
  99. package/src/tests/garbageCollection.test.ts +3 -6
  100. package/src/tests/meNameSuccessor.ts +1 -1
  101. package/src/tests/nodeQuery.ts +1 -1
  102. package/src/tests/normalizeData.test.ts +5 -3
  103. package/src/tests/optimisticProxy.test.ts +7 -5
  104. package/src/tests/startUpdate.test.ts +5 -7
  105. package/vitest.config.ts +5 -0
@@ -1,5 +1,5 @@
1
1
  ../.. |  WARN  Unsupported engine: wanted: {"node":"22.9.0"} (current: {"node":"v22.21.1","pnpm":"10.15.0"})
2
2
 
3
- > @isograph/react@0.0.0-main-e403ba82 compile-libs /home/runner/work/isograph/isograph/libs/isograph-react
3
+ > @isograph/react@0.0.0-main-82cbc3c0 compile-libs /home/runner/work/isograph/isograph/libs/isograph-react
4
4
  > rimraf dist && tsc -p tsconfig.pkg.json
5
5
 
@@ -1,4 +1,4 @@
1
- import { ReaderWithRefetchQueries } from '../core/entrypoint';
1
+ import { ReaderWithRefetchQueries } from './entrypoint';
2
2
  import { type ComponentOrFieldName, type StoreLink } from './IsographEnvironment';
3
3
  import { PromiseWrapper } from './PromiseWrapper';
4
4
  import type { StartUpdate } from './reader';
@@ -1 +1 @@
1
- {"version":3,"file":"FragmentReference.d.ts","sourceRoot":"","sources":["../../src/core/FragmentReference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ;IACE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC;CACzC,GACD,aAAa,EAAE,CAAC;AAEpB,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,CAAC;AAEpE,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS;IACrC,IAAI,EAAE,MAAM,CAAC,SAAS,MAAM,CAAC;CAC9B,GACG,CAAC,GACD,KAAK,CAAC;AAEV,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS;IAC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C5C,iBAAiB,IACf;IACF,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,wBAAwB,EAAE,cAAc,CAC/C,wBAAwB,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAC5D,CAAC;IACF,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,oBAAoB,CAAC;IACzC,QAAQ,CAAC,kBAAkB,EACvB,qBAAqB,GACrB,yBAAyB,CAAC;IAO9B,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IACtD,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;CACpD,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC;AAElD,wBAAgB,4BAA4B,CAC1C,iBAAiB,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,GAC7C,4BAA4B,CAE9B"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.stableIdForFragmentReference = stableIdForFragmentReference;
4
- const cache_1 = require("./cache");
4
+ const util_1 = require("./util");
5
5
  function stableIdForFragmentReference(fragmentReference) {
6
- return `${fragmentReference.root.__typename}/${fragmentReference.root.__link}/${fragmentReference.fieldName}/${JSON.stringify((0, cache_1.stableCopy)(fragmentReference.variables))}`;
6
+ return `${fragmentReference.root.__typename}/${fragmentReference.root.__link}/${fragmentReference.fieldName}/${JSON.stringify((0, util_1.stableCopy)(fragmentReference.variables))}`;
7
7
  }
@@ -1,12 +1,12 @@
1
1
  import { ParentCache } from '@isograph/react-disposable-state';
2
2
  import type { Brand } from './brand';
3
- import { IsographEntrypoint, IsographOperation, IsographPersistedOperation, type ReaderWithRefetchQueries, type ReaderWithRefetchQueriesLoader } from './entrypoint';
4
- import { FragmentReference, Variables, type StableIdForFragmentReference, type UnknownTReadFromStore } from './FragmentReference';
3
+ import type { IsographEntrypoint, IsographOperation, IsographPersistedOperation, ReaderWithRefetchQueries, ReaderWithRefetchQueriesLoader } from './entrypoint';
4
+ import type { ExtractStartUpdate, FragmentReference, StableIdForFragmentReference, UnknownTReadFromStore, Variables } from './FragmentReference';
5
5
  import type { RetainedQuery } from './garbageCollection';
6
- import { LogFunction, WrappedLogFunction } from './logging';
6
+ import type { LogFunction, WrappedLogFunction } from './logging';
7
7
  import { type StoreLayer } from './optimisticProxy';
8
8
  import { PromiseWrapper } from './PromiseWrapper';
9
- import { WithEncounteredRecords } from './read';
9
+ import type { NetworkRequestReaderOptions, WithEncounteredRecords } from './read';
10
10
  import type { ReaderAst, StartUpdate } from './reader';
11
11
  export type ComponentOrFieldName = string;
12
12
  export type StringifiedArgs = string;
@@ -38,6 +38,7 @@ export type CacheMap<T> = {
38
38
  export type IsographEnvironment = {
39
39
  store: StoreLayer;
40
40
  readonly networkFunction: IsographNetworkFunction;
41
+ readonly componentFunction: IsographComponentFunction;
41
42
  readonly missingFieldHandler: MissingFieldHandler | null;
42
43
  readonly componentCache: FieldCache<React.FC<any>>;
43
44
  readonly eagerReaderCache: FieldCache<StartUpdate<any> | undefined>;
@@ -53,6 +54,7 @@ export type MissingFieldHandler = (storeRecord: StoreRecord, root: StoreLink, fi
53
54
  [index: string]: any;
54
55
  } | null, variables: Variables | null) => StoreLink | undefined;
55
56
  export type IsographNetworkFunction = (operation: IsographOperation | IsographPersistedOperation, variables: Variables) => Promise<any>;
57
+ export type IsographComponentFunction = <TReadFromStore extends UnknownTReadFromStore = any>(environment: IsographEnvironment, fragmentReference: FragmentReference<TReadFromStore, any>, networkRequestOptions: NetworkRequestReaderOptions, startUpdate: ExtractStartUpdate<TReadFromStore>) => React.FC<any>;
56
58
  export interface Link<T extends TypeName> extends StoreLink {
57
59
  readonly __link: Brand<DataId, T>;
58
60
  readonly __typename: T;
@@ -79,7 +81,7 @@ export interface BaseStoreLayerData extends StoreLayerData {
79
81
  readonly __ROOT: StoreRecord;
80
82
  };
81
83
  }
82
- export declare function createIsographEnvironment(baseStoreLayerData: BaseStoreLayerData, networkFunction: IsographNetworkFunction, missingFieldHandler?: MissingFieldHandler | null, logFunction?: LogFunction | null): IsographEnvironment;
84
+ export declare function createIsographEnvironmentCore(baseStoreLayerData: BaseStoreLayerData, networkFunction: IsographNetworkFunction, componentFunction: IsographComponentFunction, missingFieldHandler?: MissingFieldHandler | null, logFunction?: LogFunction | null): IsographEnvironment;
83
85
  export declare function createIsographStore(): BaseStoreLayerData;
84
86
  export declare function assertLink(link: DataTypeValue): StoreLink | null | undefined;
85
87
  export declare function getLink(maybeLink: DataTypeValue): StoreLink | null;
@@ -1 +1 @@
1
- {"version":3,"file":"IsographEnvironment.d.ts","sourceRoot":"","sources":["../../src/core/IsographEnvironment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,0BAA0B,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,EACpC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,cAAc,EAGf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvD,MAAM,MAAM,oBAAoB,GAAG,M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,CAQxD;AAED,wBAAgB,iCAAiC,CAC/C,YAAY,EAAE,mBAAmB,EACjC,wBAAwB,EACpB,wBAAwB,CAAC,GAAG,EAAE,GAAG,CAAC,GAClC,8BAA8B,CAAC,GAAG,EAAE,GAAG,CAAC,GAC3C;IACD,wBAAwB,EAAE,cAAc,CAAC,wBAAwB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,qBAAqB,GAAG,yBAAyB,CAAC;CACvE,CAkBA"}
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ROOT_ID = void 0;
4
- exports.createIsographEnvironment = createIsographEnvironment;
4
+ exports.createIsographEnvironmentCore = createIsographEnvironmentCore;
5
5
  exports.createIsographStore = createIsographStore;
6
6
  exports.assertLink = assertLink;
7
7
  exports.getLink = getLink;
8
8
  exports.getOrLoadIsographArtifact = getOrLoadIsographArtifact;
9
9
  exports.getOrLoadReaderWithRefetchQueries = getOrLoadReaderWithRefetchQueries;
10
- const cache_1 = require("./cache");
11
10
  const PromiseWrapper_1 = require("./PromiseWrapper");
11
+ const util_1 = require("./util");
12
12
  exports.ROOT_ID = '__ROOT';
13
13
  const DEFAULT_GC_BUFFER_SIZE = 10;
14
- function createIsographEnvironment(baseStoreLayerData, networkFunction, missingFieldHandler, logFunction) {
14
+ function createIsographEnvironmentCore(baseStoreLayerData, networkFunction, componentFunction, missingFieldHandler, logFunction) {
15
15
  logFunction === null || logFunction === void 0 ? void 0 : logFunction({
16
16
  kind: 'EnvironmentCreated',
17
17
  });
@@ -24,6 +24,7 @@ function createIsographEnvironment(baseStoreLayerData, networkFunction, missingF
24
24
  return {
25
25
  store,
26
26
  networkFunction,
27
+ componentFunction,
27
28
  missingFieldHandler: missingFieldHandler !== null && missingFieldHandler !== void 0 ? missingFieldHandler : null,
28
29
  componentCache: {},
29
30
  eagerReaderCache: {},
@@ -44,7 +45,7 @@ function createIsographStore() {
44
45
  };
45
46
  }
46
47
  function assertLink(link) {
47
- if ((0, cache_1.isArray)(link)) {
48
+ if ((0, util_1.isArray)(link)) {
48
49
  throw new Error('Unexpected array');
49
50
  }
50
51
  if (link == null) {
@@ -1 +1 @@
1
- {"version":3,"file":"areEqualWithDeepComparison.d.ts","sourceRoot":"","sources":["../../src/core/areEqualWithDeepComparison.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAwC,MAAM,UAAU,CAAC;AA+DhF,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,EACtB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,GACpB,MAAM,CAoER"}
1
+ {"version":3,"file":"areEqualWithDeepComparison.d.ts","sourceRoot":"","sources":["../../src/core/areEqualWithDeepComparison.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAwC,MAAM,UAAU,CAAC;AA2DhF,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,EACtB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,GACpB,MAAM,CAoER"}
@@ -2,11 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mergeObjectsUsingReaderAst = mergeObjectsUsingReaderAst;
4
4
  function mergeUsingReaderAst(field, oldItem, newItem) {
5
- if (newItem === null) {
6
- return oldItem === null ? oldItem : newItem;
7
- }
8
- if (newItem === undefined) {
9
- return oldItem === undefined ? oldItem : newItem;
5
+ if (newItem == null || oldItem == null) {
6
+ return newItem;
10
7
  }
11
8
  if (Array.isArray(newItem)) {
12
9
  if (!Array.isArray(oldItem)) {
@@ -1,20 +1,11 @@
1
- import { Factory, ItemCleanupPair, ParentCache } from '@isograph/react-disposable-state';
2
- import { IsographEntrypoint, NormalizationLinkedField, NormalizationScalarField, type NormalizationAst, type NormalizationAstLoader, type NormalizationAstNodes } from '../core/entrypoint';
3
- import { FetchOptions } from './check';
4
- import { ExtractParameters, FragmentReference, Variables, type UnknownTReadFromStore } from './FragmentReference';
5
- import { DataId, StoreLink, type IsographEnvironment, type TypeName } from './IsographEnvironment';
1
+ import { type Factory, ParentCache } from '@isograph/react-disposable-state';
2
+ import type { NormalizationAstNodes, NormalizationLinkedField, NormalizationScalarField } from './entrypoint';
3
+ import type { FragmentReference, UnknownTReadFromStore, Variables } from './FragmentReference';
4
+ import { type DataId, type IsographEnvironment, type StoreLink, type TypeName } from './IsographEnvironment';
6
5
  import { type StoreLayerWithData } from './optimisticProxy';
7
- import { WithEncounteredRecords } from './read';
8
- import { ReaderLinkedField, ReaderScalarField, type ReaderAst } from './reader';
6
+ import type { ReaderLinkedField, ReaderScalarField } from './reader';
9
7
  export declare const TYPENAME_FIELD_NAME = "__typename";
10
8
  export declare function getOrCreateItemInSuspenseCache<TReadFromStore extends UnknownTReadFromStore, TClientFieldValue>(environment: IsographEnvironment, index: string, factory: Factory<FragmentReference<TReadFromStore, TClientFieldValue>>): ParentCache<FragmentReference<TReadFromStore, TClientFieldValue>>;
11
- /**
12
- * Creates a copy of the provided value, ensuring any nested objects have their
13
- * keys sorted such that equivalent values would have identical JSON.stringify
14
- * results.
15
- */
16
- export declare function stableCopy<T>(value: T): T;
17
- export declare function getOrCreateCacheForArtifact<TReadFromStore extends UnknownTReadFromStore, TClientFieldValue, TNormalizationAst extends NormalizationAst | NormalizationAstLoader, TRawResponseType extends NetworkResponseObject>(environment: IsographEnvironment, entrypoint: IsographEntrypoint<TReadFromStore, TClientFieldValue, TNormalizationAst, TRawResponseType>, variables: ExtractParameters<TReadFromStore>, fetchOptions?: FetchOptions<TClientFieldValue, TRawResponseType>): ParentCache<FragmentReference<TReadFromStore, TClientFieldValue>>;
18
9
  export type NetworkResponseScalarValue = string | number | boolean;
19
10
  export type NetworkResponseValue = NetworkResponseScalarValue | null | NetworkResponseObject | readonly (NetworkResponseObject | null)[] | readonly (NetworkResponseScalarValue | null)[];
20
11
  export type NetworkResponseObject = {
@@ -25,15 +16,11 @@ export type NetworkResponseObject = {
25
16
  export declare function normalizeData(environment: IsographEnvironment, storeLayer: StoreLayerWithData, normalizationAst: NormalizationAstNodes, networkResponse: NetworkResponseObject, variables: Variables, root: StoreLink, encounteredIds: EncounteredIds): EncounteredIds;
26
17
  export declare function subscribeToAnyChange(environment: IsographEnvironment, callback: () => void): () => void;
27
18
  export declare function subscribeToAnyChangesToRecord(environment: IsographEnvironment, recordLink: StoreLink, callback: () => void): () => void;
28
- export declare function subscribe<TReadFromStore extends UnknownTReadFromStore>(environment: IsographEnvironment, encounteredDataAndRecords: WithEncounteredRecords<TReadFromStore>, fragmentReference: FragmentReference<TReadFromStore, any>, callback: (newEncounteredDataAndRecords: WithEncounteredRecords<TReadFromStore>) => void, readerAst: ReaderAst<TReadFromStore>): () => void;
29
19
  export declare function onNextChangeToRecord(environment: IsographEnvironment, recordLink: StoreLink): Promise<void>;
30
- export declare function callSubscriptions(environment: IsographEnvironment, recordsEncounteredWhenNormalizing: EncounteredIds): void;
31
20
  export type EncounteredIds = Map<TypeName, Set<DataId>>;
32
21
  export declare function insertEmptySetIfMissing<K, V>(map: Map<K, Set<V>>, key: K): Set<V>;
33
- export declare function isArray(value: unknown): value is readonly unknown[];
34
22
  export declare function getParentRecordKey(astNode: NormalizationLinkedField | NormalizationScalarField | ReaderLinkedField | ReaderScalarField, variables: Variables): string;
35
23
  export declare const FIRST_SPLIT_KEY = "____";
36
24
  export declare const SECOND_SPLIT_KEY = "___";
37
25
  export declare const THIRD_SPLIT_KEY = "__";
38
- export declare function writeData<TReadFromStore extends UnknownTReadFromStore, TRawResponseType extends NetworkResponseObject, TClientFieldValue>(environment: IsographEnvironment, entrypoint: IsographEntrypoint<TReadFromStore, TClientFieldValue, NormalizationAst, TRawResponseType>, data: TRawResponseType, variables: ExtractParameters<TReadFromStore>): ItemCleanupPair<FragmentReference<TReadFromStore, TClientFieldValue>>;
39
26
  //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GACxB,wBAAwB,GACxB,iBAAiB,GACjB,iBAAiB,EACrB,SAAS,EAAE,SAAS,GACnB,MAAM,CAUR;AA2GD,eAAO,MAAM,eAAe,SAAS,CAAC;AACtC,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AACtC,eAAO,MAAM,eAAe,OAAO,CAAC"}
@@ -2,25 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.THIRD_SPLIT_KEY = exports.SECOND_SPLIT_KEY = exports.FIRST_SPLIT_KEY = exports.TYPENAME_FIELD_NAME = void 0;
4
4
  exports.getOrCreateItemInSuspenseCache = getOrCreateItemInSuspenseCache;
5
- exports.stableCopy = stableCopy;
6
- exports.getOrCreateCacheForArtifact = getOrCreateCacheForArtifact;
7
5
  exports.normalizeData = normalizeData;
8
6
  exports.subscribeToAnyChange = subscribeToAnyChange;
9
7
  exports.subscribeToAnyChangesToRecord = subscribeToAnyChangesToRecord;
10
- exports.subscribe = subscribe;
11
8
  exports.onNextChangeToRecord = onNextChangeToRecord;
12
- exports.callSubscriptions = callSubscriptions;
13
9
  exports.insertEmptySetIfMissing = insertEmptySetIfMissing;
14
- exports.isArray = isArray;
15
10
  exports.getParentRecordKey = getParentRecordKey;
16
- exports.writeData = writeData;
17
11
  const react_disposable_state_1 = require("@isograph/react-disposable-state");
18
- const areEqualWithDeepComparison_1 = require("./areEqualWithDeepComparison");
19
12
  const IsographEnvironment_1 = require("./IsographEnvironment");
20
13
  const logging_1 = require("./logging");
21
- const makeNetworkRequest_1 = require("./makeNetworkRequest");
22
14
  const optimisticProxy_1 = require("./optimisticProxy");
23
- const read_1 = require("./read");
15
+ const util_1 = require("./util");
24
16
  exports.TYPENAME_FIELD_NAME = '__typename';
25
17
  function getOrCreateItemInSuspenseCache(environment, index, factory) {
26
18
  if (environment.fragmentCache[index] == null) {
@@ -28,60 +20,6 @@ function getOrCreateItemInSuspenseCache(environment, index, factory) {
28
20
  }
29
21
  return environment.fragmentCache[index];
30
22
  }
31
- /**
32
- * Creates a copy of the provided value, ensuring any nested objects have their
33
- * keys sorted such that equivalent values would have identical JSON.stringify
34
- * results.
35
- */
36
- function stableCopy(value) {
37
- if (value == null || typeof value !== 'object') {
38
- return value;
39
- }
40
- if (isArray(value)) {
41
- // @ts-ignore
42
- return value.map(stableCopy);
43
- }
44
- const keys = Object.keys(value).sort();
45
- const stable = {};
46
- for (let i = 0; i < keys.length; i++) {
47
- // @ts-ignore
48
- stable[keys[i]] = stableCopy(value[keys[i]]);
49
- }
50
- return stable;
51
- }
52
- function getOrCreateCacheForArtifact(environment, entrypoint, variables, fetchOptions) {
53
- let cacheKey = '';
54
- switch (entrypoint.networkRequestInfo.operation.kind) {
55
- case 'Operation':
56
- cacheKey =
57
- entrypoint.networkRequestInfo.operation.text +
58
- JSON.stringify(stableCopy(variables));
59
- break;
60
- case 'PersistedOperation':
61
- cacheKey =
62
- entrypoint.networkRequestInfo.operation.operationId +
63
- JSON.stringify(stableCopy(variables));
64
- break;
65
- }
66
- const factory = () => {
67
- const { fieldName, readerArtifactKind, readerWithRefetchQueries } = (0, IsographEnvironment_1.getOrLoadReaderWithRefetchQueries)(environment, entrypoint.readerWithRefetchQueries);
68
- const [networkRequest, disposeNetworkRequest] = (0, makeNetworkRequest_1.maybeMakeNetworkRequest)(environment, entrypoint, variables, readerWithRefetchQueries, fetchOptions !== null && fetchOptions !== void 0 ? fetchOptions : null);
69
- const itemCleanupPair = [
70
- {
71
- kind: 'FragmentReference',
72
- readerWithRefetchQueries,
73
- fieldName,
74
- readerArtifactKind,
75
- root: { __link: IsographEnvironment_1.ROOT_ID, __typename: entrypoint.concreteType },
76
- variables,
77
- networkRequest: networkRequest,
78
- },
79
- disposeNetworkRequest,
80
- ];
81
- return itemCleanupPair;
82
- };
83
- return getOrCreateItemInSuspenseCache(environment, cacheKey, factory);
84
- }
85
23
  function normalizeData(environment, storeLayer, normalizationAst, networkResponse, variables, root, encounteredIds) {
86
24
  (0, logging_1.logMessage)(environment, () => ({
87
25
  kind: 'AboutToNormalize',
@@ -110,22 +48,6 @@ function subscribeToAnyChangesToRecord(environment, recordLink, callback) {
110
48
  environment.subscriptions.add(subscription);
111
49
  return () => environment.subscriptions.delete(subscription);
112
50
  }
113
- function subscribe(environment, encounteredDataAndRecords, fragmentReference, callback, readerAst) {
114
- const fragmentSubscription = {
115
- kind: 'FragmentSubscription',
116
- callback,
117
- encounteredDataAndRecords,
118
- fragmentReference,
119
- readerAst,
120
- };
121
- // subscribe is called in an effect. (We should actually subscribe during the
122
- // initial render.) Because it's called in an effect, we might have missed some
123
- // changes since the initial render! So, at this point, we re-read and call the
124
- // subscription (i.e. re-render) if the fragment data has changed.
125
- callSubscriptionIfDataChanged(environment, fragmentSubscription);
126
- environment.subscriptions.add(fragmentSubscription);
127
- return () => environment.subscriptions.delete(fragmentSubscription);
128
- }
129
51
  function onNextChangeToRecord(environment, recordLink) {
130
52
  return new Promise((resolve) => {
131
53
  const unsubscribe = subscribeToAnyChangesToRecord(environment, recordLink, () => {
@@ -134,110 +56,6 @@ function onNextChangeToRecord(environment, recordLink) {
134
56
  });
135
57
  });
136
58
  }
137
- // Calls to readButDoNotEvaluate can suspend (i.e. throw a promise).
138
- // Maybe in the future, they will be able to throw errors.
139
- //
140
- // That's probably okay to ignore. We don't, however, want to prevent
141
- // updating other subscriptions if one subscription had missing data.
142
- function logAnyError(environment, context, f) {
143
- try {
144
- f();
145
- }
146
- catch (e) {
147
- (0, logging_1.logMessage)(environment, () => ({
148
- kind: 'ErrorEncounteredInWithErrorHandling',
149
- error: e,
150
- context,
151
- }));
152
- }
153
- }
154
- function callSubscriptions(environment, recordsEncounteredWhenNormalizing) {
155
- environment.subscriptions.forEach((subscription) => logAnyError(environment, { situation: 'calling subscriptions' }, () => {
156
- var _a;
157
- switch (subscription.kind) {
158
- case 'FragmentSubscription': {
159
- // TODO if there are multiple components subscribed to the same
160
- // fragment, we will call readButNotEvaluate multiple times. We
161
- // should fix that.
162
- if (hasOverlappingIds(recordsEncounteredWhenNormalizing, subscription.encounteredDataAndRecords.encounteredRecords)) {
163
- callSubscriptionIfDataChanged(environment, subscription);
164
- }
165
- return;
166
- }
167
- case 'AnyRecords': {
168
- logAnyError(environment, { situation: 'calling AnyRecords callback' }, () => subscription.callback());
169
- return;
170
- }
171
- case 'AnyChangesToRecord': {
172
- if (((_a = recordsEncounteredWhenNormalizing
173
- .get(subscription.recordLink.__typename)) === null || _a === void 0 ? void 0 : _a.has(subscription.recordLink.__link)) != null) {
174
- logAnyError(environment, { situation: 'calling AnyChangesToRecord callback' }, () => subscription.callback());
175
- }
176
- return;
177
- }
178
- default: {
179
- // Ensure we have covered all variants
180
- const _ = subscription;
181
- _;
182
- throw new Error('Unexpected case');
183
- }
184
- }
185
- }));
186
- }
187
- function callSubscriptionIfDataChanged(environment, subscription) {
188
- const newEncounteredDataAndRecords = (0, read_1.readButDoNotEvaluate)(environment, subscription.fragmentReference,
189
- // Is this wrong?
190
- // Reasons to think no:
191
- // - we are only updating the read-out value, and the network
192
- // options only affect whether we throw.
193
- // - the component will re-render, and re-throw on its own, anyway.
194
- //
195
- // Reasons to think not:
196
- // - it seems more efficient to suspend here and not update state,
197
- // if we expect that the component will just throw anyway
198
- // - consistency
199
- // - it's also weird, this is called from makeNetworkRequest, where
200
- // we don't currently pass network request options
201
- {
202
- suspendIfInFlight: false,
203
- throwOnNetworkError: false,
204
- });
205
- const mergedItem = (0, areEqualWithDeepComparison_1.mergeObjectsUsingReaderAst)(subscription.readerAst, subscription.encounteredDataAndRecords.item, newEncounteredDataAndRecords.item);
206
- (0, logging_1.logMessage)(environment, () => ({
207
- kind: 'DeepEqualityCheck',
208
- fragmentReference: subscription.fragmentReference,
209
- old: subscription.encounteredDataAndRecords.item,
210
- new: newEncounteredDataAndRecords.item,
211
- deeplyEqual: mergedItem === subscription.encounteredDataAndRecords.item,
212
- }));
213
- if (mergedItem !== subscription.encounteredDataAndRecords.item) {
214
- logAnyError(environment, { situation: 'calling FragmentSubscription callback' }, () => {
215
- subscription.callback(newEncounteredDataAndRecords);
216
- });
217
- subscription.encounteredDataAndRecords = newEncounteredDataAndRecords;
218
- }
219
- }
220
- function hasOverlappingIds(ids1, ids2) {
221
- for (const [typeName, set1] of ids1.entries()) {
222
- const set2 = ids2.get(typeName);
223
- if (set2 === undefined) {
224
- continue;
225
- }
226
- if (isNotDisjointFrom(set1, set2)) {
227
- return true;
228
- }
229
- }
230
- return false;
231
- }
232
- // TODO use a polyfill library
233
- function isNotDisjointFrom(set1, set2) {
234
- for (const id of set1) {
235
- if (set2.has(id)) {
236
- return true;
237
- }
238
- }
239
- return false;
240
- }
241
59
  /**
242
60
  * Mutate targetParentRecord according to the normalizationAst and networkResponseParentRecord.
243
61
  */
@@ -292,7 +110,7 @@ function normalizeScalarField(astNode, networkResponseParentRecord, targetStoreR
292
110
  const existingValue = targetStoreRecord[parentRecordKey];
293
111
  if (networkResponseData == null) {
294
112
  targetStoreRecord[parentRecordKey] = null;
295
- return existingValue !== null;
113
+ return existingValue === undefined || existingValue != null;
296
114
  }
297
115
  if (isScalarOrEmptyArray(networkResponseData)) {
298
116
  targetStoreRecord[parentRecordKey] = networkResponseData;
@@ -302,9 +120,6 @@ function normalizeScalarField(astNode, networkResponseParentRecord, targetStoreR
302
120
  throw new Error('Unexpected object array when normalizing scalar');
303
121
  }
304
122
  }
305
- function isArray(value) {
306
- return Array.isArray(value);
307
- }
308
123
  /**
309
124
  * Mutate targetParentRecord with a given linked field ast node.
310
125
  */
@@ -316,13 +131,13 @@ function normalizeLinkedField(environment, storeLayer, astNode, networkResponseP
316
131
  const existingValue = targetParentRecord[parentRecordKey];
317
132
  if (networkResponseData == null) {
318
133
  targetParentRecord[parentRecordKey] = null;
319
- return existingValue !== null;
134
+ return existingValue === undefined || existingValue != null;
320
135
  }
321
136
  if (isScalarOrEmptyArray(networkResponseData) &&
322
137
  !isNullOrEmptyArray(networkResponseData)) {
323
138
  throw new Error('Unexpected scalar network response when normalizing a linked field');
324
139
  }
325
- if (isArray(networkResponseData)) {
140
+ if ((0, util_1.isArray)(networkResponseData)) {
326
141
  // TODO check astNode.plural or the like
327
142
  const dataIds = [];
328
143
  for (let i = 0; i < networkResponseData.length; i++) {
@@ -373,7 +188,7 @@ function normalizeInlineFragment(environment, storeLayer, astNode, networkRespon
373
188
  }
374
189
  function dataIdsAreTheSame(existingValue, newDataIds) {
375
190
  var _a, _b;
376
- if (isArray(existingValue)) {
191
+ if ((0, util_1.isArray)(existingValue)) {
377
192
  if (newDataIds.length !== existingValue.length) {
378
193
  return false;
379
194
  }
@@ -405,23 +220,23 @@ function normalizeNetworkResponseObject(environment, storeLayer, astNode, networ
405
220
  }
406
221
  function isScalarOrEmptyArray(data) {
407
222
  // N.B. empty arrays count as empty arrays of scalar fields.
408
- if (isArray(data)) {
223
+ if ((0, util_1.isArray)(data)) {
409
224
  return data.every((x) => isScalarOrEmptyArray(x));
410
225
  }
411
- const isScalarValue = data === null ||
226
+ const isScalarValue = data == null ||
412
227
  typeof data === 'string' ||
413
228
  typeof data === 'number' ||
414
229
  typeof data === 'boolean';
415
230
  return isScalarValue;
416
231
  }
417
232
  function isNullOrEmptyArray(data) {
418
- if (isArray(data)) {
233
+ if ((0, util_1.isArray)(data)) {
419
234
  if (data.length === 0) {
420
235
  return true;
421
236
  }
422
237
  return data.every((x) => isNullOrEmptyArray(x));
423
238
  }
424
- return data === null;
239
+ return data == null;
425
240
  }
426
241
  function getParentRecordKey(astNode, variables) {
427
242
  let parentRecordKey = astNode.fieldName;
@@ -470,7 +285,7 @@ function getStoreKeyChunkForArgument(argument, variables) {
470
285
  const [argumentName, argumentValue] = argument;
471
286
  let chunk = getStoreKeyChunkForArgumentValue(argumentValue, variables);
472
287
  if (typeof chunk === 'object') {
473
- chunk = JSON.stringify(stableCopy(chunk));
288
+ chunk = JSON.stringify((0, util_1.stableCopy)(chunk));
474
289
  }
475
290
  return `${exports.FIRST_SPLIT_KEY}${argumentName}${exports.SECOND_SPLIT_KEY}${chunk}`;
476
291
  }
@@ -549,30 +364,3 @@ function getDataIdOfNetworkResponse(parentRecordLink, dataToNormalize, astNode,
549
364
  }
550
365
  return storeKey;
551
366
  }
552
- function writeData(environment, entrypoint, data, variables) {
553
- const encounteredIds = new Map();
554
- environment.store = (0, optimisticProxy_1.addNetworkResponseStoreLayer)(environment.store);
555
- normalizeData(environment, environment.store, entrypoint.networkRequestInfo.normalizationAst.selections, data, variables, { __link: IsographEnvironment_1.ROOT_ID, __typename: entrypoint.concreteType }, encounteredIds);
556
- (0, logging_1.logMessage)(environment, () => ({
557
- kind: 'AfterNormalization',
558
- store: environment.store,
559
- encounteredIds,
560
- }));
561
- callSubscriptions(environment, encounteredIds);
562
- const { fieldName, readerArtifactKind, readerWithRefetchQueries } = (0, IsographEnvironment_1.getOrLoadReaderWithRefetchQueries)(environment, entrypoint.readerWithRefetchQueries);
563
- const [networkRequest, disposeNetworkRequest] = (0, makeNetworkRequest_1.retainQueryWithoutMakingNetworkRequest)(environment, entrypoint, variables);
564
- return [
565
- {
566
- kind: 'FragmentReference',
567
- readerWithRefetchQueries,
568
- fieldName,
569
- readerArtifactKind,
570
- root: { __link: IsographEnvironment_1.ROOT_ID, __typename: entrypoint.concreteType },
571
- variables,
572
- networkRequest,
573
- },
574
- () => {
575
- disposeNetworkRequest();
576
- },
577
- ];
578
- }
@@ -47,13 +47,13 @@ function checkFromRecord(environment, normalizationAst, variables, record, recor
47
47
  record: recordLink,
48
48
  };
49
49
  }
50
- else if (linkedValue === null) {
50
+ else if (linkedValue == null) {
51
51
  continue;
52
52
  }
53
53
  else if (Array.isArray(linkedValue)) {
54
54
  arrayItemsLoop: for (const item of linkedValue) {
55
55
  const link = (0, IsographEnvironment_1.getLink)(item);
56
- if (link === null) {
56
+ if (link == null) {
57
57
  throw new Error('Unexpected non-link in the Isograph store. ' +
58
58
  'This is indicative of a bug in Isograph.');
59
59
  }
@@ -64,7 +64,7 @@ function checkFromRecord(environment, normalizationAst, variables, record, recor
64
64
  record: link,
65
65
  };
66
66
  }
67
- else if (linkedRecord === null) {
67
+ else if (linkedRecord == null) {
68
68
  continue arrayItemsLoop;
69
69
  }
70
70
  else {
@@ -78,7 +78,7 @@ function checkFromRecord(environment, normalizationAst, variables, record, recor
78
78
  }
79
79
  else {
80
80
  const link = (0, IsographEnvironment_1.getLink)(linkedValue);
81
- if (link === null) {
81
+ if (link == null) {
82
82
  throw new Error('Unexpected non-link in the Isograph store. ' +
83
83
  'This is indicative of a bug in Isograph.');
84
84
  }
@@ -89,7 +89,7 @@ function checkFromRecord(environment, normalizationAst, variables, record, recor
89
89
  record: link,
90
90
  };
91
91
  }
92
- else if (linkedRecord === null) {
92
+ else if (linkedRecord == null) {
93
93
  continue normalizationAstLoop;
94
94
  }
95
95
  else {
@@ -1,5 +1,5 @@
1
1
  import { FragmentReference } from './FragmentReference';
2
- import { IsographEnvironment } from './IsographEnvironment';
3
- import { NetworkRequestReaderOptions } from './read';
2
+ import type { IsographEnvironment } from './IsographEnvironment';
3
+ import type { NetworkRequestReaderOptions } from './read';
4
4
  export declare function getOrCreateCachedComponent(environment: IsographEnvironment, fragmentReference: FragmentReference<any, any>, networkRequestOptions: NetworkRequestReaderOptions): React.FC<any>;
5
5
  //# sourceMappingURL=componentCache.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"componentCache.d.ts","sourceRoot":"","sources":["../../src/core/componentCache.ts"],"names":[],"mappings":"AAEA,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,iBAAiB,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,EAC9C,qBAAqB,EAAE,2BAA2B,GACjD,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CA+Cf"}
1
+ {"version":3,"file":"componentCache.d.ts","sourceRoot":"","sources":["../../src/core/componentCache.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,QAAQ,CAAC;AAG1D,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,mBAAmB,EAChC,iBAAiB,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,EAC9C,qBAAqB,EAAE,2BAA2B,GACjD,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAgBf"}