@mmstack/resource 20.4.1 → 21.0.0

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.
@@ -1178,15 +1178,21 @@ function hasSlowConnection() {
1178
1178
 
1179
1179
  function persist(src, equal) {
1180
1180
  // linkedSignal allows us to access previous source value
1181
- const persisted = linkedSignal({
1182
- source: () => src(),
1183
- computation: (next, prev) => {
1184
- if (next === undefined && prev !== undefined)
1185
- return prev.value;
1186
- return next;
1187
- },
1188
- equal,
1189
- });
1181
+ const persisted = linkedSignal(...(ngDevMode ? [{ debugName: "persisted", source: () => src(),
1182
+ computation: (next, prev) => {
1183
+ if (next === undefined && prev !== undefined)
1184
+ return prev.value;
1185
+ return next;
1186
+ },
1187
+ equal }] : [{
1188
+ source: () => src(),
1189
+ computation: (next, prev) => {
1190
+ if (next === undefined && prev !== undefined)
1191
+ return prev.value;
1192
+ return next;
1193
+ },
1194
+ equal,
1195
+ }]));
1190
1196
  // if original value was WritableSignal then override linkedSignal methods to original...angular uses linkedSignal under the hood in ResourceImpl, this applies to that.
1191
1197
  if ('set' in src) {
1192
1198
  persisted.set = src.set;
@@ -1271,10 +1277,10 @@ function retryOnError(res, opt) {
1271
1277
 
1272
1278
  class ResourceSensors {
1273
1279
  networkStatus = sensor('networkStatus');
1274
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: ResourceSensors, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1275
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: ResourceSensors, providedIn: 'root' });
1280
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: ResourceSensors, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1281
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: ResourceSensors, providedIn: 'root' });
1276
1282
  }
1277
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: ResourceSensors, decorators: [{
1283
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: ResourceSensors, decorators: [{
1278
1284
  type: Injectable,
1279
1285
  args: [{
1280
1286
  providedIn: 'root',
@@ -1393,27 +1399,45 @@ function queryResource(request, options) {
1393
1399
  resource = catchValueError(resource, options?.defaultValue);
1394
1400
  // get full HttpResonse from Cache
1395
1401
  const cachedEvent = cache.getEntryOrKey(cacheKey);
1396
- const cacheEntry = linkedSignal({
1397
- source: () => cachedEvent(),
1398
- computation: (entry, prev) => {
1399
- if (!entry)
1400
- return null;
1401
- if (typeof entry === 'string' &&
1402
- prev &&
1403
- prev.value !== null &&
1404
- prev.value.key === entry) {
1405
- return prev.value;
1406
- }
1407
- if (typeof entry === 'string')
1408
- return { key: entry, value: null };
1409
- if (!(entry.value instanceof HttpResponse))
1410
- return { key: entry.key, value: null };
1411
- return {
1412
- value: entry.value.body,
1413
- key: entry.key,
1414
- };
1415
- },
1416
- });
1402
+ const cacheEntry = linkedSignal(...(ngDevMode ? [{ debugName: "cacheEntry", source: () => cachedEvent(),
1403
+ computation: (entry, prev) => {
1404
+ if (!entry)
1405
+ return null;
1406
+ if (typeof entry === 'string' &&
1407
+ prev &&
1408
+ prev.value !== null &&
1409
+ prev.value.key === entry) {
1410
+ return prev.value;
1411
+ }
1412
+ if (typeof entry === 'string')
1413
+ return { key: entry, value: null };
1414
+ if (!(entry.value instanceof HttpResponse))
1415
+ return { key: entry.key, value: null };
1416
+ return {
1417
+ value: entry.value.body,
1418
+ key: entry.key,
1419
+ };
1420
+ } }] : [{
1421
+ source: () => cachedEvent(),
1422
+ computation: (entry, prev) => {
1423
+ if (!entry)
1424
+ return null;
1425
+ if (typeof entry === 'string' &&
1426
+ prev &&
1427
+ prev.value !== null &&
1428
+ prev.value.key === entry) {
1429
+ return prev.value;
1430
+ }
1431
+ if (typeof entry === 'string')
1432
+ return { key: entry, value: null };
1433
+ if (!(entry.value instanceof HttpResponse))
1434
+ return { key: entry.key, value: null };
1435
+ return {
1436
+ value: entry.value.body,
1437
+ key: entry.key,
1438
+ };
1439
+ },
1440
+ }]));
1417
1441
  resource = refresh(resource, destroyRef, options?.refresh);
1418
1442
  resource = retryOnError(resource, options?.retry);
1419
1443
  resource = persistResourceValues(resource, options?.keepPrevious, options?.equal);
@@ -1498,6 +1522,7 @@ function queryResource(request, options) {
1498
1522
  try {
1499
1523
  await firstValueFrom(client.request(prefetchRequest.method ?? 'GET', prefetchRequest.url, {
1500
1524
  ...prefetchRequest,
1525
+ referrerPolicy: prefetchRequest.referrerPolicy,
1501
1526
  credentials: prefetchRequest.credentials,
1502
1527
  priority: prefetchRequest.priority,
1503
1528
  cache: prefetchRequest.cache,
@@ -1585,14 +1610,19 @@ function mutationResource(request, options = {}) {
1585
1610
  }, ...(ngDevMode ? [{ debugName: "req", equal: requestEqual }] : [{
1586
1611
  equal: requestEqual,
1587
1612
  }]));
1588
- const lastValue = linkedSignal({
1589
- source: next,
1590
- computation: (next, prev) => {
1591
- if (next === null && !!prev)
1592
- return prev.value;
1593
- return next;
1594
- },
1595
- });
1613
+ const lastValue = linkedSignal(...(ngDevMode ? [{ debugName: "lastValue", source: next,
1614
+ computation: (next, prev) => {
1615
+ if (next === null && !!prev)
1616
+ return prev.value;
1617
+ return next;
1618
+ } }] : [{
1619
+ source: next,
1620
+ computation: (next, prev) => {
1621
+ if (next === null && !!prev)
1622
+ return prev.value;
1623
+ return next;
1624
+ },
1625
+ }]));
1596
1626
  const lastValueRequest = computed(() => {
1597
1627
  const nr = lastValue();
1598
1628
  if (!nr)