@isograph/react 0.0.0-main-c29b1443 → 0.0.0-main-9cda9690
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/.turbo/turbo-compile-libs.log +1 -1
- package/dist/core/cache.d.ts.map +1 -1
- package/dist/core/cache.js +39 -33
- package/package.json +4 -4
- package/src/core/cache.ts +61 -48
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
../.. | WARN Unsupported engine: wanted: {"node":"22.9.0"} (current: {"node":"v22.20.0","pnpm":"10.15.0"})
|
|
2
2
|
|
|
3
|
-
> @isograph/react@0.0.0-main-
|
|
3
|
+
> @isograph/react@0.0.0-main-9cda9690 compile-libs /home/runner/work/isograph/isograph/libs/isograph-react
|
|
4
4
|
> rimraf dist && tsc -p tsconfig.pkg.json
|
|
5
5
|
|
package/dist/core/cache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/core/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,WAAW,EACZ,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAElB,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC3B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACT,KAAK,qBAAqB,EAE3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,MAAM,EAKN,SAAS,EAET,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EACd,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAwB,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,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function subscribeToAnyChangesToRecord(environment, recordLink, callback) {
|
|
|
119
119
|
environment.subscriptions.add(subscription);
|
|
120
120
|
return () => environment.subscriptions.delete(subscription);
|
|
121
121
|
}
|
|
122
|
-
// TODO we should re-read and call callback if the value has changed
|
|
123
122
|
function subscribe(environment, encounteredDataAndRecords, fragmentReference, callback, readerAst) {
|
|
124
123
|
const fragmentSubscription = {
|
|
125
124
|
kind: 'FragmentSubscription',
|
|
@@ -128,6 +127,11 @@ function subscribe(environment, encounteredDataAndRecords, fragmentReference, ca
|
|
|
128
127
|
fragmentReference,
|
|
129
128
|
readerAst,
|
|
130
129
|
};
|
|
130
|
+
// subscribe is called in an effect. (We should actually subscribe during the
|
|
131
|
+
// initial render.) Because it's called in an effect, we might have missed some
|
|
132
|
+
// changes since the initial render! So, at this point, we re-read and call the
|
|
133
|
+
// subscription (i.e. re-render) if the fragment data has changed.
|
|
134
|
+
callSubscriptionIfDataChanged(environment, fragmentSubscription);
|
|
131
135
|
environment.subscriptions.add(fragmentSubscription);
|
|
132
136
|
return () => environment.subscriptions.delete(fragmentSubscription);
|
|
133
137
|
}
|
|
@@ -165,38 +169,7 @@ function callSubscriptions(environment, recordsEncounteredWhenNormalizing) {
|
|
|
165
169
|
// fragment, we will call readButNotEvaluate multiple times. We
|
|
166
170
|
// should fix that.
|
|
167
171
|
if (hasOverlappingIds(recordsEncounteredWhenNormalizing, subscription.encounteredDataAndRecords.encounteredRecords)) {
|
|
168
|
-
|
|
169
|
-
// Is this wrong?
|
|
170
|
-
// Reasons to think no:
|
|
171
|
-
// - we are only updating the read-out value, and the network
|
|
172
|
-
// options only affect whether we throw.
|
|
173
|
-
// - the component will re-render, and re-throw on its own, anyway.
|
|
174
|
-
//
|
|
175
|
-
// Reasons to think not:
|
|
176
|
-
// - it seems more efficient to suspend here and not update state,
|
|
177
|
-
// if we expect that the component will just throw anyway
|
|
178
|
-
// - consistency
|
|
179
|
-
// - it's also weird, this is called from makeNetworkRequest, where
|
|
180
|
-
// we don't currently pass network request options
|
|
181
|
-
{
|
|
182
|
-
suspendIfInFlight: false,
|
|
183
|
-
throwOnNetworkError: false,
|
|
184
|
-
});
|
|
185
|
-
const mergedItem = (0, areEqualWithDeepComparison_1.mergeObjectsUsingReaderAst)(subscription.readerAst, subscription.encounteredDataAndRecords.item, newEncounteredDataAndRecords.item);
|
|
186
|
-
(0, logging_1.logMessage)(environment, () => ({
|
|
187
|
-
kind: 'DeepEqualityCheck',
|
|
188
|
-
fragmentReference: subscription.fragmentReference,
|
|
189
|
-
old: subscription.encounteredDataAndRecords.item,
|
|
190
|
-
new: newEncounteredDataAndRecords.item,
|
|
191
|
-
deeplyEqual: mergedItem === subscription.encounteredDataAndRecords.item,
|
|
192
|
-
}));
|
|
193
|
-
if (mergedItem !== subscription.encounteredDataAndRecords.item) {
|
|
194
|
-
logAnyError(environment, { situation: 'calling FragmentSubscription callback' }, () => {
|
|
195
|
-
subscription.callback(newEncounteredDataAndRecords);
|
|
196
|
-
});
|
|
197
|
-
subscription.encounteredDataAndRecords =
|
|
198
|
-
newEncounteredDataAndRecords;
|
|
199
|
-
}
|
|
172
|
+
callSubscriptionIfDataChanged(environment, subscription);
|
|
200
173
|
}
|
|
201
174
|
return;
|
|
202
175
|
}
|
|
@@ -220,6 +193,39 @@ function callSubscriptions(environment, recordsEncounteredWhenNormalizing) {
|
|
|
220
193
|
}
|
|
221
194
|
}));
|
|
222
195
|
}
|
|
196
|
+
function callSubscriptionIfDataChanged(environment, subscription) {
|
|
197
|
+
const newEncounteredDataAndRecords = (0, read_1.readButDoNotEvaluate)(environment, subscription.fragmentReference,
|
|
198
|
+
// Is this wrong?
|
|
199
|
+
// Reasons to think no:
|
|
200
|
+
// - we are only updating the read-out value, and the network
|
|
201
|
+
// options only affect whether we throw.
|
|
202
|
+
// - the component will re-render, and re-throw on its own, anyway.
|
|
203
|
+
//
|
|
204
|
+
// Reasons to think not:
|
|
205
|
+
// - it seems more efficient to suspend here and not update state,
|
|
206
|
+
// if we expect that the component will just throw anyway
|
|
207
|
+
// - consistency
|
|
208
|
+
// - it's also weird, this is called from makeNetworkRequest, where
|
|
209
|
+
// we don't currently pass network request options
|
|
210
|
+
{
|
|
211
|
+
suspendIfInFlight: false,
|
|
212
|
+
throwOnNetworkError: false,
|
|
213
|
+
});
|
|
214
|
+
const mergedItem = (0, areEqualWithDeepComparison_1.mergeObjectsUsingReaderAst)(subscription.readerAst, subscription.encounteredDataAndRecords.item, newEncounteredDataAndRecords.item);
|
|
215
|
+
(0, logging_1.logMessage)(environment, () => ({
|
|
216
|
+
kind: 'DeepEqualityCheck',
|
|
217
|
+
fragmentReference: subscription.fragmentReference,
|
|
218
|
+
old: subscription.encounteredDataAndRecords.item,
|
|
219
|
+
new: newEncounteredDataAndRecords.item,
|
|
220
|
+
deeplyEqual: mergedItem === subscription.encounteredDataAndRecords.item,
|
|
221
|
+
}));
|
|
222
|
+
if (mergedItem !== subscription.encounteredDataAndRecords.item) {
|
|
223
|
+
logAnyError(environment, { situation: 'calling FragmentSubscription callback' }, () => {
|
|
224
|
+
subscription.callback(newEncounteredDataAndRecords);
|
|
225
|
+
});
|
|
226
|
+
subscription.encounteredDataAndRecords = newEncounteredDataAndRecords;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
223
229
|
function hasOverlappingIds(ids1, ids2) {
|
|
224
230
|
for (const [typeName, set1] of ids1.entries()) {
|
|
225
231
|
const set2 = ids2.get(typeName);
|
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-9cda9690",
|
|
4
4
|
"description": "Use Isograph with React",
|
|
5
5
|
"homepage": "https://isograph.dev",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"iso": "cross-env ISO_PRINT_ABSOLUTE_FILEPATH=1 ../../target/debug/isograph_cli --config ./isograph.config.json"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@isograph/disposable-types": "0.0.0-main-
|
|
23
|
-
"@isograph/react-disposable-state": "0.0.0-main-
|
|
24
|
-
"@isograph/reference-counted-pointer": "0.0.0-main-
|
|
22
|
+
"@isograph/disposable-types": "0.0.0-main-9cda9690",
|
|
23
|
+
"@isograph/react-disposable-state": "0.0.0-main-9cda9690",
|
|
24
|
+
"@isograph/reference-counted-pointer": "0.0.0-main-9cda9690"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": "^18.0.0 || ^19.0.0"
|
package/src/core/cache.ts
CHANGED
|
@@ -217,7 +217,6 @@ export function subscribeToAnyChangesToRecord(
|
|
|
217
217
|
return () => environment.subscriptions.delete(subscription);
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
// TODO we should re-read and call callback if the value has changed
|
|
221
220
|
export function subscribe<TReadFromStore extends UnknownTReadFromStore>(
|
|
222
221
|
environment: IsographEnvironment,
|
|
223
222
|
encounteredDataAndRecords: WithEncounteredRecords<TReadFromStore>,
|
|
@@ -234,6 +233,13 @@ export function subscribe<TReadFromStore extends UnknownTReadFromStore>(
|
|
|
234
233
|
fragmentReference,
|
|
235
234
|
readerAst,
|
|
236
235
|
};
|
|
236
|
+
|
|
237
|
+
// subscribe is called in an effect. (We should actually subscribe during the
|
|
238
|
+
// initial render.) Because it's called in an effect, we might have missed some
|
|
239
|
+
// changes since the initial render! So, at this point, we re-read and call the
|
|
240
|
+
// subscription (i.e. re-render) if the fragment data has changed.
|
|
241
|
+
callSubscriptionIfDataChanged(environment, fragmentSubscription);
|
|
242
|
+
|
|
237
243
|
environment.subscriptions.add(fragmentSubscription);
|
|
238
244
|
return () => environment.subscriptions.delete(fragmentSubscription);
|
|
239
245
|
}
|
|
@@ -292,53 +298,7 @@ export function callSubscriptions(
|
|
|
292
298
|
subscription.encounteredDataAndRecords.encounteredRecords,
|
|
293
299
|
)
|
|
294
300
|
) {
|
|
295
|
-
|
|
296
|
-
environment,
|
|
297
|
-
subscription.fragmentReference,
|
|
298
|
-
// Is this wrong?
|
|
299
|
-
// Reasons to think no:
|
|
300
|
-
// - we are only updating the read-out value, and the network
|
|
301
|
-
// options only affect whether we throw.
|
|
302
|
-
// - the component will re-render, and re-throw on its own, anyway.
|
|
303
|
-
//
|
|
304
|
-
// Reasons to think not:
|
|
305
|
-
// - it seems more efficient to suspend here and not update state,
|
|
306
|
-
// if we expect that the component will just throw anyway
|
|
307
|
-
// - consistency
|
|
308
|
-
// - it's also weird, this is called from makeNetworkRequest, where
|
|
309
|
-
// we don't currently pass network request options
|
|
310
|
-
{
|
|
311
|
-
suspendIfInFlight: false,
|
|
312
|
-
throwOnNetworkError: false,
|
|
313
|
-
},
|
|
314
|
-
);
|
|
315
|
-
|
|
316
|
-
const mergedItem = mergeObjectsUsingReaderAst(
|
|
317
|
-
subscription.readerAst,
|
|
318
|
-
subscription.encounteredDataAndRecords.item,
|
|
319
|
-
newEncounteredDataAndRecords.item,
|
|
320
|
-
);
|
|
321
|
-
|
|
322
|
-
logMessage(environment, () => ({
|
|
323
|
-
kind: 'DeepEqualityCheck',
|
|
324
|
-
fragmentReference: subscription.fragmentReference,
|
|
325
|
-
old: subscription.encounteredDataAndRecords.item,
|
|
326
|
-
new: newEncounteredDataAndRecords.item,
|
|
327
|
-
deeplyEqual:
|
|
328
|
-
mergedItem === subscription.encounteredDataAndRecords.item,
|
|
329
|
-
}));
|
|
330
|
-
|
|
331
|
-
if (mergedItem !== subscription.encounteredDataAndRecords.item) {
|
|
332
|
-
logAnyError(
|
|
333
|
-
environment,
|
|
334
|
-
{ situation: 'calling FragmentSubscription callback' },
|
|
335
|
-
() => {
|
|
336
|
-
subscription.callback(newEncounteredDataAndRecords);
|
|
337
|
-
},
|
|
338
|
-
);
|
|
339
|
-
subscription.encounteredDataAndRecords =
|
|
340
|
-
newEncounteredDataAndRecords;
|
|
341
|
-
}
|
|
301
|
+
callSubscriptionIfDataChanged(environment, subscription);
|
|
342
302
|
}
|
|
343
303
|
return;
|
|
344
304
|
}
|
|
@@ -375,6 +335,59 @@ export function callSubscriptions(
|
|
|
375
335
|
);
|
|
376
336
|
}
|
|
377
337
|
|
|
338
|
+
function callSubscriptionIfDataChanged<
|
|
339
|
+
TReadFromStore extends UnknownTReadFromStore,
|
|
340
|
+
>(
|
|
341
|
+
environment: IsographEnvironment,
|
|
342
|
+
subscription: FragmentSubscription<TReadFromStore>,
|
|
343
|
+
) {
|
|
344
|
+
const newEncounteredDataAndRecords = readButDoNotEvaluate(
|
|
345
|
+
environment,
|
|
346
|
+
subscription.fragmentReference,
|
|
347
|
+
// Is this wrong?
|
|
348
|
+
// Reasons to think no:
|
|
349
|
+
// - we are only updating the read-out value, and the network
|
|
350
|
+
// options only affect whether we throw.
|
|
351
|
+
// - the component will re-render, and re-throw on its own, anyway.
|
|
352
|
+
//
|
|
353
|
+
// Reasons to think not:
|
|
354
|
+
// - it seems more efficient to suspend here and not update state,
|
|
355
|
+
// if we expect that the component will just throw anyway
|
|
356
|
+
// - consistency
|
|
357
|
+
// - it's also weird, this is called from makeNetworkRequest, where
|
|
358
|
+
// we don't currently pass network request options
|
|
359
|
+
{
|
|
360
|
+
suspendIfInFlight: false,
|
|
361
|
+
throwOnNetworkError: false,
|
|
362
|
+
},
|
|
363
|
+
);
|
|
364
|
+
|
|
365
|
+
const mergedItem = mergeObjectsUsingReaderAst(
|
|
366
|
+
subscription.readerAst,
|
|
367
|
+
subscription.encounteredDataAndRecords.item,
|
|
368
|
+
newEncounteredDataAndRecords.item,
|
|
369
|
+
);
|
|
370
|
+
|
|
371
|
+
logMessage(environment, () => ({
|
|
372
|
+
kind: 'DeepEqualityCheck',
|
|
373
|
+
fragmentReference: subscription.fragmentReference,
|
|
374
|
+
old: subscription.encounteredDataAndRecords.item,
|
|
375
|
+
new: newEncounteredDataAndRecords.item,
|
|
376
|
+
deeplyEqual: mergedItem === subscription.encounteredDataAndRecords.item,
|
|
377
|
+
}));
|
|
378
|
+
|
|
379
|
+
if (mergedItem !== subscription.encounteredDataAndRecords.item) {
|
|
380
|
+
logAnyError(
|
|
381
|
+
environment,
|
|
382
|
+
{ situation: 'calling FragmentSubscription callback' },
|
|
383
|
+
() => {
|
|
384
|
+
subscription.callback(newEncounteredDataAndRecords);
|
|
385
|
+
},
|
|
386
|
+
);
|
|
387
|
+
subscription.encounteredDataAndRecords = newEncounteredDataAndRecords;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
378
391
|
function hasOverlappingIds(
|
|
379
392
|
ids1: EncounteredIds,
|
|
380
393
|
ids2: EncounteredIds,
|