@nexushub/client 0.7.0 → 0.7.2

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 CHANGED
@@ -1048,7 +1048,7 @@ var ContentEngine = class {
1048
1048
  }
1049
1049
  return includeMetadata ? cached : cached.data;
1050
1050
  }
1051
- if (!forceRefresh && process.env.NODE_ENV === "development") {
1051
+ if (!forceRefresh && this.localCache.isLoaded()) {
1052
1052
  const localCollection = await this.localCache.getCollection(collectionId);
1053
1053
  if (localCollection) {
1054
1054
  const result = this.applyLocalQuery(
@@ -1057,7 +1057,7 @@ var ContentEngine = class {
1057
1057
  );
1058
1058
  if (this.config.debug) {
1059
1059
  console.log(
1060
- `[NexusHub] \u{1F4C1} Served collection '${collectionId}' from local cache.`
1060
+ `[NexusHub] \u{1F4C1} Compiled collection '${collectionId}' from local offline binaries.`
1061
1061
  );
1062
1062
  }
1063
1063
  this.memoryCache.set(cacheKey, result, {
@@ -1120,8 +1120,8 @@ var ContentEngine = class {
1120
1120
  return cached;
1121
1121
  }
1122
1122
  }
1123
- if (!forceRefresh && process.env.NODE_ENV === "development") {
1124
- const localGlobals = this.localCache.getGlobals();
1123
+ if (!forceRefresh && this.localCache.isLoaded()) {
1124
+ const localGlobals = await this.localCache.getGlobals();
1125
1125
  if (localGlobals) {
1126
1126
  this.memoryCache.set(cacheKey, localGlobals, {
1127
1127
  tags: [CacheTags.global],
@@ -1159,7 +1159,6 @@ var ContentEngine = class {
1159
1159
  }
1160
1160
  /**
1161
1161
  * 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
1162
  */
1164
1163
  async getItem(collectionId, itemId, options = {}) {
1165
1164
  const cacheKey = `item:${collectionId}:${itemId}`;
@@ -1313,7 +1312,7 @@ var ContentEngine = class {
1313
1312
  };
1314
1313
  }
1315
1314
  }
1316
- if (process.env.NODE_ENV === "development") {
1315
+ if (this.localCache.isLoaded()) {
1317
1316
  if (key.startsWith("page:")) {
1318
1317
  const slug = key.split(":")[1];
1319
1318
  const local = await this.localCache.getPage(slug);
@@ -1321,7 +1320,7 @@ var ContentEngine = class {
1321
1320
  return {
1322
1321
  data: local,
1323
1322
  metadata: {
1324
- timestamp: 0,
1323
+ timestamp: Date.now(),
1325
1324
  expiresAt: Infinity,
1326
1325
  tags: [],
1327
1326
  etag: void 0
@@ -1519,7 +1518,6 @@ var ContentEngine = class {
1519
1518
  const response = await fetch(url, {
1520
1519
  ...fetchOptions,
1521
1520
  ...nextConfig,
1522
- // Inject Next.js tags
1523
1521
  signal: controller.signal
1524
1522
  });
1525
1523
  clearTimeout(id);
@@ -1552,18 +1550,12 @@ var ContentEngine = class {
1552
1550
  }
1553
1551
  return new Error(`${context}: ${String(error)}`);
1554
1552
  }
1555
- /**
1556
- * Cancel ongoing requests
1557
- */
1558
1553
  cancelRequests() {
1559
1554
  if (this.abortController) {
1560
1555
  this.abortController.abort();
1561
1556
  this.abortController = new AbortController();
1562
1557
  }
1563
1558
  }
1564
- /**
1565
- * Cleanup resources
1566
- */
1567
1559
  cleanup() {
1568
1560
  this.cancelRequests();
1569
1561
  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,7 +1002,7 @@ var ContentEngine = class {
1002
1002
  }
1003
1003
  return includeMetadata ? cached : cached.data;
1004
1004
  }
1005
- if (!forceRefresh && process.env.NODE_ENV === "development") {
1005
+ if (!forceRefresh && this.localCache.isLoaded()) {
1006
1006
  const localCollection = await this.localCache.getCollection(collectionId);
1007
1007
  if (localCollection) {
1008
1008
  const result = this.applyLocalQuery(
@@ -1011,7 +1011,7 @@ var ContentEngine = class {
1011
1011
  );
1012
1012
  if (this.config.debug) {
1013
1013
  console.log(
1014
- `[NexusHub] \u{1F4C1} Served collection '${collectionId}' from local cache.`
1014
+ `[NexusHub] \u{1F4C1} Compiled collection '${collectionId}' from local offline binaries.`
1015
1015
  );
1016
1016
  }
1017
1017
  this.memoryCache.set(cacheKey, result, {
@@ -1074,8 +1074,8 @@ var ContentEngine = class {
1074
1074
  return cached;
1075
1075
  }
1076
1076
  }
1077
- if (!forceRefresh && process.env.NODE_ENV === "development") {
1078
- const localGlobals = this.localCache.getGlobals();
1077
+ if (!forceRefresh && this.localCache.isLoaded()) {
1078
+ const localGlobals = await this.localCache.getGlobals();
1079
1079
  if (localGlobals) {
1080
1080
  this.memoryCache.set(cacheKey, localGlobals, {
1081
1081
  tags: [CacheTags.global],
@@ -1113,7 +1113,6 @@ var ContentEngine = class {
1113
1113
  }
1114
1114
  /**
1115
1115
  * 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
1116
  */
1118
1117
  async getItem(collectionId, itemId, options = {}) {
1119
1118
  const cacheKey = `item:${collectionId}:${itemId}`;
@@ -1267,7 +1266,7 @@ var ContentEngine = class {
1267
1266
  };
1268
1267
  }
1269
1268
  }
1270
- if (process.env.NODE_ENV === "development") {
1269
+ if (this.localCache.isLoaded()) {
1271
1270
  if (key.startsWith("page:")) {
1272
1271
  const slug = key.split(":")[1];
1273
1272
  const local = await this.localCache.getPage(slug);
@@ -1275,7 +1274,7 @@ var ContentEngine = class {
1275
1274
  return {
1276
1275
  data: local,
1277
1276
  metadata: {
1278
- timestamp: 0,
1277
+ timestamp: Date.now(),
1279
1278
  expiresAt: Infinity,
1280
1279
  tags: [],
1281
1280
  etag: void 0
@@ -1473,7 +1472,6 @@ var ContentEngine = class {
1473
1472
  const response = await fetch(url, {
1474
1473
  ...fetchOptions,
1475
1474
  ...nextConfig,
1476
- // Inject Next.js tags
1477
1475
  signal: controller.signal
1478
1476
  });
1479
1477
  clearTimeout(id);
@@ -1506,18 +1504,12 @@ var ContentEngine = class {
1506
1504
  }
1507
1505
  return new Error(`${context}: ${String(error)}`);
1508
1506
  }
1509
- /**
1510
- * Cancel ongoing requests
1511
- */
1512
1507
  cancelRequests() {
1513
1508
  if (this.abortController) {
1514
1509
  this.abortController.abort();
1515
1510
  this.abortController = new AbortController();
1516
1511
  }
1517
1512
  }
1518
- /**
1519
- * Cleanup resources
1520
- */
1521
1513
  cleanup() {
1522
1514
  this.cancelRequests();
1523
1515
  if (!this.isServer) {
package/dist/react.cjs CHANGED
@@ -647,7 +647,7 @@ var ContentEngine = class {
647
647
  }
648
648
  return includeMetadata ? cached : cached.data;
649
649
  }
650
- if (!forceRefresh && process.env.NODE_ENV === "development") {
650
+ if (!forceRefresh && this.localCache.isLoaded()) {
651
651
  const localCollection = await this.localCache.getCollection(collectionId);
652
652
  if (localCollection) {
653
653
  const result = this.applyLocalQuery(
@@ -656,7 +656,7 @@ var ContentEngine = class {
656
656
  );
657
657
  if (this.config.debug) {
658
658
  console.log(
659
- `[NexusHub] \u{1F4C1} Served collection '${collectionId}' from local cache.`
659
+ `[NexusHub] \u{1F4C1} Compiled collection '${collectionId}' from local offline binaries.`
660
660
  );
661
661
  }
662
662
  this.memoryCache.set(cacheKey, result, {
@@ -719,8 +719,8 @@ var ContentEngine = class {
719
719
  return cached;
720
720
  }
721
721
  }
722
- if (!forceRefresh && process.env.NODE_ENV === "development") {
723
- const localGlobals = this.localCache.getGlobals();
722
+ if (!forceRefresh && this.localCache.isLoaded()) {
723
+ const localGlobals = await this.localCache.getGlobals();
724
724
  if (localGlobals) {
725
725
  this.memoryCache.set(cacheKey, localGlobals, {
726
726
  tags: [CacheTags.global],
@@ -758,7 +758,6 @@ var ContentEngine = class {
758
758
  }
759
759
  /**
760
760
  * 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
761
  */
763
762
  async getItem(collectionId, itemId, options = {}) {
764
763
  const cacheKey = `item:${collectionId}:${itemId}`;
@@ -912,7 +911,7 @@ var ContentEngine = class {
912
911
  };
913
912
  }
914
913
  }
915
- if (process.env.NODE_ENV === "development") {
914
+ if (this.localCache.isLoaded()) {
916
915
  if (key.startsWith("page:")) {
917
916
  const slug = key.split(":")[1];
918
917
  const local = await this.localCache.getPage(slug);
@@ -920,7 +919,7 @@ var ContentEngine = class {
920
919
  return {
921
920
  data: local,
922
921
  metadata: {
923
- timestamp: 0,
922
+ timestamp: Date.now(),
924
923
  expiresAt: Infinity,
925
924
  tags: [],
926
925
  etag: void 0
@@ -1118,7 +1117,6 @@ var ContentEngine = class {
1118
1117
  const response = await fetch(url, {
1119
1118
  ...fetchOptions,
1120
1119
  ...nextConfig,
1121
- // Inject Next.js tags
1122
1120
  signal: controller.signal
1123
1121
  });
1124
1122
  clearTimeout(id);
@@ -1151,18 +1149,12 @@ var ContentEngine = class {
1151
1149
  }
1152
1150
  return new Error(`${context}: ${String(error)}`);
1153
1151
  }
1154
- /**
1155
- * Cancel ongoing requests
1156
- */
1157
1152
  cancelRequests() {
1158
1153
  if (this.abortController) {
1159
1154
  this.abortController.abort();
1160
1155
  this.abortController = new AbortController();
1161
1156
  }
1162
1157
  }
1163
- /**
1164
- * Cleanup resources
1165
- */
1166
1158
  cleanup() {
1167
1159
  this.cancelRequests();
1168
1160
  if (!this.isServer) {
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,7 +647,7 @@ var ContentEngine = class {
647
647
  }
648
648
  return includeMetadata ? cached : cached.data;
649
649
  }
650
- if (!forceRefresh && process.env.NODE_ENV === "development") {
650
+ if (!forceRefresh && this.localCache.isLoaded()) {
651
651
  const localCollection = await this.localCache.getCollection(collectionId);
652
652
  if (localCollection) {
653
653
  const result = this.applyLocalQuery(
@@ -656,7 +656,7 @@ var ContentEngine = class {
656
656
  );
657
657
  if (this.config.debug) {
658
658
  console.log(
659
- `[NexusHub] \u{1F4C1} Served collection '${collectionId}' from local cache.`
659
+ `[NexusHub] \u{1F4C1} Compiled collection '${collectionId}' from local offline binaries.`
660
660
  );
661
661
  }
662
662
  this.memoryCache.set(cacheKey, result, {
@@ -719,8 +719,8 @@ var ContentEngine = class {
719
719
  return cached;
720
720
  }
721
721
  }
722
- if (!forceRefresh && process.env.NODE_ENV === "development") {
723
- const localGlobals = this.localCache.getGlobals();
722
+ if (!forceRefresh && this.localCache.isLoaded()) {
723
+ const localGlobals = await this.localCache.getGlobals();
724
724
  if (localGlobals) {
725
725
  this.memoryCache.set(cacheKey, localGlobals, {
726
726
  tags: [CacheTags.global],
@@ -758,7 +758,6 @@ var ContentEngine = class {
758
758
  }
759
759
  /**
760
760
  * 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
761
  */
763
762
  async getItem(collectionId, itemId, options = {}) {
764
763
  const cacheKey = `item:${collectionId}:${itemId}`;
@@ -912,7 +911,7 @@ var ContentEngine = class {
912
911
  };
913
912
  }
914
913
  }
915
- if (process.env.NODE_ENV === "development") {
914
+ if (this.localCache.isLoaded()) {
916
915
  if (key.startsWith("page:")) {
917
916
  const slug = key.split(":")[1];
918
917
  const local = await this.localCache.getPage(slug);
@@ -920,7 +919,7 @@ var ContentEngine = class {
920
919
  return {
921
920
  data: local,
922
921
  metadata: {
923
- timestamp: 0,
922
+ timestamp: Date.now(),
924
923
  expiresAt: Infinity,
925
924
  tags: [],
926
925
  etag: void 0
@@ -1118,7 +1117,6 @@ var ContentEngine = class {
1118
1117
  const response = await fetch(url, {
1119
1118
  ...fetchOptions,
1120
1119
  ...nextConfig,
1121
- // Inject Next.js tags
1122
1120
  signal: controller.signal
1123
1121
  });
1124
1122
  clearTimeout(id);
@@ -1151,18 +1149,12 @@ var ContentEngine = class {
1151
1149
  }
1152
1150
  return new Error(`${context}: ${String(error)}`);
1153
1151
  }
1154
- /**
1155
- * Cancel ongoing requests
1156
- */
1157
1152
  cancelRequests() {
1158
1153
  if (this.abortController) {
1159
1154
  this.abortController.abort();
1160
1155
  this.abortController = new AbortController();
1161
1156
  }
1162
1157
  }
1163
- /**
1164
- * Cleanup resources
1165
- */
1166
1158
  cleanup() {
1167
1159
  this.cancelRequests();
1168
1160
  if (!this.isServer) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nexushub/client",
3
3
  "private": false,
4
- "version": "0.7.0",
4
+ "version": "0.7.2",
5
5
  "description": "The God-Tier NexusHub SDK",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",