@nexushub/client 0.4.1 → 0.4.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/content/local-cache-client.cjs +29 -4
- package/dist/content/local-cache-server.cjs +61 -26
- package/dist/index.cjs +314 -403
- package/dist/index.d.cts +1 -39
- package/dist/index.d.ts +1 -39
- package/dist/index.js +201 -337
- package/dist/local-cache-client-I6UYVJJV.js +59 -0
- package/dist/local-cache-client-IGAL7SZ6.cjs +59 -0
- package/dist/local-cache-server-6DXQJFCQ.cjs +114 -0
- package/dist/local-cache-server-DBJWR7HD.js +114 -0
- package/dist/react.cjs +2624 -0
- package/dist/react.d.cts +349 -0
- package/dist/react.d.ts +349 -0
- package/dist/react.js +2624 -0
- package/package.json +16 -2
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,249 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// src/content/local-cache-server.ts
|
|
34
|
+
var local_cache_server_exports = {};
|
|
35
|
+
__export(local_cache_server_exports, {
|
|
36
|
+
LocalCache: () => LocalCache
|
|
37
|
+
});
|
|
38
|
+
var import_fs, import_path, LocalCache;
|
|
39
|
+
var init_local_cache_server = __esm({
|
|
40
|
+
"src/content/local-cache-server.ts"() {
|
|
41
|
+
"use strict";
|
|
42
|
+
import_fs = __toESM(require("fs"), 1);
|
|
43
|
+
import_path = __toESM(require("path"), 1);
|
|
44
|
+
LocalCache = class {
|
|
45
|
+
constructor(customPath) {
|
|
46
|
+
this.baseDir = customPath || ".nexus/local";
|
|
47
|
+
}
|
|
48
|
+
isLoaded() {
|
|
49
|
+
return import_fs.default.existsSync(import_path.default.resolve(process.cwd(), this.baseDir));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Retrieve a specific page directly from its file.
|
|
53
|
+
*/
|
|
54
|
+
async getPage(slug) {
|
|
55
|
+
try {
|
|
56
|
+
const filePath = import_path.default.resolve(
|
|
57
|
+
process.cwd(),
|
|
58
|
+
this.baseDir,
|
|
59
|
+
"pages",
|
|
60
|
+
`${slug}.json`
|
|
61
|
+
);
|
|
62
|
+
if (import_fs.default.existsSync(filePath)) {
|
|
63
|
+
const fileContent = import_fs.default.readFileSync(filePath, "utf-8");
|
|
64
|
+
const pageData = JSON.parse(fileContent);
|
|
65
|
+
return pageData.data !== void 0 ? pageData.data : pageData;
|
|
66
|
+
}
|
|
67
|
+
} catch (error) {
|
|
68
|
+
if (process.env.NODE_ENV === "development") {
|
|
69
|
+
console.warn(
|
|
70
|
+
`\u26A0\uFE0F NexusHub: Failed to load local page '${slug}':`,
|
|
71
|
+
error
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Retrieve an entire collection from its specific collection file.
|
|
79
|
+
*/
|
|
80
|
+
async getCollection(collectionId) {
|
|
81
|
+
try {
|
|
82
|
+
const filePath = import_path.default.resolve(
|
|
83
|
+
process.cwd(),
|
|
84
|
+
this.baseDir,
|
|
85
|
+
"collections",
|
|
86
|
+
`${collectionId}.json`
|
|
87
|
+
);
|
|
88
|
+
if (import_fs.default.existsSync(filePath)) {
|
|
89
|
+
const fileContent = import_fs.default.readFileSync(filePath, "utf-8");
|
|
90
|
+
return JSON.parse(fileContent);
|
|
91
|
+
}
|
|
92
|
+
} catch (error) {
|
|
93
|
+
if (process.env.NODE_ENV === "development") {
|
|
94
|
+
console.warn(
|
|
95
|
+
`\u26A0\uFE0F NexusHub: Failed to load local collection '${collectionId}':`,
|
|
96
|
+
error
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Retrieve global settings from its file.
|
|
104
|
+
*/
|
|
105
|
+
async getGlobals() {
|
|
106
|
+
try {
|
|
107
|
+
const filePath = import_path.default.resolve(
|
|
108
|
+
process.cwd(),
|
|
109
|
+
this.baseDir,
|
|
110
|
+
"globals.json"
|
|
111
|
+
);
|
|
112
|
+
if (import_fs.default.existsSync(filePath)) {
|
|
113
|
+
const fileContent = import_fs.default.readFileSync(filePath, "utf-8");
|
|
114
|
+
return JSON.parse(fileContent);
|
|
115
|
+
}
|
|
116
|
+
} catch {
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Returns a merged JSON of the entire workspace structure (for dev analytics/inspectors)
|
|
122
|
+
*/
|
|
123
|
+
async getAllData() {
|
|
124
|
+
const pages = {};
|
|
125
|
+
const collections = {};
|
|
126
|
+
let globals = {};
|
|
127
|
+
try {
|
|
128
|
+
const pagesDir = import_path.default.resolve(process.cwd(), this.baseDir, "pages");
|
|
129
|
+
if (import_fs.default.existsSync(pagesDir)) {
|
|
130
|
+
for (const file of import_fs.default.readdirSync(pagesDir)) {
|
|
131
|
+
if (file.endsWith(".json")) {
|
|
132
|
+
const slug = import_path.default.basename(file, ".json");
|
|
133
|
+
pages[slug] = await this.getPage(slug);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const colsDir = import_path.default.resolve(process.cwd(), this.baseDir, "collections");
|
|
138
|
+
if (import_fs.default.existsSync(colsDir)) {
|
|
139
|
+
for (const file of import_fs.default.readdirSync(colsDir)) {
|
|
140
|
+
if (file.endsWith(".json")) {
|
|
141
|
+
const id = import_path.default.basename(file, ".json");
|
|
142
|
+
collections[id] = await this.getCollection(id) || [];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
globals = await this.getGlobals() || {};
|
|
147
|
+
} catch {
|
|
148
|
+
}
|
|
149
|
+
return { pages, collections, globals };
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// src/content/local-cache-client.ts
|
|
156
|
+
var local_cache_client_exports = {};
|
|
157
|
+
__export(local_cache_client_exports, {
|
|
158
|
+
LocalCache: () => LocalCache2
|
|
159
|
+
});
|
|
160
|
+
var LocalCache2;
|
|
161
|
+
var init_local_cache_client = __esm({
|
|
162
|
+
"src/content/local-cache-client.ts"() {
|
|
163
|
+
"use strict";
|
|
164
|
+
LocalCache2 = class {
|
|
165
|
+
constructor(customPath) {
|
|
166
|
+
// Maintain private properties for type parity with the Server version
|
|
167
|
+
this.data = null;
|
|
168
|
+
this.hasLoaded = false;
|
|
169
|
+
this.cachePath = customPath || ".nexus/cache.json";
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Always returns false in the browser as local file caching
|
|
173
|
+
* is a server-side only feature.
|
|
174
|
+
*/
|
|
175
|
+
isLoaded() {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* No-op method to maintain internal API compatibility.
|
|
180
|
+
*/
|
|
181
|
+
load() {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Returns null. Browsers should fetch pages from the Remote API
|
|
186
|
+
* or the Memory/Browser cache.
|
|
187
|
+
*/
|
|
188
|
+
async getPage(_slug) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Returns null. Browsers should fetch collections from the Remote API.
|
|
193
|
+
*/
|
|
194
|
+
async getCollection(_collectionId) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Returns null.
|
|
199
|
+
*/
|
|
200
|
+
async getGlobals() {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Returns null.
|
|
205
|
+
*/
|
|
206
|
+
async getAllData() {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Dummy helper to match Node implementation.
|
|
211
|
+
*/
|
|
212
|
+
shouldWarnAboutMissingCache(error) {
|
|
213
|
+
const isMissing = error.code === "ENOENT";
|
|
214
|
+
const isMalformed = error instanceof SyntaxError;
|
|
215
|
+
if (process.env.NODE_ENV !== "development") return false;
|
|
216
|
+
return !isMissing || isMalformed;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// src/index.ts
|
|
223
|
+
var index_exports = {};
|
|
224
|
+
__export(index_exports, {
|
|
225
|
+
AnalyticsEngine: () => AnalyticsEngine,
|
|
226
|
+
BrowserCache: () => BrowserCache,
|
|
227
|
+
CacheTags: () => CacheTags,
|
|
228
|
+
ContentEngine: () => ContentEngine,
|
|
229
|
+
DEFAULT_ANALYTICS_URL: () => DEFAULT_ANALYTICS_URL,
|
|
230
|
+
DEFAULT_API_URL: () => DEFAULT_API_URL,
|
|
231
|
+
LOCAL_NEST_URL: () => LOCAL_NEST_URL,
|
|
232
|
+
LOCAL_RUST_URL: () => LOCAL_RUST_URL,
|
|
233
|
+
LocalCache: () => LocalCacheProxy,
|
|
234
|
+
MemoryCache: () => MemoryCache,
|
|
235
|
+
NexusClient: () => NexusClient,
|
|
236
|
+
VERSION: () => VERSION,
|
|
237
|
+
createNexusClient: () => createNexusClient,
|
|
238
|
+
getEnvConfig: () => getEnvConfig,
|
|
239
|
+
getFullConfig: () => getFullConfig,
|
|
240
|
+
mergeConfigs: () => mergeConfigs,
|
|
241
|
+
nexus: () => nexus,
|
|
242
|
+
validateConfig: () => validateConfig
|
|
243
|
+
});
|
|
244
|
+
module.exports = __toCommonJS(index_exports);
|
|
245
|
+
|
|
246
|
+
// src/config.ts
|
|
2
247
|
var DEFAULT_API_URL = "https://endpoints.gnexus.co.tz";
|
|
3
248
|
var DEFAULT_ANALYTICS_URL = "https://sentry.gnexus.co.tz";
|
|
4
249
|
var LOCAL_NEST_URL = "https://endpoints.gnexus.co.tz";
|
|
@@ -12,9 +257,9 @@ var getEnvConfig = () => {
|
|
|
12
257
|
const NODE_URL = typeof process !== "undefined" ? process.env.NEXUS_API_URL : void 0;
|
|
13
258
|
const NODE_ENV = typeof process !== "undefined" ? process.env.NODE_ENV : "production";
|
|
14
259
|
const isDev = NODE_ENV === "development" || typeof window !== "undefined" && window.location.hostname === "localhost";
|
|
15
|
-
const projectId =
|
|
16
|
-
const apiKey =
|
|
17
|
-
const apiUrl =
|
|
260
|
+
const projectId = NEXT_PUBLIC_ID ?? NODE_ID;
|
|
261
|
+
const apiKey = NEXT_PUBLIC_KEY ?? NODE_KEY;
|
|
262
|
+
const apiUrl = NEXT_PUBLIC_URL ?? NODE_URL ?? (isDev ? LOCAL_NEST_URL : DEFAULT_API_URL);
|
|
18
263
|
const analyticsUrl = apiUrl.includes("localhost") ? LOCAL_RUST_URL : DEFAULT_ANALYTICS_URL;
|
|
19
264
|
return {
|
|
20
265
|
projectId,
|
|
@@ -170,7 +415,7 @@ var MemoryCache = class {
|
|
|
170
415
|
try {
|
|
171
416
|
const jsonString = JSON.stringify(data);
|
|
172
417
|
return new Blob([jsonString]).size;
|
|
173
|
-
} catch
|
|
418
|
+
} catch {
|
|
174
419
|
return 0;
|
|
175
420
|
}
|
|
176
421
|
}
|
|
@@ -230,7 +475,7 @@ var BrowserCache = class {
|
|
|
230
475
|
return null;
|
|
231
476
|
}
|
|
232
477
|
return entry.data;
|
|
233
|
-
} catch
|
|
478
|
+
} catch {
|
|
234
479
|
this.delete(key);
|
|
235
480
|
return null;
|
|
236
481
|
}
|
|
@@ -249,7 +494,7 @@ var BrowserCache = class {
|
|
|
249
494
|
const keysToRemove = [];
|
|
250
495
|
for (let i = 0; i < localStorage.length; i++) {
|
|
251
496
|
const key = localStorage.key(i);
|
|
252
|
-
if (
|
|
497
|
+
if (key?.startsWith(this.prefix)) {
|
|
253
498
|
keysToRemove.push(key);
|
|
254
499
|
}
|
|
255
500
|
}
|
|
@@ -263,7 +508,7 @@ var BrowserCache = class {
|
|
|
263
508
|
this.currentSize = 0;
|
|
264
509
|
for (let i = 0; i < localStorage.length; i++) {
|
|
265
510
|
const key = localStorage.key(i);
|
|
266
|
-
if (
|
|
511
|
+
if (key?.startsWith(this.prefix)) {
|
|
267
512
|
const item = localStorage.getItem(key);
|
|
268
513
|
if (item) {
|
|
269
514
|
this.currentSize += new Blob([item]).size;
|
|
@@ -279,7 +524,7 @@ var BrowserCache = class {
|
|
|
279
524
|
let oldestTime = Infinity;
|
|
280
525
|
for (let i = 0; i < localStorage.length; i++) {
|
|
281
526
|
const key = localStorage.key(i);
|
|
282
|
-
if (
|
|
527
|
+
if (key?.startsWith(this.prefix)) {
|
|
283
528
|
const item = localStorage.getItem(key);
|
|
284
529
|
if (item) {
|
|
285
530
|
try {
|
|
@@ -288,7 +533,7 @@ var BrowserCache = class {
|
|
|
288
533
|
oldestTime = entry.metadata.timestamp;
|
|
289
534
|
oldestKey = key;
|
|
290
535
|
}
|
|
291
|
-
} catch
|
|
536
|
+
} catch {
|
|
292
537
|
localStorage.removeItem(key);
|
|
293
538
|
}
|
|
294
539
|
}
|
|
@@ -313,16 +558,16 @@ var LocalCacheProxy = class {
|
|
|
313
558
|
async getInstance() {
|
|
314
559
|
if (this.instance) return this.instance;
|
|
315
560
|
if (typeof window === "undefined") {
|
|
316
|
-
const mod = await Promise.resolve().then(() =>
|
|
561
|
+
const mod = await Promise.resolve().then(() => (init_local_cache_server(), local_cache_server_exports));
|
|
317
562
|
this.instance = new mod.LocalCache(this.cachePath);
|
|
318
563
|
} else {
|
|
319
|
-
const mod = await Promise.resolve().then(() =>
|
|
564
|
+
const mod = await Promise.resolve().then(() => (init_local_cache_client(), local_cache_client_exports));
|
|
320
565
|
this.instance = new mod.LocalCache(this.cachePath);
|
|
321
566
|
}
|
|
322
567
|
return this.instance;
|
|
323
568
|
}
|
|
324
569
|
isLoaded() {
|
|
325
|
-
return
|
|
570
|
+
return this.instance?.isLoaded() || false;
|
|
326
571
|
}
|
|
327
572
|
async getPage(slug) {
|
|
328
573
|
const inst = await this.getInstance();
|
|
@@ -405,10 +650,10 @@ var ExponentialBackoff = class {
|
|
|
405
650
|
return delay;
|
|
406
651
|
}
|
|
407
652
|
isClientError(error) {
|
|
408
|
-
return
|
|
653
|
+
return error?.status >= 400 && error?.status < 500;
|
|
409
654
|
}
|
|
410
655
|
isRateLimitError(error) {
|
|
411
|
-
return
|
|
656
|
+
return error?.status === 429;
|
|
412
657
|
}
|
|
413
658
|
};
|
|
414
659
|
var CircuitBreaker = class {
|
|
@@ -519,10 +764,10 @@ function buildQueryString(query) {
|
|
|
519
764
|
if (query.sort) params.append("sort", query.sort);
|
|
520
765
|
if (query.order) params.append("order", query.order);
|
|
521
766
|
if (query.search) params.append("search", query.search);
|
|
522
|
-
if (
|
|
767
|
+
if (query.include?.length) {
|
|
523
768
|
params.append("include", query.include.join(","));
|
|
524
769
|
}
|
|
525
|
-
if (
|
|
770
|
+
if (query.fields?.length) {
|
|
526
771
|
params.append("fields", query.fields.join(","));
|
|
527
772
|
}
|
|
528
773
|
if (query.filter) {
|
|
@@ -804,7 +1049,7 @@ var ContentEngine = class {
|
|
|
804
1049
|
}
|
|
805
1050
|
return this.requestBatcher.schedule(cacheKey, async () => {
|
|
806
1051
|
const params = new URLSearchParams();
|
|
807
|
-
if (
|
|
1052
|
+
if (options.include?.length) {
|
|
808
1053
|
params.append("include", options.include.join(","));
|
|
809
1054
|
}
|
|
810
1055
|
const url = `${this.config.apiUrl}/content/${this.config.projectId}/collection/${collectionId}/${itemId}?${params}`;
|
|
@@ -837,10 +1082,10 @@ var ContentEngine = class {
|
|
|
837
1082
|
q: query,
|
|
838
1083
|
limit: (options.limit || 20).toString()
|
|
839
1084
|
});
|
|
840
|
-
if (
|
|
1085
|
+
if (options.collections?.length) {
|
|
841
1086
|
params.append("collections", options.collections.join(","));
|
|
842
1087
|
}
|
|
843
|
-
if (
|
|
1088
|
+
if (options.fields?.length) {
|
|
844
1089
|
params.append("fields", options.fields.join(","));
|
|
845
1090
|
}
|
|
846
1091
|
const url = `${this.config.apiUrl}/content/${this.config.projectId}/search?${params}`;
|
|
@@ -901,7 +1146,7 @@ var ContentEngine = class {
|
|
|
901
1146
|
}
|
|
902
1147
|
};
|
|
903
1148
|
eventSource.onerror = () => {
|
|
904
|
-
|
|
1149
|
+
eventSource?.close();
|
|
905
1150
|
if (isClosed) return;
|
|
906
1151
|
const timeout = Math.min(1e3 * Math.pow(2, retryCount), 1e4);
|
|
907
1152
|
retryCount++;
|
|
@@ -914,7 +1159,7 @@ var ContentEngine = class {
|
|
|
914
1159
|
connect();
|
|
915
1160
|
return () => {
|
|
916
1161
|
isClosed = true;
|
|
917
|
-
|
|
1162
|
+
eventSource?.close();
|
|
918
1163
|
};
|
|
919
1164
|
}
|
|
920
1165
|
// --- CACHE MANAGEMENT ---
|
|
@@ -1284,7 +1529,7 @@ var generateCanvasHash = async () => {
|
|
|
1284
1529
|
hash = hash & hash;
|
|
1285
1530
|
}
|
|
1286
1531
|
return hash.toString(16);
|
|
1287
|
-
} catch
|
|
1532
|
+
} catch {
|
|
1288
1533
|
return "";
|
|
1289
1534
|
}
|
|
1290
1535
|
};
|
|
@@ -1315,7 +1560,7 @@ var getVisitorId = async () => {
|
|
|
1315
1560
|
};
|
|
1316
1561
|
|
|
1317
1562
|
// src/analytics/vitals.ts
|
|
1318
|
-
var
|
|
1563
|
+
var import_web_vitals = require("web-vitals");
|
|
1319
1564
|
var METRIC_KEY_MAP = {
|
|
1320
1565
|
CLS: "cls",
|
|
1321
1566
|
LCP: "lcp",
|
|
@@ -1337,11 +1582,11 @@ var VitalsCollector = class {
|
|
|
1337
1582
|
this.metrics[key] = metric.value;
|
|
1338
1583
|
this.hasUpdates = true;
|
|
1339
1584
|
};
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1585
|
+
(0, import_web_vitals.onCLS)(recordMetric);
|
|
1586
|
+
(0, import_web_vitals.onLCP)(recordMetric);
|
|
1587
|
+
(0, import_web_vitals.onTTFB)(recordMetric);
|
|
1588
|
+
(0, import_web_vitals.onINP)(recordMetric);
|
|
1589
|
+
(0, import_web_vitals.onFCP)(recordMetric);
|
|
1345
1590
|
const navEntry = performance.getEntriesByType("navigation")[0];
|
|
1346
1591
|
if (navEntry) {
|
|
1347
1592
|
this.metrics.navigation_timing = {
|
|
@@ -1516,20 +1761,20 @@ var SDK_VERSION = "0.1.0";
|
|
|
1516
1761
|
var safeGetItem = (key) => {
|
|
1517
1762
|
try {
|
|
1518
1763
|
return localStorage.getItem(key);
|
|
1519
|
-
} catch
|
|
1764
|
+
} catch {
|
|
1520
1765
|
return null;
|
|
1521
1766
|
}
|
|
1522
1767
|
};
|
|
1523
1768
|
var safeSetItem = (key, value) => {
|
|
1524
1769
|
try {
|
|
1525
1770
|
localStorage.setItem(key, value);
|
|
1526
|
-
} catch
|
|
1771
|
+
} catch {
|
|
1527
1772
|
}
|
|
1528
1773
|
};
|
|
1529
1774
|
var safeRemoveItem = (key) => {
|
|
1530
1775
|
try {
|
|
1531
1776
|
localStorage.removeItem(key);
|
|
1532
|
-
} catch
|
|
1777
|
+
} catch {
|
|
1533
1778
|
}
|
|
1534
1779
|
};
|
|
1535
1780
|
var generateUUID = () => {
|
|
@@ -1603,7 +1848,7 @@ var Tracker = class {
|
|
|
1603
1848
|
eventType,
|
|
1604
1849
|
eventName,
|
|
1605
1850
|
eventData: data,
|
|
1606
|
-
ecommerce:
|
|
1851
|
+
ecommerce: ecommerce ?? void 0,
|
|
1607
1852
|
performance: perfMetrics || void 0,
|
|
1608
1853
|
context: {
|
|
1609
1854
|
device: {
|
|
@@ -1718,7 +1963,7 @@ function extractUtmParams(url) {
|
|
|
1718
1963
|
if (val) result[key] = val;
|
|
1719
1964
|
});
|
|
1720
1965
|
return result;
|
|
1721
|
-
} catch
|
|
1966
|
+
} catch {
|
|
1722
1967
|
return {};
|
|
1723
1968
|
}
|
|
1724
1969
|
}
|
|
@@ -1727,7 +1972,7 @@ function extractUtmParams(url) {
|
|
|
1727
1972
|
var safeRemoveItem2 = (key) => {
|
|
1728
1973
|
try {
|
|
1729
1974
|
localStorage.removeItem(key);
|
|
1730
|
-
} catch
|
|
1975
|
+
} catch {
|
|
1731
1976
|
}
|
|
1732
1977
|
};
|
|
1733
1978
|
var AnalyticsEngine = class {
|
|
@@ -1786,8 +2031,8 @@ var AnalyticsEngine = class {
|
|
|
1786
2031
|
navigator.share = (data) => {
|
|
1787
2032
|
this.tracker.send("social_share", {
|
|
1788
2033
|
method: "native_share_menu",
|
|
1789
|
-
url:
|
|
1790
|
-
title:
|
|
2034
|
+
url: data?.url || window.location.href,
|
|
2035
|
+
title: data?.title
|
|
1791
2036
|
});
|
|
1792
2037
|
return originalShare(data);
|
|
1793
2038
|
};
|
|
@@ -1836,7 +2081,7 @@ var AnalyticsEngine = class {
|
|
|
1836
2081
|
this.tracker.send("click", {
|
|
1837
2082
|
element_type: "link",
|
|
1838
2083
|
href: link.href,
|
|
1839
|
-
text:
|
|
2084
|
+
text: link.innerText?.substring(0, 50),
|
|
1840
2085
|
id: link.id,
|
|
1841
2086
|
classes: link.className,
|
|
1842
2087
|
dataset: { ...link.dataset },
|
|
@@ -1847,7 +2092,7 @@ var AnalyticsEngine = class {
|
|
|
1847
2092
|
if (button) {
|
|
1848
2093
|
this.tracker.send("click", {
|
|
1849
2094
|
element_type: "button",
|
|
1850
|
-
text:
|
|
2095
|
+
text: button.innerText?.substring(0, 50),
|
|
1851
2096
|
id: button.id,
|
|
1852
2097
|
classes: button.className,
|
|
1853
2098
|
coordinates: { x: e.clientX, y: e.clientY }
|
|
@@ -1939,14 +2184,14 @@ var AnalyticsEngine = class {
|
|
|
1939
2184
|
{
|
|
1940
2185
|
event_name: "outbound_click",
|
|
1941
2186
|
href: link.href,
|
|
1942
|
-
text:
|
|
2187
|
+
text: link.innerText?.substring(0, 50),
|
|
1943
2188
|
destination_host: linkHost,
|
|
1944
2189
|
coordinates: { x: e.clientX, y: e.clientY }
|
|
1945
2190
|
},
|
|
1946
2191
|
"outbound_click"
|
|
1947
2192
|
);
|
|
1948
2193
|
}
|
|
1949
|
-
} catch
|
|
2194
|
+
} catch {
|
|
1950
2195
|
}
|
|
1951
2196
|
};
|
|
1952
2197
|
window.addEventListener("click", outboundHandler, { passive: true });
|
|
@@ -2030,7 +2275,7 @@ var AnalyticsEngine = class {
|
|
|
2030
2275
|
filename: e.filename,
|
|
2031
2276
|
lineno: e.lineno,
|
|
2032
2277
|
colno: e.colno,
|
|
2033
|
-
stack:
|
|
2278
|
+
stack: e.error?.stack,
|
|
2034
2279
|
url: window.location.href,
|
|
2035
2280
|
type: "uncaught_error"
|
|
2036
2281
|
});
|
|
@@ -2129,7 +2374,7 @@ var AnalyticsEngine = class {
|
|
|
2129
2374
|
const ecommerce = {
|
|
2130
2375
|
orderId: orderData.orderId,
|
|
2131
2376
|
total: orderData.total,
|
|
2132
|
-
revenue:
|
|
2377
|
+
revenue: orderData.revenue ?? orderData.total,
|
|
2133
2378
|
currency: orderData.currency || "USD",
|
|
2134
2379
|
products: orderData.products.map((p) => ({
|
|
2135
2380
|
productId: p.id,
|
|
@@ -2213,11 +2458,11 @@ var NexusClient = class {
|
|
|
2213
2458
|
constructor(config) {
|
|
2214
2459
|
const fullConfig = getFullConfig(config);
|
|
2215
2460
|
this.config = {
|
|
2216
|
-
debug:
|
|
2217
|
-
cacheStrategy:
|
|
2218
|
-
revalidateTime:
|
|
2219
|
-
timeout:
|
|
2220
|
-
retries:
|
|
2461
|
+
debug: config?.debug ?? false,
|
|
2462
|
+
cacheStrategy: config?.cacheStrategy ?? "memory",
|
|
2463
|
+
revalidateTime: config?.revalidateTime ?? 60,
|
|
2464
|
+
timeout: config?.timeout ?? 1e4,
|
|
2465
|
+
retries: config?.retries ?? 3,
|
|
2221
2466
|
...fullConfig
|
|
2222
2467
|
};
|
|
2223
2468
|
const errors = validateConfig(this.config);
|
|
@@ -2257,360 +2502,26 @@ var NexusClient = class {
|
|
|
2257
2502
|
var nexus = new NexusClient();
|
|
2258
2503
|
var createNexusClient = (config) => new NexusClient(config);
|
|
2259
2504
|
|
|
2260
|
-
// src/components/NexusProvider.tsx
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
2270
|
-
var _navigation = require('next/navigation');
|
|
2271
|
-
|
|
2272
|
-
// src/auth/context.tsx
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
2281
|
-
var AuthContext = _react.createContext.call(void 0, null);
|
|
2282
|
-
var AuthProvider = ({
|
|
2283
|
-
children,
|
|
2284
|
-
config
|
|
2285
|
-
}) => {
|
|
2286
|
-
const [user, setUser] = _react.useState.call(void 0, null);
|
|
2287
|
-
const [isLoading, setIsLoading] = _react.useState.call(void 0, true);
|
|
2288
|
-
const [error, setError] = _react.useState.call(void 0, null);
|
|
2289
|
-
const AUTH_BASE = `${config.apiUrl}/auth/project/${config.projectId}`;
|
|
2290
|
-
const checkSession = _react.useCallback.call(void 0, async () => {
|
|
2291
|
-
try {
|
|
2292
|
-
const res = await fetch(`${AUTH_BASE}/me`, {
|
|
2293
|
-
headers: getHeaders(config)
|
|
2294
|
-
});
|
|
2295
|
-
if (res.ok) {
|
|
2296
|
-
const data = await res.json();
|
|
2297
|
-
setUser(data.user);
|
|
2298
|
-
if (nexus.analytics) {
|
|
2299
|
-
nexus.analytics.identify(data.user.id, {
|
|
2300
|
-
email: data.user.email,
|
|
2301
|
-
role: data.user.role,
|
|
2302
|
-
...data.user.metadata
|
|
2303
|
-
});
|
|
2304
|
-
}
|
|
2305
|
-
} else {
|
|
2306
|
-
setUser(null);
|
|
2307
|
-
}
|
|
2308
|
-
} catch (err) {
|
|
2309
|
-
console.debug("[NexusHub Auth] Session check failed:", err);
|
|
2310
|
-
setUser(null);
|
|
2311
|
-
} finally {
|
|
2312
|
-
setIsLoading(false);
|
|
2313
|
-
}
|
|
2314
|
-
}, [AUTH_BASE, config]);
|
|
2315
|
-
_react.useEffect.call(void 0, () => {
|
|
2316
|
-
checkSession();
|
|
2317
|
-
}, [checkSession]);
|
|
2318
|
-
const login = async (creds) => {
|
|
2319
|
-
setIsLoading(true);
|
|
2320
|
-
setError(null);
|
|
2321
|
-
try {
|
|
2322
|
-
const res = await fetch(`${AUTH_BASE}/login`, {
|
|
2323
|
-
method: "POST",
|
|
2324
|
-
headers: getHeaders(config),
|
|
2325
|
-
body: JSON.stringify(creds)
|
|
2326
|
-
});
|
|
2327
|
-
if (!res.ok) throw await parseError(res);
|
|
2328
|
-
const data = await res.json();
|
|
2329
|
-
setUser(data.user);
|
|
2330
|
-
if (nexus.analytics) {
|
|
2331
|
-
await nexus.analytics.identify(data.user.id, {
|
|
2332
|
-
email: data.user.email,
|
|
2333
|
-
role: data.user.role,
|
|
2334
|
-
login_method: "email",
|
|
2335
|
-
...data.user.metadata
|
|
2336
|
-
});
|
|
2337
|
-
}
|
|
2338
|
-
} catch (err) {
|
|
2339
|
-
setError(err);
|
|
2340
|
-
throw err;
|
|
2341
|
-
} finally {
|
|
2342
|
-
setIsLoading(false);
|
|
2343
|
-
}
|
|
2344
|
-
};
|
|
2345
|
-
const register = async (creds) => {
|
|
2346
|
-
setIsLoading(true);
|
|
2347
|
-
setError(null);
|
|
2348
|
-
try {
|
|
2349
|
-
const res = await fetch(`${AUTH_BASE}/register`, {
|
|
2350
|
-
method: "POST",
|
|
2351
|
-
headers: getHeaders(config),
|
|
2352
|
-
body: JSON.stringify(creds)
|
|
2353
|
-
});
|
|
2354
|
-
if (!res.ok) throw await parseError(res);
|
|
2355
|
-
const data = await res.json();
|
|
2356
|
-
setUser(data.user);
|
|
2357
|
-
if (nexus.analytics) {
|
|
2358
|
-
nexus.analytics.track("signup", { method: "email" });
|
|
2359
|
-
nexus.analytics.identify(data.user.id, {
|
|
2360
|
-
email: data.user.email,
|
|
2361
|
-
role: data.user.role,
|
|
2362
|
-
...data.user.metadata
|
|
2363
|
-
});
|
|
2364
|
-
}
|
|
2365
|
-
} catch (err) {
|
|
2366
|
-
setError(err);
|
|
2367
|
-
throw err;
|
|
2368
|
-
} finally {
|
|
2369
|
-
setIsLoading(false);
|
|
2370
|
-
}
|
|
2371
|
-
};
|
|
2372
|
-
const logout = async () => {
|
|
2373
|
-
setIsLoading(true);
|
|
2374
|
-
try {
|
|
2375
|
-
await fetch(`${AUTH_BASE}/logout`, {
|
|
2376
|
-
method: "POST",
|
|
2377
|
-
headers: getHeaders(config)
|
|
2378
|
-
});
|
|
2379
|
-
} catch (e) {
|
|
2380
|
-
console.warn("Logout network error", e);
|
|
2381
|
-
} finally {
|
|
2382
|
-
setUser(null);
|
|
2383
|
-
setIsLoading(false);
|
|
2384
|
-
if (nexus.analytics) {
|
|
2385
|
-
nexus.analytics.track("logout");
|
|
2386
|
-
}
|
|
2387
|
-
}
|
|
2388
|
-
};
|
|
2389
|
-
const updateProfile = async (updates) => {
|
|
2390
|
-
try {
|
|
2391
|
-
const res = await fetch(`${AUTH_BASE}/profile`, {
|
|
2392
|
-
method: "PATCH",
|
|
2393
|
-
headers: getHeaders(config),
|
|
2394
|
-
body: JSON.stringify(updates)
|
|
2395
|
-
});
|
|
2396
|
-
if (!res.ok) throw await parseError(res);
|
|
2397
|
-
const data = await res.json();
|
|
2398
|
-
setUser(data.user);
|
|
2399
|
-
if (nexus.analytics) {
|
|
2400
|
-
nexus.analytics.identify(data.user.id, updates);
|
|
2401
|
-
}
|
|
2402
|
-
} catch (err) {
|
|
2403
|
-
setError(err);
|
|
2404
|
-
throw err;
|
|
2405
|
-
}
|
|
2406
|
-
};
|
|
2407
|
-
const requestPasswordReset = async (email) => {
|
|
2408
|
-
const res = await fetch(`${AUTH_BASE}/password/reset-request`, {
|
|
2409
|
-
method: "POST",
|
|
2410
|
-
headers: getHeaders(config),
|
|
2411
|
-
body: JSON.stringify({ email })
|
|
2412
|
-
});
|
|
2413
|
-
if (!res.ok) throw await parseError(res);
|
|
2414
|
-
};
|
|
2415
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2416
|
-
AuthContext.Provider,
|
|
2417
|
-
{
|
|
2418
|
-
value: {
|
|
2419
|
-
user,
|
|
2420
|
-
isLoading,
|
|
2421
|
-
error,
|
|
2422
|
-
isAuthenticated: !!user,
|
|
2423
|
-
login,
|
|
2424
|
-
register,
|
|
2425
|
-
logout,
|
|
2426
|
-
updateProfile,
|
|
2427
|
-
requestPasswordReset
|
|
2428
|
-
},
|
|
2429
|
-
children
|
|
2430
|
-
}
|
|
2431
|
-
);
|
|
2432
|
-
};
|
|
2433
|
-
var useNexusAuth = () => {
|
|
2434
|
-
const context = _react.useContext.call(void 0, AuthContext);
|
|
2435
|
-
if (!context) {
|
|
2436
|
-
throw new Error("useNexusAuth must be used within a NexusProvider");
|
|
2437
|
-
}
|
|
2438
|
-
return context;
|
|
2439
|
-
};
|
|
2440
|
-
function getHeaders(config) {
|
|
2441
|
-
return {
|
|
2442
|
-
"Content-Type": "application/json",
|
|
2443
|
-
"x-nexus-project": config.projectId,
|
|
2444
|
-
Authorization: `Bearer ${config.apiKey}`
|
|
2445
|
-
// 👈 CRITICAL: Send the nx_pk_ key
|
|
2446
|
-
// Note: We do NOT send the Master API Key here.
|
|
2447
|
-
// This is client-side. The backend uses Cookies or public tokens.
|
|
2448
|
-
};
|
|
2449
|
-
}
|
|
2450
|
-
async function parseError(res) {
|
|
2451
|
-
try {
|
|
2452
|
-
const json = await res.json();
|
|
2453
|
-
return {
|
|
2454
|
-
status: res.status,
|
|
2455
|
-
code: json.code || "UNKNOWN_ERROR",
|
|
2456
|
-
message: json.message || "An error occurred during authentication"
|
|
2457
|
-
};
|
|
2458
|
-
} catch (e12) {
|
|
2459
|
-
return {
|
|
2460
|
-
status: res.status,
|
|
2461
|
-
code: "NETWORK_ERROR",
|
|
2462
|
-
message: res.statusText
|
|
2463
|
-
};
|
|
2464
|
-
}
|
|
2465
|
-
}
|
|
2466
|
-
|
|
2467
|
-
// src/components/NexusProvider.tsx
|
|
2468
|
-
|
|
2469
|
-
var NexusContext = _react.createContext.call(void 0, nexus);
|
|
2470
|
-
var NexusLiveFeedContext = _react.createContext.call(void 0, {
|
|
2471
|
-
latestEvent: null,
|
|
2472
|
-
isConnected: false
|
|
2473
|
-
});
|
|
2474
|
-
function NexusAnalyticsTracker({
|
|
2475
|
-
disableAnalytics
|
|
2476
|
-
}) {
|
|
2477
|
-
const pathname = _navigation.usePathname.call(void 0, );
|
|
2478
|
-
const searchParams = _navigation.useSearchParams.call(void 0, );
|
|
2479
|
-
const prevPathRef = _react.useRef.call(void 0, "");
|
|
2480
|
-
const searchParamsString = searchParams.toString();
|
|
2481
|
-
_react.useEffect.call(void 0, () => {
|
|
2482
|
-
if (nexus.analytics && !disableAnalytics) {
|
|
2483
|
-
nexus.analytics.pageView(prevPathRef.current || document.referrer);
|
|
2484
|
-
prevPathRef.current = pathname;
|
|
2485
|
-
}
|
|
2486
|
-
}, [pathname, searchParamsString, disableAnalytics]);
|
|
2487
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { id: "__nexus_react_active", style: { display: "none" } });
|
|
2488
|
-
}
|
|
2489
|
-
var NexusProvider = ({
|
|
2490
|
-
children,
|
|
2491
|
-
projectId,
|
|
2492
|
-
disableAnalytics = false,
|
|
2493
|
-
hasConsent = true,
|
|
2494
|
-
// NEW: default true to preserve existing behaviour
|
|
2495
|
-
enableLiveFeed = false,
|
|
2496
|
-
// NEW
|
|
2497
|
-
onLiveEvent
|
|
2498
|
-
// NEW
|
|
2499
|
-
}) => {
|
|
2500
|
-
const isInitialized = _react.useRef.call(void 0, false);
|
|
2501
|
-
const socketRef = _react.useRef.call(void 0, null);
|
|
2502
|
-
const [latestEvent, setLatestEvent] = _react.useState.call(void 0,
|
|
2503
|
-
null
|
|
2504
|
-
);
|
|
2505
|
-
const [isConnected, setIsConnected] = _react.useState.call(void 0, false);
|
|
2506
|
-
const liveFeedValue = _react.useMemo.call(void 0,
|
|
2507
|
-
() => ({ latestEvent, isConnected }),
|
|
2508
|
-
[latestEvent, isConnected]
|
|
2509
|
-
);
|
|
2510
|
-
const config = _react.useMemo.call(void 0, () => {
|
|
2511
|
-
if (projectId && nexus.getConfig().projectId !== projectId) {
|
|
2512
|
-
nexus.updateConfig({ projectId });
|
|
2513
|
-
}
|
|
2514
|
-
return nexus.getConfig();
|
|
2515
|
-
}, [projectId]);
|
|
2516
|
-
_react.useEffect.call(void 0, () => {
|
|
2517
|
-
if (typeof window === "undefined" || disableAnalytics || !hasConsent)
|
|
2518
|
-
return;
|
|
2519
|
-
if (!isInitialized.current) {
|
|
2520
|
-
if (!nexus.analytics) {
|
|
2521
|
-
nexus.analytics = new AnalyticsEngine(nexus.getConfig());
|
|
2522
|
-
}
|
|
2523
|
-
nexus.analytics.start();
|
|
2524
|
-
isInitialized.current = true;
|
|
2525
|
-
if (nexus.getConfig().debug) {
|
|
2526
|
-
console.log("[NexusHub] \u{1F680} Provider initialized analytics");
|
|
2527
|
-
}
|
|
2528
|
-
}
|
|
2529
|
-
return () => {
|
|
2530
|
-
if (nexus.analytics) {
|
|
2531
|
-
nexus.analytics.stop();
|
|
2532
|
-
isInitialized.current = false;
|
|
2533
|
-
}
|
|
2534
|
-
};
|
|
2535
|
-
}, [disableAnalytics, hasConsent]);
|
|
2536
|
-
const connectLiveFeed = _react.useCallback.call(void 0, async () => {
|
|
2537
|
-
if (typeof window === "undefined" || !enableLiveFeed) return;
|
|
2538
|
-
try {
|
|
2539
|
-
const { io } = await Promise.resolve().then(() => _interopRequireWildcard(require("socket.io-client")));
|
|
2540
|
-
const cfg = nexus.getConfig();
|
|
2541
|
-
const wsUrl = cfg.apiUrl || "http://localhost:3001";
|
|
2542
|
-
const socket = io(`${wsUrl}/analytics`, {
|
|
2543
|
-
auth: { token: cfg.apiKey },
|
|
2544
|
-
query: { projectId: cfg.projectId },
|
|
2545
|
-
transports: ["websocket"],
|
|
2546
|
-
reconnectionAttempts: 5,
|
|
2547
|
-
reconnectionDelay: 2e3
|
|
2548
|
-
});
|
|
2549
|
-
socket.on("connect", () => {
|
|
2550
|
-
setIsConnected(true);
|
|
2551
|
-
if (cfg.debug) console.log("[NexusHub] \u{1F534} Live feed connected");
|
|
2552
|
-
});
|
|
2553
|
-
socket.on("disconnect", () => {
|
|
2554
|
-
setIsConnected(false);
|
|
2555
|
-
if (cfg.debug) console.log("[NexusHub] Live feed disconnected");
|
|
2556
|
-
});
|
|
2557
|
-
socket.on("live_event", (event) => {
|
|
2558
|
-
setLatestEvent(event);
|
|
2559
|
-
_optionalChain([onLiveEvent, 'optionalCall', _45 => _45(event)]);
|
|
2560
|
-
});
|
|
2561
|
-
socketRef.current = socket;
|
|
2562
|
-
} catch (err) {
|
|
2563
|
-
console.error("[NexusHub] Live feed connection failed:", err);
|
|
2564
|
-
}
|
|
2565
|
-
}, [enableLiveFeed, onLiveEvent]);
|
|
2566
|
-
_react.useEffect.call(void 0, () => {
|
|
2567
|
-
if (enableLiveFeed) {
|
|
2568
|
-
connectLiveFeed();
|
|
2569
|
-
}
|
|
2570
|
-
return () => {
|
|
2571
|
-
if (socketRef.current) {
|
|
2572
|
-
socketRef.current.disconnect();
|
|
2573
|
-
socketRef.current = null;
|
|
2574
|
-
setIsConnected(false);
|
|
2575
|
-
}
|
|
2576
|
-
};
|
|
2577
|
-
}, [enableLiveFeed, connectLiveFeed]);
|
|
2578
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NexusContext.Provider, { value: nexus, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NexusLiveFeedContext.Provider, { value: liveFeedValue, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, AuthProvider, { config, children: [
|
|
2579
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Suspense, { fallback: null, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NexusAnalyticsTracker, { disableAnalytics }) }),
|
|
2580
|
-
children
|
|
2581
|
-
] }) }) });
|
|
2582
|
-
};
|
|
2583
|
-
var useNexus = () => {
|
|
2584
|
-
const context = _react2.default.useContext(NexusContext);
|
|
2585
|
-
if (!context) {
|
|
2586
|
-
throw new Error("useNexus must be used within a NexusProvider");
|
|
2587
|
-
}
|
|
2588
|
-
return context;
|
|
2589
|
-
};
|
|
2590
|
-
|
|
2591
2505
|
// src/index.ts
|
|
2592
2506
|
var VERSION = "0.0.1";
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
exports.AnalyticsEngine = AnalyticsEngine; exports.AuthProvider = AuthProvider; exports.BrowserCache = BrowserCache; exports.CacheTags = CacheTags; exports.ContentEngine = ContentEngine; exports.DEFAULT_ANALYTICS_URL = DEFAULT_ANALYTICS_URL; exports.DEFAULT_API_URL = DEFAULT_API_URL; exports.LOCAL_NEST_URL = LOCAL_NEST_URL; exports.LOCAL_RUST_URL = LOCAL_RUST_URL; exports.LocalCache = LocalCacheProxy; exports.MemoryCache = MemoryCache; exports.NexusClient = NexusClient; exports.NexusProvider = NexusProvider; exports.VERSION = VERSION; exports.createNexusClient = createNexusClient; exports.getEnvConfig = getEnvConfig; exports.getFullConfig = getFullConfig; exports.mergeConfigs = mergeConfigs; exports.nexus = nexus; exports.useNexus = useNexus; exports.useNexusAuth = useNexusAuth; exports.validateConfig = validateConfig;
|
|
2507
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2508
|
+
0 && (module.exports = {
|
|
2509
|
+
AnalyticsEngine,
|
|
2510
|
+
BrowserCache,
|
|
2511
|
+
CacheTags,
|
|
2512
|
+
ContentEngine,
|
|
2513
|
+
DEFAULT_ANALYTICS_URL,
|
|
2514
|
+
DEFAULT_API_URL,
|
|
2515
|
+
LOCAL_NEST_URL,
|
|
2516
|
+
LOCAL_RUST_URL,
|
|
2517
|
+
LocalCache,
|
|
2518
|
+
MemoryCache,
|
|
2519
|
+
NexusClient,
|
|
2520
|
+
VERSION,
|
|
2521
|
+
createNexusClient,
|
|
2522
|
+
getEnvConfig,
|
|
2523
|
+
getFullConfig,
|
|
2524
|
+
mergeConfigs,
|
|
2525
|
+
nexus,
|
|
2526
|
+
validateConfig
|
|
2527
|
+
});
|