@nexushub/client 0.5.9 → 0.6.1
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/{chunk-NOIMIIA5.js → chunk-HUABKET6.js} +2 -2
- package/dist/{chunk-VFVPDENW.cjs → chunk-WZ47UVA2.cjs} +2 -2
- package/dist/cli.cjs +34 -34
- package/dist/content/local-cache-server.cjs +2 -2
- package/dist/content/local-cache-server.js +2 -2
- package/dist/index.cjs +13 -50
- package/dist/index.d.cts +11 -23
- package/dist/index.d.ts +11 -23
- package/dist/index.js +13 -50
- package/dist/{local-cache-server-VL4YNBME.js → local-cache-server-667T23JJ.js} +1 -1
- package/dist/{local-cache-server-SGSGWUCL.cjs → local-cache-server-S5KIABVH.cjs} +2 -2
- package/dist/react.cjs +15 -52
- package/dist/react.d.cts +9 -21
- package/dist/react.d.ts +9 -21
- package/dist/react.js +13 -50
- package/dist/studio/assets/{BoQ-SWw9.js → Bqyy7TUK.js} +1 -1
- package/dist/studio/index.html +1 -1
- package/package.json +1 -1
package/dist/react.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkWZ47UVA2cjs = require('./chunk-WZ47UVA2.cjs');
|
|
5
5
|
|
|
6
6
|
// src/components/NexusProvider.tsx
|
|
7
7
|
|
|
@@ -282,7 +282,7 @@ var LocalCacheProxy = class {
|
|
|
282
282
|
async getInstance() {
|
|
283
283
|
if (this.instance) return this.instance;
|
|
284
284
|
if (typeof window === "undefined") {
|
|
285
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./local-cache-server-
|
|
285
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./local-cache-server-S5KIABVH.cjs")));
|
|
286
286
|
this.instance = new mod.LocalCache(this.cachePath);
|
|
287
287
|
} else {
|
|
288
288
|
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./local-cache-client-IGAL7SZ6.cjs")));
|
|
@@ -535,7 +535,7 @@ var ContentEngine = class {
|
|
|
535
535
|
});
|
|
536
536
|
this.requestBatcher = new RequestBatcher(20, 50);
|
|
537
537
|
this.circuitBreaker = new CircuitBreaker();
|
|
538
|
-
this.defaultRevalidate = config.revalidateTime ||
|
|
538
|
+
this.defaultRevalidate = config.revalidateTime || false;
|
|
539
539
|
this.cacheStrategy = config.cacheStrategy || "memory";
|
|
540
540
|
if (!this.isServer) {
|
|
541
541
|
window.addEventListener("beforeunload", this.cleanup.bind(this));
|
|
@@ -661,7 +661,7 @@ var ContentEngine = class {
|
|
|
661
661
|
}
|
|
662
662
|
this.memoryCache.set(cacheKey, result, {
|
|
663
663
|
tags: [...tags, CacheTags.collection(collectionId)],
|
|
664
|
-
revalidate
|
|
664
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
665
665
|
});
|
|
666
666
|
return result;
|
|
667
667
|
}
|
|
@@ -724,7 +724,7 @@ var ContentEngine = class {
|
|
|
724
724
|
if (localGlobals) {
|
|
725
725
|
this.memoryCache.set(cacheKey, localGlobals, {
|
|
726
726
|
tags: [CacheTags.global],
|
|
727
|
-
revalidate
|
|
727
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
728
728
|
});
|
|
729
729
|
return localGlobals;
|
|
730
730
|
}
|
|
@@ -932,54 +932,15 @@ var ContentEngine = class {
|
|
|
932
932
|
return null;
|
|
933
933
|
}
|
|
934
934
|
writeCache(key, data, options) {
|
|
935
|
+
const numericRevalidate = options.revalidate === false ? 31536e5 : options.revalidate;
|
|
935
936
|
if (this.cacheStrategy === "memory") {
|
|
936
937
|
this.memoryCache.set(key, data, {
|
|
937
938
|
tags: options.tags,
|
|
938
|
-
revalidate:
|
|
939
|
+
revalidate: numericRevalidate
|
|
939
940
|
});
|
|
940
941
|
}
|
|
941
942
|
if (!this.isServer && this.cacheStrategy === "localStorage" && this.browserCache) {
|
|
942
|
-
this.browserCache.set(key, data,
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
// packages/client-sdk/src/content/index.ts
|
|
946
|
-
/**
|
|
947
|
-
* ⚡ THE PULSE: Next.js Cache Revalidation Receiver
|
|
948
|
-
* Used in app/api/nexus-revalidate/route.ts to handle instant updates from the NexusHub backend.
|
|
949
|
-
*
|
|
950
|
-
* @param req The incoming Request object from Next.js
|
|
951
|
-
* @param revalidateFn The revalidateTag function imported from 'next/cache'
|
|
952
|
-
*/
|
|
953
|
-
async handleRevalidation(req, revalidateFn) {
|
|
954
|
-
try {
|
|
955
|
-
if (!req.body) {
|
|
956
|
-
return { success: false, message: "Missing Pulse Payload" };
|
|
957
|
-
}
|
|
958
|
-
const body = await req.json();
|
|
959
|
-
const { secret, tag } = body;
|
|
960
|
-
if (!secret || secret !== this.config.projectId) {
|
|
961
|
-
if (this.config.debug) {
|
|
962
|
-
console.warn(`[NexusHub] \u26A0\uFE0F Blocked unauthorized Pulse request.`);
|
|
963
|
-
}
|
|
964
|
-
return { success: false, message: "Invalid Pulse Signature" };
|
|
965
|
-
}
|
|
966
|
-
const targetTag = tag || "content_all";
|
|
967
|
-
revalidateFn(targetTag);
|
|
968
|
-
this.invalidateCache([targetTag]);
|
|
969
|
-
if (this.config.debug) {
|
|
970
|
-
console.log(
|
|
971
|
-
`[NexusHub] \u26A1 Pulse Received: Successfully revalidated tag [${targetTag}]`
|
|
972
|
-
);
|
|
973
|
-
}
|
|
974
|
-
return { success: true, now: Date.now() };
|
|
975
|
-
} catch (e) {
|
|
976
|
-
if (this.config.debug) {
|
|
977
|
-
console.error(`[NexusHub] \u274C Pulse Processing Error:`, e.message);
|
|
978
|
-
}
|
|
979
|
-
return {
|
|
980
|
-
success: false,
|
|
981
|
-
message: "Malformed Pulse Payload or Processing Error"
|
|
982
|
-
};
|
|
943
|
+
this.browserCache.set(key, data, numericRevalidate * 1e3);
|
|
983
944
|
}
|
|
984
945
|
}
|
|
985
946
|
/**
|
|
@@ -1024,6 +985,7 @@ var ContentEngine = class {
|
|
|
1024
985
|
if (this.config.debug) {
|
|
1025
986
|
console.log(`[NexusHub] \u{1F310} Fetching: ${url}`);
|
|
1026
987
|
}
|
|
988
|
+
const expiresAt = revalidate === false ? Infinity : Date.now() + revalidate * 1e3;
|
|
1027
989
|
const res = await this.fetchWithTimeout(url, {
|
|
1028
990
|
method: "GET",
|
|
1029
991
|
headers: this.getHeaders(),
|
|
@@ -1045,7 +1007,7 @@ var ContentEngine = class {
|
|
|
1045
1007
|
metadata: {
|
|
1046
1008
|
timestamp: Date.now(),
|
|
1047
1009
|
etag: etag || void 0,
|
|
1048
|
-
expiresAt
|
|
1010
|
+
expiresAt,
|
|
1049
1011
|
tags: [...tags, CacheTags.content(slug)]
|
|
1050
1012
|
}
|
|
1051
1013
|
};
|
|
@@ -1076,12 +1038,13 @@ var ContentEngine = class {
|
|
|
1076
1038
|
}
|
|
1077
1039
|
const json = await res.json();
|
|
1078
1040
|
const etag = res.headers.get("etag");
|
|
1041
|
+
const expiresAt = revalidate === false ? Infinity : Date.now() + revalidate * 1e3;
|
|
1079
1042
|
const cacheEntry = {
|
|
1080
1043
|
data: json,
|
|
1081
1044
|
metadata: {
|
|
1082
1045
|
timestamp: Date.now(),
|
|
1083
1046
|
etag: etag || void 0,
|
|
1084
|
-
expiresAt
|
|
1047
|
+
expiresAt,
|
|
1085
1048
|
tags: [...tags, CacheTags.collection(collectionId)]
|
|
1086
1049
|
}
|
|
1087
1050
|
};
|
|
@@ -2180,16 +2143,16 @@ function getSelector(el, depth = 0) {
|
|
|
2180
2143
|
// src/client.ts
|
|
2181
2144
|
var NexusClient = class {
|
|
2182
2145
|
constructor(config) {
|
|
2183
|
-
const fullConfig =
|
|
2146
|
+
const fullConfig = _chunkWZ47UVA2cjs.getFullConfig.call(void 0, config);
|
|
2184
2147
|
this.config = {
|
|
2185
2148
|
debug: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _41 => _41.debug]), () => ( false)),
|
|
2186
2149
|
cacheStrategy: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _42 => _42.cacheStrategy]), () => ( "memory")),
|
|
2187
|
-
revalidateTime: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _43 => _43.revalidateTime]), () => (
|
|
2150
|
+
revalidateTime: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _43 => _43.revalidateTime]), () => ( false)),
|
|
2188
2151
|
timeout: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _44 => _44.timeout]), () => ( 1e4)),
|
|
2189
2152
|
retries: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _45 => _45.retries]), () => ( 3)),
|
|
2190
2153
|
...fullConfig
|
|
2191
2154
|
};
|
|
2192
|
-
const errors =
|
|
2155
|
+
const errors = _chunkWZ47UVA2cjs.validateConfig.call(void 0, this.config);
|
|
2193
2156
|
if (errors.length > 0) {
|
|
2194
2157
|
console.warn("\u26A0\uFE0F NexusHub: Configuration issues:", errors.join(", "));
|
|
2195
2158
|
if (!this.config.projectId) {
|
package/dist/react.d.cts
CHANGED
|
@@ -10,8 +10,8 @@ interface MinimalNexusConfig {
|
|
|
10
10
|
|
|
11
11
|
interface NexusConfig extends MinimalNexusConfig {
|
|
12
12
|
debug?: boolean;
|
|
13
|
-
cacheStrategy?:
|
|
14
|
-
revalidateTime?: number;
|
|
13
|
+
cacheStrategy?: "memory" | "localStorage" | "none";
|
|
14
|
+
revalidateTime?: number | false;
|
|
15
15
|
timeout?: number;
|
|
16
16
|
retries?: number;
|
|
17
17
|
}
|
|
@@ -37,7 +37,7 @@ interface CollectionQuery {
|
|
|
37
37
|
page?: number;
|
|
38
38
|
limit?: number;
|
|
39
39
|
sort?: string;
|
|
40
|
-
order?:
|
|
40
|
+
order?: "asc" | "desc";
|
|
41
41
|
filter?: Record<string, any>;
|
|
42
42
|
fields?: string[];
|
|
43
43
|
search?: string;
|
|
@@ -62,7 +62,7 @@ declare class ContentEngine {
|
|
|
62
62
|
* Fetch a Single Page with full strategy pipeline
|
|
63
63
|
*/
|
|
64
64
|
getPage<T = any>(slug: string, options?: {
|
|
65
|
-
revalidate?: number;
|
|
65
|
+
revalidate?: number | false;
|
|
66
66
|
tags?: string[];
|
|
67
67
|
forceRefresh?: boolean;
|
|
68
68
|
includeMetadata?: boolean;
|
|
@@ -72,7 +72,7 @@ declare class ContentEngine {
|
|
|
72
72
|
* Fetch a Collection (Optimized)
|
|
73
73
|
*/
|
|
74
74
|
getCollection<T = any>(collectionId: string, query?: CollectionQuery, options?: {
|
|
75
|
-
revalidate?: number;
|
|
75
|
+
revalidate?: number | false;
|
|
76
76
|
tags?: string[];
|
|
77
77
|
forceRefresh?: boolean;
|
|
78
78
|
includeMetadata?: boolean;
|
|
@@ -83,7 +83,7 @@ declare class ContentEngine {
|
|
|
83
83
|
*/
|
|
84
84
|
getGlobals<T = any>(options?: {
|
|
85
85
|
include?: string[];
|
|
86
|
-
revalidate?: number;
|
|
86
|
+
revalidate?: number | false;
|
|
87
87
|
forceRefresh?: boolean;
|
|
88
88
|
}): Promise<T>;
|
|
89
89
|
/**
|
|
@@ -91,7 +91,7 @@ declare class ContentEngine {
|
|
|
91
91
|
* If you call this 10 times in a loop, it sends 1 HTTP request.
|
|
92
92
|
*/
|
|
93
93
|
getItem<T = any>(collectionId: string, itemId: string, options?: {
|
|
94
|
-
revalidate?: number;
|
|
94
|
+
revalidate?: number | false;
|
|
95
95
|
tags?: string[];
|
|
96
96
|
include?: string[];
|
|
97
97
|
}): Promise<T>;
|
|
@@ -102,7 +102,7 @@ declare class ContentEngine {
|
|
|
102
102
|
collections?: string[];
|
|
103
103
|
fields?: string[];
|
|
104
104
|
limit?: number;
|
|
105
|
-
revalidate?: number;
|
|
105
|
+
revalidate?: number | false;
|
|
106
106
|
}): Promise<{
|
|
107
107
|
results: T[];
|
|
108
108
|
total: number;
|
|
@@ -120,18 +120,6 @@ declare class ContentEngine {
|
|
|
120
120
|
*/
|
|
121
121
|
private checkCaches;
|
|
122
122
|
private writeCache;
|
|
123
|
-
/**
|
|
124
|
-
* ⚡ THE PULSE: Next.js Cache Revalidation Receiver
|
|
125
|
-
* Used in app/api/nexus-revalidate/route.ts to handle instant updates from the NexusHub backend.
|
|
126
|
-
*
|
|
127
|
-
* @param req The incoming Request object from Next.js
|
|
128
|
-
* @param revalidateFn The revalidateTag function imported from 'next/cache'
|
|
129
|
-
*/
|
|
130
|
-
handleRevalidation(req: Request, revalidateFn: (tag: string) => void): Promise<{
|
|
131
|
-
success: boolean;
|
|
132
|
-
message?: string;
|
|
133
|
-
now?: number;
|
|
134
|
-
}>;
|
|
135
123
|
/**
|
|
136
124
|
* Invalidate cache by tags
|
|
137
125
|
*/
|
|
@@ -485,4 +473,4 @@ interface NexusBooleanProps {
|
|
|
485
473
|
*/
|
|
486
474
|
declare function NexusBoolean({ value, className, trueLabel, falseLabel, }: NexusBooleanProps): react_jsx_runtime.JSX.Element | null;
|
|
487
475
|
|
|
488
|
-
export { AuthProvider, NexusAddress, type NexusAddressProps, NexusBlendContainer, type NexusBlendContainerProps, NexusBoolean, type NexusBooleanProps, NexusCode, type NexusCodeProps, NexusColor, type NexusColorProps, NexusGallery, type NexusGalleryProps, NexusGradient, type NexusGradientProps, NexusIcon, type NexusIconProps, NexusImage, type NexusImageProps, NexusKeyValue, type NexusKeyValueProps, NexusLongText, type NexusLongTextProps, NexusMap, type NexusMapProps, NexusProgress, type NexusProgressProps, NexusProvider, NexusRichText, type NexusRichTextProps, NexusTags, type NexusTagsProps, NexusVideo, type NexusVideoProps, useNexus, useNexusAnalytics, useNexusAuth, useNexusLiveFeed };
|
|
476
|
+
export { AuthProvider, type LiveAnalyticsEvent, NexusAddress, type NexusAddressProps, NexusBlendContainer, type NexusBlendContainerProps, NexusBoolean, type NexusBooleanProps, NexusCode, type NexusCodeProps, NexusColor, type NexusColorProps, NexusGallery, type NexusGalleryProps, NexusGradient, type NexusGradientProps, NexusIcon, type NexusIconProps, NexusImage, type NexusImageProps, NexusKeyValue, type NexusKeyValueProps, NexusLongText, type NexusLongTextProps, NexusMap, type NexusMapProps, NexusProgress, type NexusProgressProps, NexusProvider, type NexusProviderProps, NexusRichText, type NexusRichTextProps, NexusTags, type NexusTagsProps, NexusVideo, type NexusVideoProps, useNexus, useNexusAnalytics, useNexusAuth, useNexusLiveFeed };
|
package/dist/react.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ interface MinimalNexusConfig {
|
|
|
10
10
|
|
|
11
11
|
interface NexusConfig extends MinimalNexusConfig {
|
|
12
12
|
debug?: boolean;
|
|
13
|
-
cacheStrategy?:
|
|
14
|
-
revalidateTime?: number;
|
|
13
|
+
cacheStrategy?: "memory" | "localStorage" | "none";
|
|
14
|
+
revalidateTime?: number | false;
|
|
15
15
|
timeout?: number;
|
|
16
16
|
retries?: number;
|
|
17
17
|
}
|
|
@@ -37,7 +37,7 @@ interface CollectionQuery {
|
|
|
37
37
|
page?: number;
|
|
38
38
|
limit?: number;
|
|
39
39
|
sort?: string;
|
|
40
|
-
order?:
|
|
40
|
+
order?: "asc" | "desc";
|
|
41
41
|
filter?: Record<string, any>;
|
|
42
42
|
fields?: string[];
|
|
43
43
|
search?: string;
|
|
@@ -62,7 +62,7 @@ declare class ContentEngine {
|
|
|
62
62
|
* Fetch a Single Page with full strategy pipeline
|
|
63
63
|
*/
|
|
64
64
|
getPage<T = any>(slug: string, options?: {
|
|
65
|
-
revalidate?: number;
|
|
65
|
+
revalidate?: number | false;
|
|
66
66
|
tags?: string[];
|
|
67
67
|
forceRefresh?: boolean;
|
|
68
68
|
includeMetadata?: boolean;
|
|
@@ -72,7 +72,7 @@ declare class ContentEngine {
|
|
|
72
72
|
* Fetch a Collection (Optimized)
|
|
73
73
|
*/
|
|
74
74
|
getCollection<T = any>(collectionId: string, query?: CollectionQuery, options?: {
|
|
75
|
-
revalidate?: number;
|
|
75
|
+
revalidate?: number | false;
|
|
76
76
|
tags?: string[];
|
|
77
77
|
forceRefresh?: boolean;
|
|
78
78
|
includeMetadata?: boolean;
|
|
@@ -83,7 +83,7 @@ declare class ContentEngine {
|
|
|
83
83
|
*/
|
|
84
84
|
getGlobals<T = any>(options?: {
|
|
85
85
|
include?: string[];
|
|
86
|
-
revalidate?: number;
|
|
86
|
+
revalidate?: number | false;
|
|
87
87
|
forceRefresh?: boolean;
|
|
88
88
|
}): Promise<T>;
|
|
89
89
|
/**
|
|
@@ -91,7 +91,7 @@ declare class ContentEngine {
|
|
|
91
91
|
* If you call this 10 times in a loop, it sends 1 HTTP request.
|
|
92
92
|
*/
|
|
93
93
|
getItem<T = any>(collectionId: string, itemId: string, options?: {
|
|
94
|
-
revalidate?: number;
|
|
94
|
+
revalidate?: number | false;
|
|
95
95
|
tags?: string[];
|
|
96
96
|
include?: string[];
|
|
97
97
|
}): Promise<T>;
|
|
@@ -102,7 +102,7 @@ declare class ContentEngine {
|
|
|
102
102
|
collections?: string[];
|
|
103
103
|
fields?: string[];
|
|
104
104
|
limit?: number;
|
|
105
|
-
revalidate?: number;
|
|
105
|
+
revalidate?: number | false;
|
|
106
106
|
}): Promise<{
|
|
107
107
|
results: T[];
|
|
108
108
|
total: number;
|
|
@@ -120,18 +120,6 @@ declare class ContentEngine {
|
|
|
120
120
|
*/
|
|
121
121
|
private checkCaches;
|
|
122
122
|
private writeCache;
|
|
123
|
-
/**
|
|
124
|
-
* ⚡ THE PULSE: Next.js Cache Revalidation Receiver
|
|
125
|
-
* Used in app/api/nexus-revalidate/route.ts to handle instant updates from the NexusHub backend.
|
|
126
|
-
*
|
|
127
|
-
* @param req The incoming Request object from Next.js
|
|
128
|
-
* @param revalidateFn The revalidateTag function imported from 'next/cache'
|
|
129
|
-
*/
|
|
130
|
-
handleRevalidation(req: Request, revalidateFn: (tag: string) => void): Promise<{
|
|
131
|
-
success: boolean;
|
|
132
|
-
message?: string;
|
|
133
|
-
now?: number;
|
|
134
|
-
}>;
|
|
135
123
|
/**
|
|
136
124
|
* Invalidate cache by tags
|
|
137
125
|
*/
|
|
@@ -485,4 +473,4 @@ interface NexusBooleanProps {
|
|
|
485
473
|
*/
|
|
486
474
|
declare function NexusBoolean({ value, className, trueLabel, falseLabel, }: NexusBooleanProps): react_jsx_runtime.JSX.Element | null;
|
|
487
475
|
|
|
488
|
-
export { AuthProvider, NexusAddress, type NexusAddressProps, NexusBlendContainer, type NexusBlendContainerProps, NexusBoolean, type NexusBooleanProps, NexusCode, type NexusCodeProps, NexusColor, type NexusColorProps, NexusGallery, type NexusGalleryProps, NexusGradient, type NexusGradientProps, NexusIcon, type NexusIconProps, NexusImage, type NexusImageProps, NexusKeyValue, type NexusKeyValueProps, NexusLongText, type NexusLongTextProps, NexusMap, type NexusMapProps, NexusProgress, type NexusProgressProps, NexusProvider, NexusRichText, type NexusRichTextProps, NexusTags, type NexusTagsProps, NexusVideo, type NexusVideoProps, useNexus, useNexusAnalytics, useNexusAuth, useNexusLiveFeed };
|
|
476
|
+
export { AuthProvider, type LiveAnalyticsEvent, NexusAddress, type NexusAddressProps, NexusBlendContainer, type NexusBlendContainerProps, NexusBoolean, type NexusBooleanProps, NexusCode, type NexusCodeProps, NexusColor, type NexusColorProps, NexusGallery, type NexusGalleryProps, NexusGradient, type NexusGradientProps, NexusIcon, type NexusIconProps, NexusImage, type NexusImageProps, NexusKeyValue, type NexusKeyValueProps, NexusLongText, type NexusLongTextProps, NexusMap, type NexusMapProps, NexusProgress, type NexusProgressProps, NexusProvider, type NexusProviderProps, NexusRichText, type NexusRichTextProps, NexusTags, type NexusTagsProps, NexusVideo, type NexusVideoProps, useNexus, useNexusAnalytics, useNexusAuth, useNexusLiveFeed };
|
package/dist/react.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getFullConfig,
|
|
3
3
|
validateConfig
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-HUABKET6.js";
|
|
5
5
|
|
|
6
6
|
// src/components/NexusProvider.tsx
|
|
7
7
|
import React2, {
|
|
@@ -282,7 +282,7 @@ var LocalCacheProxy = class {
|
|
|
282
282
|
async getInstance() {
|
|
283
283
|
if (this.instance) return this.instance;
|
|
284
284
|
if (typeof window === "undefined") {
|
|
285
|
-
const mod = await import("./local-cache-server-
|
|
285
|
+
const mod = await import("./local-cache-server-667T23JJ.js");
|
|
286
286
|
this.instance = new mod.LocalCache(this.cachePath);
|
|
287
287
|
} else {
|
|
288
288
|
const mod = await import("./local-cache-client-I6UYVJJV.js");
|
|
@@ -535,7 +535,7 @@ var ContentEngine = class {
|
|
|
535
535
|
});
|
|
536
536
|
this.requestBatcher = new RequestBatcher(20, 50);
|
|
537
537
|
this.circuitBreaker = new CircuitBreaker();
|
|
538
|
-
this.defaultRevalidate = config.revalidateTime ||
|
|
538
|
+
this.defaultRevalidate = config.revalidateTime || false;
|
|
539
539
|
this.cacheStrategy = config.cacheStrategy || "memory";
|
|
540
540
|
if (!this.isServer) {
|
|
541
541
|
window.addEventListener("beforeunload", this.cleanup.bind(this));
|
|
@@ -661,7 +661,7 @@ var ContentEngine = class {
|
|
|
661
661
|
}
|
|
662
662
|
this.memoryCache.set(cacheKey, result, {
|
|
663
663
|
tags: [...tags, CacheTags.collection(collectionId)],
|
|
664
|
-
revalidate
|
|
664
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
665
665
|
});
|
|
666
666
|
return result;
|
|
667
667
|
}
|
|
@@ -724,7 +724,7 @@ var ContentEngine = class {
|
|
|
724
724
|
if (localGlobals) {
|
|
725
725
|
this.memoryCache.set(cacheKey, localGlobals, {
|
|
726
726
|
tags: [CacheTags.global],
|
|
727
|
-
revalidate
|
|
727
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
728
728
|
});
|
|
729
729
|
return localGlobals;
|
|
730
730
|
}
|
|
@@ -932,54 +932,15 @@ var ContentEngine = class {
|
|
|
932
932
|
return null;
|
|
933
933
|
}
|
|
934
934
|
writeCache(key, data, options) {
|
|
935
|
+
const numericRevalidate = options.revalidate === false ? 31536e5 : options.revalidate;
|
|
935
936
|
if (this.cacheStrategy === "memory") {
|
|
936
937
|
this.memoryCache.set(key, data, {
|
|
937
938
|
tags: options.tags,
|
|
938
|
-
revalidate:
|
|
939
|
+
revalidate: numericRevalidate
|
|
939
940
|
});
|
|
940
941
|
}
|
|
941
942
|
if (!this.isServer && this.cacheStrategy === "localStorage" && this.browserCache) {
|
|
942
|
-
this.browserCache.set(key, data,
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
// packages/client-sdk/src/content/index.ts
|
|
946
|
-
/**
|
|
947
|
-
* ⚡ THE PULSE: Next.js Cache Revalidation Receiver
|
|
948
|
-
* Used in app/api/nexus-revalidate/route.ts to handle instant updates from the NexusHub backend.
|
|
949
|
-
*
|
|
950
|
-
* @param req The incoming Request object from Next.js
|
|
951
|
-
* @param revalidateFn The revalidateTag function imported from 'next/cache'
|
|
952
|
-
*/
|
|
953
|
-
async handleRevalidation(req, revalidateFn) {
|
|
954
|
-
try {
|
|
955
|
-
if (!req.body) {
|
|
956
|
-
return { success: false, message: "Missing Pulse Payload" };
|
|
957
|
-
}
|
|
958
|
-
const body = await req.json();
|
|
959
|
-
const { secret, tag } = body;
|
|
960
|
-
if (!secret || secret !== this.config.projectId) {
|
|
961
|
-
if (this.config.debug) {
|
|
962
|
-
console.warn(`[NexusHub] \u26A0\uFE0F Blocked unauthorized Pulse request.`);
|
|
963
|
-
}
|
|
964
|
-
return { success: false, message: "Invalid Pulse Signature" };
|
|
965
|
-
}
|
|
966
|
-
const targetTag = tag || "content_all";
|
|
967
|
-
revalidateFn(targetTag);
|
|
968
|
-
this.invalidateCache([targetTag]);
|
|
969
|
-
if (this.config.debug) {
|
|
970
|
-
console.log(
|
|
971
|
-
`[NexusHub] \u26A1 Pulse Received: Successfully revalidated tag [${targetTag}]`
|
|
972
|
-
);
|
|
973
|
-
}
|
|
974
|
-
return { success: true, now: Date.now() };
|
|
975
|
-
} catch (e) {
|
|
976
|
-
if (this.config.debug) {
|
|
977
|
-
console.error(`[NexusHub] \u274C Pulse Processing Error:`, e.message);
|
|
978
|
-
}
|
|
979
|
-
return {
|
|
980
|
-
success: false,
|
|
981
|
-
message: "Malformed Pulse Payload or Processing Error"
|
|
982
|
-
};
|
|
943
|
+
this.browserCache.set(key, data, numericRevalidate * 1e3);
|
|
983
944
|
}
|
|
984
945
|
}
|
|
985
946
|
/**
|
|
@@ -1024,6 +985,7 @@ var ContentEngine = class {
|
|
|
1024
985
|
if (this.config.debug) {
|
|
1025
986
|
console.log(`[NexusHub] \u{1F310} Fetching: ${url}`);
|
|
1026
987
|
}
|
|
988
|
+
const expiresAt = revalidate === false ? Infinity : Date.now() + revalidate * 1e3;
|
|
1027
989
|
const res = await this.fetchWithTimeout(url, {
|
|
1028
990
|
method: "GET",
|
|
1029
991
|
headers: this.getHeaders(),
|
|
@@ -1045,7 +1007,7 @@ var ContentEngine = class {
|
|
|
1045
1007
|
metadata: {
|
|
1046
1008
|
timestamp: Date.now(),
|
|
1047
1009
|
etag: etag || void 0,
|
|
1048
|
-
expiresAt
|
|
1010
|
+
expiresAt,
|
|
1049
1011
|
tags: [...tags, CacheTags.content(slug)]
|
|
1050
1012
|
}
|
|
1051
1013
|
};
|
|
@@ -1076,12 +1038,13 @@ var ContentEngine = class {
|
|
|
1076
1038
|
}
|
|
1077
1039
|
const json = await res.json();
|
|
1078
1040
|
const etag = res.headers.get("etag");
|
|
1041
|
+
const expiresAt = revalidate === false ? Infinity : Date.now() + revalidate * 1e3;
|
|
1079
1042
|
const cacheEntry = {
|
|
1080
1043
|
data: json,
|
|
1081
1044
|
metadata: {
|
|
1082
1045
|
timestamp: Date.now(),
|
|
1083
1046
|
etag: etag || void 0,
|
|
1084
|
-
expiresAt
|
|
1047
|
+
expiresAt,
|
|
1085
1048
|
tags: [...tags, CacheTags.collection(collectionId)]
|
|
1086
1049
|
}
|
|
1087
1050
|
};
|
|
@@ -2184,7 +2147,7 @@ var NexusClient = class {
|
|
|
2184
2147
|
this.config = {
|
|
2185
2148
|
debug: config?.debug ?? false,
|
|
2186
2149
|
cacheStrategy: config?.cacheStrategy ?? "memory",
|
|
2187
|
-
revalidateTime: config?.revalidateTime ??
|
|
2150
|
+
revalidateTime: config?.revalidateTime ?? false,
|
|
2188
2151
|
timeout: config?.timeout ?? 1e4,
|
|
2189
2152
|
retries: config?.retries ?? 3,
|
|
2190
2153
|
...fullConfig
|