@nexushub/client 0.7.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +34 -35
- package/dist/index.d.cts +0 -7
- package/dist/index.d.ts +0 -7
- package/dist/index.js +34 -35
- package/dist/react.cjs +42 -43
- package/dist/react.d.cts +0 -7
- package/dist/react.d.ts +0 -7
- package/dist/react.js +34 -35
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1048,23 +1048,26 @@ var ContentEngine = class {
|
|
|
1048
1048
|
}
|
|
1049
1049
|
return includeMetadata ? cached : cached.data;
|
|
1050
1050
|
}
|
|
1051
|
-
if (!forceRefresh
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
if (this.config.debug) {
|
|
1059
|
-
console.log(
|
|
1060
|
-
`[NexusHub] \u{1F4C1} Served collection '${collectionId}' from local cache.`
|
|
1051
|
+
if (!forceRefresh) {
|
|
1052
|
+
try {
|
|
1053
|
+
const localCollection = await this.localCache.getCollection(collectionId);
|
|
1054
|
+
if (localCollection) {
|
|
1055
|
+
const result = this.applyLocalQuery(
|
|
1056
|
+
localCollection,
|
|
1057
|
+
normalizedQuery
|
|
1061
1058
|
);
|
|
1059
|
+
if (this.config.debug) {
|
|
1060
|
+
console.log(
|
|
1061
|
+
`[NexusHub] \u{1F4C1} Compiled collection '${collectionId}' from local offline binaries.`
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
this.memoryCache.set(cacheKey, result, {
|
|
1065
|
+
tags: [...tags, CacheTags.collection(collectionId)],
|
|
1066
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
1067
|
+
});
|
|
1068
|
+
return result;
|
|
1062
1069
|
}
|
|
1063
|
-
|
|
1064
|
-
tags: [...tags, CacheTags.collection(collectionId)],
|
|
1065
|
-
revalidate: revalidate === false ? void 0 : revalidate
|
|
1066
|
-
});
|
|
1067
|
-
return result;
|
|
1070
|
+
} catch {
|
|
1068
1071
|
}
|
|
1069
1072
|
}
|
|
1070
1073
|
if (this.circuitBreaker.isOpen()) throw new Error("Circuit open");
|
|
@@ -1120,14 +1123,17 @@ var ContentEngine = class {
|
|
|
1120
1123
|
return cached;
|
|
1121
1124
|
}
|
|
1122
1125
|
}
|
|
1123
|
-
if (!forceRefresh
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1126
|
+
if (!forceRefresh) {
|
|
1127
|
+
try {
|
|
1128
|
+
const localGlobals = await this.localCache.getGlobals();
|
|
1129
|
+
if (localGlobals) {
|
|
1130
|
+
this.memoryCache.set(cacheKey, localGlobals, {
|
|
1131
|
+
tags: [CacheTags.global],
|
|
1132
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
1133
|
+
});
|
|
1134
|
+
return localGlobals;
|
|
1135
|
+
}
|
|
1136
|
+
} catch {
|
|
1131
1137
|
}
|
|
1132
1138
|
}
|
|
1133
1139
|
try {
|
|
@@ -1159,7 +1165,6 @@ var ContentEngine = class {
|
|
|
1159
1165
|
}
|
|
1160
1166
|
/**
|
|
1161
1167
|
* Get a single item from a collection (Uses Request Batching)
|
|
1162
|
-
* If you call this 10 times in a loop, it sends 1 HTTP request.
|
|
1163
1168
|
*/
|
|
1164
1169
|
async getItem(collectionId, itemId, options = {}) {
|
|
1165
1170
|
const cacheKey = `item:${collectionId}:${itemId}`;
|
|
@@ -1313,21 +1318,22 @@ var ContentEngine = class {
|
|
|
1313
1318
|
};
|
|
1314
1319
|
}
|
|
1315
1320
|
}
|
|
1316
|
-
if (
|
|
1317
|
-
|
|
1318
|
-
|
|
1321
|
+
if (key.startsWith("page:")) {
|
|
1322
|
+
const slug = key.split(":")[1];
|
|
1323
|
+
try {
|
|
1319
1324
|
const local = await this.localCache.getPage(slug);
|
|
1320
1325
|
if (local) {
|
|
1321
1326
|
return {
|
|
1322
1327
|
data: local,
|
|
1323
1328
|
metadata: {
|
|
1324
|
-
timestamp:
|
|
1329
|
+
timestamp: Date.now(),
|
|
1325
1330
|
expiresAt: Infinity,
|
|
1326
1331
|
tags: [],
|
|
1327
1332
|
etag: void 0
|
|
1328
1333
|
}
|
|
1329
1334
|
};
|
|
1330
1335
|
}
|
|
1336
|
+
} catch {
|
|
1331
1337
|
}
|
|
1332
1338
|
}
|
|
1333
1339
|
return null;
|
|
@@ -1519,7 +1525,6 @@ var ContentEngine = class {
|
|
|
1519
1525
|
const response = await fetch(url, {
|
|
1520
1526
|
...fetchOptions,
|
|
1521
1527
|
...nextConfig,
|
|
1522
|
-
// Inject Next.js tags
|
|
1523
1528
|
signal: controller.signal
|
|
1524
1529
|
});
|
|
1525
1530
|
clearTimeout(id);
|
|
@@ -1552,18 +1557,12 @@ var ContentEngine = class {
|
|
|
1552
1557
|
}
|
|
1553
1558
|
return new Error(`${context}: ${String(error)}`);
|
|
1554
1559
|
}
|
|
1555
|
-
/**
|
|
1556
|
-
* Cancel ongoing requests
|
|
1557
|
-
*/
|
|
1558
1560
|
cancelRequests() {
|
|
1559
1561
|
if (this.abortController) {
|
|
1560
1562
|
this.abortController.abort();
|
|
1561
1563
|
this.abortController = new AbortController();
|
|
1562
1564
|
}
|
|
1563
1565
|
}
|
|
1564
|
-
/**
|
|
1565
|
-
* Cleanup resources
|
|
1566
|
-
*/
|
|
1567
1566
|
cleanup() {
|
|
1568
1567
|
this.cancelRequests();
|
|
1569
1568
|
if (!this.isServer) {
|
package/dist/index.d.cts
CHANGED
|
@@ -122,7 +122,6 @@ declare class ContentEngine {
|
|
|
122
122
|
}): Promise<T>;
|
|
123
123
|
/**
|
|
124
124
|
* Get a single item from a collection (Uses Request Batching)
|
|
125
|
-
* If you call this 10 times in a loop, it sends 1 HTTP request.
|
|
126
125
|
*/
|
|
127
126
|
getItem<T = any>(collectionId: string, itemId: string, options?: {
|
|
128
127
|
revalidate?: number | false;
|
|
@@ -186,13 +185,7 @@ declare class ContentEngine {
|
|
|
186
185
|
private getHeaders;
|
|
187
186
|
private isCacheValid;
|
|
188
187
|
private normalizeError;
|
|
189
|
-
/**
|
|
190
|
-
* Cancel ongoing requests
|
|
191
|
-
*/
|
|
192
188
|
cancelRequests(): void;
|
|
193
|
-
/**
|
|
194
|
-
* Cleanup resources
|
|
195
|
-
*/
|
|
196
189
|
private cleanup;
|
|
197
190
|
}
|
|
198
191
|
|
package/dist/index.d.ts
CHANGED
|
@@ -122,7 +122,6 @@ declare class ContentEngine {
|
|
|
122
122
|
}): Promise<T>;
|
|
123
123
|
/**
|
|
124
124
|
* Get a single item from a collection (Uses Request Batching)
|
|
125
|
-
* If you call this 10 times in a loop, it sends 1 HTTP request.
|
|
126
125
|
*/
|
|
127
126
|
getItem<T = any>(collectionId: string, itemId: string, options?: {
|
|
128
127
|
revalidate?: number | false;
|
|
@@ -186,13 +185,7 @@ declare class ContentEngine {
|
|
|
186
185
|
private getHeaders;
|
|
187
186
|
private isCacheValid;
|
|
188
187
|
private normalizeError;
|
|
189
|
-
/**
|
|
190
|
-
* Cancel ongoing requests
|
|
191
|
-
*/
|
|
192
188
|
cancelRequests(): void;
|
|
193
|
-
/**
|
|
194
|
-
* Cleanup resources
|
|
195
|
-
*/
|
|
196
189
|
private cleanup;
|
|
197
190
|
}
|
|
198
191
|
|
package/dist/index.js
CHANGED
|
@@ -1002,23 +1002,26 @@ var ContentEngine = class {
|
|
|
1002
1002
|
}
|
|
1003
1003
|
return includeMetadata ? cached : cached.data;
|
|
1004
1004
|
}
|
|
1005
|
-
if (!forceRefresh
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
if (this.config.debug) {
|
|
1013
|
-
console.log(
|
|
1014
|
-
`[NexusHub] \u{1F4C1} Served collection '${collectionId}' from local cache.`
|
|
1005
|
+
if (!forceRefresh) {
|
|
1006
|
+
try {
|
|
1007
|
+
const localCollection = await this.localCache.getCollection(collectionId);
|
|
1008
|
+
if (localCollection) {
|
|
1009
|
+
const result = this.applyLocalQuery(
|
|
1010
|
+
localCollection,
|
|
1011
|
+
normalizedQuery
|
|
1015
1012
|
);
|
|
1013
|
+
if (this.config.debug) {
|
|
1014
|
+
console.log(
|
|
1015
|
+
`[NexusHub] \u{1F4C1} Compiled collection '${collectionId}' from local offline binaries.`
|
|
1016
|
+
);
|
|
1017
|
+
}
|
|
1018
|
+
this.memoryCache.set(cacheKey, result, {
|
|
1019
|
+
tags: [...tags, CacheTags.collection(collectionId)],
|
|
1020
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
1021
|
+
});
|
|
1022
|
+
return result;
|
|
1016
1023
|
}
|
|
1017
|
-
|
|
1018
|
-
tags: [...tags, CacheTags.collection(collectionId)],
|
|
1019
|
-
revalidate: revalidate === false ? void 0 : revalidate
|
|
1020
|
-
});
|
|
1021
|
-
return result;
|
|
1024
|
+
} catch {
|
|
1022
1025
|
}
|
|
1023
1026
|
}
|
|
1024
1027
|
if (this.circuitBreaker.isOpen()) throw new Error("Circuit open");
|
|
@@ -1074,14 +1077,17 @@ var ContentEngine = class {
|
|
|
1074
1077
|
return cached;
|
|
1075
1078
|
}
|
|
1076
1079
|
}
|
|
1077
|
-
if (!forceRefresh
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1080
|
+
if (!forceRefresh) {
|
|
1081
|
+
try {
|
|
1082
|
+
const localGlobals = await this.localCache.getGlobals();
|
|
1083
|
+
if (localGlobals) {
|
|
1084
|
+
this.memoryCache.set(cacheKey, localGlobals, {
|
|
1085
|
+
tags: [CacheTags.global],
|
|
1086
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
1087
|
+
});
|
|
1088
|
+
return localGlobals;
|
|
1089
|
+
}
|
|
1090
|
+
} catch {
|
|
1085
1091
|
}
|
|
1086
1092
|
}
|
|
1087
1093
|
try {
|
|
@@ -1113,7 +1119,6 @@ var ContentEngine = class {
|
|
|
1113
1119
|
}
|
|
1114
1120
|
/**
|
|
1115
1121
|
* Get a single item from a collection (Uses Request Batching)
|
|
1116
|
-
* If you call this 10 times in a loop, it sends 1 HTTP request.
|
|
1117
1122
|
*/
|
|
1118
1123
|
async getItem(collectionId, itemId, options = {}) {
|
|
1119
1124
|
const cacheKey = `item:${collectionId}:${itemId}`;
|
|
@@ -1267,21 +1272,22 @@ var ContentEngine = class {
|
|
|
1267
1272
|
};
|
|
1268
1273
|
}
|
|
1269
1274
|
}
|
|
1270
|
-
if (
|
|
1271
|
-
|
|
1272
|
-
|
|
1275
|
+
if (key.startsWith("page:")) {
|
|
1276
|
+
const slug = key.split(":")[1];
|
|
1277
|
+
try {
|
|
1273
1278
|
const local = await this.localCache.getPage(slug);
|
|
1274
1279
|
if (local) {
|
|
1275
1280
|
return {
|
|
1276
1281
|
data: local,
|
|
1277
1282
|
metadata: {
|
|
1278
|
-
timestamp:
|
|
1283
|
+
timestamp: Date.now(),
|
|
1279
1284
|
expiresAt: Infinity,
|
|
1280
1285
|
tags: [],
|
|
1281
1286
|
etag: void 0
|
|
1282
1287
|
}
|
|
1283
1288
|
};
|
|
1284
1289
|
}
|
|
1290
|
+
} catch {
|
|
1285
1291
|
}
|
|
1286
1292
|
}
|
|
1287
1293
|
return null;
|
|
@@ -1473,7 +1479,6 @@ var ContentEngine = class {
|
|
|
1473
1479
|
const response = await fetch(url, {
|
|
1474
1480
|
...fetchOptions,
|
|
1475
1481
|
...nextConfig,
|
|
1476
|
-
// Inject Next.js tags
|
|
1477
1482
|
signal: controller.signal
|
|
1478
1483
|
});
|
|
1479
1484
|
clearTimeout(id);
|
|
@@ -1506,18 +1511,12 @@ var ContentEngine = class {
|
|
|
1506
1511
|
}
|
|
1507
1512
|
return new Error(`${context}: ${String(error)}`);
|
|
1508
1513
|
}
|
|
1509
|
-
/**
|
|
1510
|
-
* Cancel ongoing requests
|
|
1511
|
-
*/
|
|
1512
1514
|
cancelRequests() {
|
|
1513
1515
|
if (this.abortController) {
|
|
1514
1516
|
this.abortController.abort();
|
|
1515
1517
|
this.abortController = new AbortController();
|
|
1516
1518
|
}
|
|
1517
1519
|
}
|
|
1518
|
-
/**
|
|
1519
|
-
* Cleanup resources
|
|
1520
|
-
*/
|
|
1521
1520
|
cleanup() {
|
|
1522
1521
|
this.cancelRequests();
|
|
1523
1522
|
if (!this.isServer) {
|
package/dist/react.cjs
CHANGED
|
@@ -647,23 +647,26 @@ var ContentEngine = class {
|
|
|
647
647
|
}
|
|
648
648
|
return includeMetadata ? cached : cached.data;
|
|
649
649
|
}
|
|
650
|
-
if (!forceRefresh
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
if (this.config.debug) {
|
|
658
|
-
console.log(
|
|
659
|
-
`[NexusHub] \u{1F4C1} Served collection '${collectionId}' from local cache.`
|
|
650
|
+
if (!forceRefresh) {
|
|
651
|
+
try {
|
|
652
|
+
const localCollection = await this.localCache.getCollection(collectionId);
|
|
653
|
+
if (localCollection) {
|
|
654
|
+
const result = this.applyLocalQuery(
|
|
655
|
+
localCollection,
|
|
656
|
+
normalizedQuery
|
|
660
657
|
);
|
|
658
|
+
if (this.config.debug) {
|
|
659
|
+
console.log(
|
|
660
|
+
`[NexusHub] \u{1F4C1} Compiled collection '${collectionId}' from local offline binaries.`
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
this.memoryCache.set(cacheKey, result, {
|
|
664
|
+
tags: [...tags, CacheTags.collection(collectionId)],
|
|
665
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
666
|
+
});
|
|
667
|
+
return result;
|
|
661
668
|
}
|
|
662
|
-
|
|
663
|
-
tags: [...tags, CacheTags.collection(collectionId)],
|
|
664
|
-
revalidate: revalidate === false ? void 0 : revalidate
|
|
665
|
-
});
|
|
666
|
-
return result;
|
|
669
|
+
} catch (e5) {
|
|
667
670
|
}
|
|
668
671
|
}
|
|
669
672
|
if (this.circuitBreaker.isOpen()) throw new Error("Circuit open");
|
|
@@ -719,14 +722,17 @@ var ContentEngine = class {
|
|
|
719
722
|
return cached;
|
|
720
723
|
}
|
|
721
724
|
}
|
|
722
|
-
if (!forceRefresh
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
725
|
+
if (!forceRefresh) {
|
|
726
|
+
try {
|
|
727
|
+
const localGlobals = await this.localCache.getGlobals();
|
|
728
|
+
if (localGlobals) {
|
|
729
|
+
this.memoryCache.set(cacheKey, localGlobals, {
|
|
730
|
+
tags: [CacheTags.global],
|
|
731
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
732
|
+
});
|
|
733
|
+
return localGlobals;
|
|
734
|
+
}
|
|
735
|
+
} catch (e6) {
|
|
730
736
|
}
|
|
731
737
|
}
|
|
732
738
|
try {
|
|
@@ -758,7 +764,6 @@ var ContentEngine = class {
|
|
|
758
764
|
}
|
|
759
765
|
/**
|
|
760
766
|
* Get a single item from a collection (Uses Request Batching)
|
|
761
|
-
* If you call this 10 times in a loop, it sends 1 HTTP request.
|
|
762
767
|
*/
|
|
763
768
|
async getItem(collectionId, itemId, options = {}) {
|
|
764
769
|
const cacheKey = `item:${collectionId}:${itemId}`;
|
|
@@ -912,21 +917,22 @@ var ContentEngine = class {
|
|
|
912
917
|
};
|
|
913
918
|
}
|
|
914
919
|
}
|
|
915
|
-
if (
|
|
916
|
-
|
|
917
|
-
|
|
920
|
+
if (key.startsWith("page:")) {
|
|
921
|
+
const slug = key.split(":")[1];
|
|
922
|
+
try {
|
|
918
923
|
const local = await this.localCache.getPage(slug);
|
|
919
924
|
if (local) {
|
|
920
925
|
return {
|
|
921
926
|
data: local,
|
|
922
927
|
metadata: {
|
|
923
|
-
timestamp:
|
|
928
|
+
timestamp: Date.now(),
|
|
924
929
|
expiresAt: Infinity,
|
|
925
930
|
tags: [],
|
|
926
931
|
etag: void 0
|
|
927
932
|
}
|
|
928
933
|
};
|
|
929
934
|
}
|
|
935
|
+
} catch (e7) {
|
|
930
936
|
}
|
|
931
937
|
}
|
|
932
938
|
return null;
|
|
@@ -1118,7 +1124,6 @@ var ContentEngine = class {
|
|
|
1118
1124
|
const response = await fetch(url, {
|
|
1119
1125
|
...fetchOptions,
|
|
1120
1126
|
...nextConfig,
|
|
1121
|
-
// Inject Next.js tags
|
|
1122
1127
|
signal: controller.signal
|
|
1123
1128
|
});
|
|
1124
1129
|
clearTimeout(id);
|
|
@@ -1151,18 +1156,12 @@ var ContentEngine = class {
|
|
|
1151
1156
|
}
|
|
1152
1157
|
return new Error(`${context}: ${String(error)}`);
|
|
1153
1158
|
}
|
|
1154
|
-
/**
|
|
1155
|
-
* Cancel ongoing requests
|
|
1156
|
-
*/
|
|
1157
1159
|
cancelRequests() {
|
|
1158
1160
|
if (this.abortController) {
|
|
1159
1161
|
this.abortController.abort();
|
|
1160
1162
|
this.abortController = new AbortController();
|
|
1161
1163
|
}
|
|
1162
1164
|
}
|
|
1163
|
-
/**
|
|
1164
|
-
* Cleanup resources
|
|
1165
|
-
*/
|
|
1166
1165
|
cleanup() {
|
|
1167
1166
|
this.cancelRequests();
|
|
1168
1167
|
if (!this.isServer) {
|
|
@@ -1216,7 +1215,7 @@ var generateCanvasHash = async () => {
|
|
|
1216
1215
|
hash = hash & hash;
|
|
1217
1216
|
}
|
|
1218
1217
|
return hash.toString(16);
|
|
1219
|
-
} catch (
|
|
1218
|
+
} catch (e8) {
|
|
1220
1219
|
return "";
|
|
1221
1220
|
}
|
|
1222
1221
|
};
|
|
@@ -1448,20 +1447,20 @@ var SDK_VERSION = "0.1.0";
|
|
|
1448
1447
|
var safeGetItem = (key) => {
|
|
1449
1448
|
try {
|
|
1450
1449
|
return localStorage.getItem(key);
|
|
1451
|
-
} catch (
|
|
1450
|
+
} catch (e9) {
|
|
1452
1451
|
return null;
|
|
1453
1452
|
}
|
|
1454
1453
|
};
|
|
1455
1454
|
var safeSetItem = (key, value) => {
|
|
1456
1455
|
try {
|
|
1457
1456
|
localStorage.setItem(key, value);
|
|
1458
|
-
} catch (
|
|
1457
|
+
} catch (e10) {
|
|
1459
1458
|
}
|
|
1460
1459
|
};
|
|
1461
1460
|
var safeRemoveItem = (key) => {
|
|
1462
1461
|
try {
|
|
1463
1462
|
localStorage.removeItem(key);
|
|
1464
|
-
} catch (
|
|
1463
|
+
} catch (e11) {
|
|
1465
1464
|
}
|
|
1466
1465
|
};
|
|
1467
1466
|
var generateUUID = () => {
|
|
@@ -1650,7 +1649,7 @@ function extractUtmParams(url) {
|
|
|
1650
1649
|
if (val) result[key] = val;
|
|
1651
1650
|
});
|
|
1652
1651
|
return result;
|
|
1653
|
-
} catch (
|
|
1652
|
+
} catch (e12) {
|
|
1654
1653
|
return {};
|
|
1655
1654
|
}
|
|
1656
1655
|
}
|
|
@@ -1659,7 +1658,7 @@ function extractUtmParams(url) {
|
|
|
1659
1658
|
var safeRemoveItem2 = (key) => {
|
|
1660
1659
|
try {
|
|
1661
1660
|
localStorage.removeItem(key);
|
|
1662
|
-
} catch (
|
|
1661
|
+
} catch (e13) {
|
|
1663
1662
|
}
|
|
1664
1663
|
};
|
|
1665
1664
|
var AnalyticsEngine = class {
|
|
@@ -1878,7 +1877,7 @@ var AnalyticsEngine = class {
|
|
|
1878
1877
|
"outbound_click"
|
|
1879
1878
|
);
|
|
1880
1879
|
}
|
|
1881
|
-
} catch (
|
|
1880
|
+
} catch (e14) {
|
|
1882
1881
|
}
|
|
1883
1882
|
};
|
|
1884
1883
|
window.addEventListener("click", outboundHandler, { passive: true });
|
|
@@ -2374,7 +2373,7 @@ async function parseError(res) {
|
|
|
2374
2373
|
code: json.code || "UNKNOWN_ERROR",
|
|
2375
2374
|
message: json.message || "An error occurred during authentication"
|
|
2376
2375
|
};
|
|
2377
|
-
} catch (
|
|
2376
|
+
} catch (e15) {
|
|
2378
2377
|
return {
|
|
2379
2378
|
status: res.status,
|
|
2380
2379
|
code: "NETWORK_ERROR",
|
package/dist/react.d.cts
CHANGED
|
@@ -88,7 +88,6 @@ declare class ContentEngine {
|
|
|
88
88
|
}): Promise<T>;
|
|
89
89
|
/**
|
|
90
90
|
* Get a single item from a collection (Uses Request Batching)
|
|
91
|
-
* If you call this 10 times in a loop, it sends 1 HTTP request.
|
|
92
91
|
*/
|
|
93
92
|
getItem<T = any>(collectionId: string, itemId: string, options?: {
|
|
94
93
|
revalidate?: number | false;
|
|
@@ -152,13 +151,7 @@ declare class ContentEngine {
|
|
|
152
151
|
private getHeaders;
|
|
153
152
|
private isCacheValid;
|
|
154
153
|
private normalizeError;
|
|
155
|
-
/**
|
|
156
|
-
* Cancel ongoing requests
|
|
157
|
-
*/
|
|
158
154
|
cancelRequests(): void;
|
|
159
|
-
/**
|
|
160
|
-
* Cleanup resources
|
|
161
|
-
*/
|
|
162
155
|
private cleanup;
|
|
163
156
|
}
|
|
164
157
|
|
package/dist/react.d.ts
CHANGED
|
@@ -88,7 +88,6 @@ declare class ContentEngine {
|
|
|
88
88
|
}): Promise<T>;
|
|
89
89
|
/**
|
|
90
90
|
* Get a single item from a collection (Uses Request Batching)
|
|
91
|
-
* If you call this 10 times in a loop, it sends 1 HTTP request.
|
|
92
91
|
*/
|
|
93
92
|
getItem<T = any>(collectionId: string, itemId: string, options?: {
|
|
94
93
|
revalidate?: number | false;
|
|
@@ -152,13 +151,7 @@ declare class ContentEngine {
|
|
|
152
151
|
private getHeaders;
|
|
153
152
|
private isCacheValid;
|
|
154
153
|
private normalizeError;
|
|
155
|
-
/**
|
|
156
|
-
* Cancel ongoing requests
|
|
157
|
-
*/
|
|
158
154
|
cancelRequests(): void;
|
|
159
|
-
/**
|
|
160
|
-
* Cleanup resources
|
|
161
|
-
*/
|
|
162
155
|
private cleanup;
|
|
163
156
|
}
|
|
164
157
|
|
package/dist/react.js
CHANGED
|
@@ -647,23 +647,26 @@ var ContentEngine = class {
|
|
|
647
647
|
}
|
|
648
648
|
return includeMetadata ? cached : cached.data;
|
|
649
649
|
}
|
|
650
|
-
if (!forceRefresh
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
if (this.config.debug) {
|
|
658
|
-
console.log(
|
|
659
|
-
`[NexusHub] \u{1F4C1} Served collection '${collectionId}' from local cache.`
|
|
650
|
+
if (!forceRefresh) {
|
|
651
|
+
try {
|
|
652
|
+
const localCollection = await this.localCache.getCollection(collectionId);
|
|
653
|
+
if (localCollection) {
|
|
654
|
+
const result = this.applyLocalQuery(
|
|
655
|
+
localCollection,
|
|
656
|
+
normalizedQuery
|
|
660
657
|
);
|
|
658
|
+
if (this.config.debug) {
|
|
659
|
+
console.log(
|
|
660
|
+
`[NexusHub] \u{1F4C1} Compiled collection '${collectionId}' from local offline binaries.`
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
this.memoryCache.set(cacheKey, result, {
|
|
664
|
+
tags: [...tags, CacheTags.collection(collectionId)],
|
|
665
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
666
|
+
});
|
|
667
|
+
return result;
|
|
661
668
|
}
|
|
662
|
-
|
|
663
|
-
tags: [...tags, CacheTags.collection(collectionId)],
|
|
664
|
-
revalidate: revalidate === false ? void 0 : revalidate
|
|
665
|
-
});
|
|
666
|
-
return result;
|
|
669
|
+
} catch {
|
|
667
670
|
}
|
|
668
671
|
}
|
|
669
672
|
if (this.circuitBreaker.isOpen()) throw new Error("Circuit open");
|
|
@@ -719,14 +722,17 @@ var ContentEngine = class {
|
|
|
719
722
|
return cached;
|
|
720
723
|
}
|
|
721
724
|
}
|
|
722
|
-
if (!forceRefresh
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
725
|
+
if (!forceRefresh) {
|
|
726
|
+
try {
|
|
727
|
+
const localGlobals = await this.localCache.getGlobals();
|
|
728
|
+
if (localGlobals) {
|
|
729
|
+
this.memoryCache.set(cacheKey, localGlobals, {
|
|
730
|
+
tags: [CacheTags.global],
|
|
731
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
732
|
+
});
|
|
733
|
+
return localGlobals;
|
|
734
|
+
}
|
|
735
|
+
} catch {
|
|
730
736
|
}
|
|
731
737
|
}
|
|
732
738
|
try {
|
|
@@ -758,7 +764,6 @@ var ContentEngine = class {
|
|
|
758
764
|
}
|
|
759
765
|
/**
|
|
760
766
|
* Get a single item from a collection (Uses Request Batching)
|
|
761
|
-
* If you call this 10 times in a loop, it sends 1 HTTP request.
|
|
762
767
|
*/
|
|
763
768
|
async getItem(collectionId, itemId, options = {}) {
|
|
764
769
|
const cacheKey = `item:${collectionId}:${itemId}`;
|
|
@@ -912,21 +917,22 @@ var ContentEngine = class {
|
|
|
912
917
|
};
|
|
913
918
|
}
|
|
914
919
|
}
|
|
915
|
-
if (
|
|
916
|
-
|
|
917
|
-
|
|
920
|
+
if (key.startsWith("page:")) {
|
|
921
|
+
const slug = key.split(":")[1];
|
|
922
|
+
try {
|
|
918
923
|
const local = await this.localCache.getPage(slug);
|
|
919
924
|
if (local) {
|
|
920
925
|
return {
|
|
921
926
|
data: local,
|
|
922
927
|
metadata: {
|
|
923
|
-
timestamp:
|
|
928
|
+
timestamp: Date.now(),
|
|
924
929
|
expiresAt: Infinity,
|
|
925
930
|
tags: [],
|
|
926
931
|
etag: void 0
|
|
927
932
|
}
|
|
928
933
|
};
|
|
929
934
|
}
|
|
935
|
+
} catch {
|
|
930
936
|
}
|
|
931
937
|
}
|
|
932
938
|
return null;
|
|
@@ -1118,7 +1124,6 @@ var ContentEngine = class {
|
|
|
1118
1124
|
const response = await fetch(url, {
|
|
1119
1125
|
...fetchOptions,
|
|
1120
1126
|
...nextConfig,
|
|
1121
|
-
// Inject Next.js tags
|
|
1122
1127
|
signal: controller.signal
|
|
1123
1128
|
});
|
|
1124
1129
|
clearTimeout(id);
|
|
@@ -1151,18 +1156,12 @@ var ContentEngine = class {
|
|
|
1151
1156
|
}
|
|
1152
1157
|
return new Error(`${context}: ${String(error)}`);
|
|
1153
1158
|
}
|
|
1154
|
-
/**
|
|
1155
|
-
* Cancel ongoing requests
|
|
1156
|
-
*/
|
|
1157
1159
|
cancelRequests() {
|
|
1158
1160
|
if (this.abortController) {
|
|
1159
1161
|
this.abortController.abort();
|
|
1160
1162
|
this.abortController = new AbortController();
|
|
1161
1163
|
}
|
|
1162
1164
|
}
|
|
1163
|
-
/**
|
|
1164
|
-
* Cleanup resources
|
|
1165
|
-
*/
|
|
1166
1165
|
cleanup() {
|
|
1167
1166
|
this.cancelRequests();
|
|
1168
1167
|
if (!this.isServer) {
|