@nexushub/client 0.9.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -1078
- package/dist/chunk-CBSACQXV.js +116 -0
- package/dist/chunk-Z7UZC7IK.cjs +116 -0
- package/dist/cli.cjs +222 -146
- package/dist/content/local-cache-server.cjs +30 -9
- package/dist/content/local-cache-server.d.cts +2 -5
- package/dist/content/local-cache-server.d.ts +2 -5
- package/dist/content/local-cache-server.js +30 -9
- package/dist/index.cjs +656 -335
- package/dist/index.d.cts +221 -32
- package/dist/index.d.ts +221 -32
- package/dist/index.js +646 -335
- package/dist/{local-cache-server-KUGMBMJP.cjs → local-cache-server-AMGC6BOZ.cjs} +16 -8
- package/dist/{local-cache-server-RM7T456Z.js → local-cache-server-SD3K7MZG.js} +15 -7
- package/dist/react.cjs +971 -374
- package/dist/react.d.cts +193 -76
- package/dist/react.d.ts +193 -76
- package/dist/react.js +1013 -416
- package/package.json +29 -27
- package/dist/chunk-3TDCUTZR.cjs +0 -53
- package/dist/chunk-VQ6IEN4I.js +0 -53
|
@@ -45,15 +45,19 @@ var getEnvConfig = () => {
|
|
|
45
45
|
const NEXT_PUBLIC_ID = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_NEXUS_ID : void 0;
|
|
46
46
|
const NEXT_PUBLIC_KEY = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_NEXUS_KEY : void 0;
|
|
47
47
|
const NEXT_PUBLIC_URL = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_NEXUS_API_URL : void 0;
|
|
48
|
+
const NEXT_PUBLIC_ANALYTICS_URL = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_NEXUS_ANALYTICS_URL : void 0;
|
|
48
49
|
const NODE_ID = typeof process !== "undefined" ? process.env.NEXUS_PROJECT_ID : void 0;
|
|
49
50
|
const NODE_KEY = typeof process !== "undefined" ? process.env.NEXUS_API_KEY : void 0;
|
|
50
51
|
const NODE_URL = typeof process !== "undefined" ? process.env.NEXUS_API_URL : void 0;
|
|
52
|
+
const NODE_ANALYTICS_URL = typeof process !== "undefined" ? process.env.NEXUS_ANALYTICS_URL : void 0;
|
|
51
53
|
const NODE_ENV = typeof process !== "undefined" ? process.env.NODE_ENV : "production";
|
|
52
54
|
const isDev = NODE_ENV === "development" || typeof window !== "undefined" && window.location.hostname === "localhost";
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
55
|
+
const runtime = typeof window !== "undefined" ? window.__GNAPEX__ ?? window.__NEXUS__ : void 0;
|
|
56
|
+
const meta = typeof document !== "undefined" ? (name) => document.querySelector(`meta[name="${name}"]`)?.getAttribute("content") ?? void 0 : (_name) => void 0;
|
|
57
|
+
const projectId = runtime?.projectId ?? meta("gnapex-project") ?? meta("nexus-project") ?? NEXT_PUBLIC_ID ?? NODE_ID;
|
|
58
|
+
const apiKey = runtime?.apiKey ?? meta("gnapex-key") ?? meta("nexus-key") ?? NEXT_PUBLIC_KEY ?? NODE_KEY;
|
|
59
|
+
const apiUrl = runtime?.apiUrl ?? meta("gnapex-api") ?? meta("nexus-api") ?? NEXT_PUBLIC_URL ?? NODE_URL ?? (isDev ? LOCAL_NEST_URL : DEFAULT_API_URL);
|
|
60
|
+
const analyticsUrl = runtime?.analyticsUrl ?? meta("gnapex-analytics") ?? meta("nexus-analytics") ?? NEXT_PUBLIC_ANALYTICS_URL ?? NODE_ANALYTICS_URL ?? (apiUrl.includes("localhost") ? LOCAL_RUST_URL : DEFAULT_ANALYTICS_URL);
|
|
57
61
|
return {
|
|
58
62
|
projectId,
|
|
59
63
|
apiKey,
|
|
@@ -160,6 +164,16 @@ BinaryCompiler.MAGIC_HEADER = "NEXS";
|
|
|
160
164
|
// 4-byte ASCII magic identifier
|
|
161
165
|
BinaryCompiler.ALGORITHM = "aes-256-cbc";
|
|
162
166
|
|
|
167
|
+
// src/content/utils.ts
|
|
168
|
+
function validateSlug(slug) {
|
|
169
|
+
if (!slug || typeof slug !== "string") {
|
|
170
|
+
throw new Error("Slug must be a non-empty string");
|
|
171
|
+
}
|
|
172
|
+
if (!/^[a-z0-9-_]+$/.test(slug)) {
|
|
173
|
+
throw new Error("Slug can only contain lowercase letters, numbers, hyphens, and underscores");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
163
177
|
// src/content/local-cache-server.ts
|
|
164
178
|
var LocalCache = class {
|
|
165
179
|
constructor(customPath, apiKey) {
|
|
@@ -171,9 +185,6 @@ var LocalCache = class {
|
|
|
171
185
|
isLoaded() {
|
|
172
186
|
return import_fs.default.existsSync(import_path.default.resolve(process.cwd(), this.baseDir));
|
|
173
187
|
}
|
|
174
|
-
/**
|
|
175
|
-
* Helper to decrypt and decompile `.nx` files on-the-fly.
|
|
176
|
-
*/
|
|
177
188
|
decompileFile(filePath) {
|
|
178
189
|
if (!this.apiKey) {
|
|
179
190
|
if (process.env.NODE_ENV === "development") {
|
|
@@ -202,9 +213,14 @@ var LocalCache = class {
|
|
|
202
213
|
}
|
|
203
214
|
}
|
|
204
215
|
/**
|
|
205
|
-
* Retrieve a specific page
|
|
216
|
+
* Retrieve a specific page safely from its .nx file.
|
|
206
217
|
*/
|
|
207
218
|
async getPage(slug) {
|
|
219
|
+
try {
|
|
220
|
+
validateSlug(slug);
|
|
221
|
+
} catch {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
208
224
|
const filePath = import_path.default.resolve(
|
|
209
225
|
process.cwd(),
|
|
210
226
|
this.baseDir,
|
|
@@ -223,9 +239,14 @@ var LocalCache = class {
|
|
|
223
239
|
return null;
|
|
224
240
|
}
|
|
225
241
|
/**
|
|
226
|
-
* Retrieve an entire collection from its specific .nx file.
|
|
242
|
+
* Retrieve an entire collection safely from its specific .nx file.
|
|
227
243
|
*/
|
|
228
244
|
async getCollection(collectionId) {
|
|
245
|
+
try {
|
|
246
|
+
validateSlug(collectionId);
|
|
247
|
+
} catch {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
229
250
|
const filePath = import_path.default.resolve(
|
|
230
251
|
process.cwd(),
|
|
231
252
|
this.baseDir,
|
|
@@ -5,16 +5,13 @@ declare class LocalCache implements ILocalCache {
|
|
|
5
5
|
private apiKey;
|
|
6
6
|
constructor(customPath?: string, apiKey?: string);
|
|
7
7
|
isLoaded(): boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Helper to decrypt and decompile `.nx` files on-the-fly.
|
|
10
|
-
*/
|
|
11
8
|
private decompileFile;
|
|
12
9
|
/**
|
|
13
|
-
* Retrieve a specific page
|
|
10
|
+
* Retrieve a specific page safely from its .nx file.
|
|
14
11
|
*/
|
|
15
12
|
getPage(slug: string): Promise<any>;
|
|
16
13
|
/**
|
|
17
|
-
* Retrieve an entire collection from its specific .nx file.
|
|
14
|
+
* Retrieve an entire collection safely from its specific .nx file.
|
|
18
15
|
*/
|
|
19
16
|
getCollection(collectionId: string): Promise<any[] | null>;
|
|
20
17
|
/**
|
|
@@ -5,16 +5,13 @@ declare class LocalCache implements ILocalCache {
|
|
|
5
5
|
private apiKey;
|
|
6
6
|
constructor(customPath?: string, apiKey?: string);
|
|
7
7
|
isLoaded(): boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Helper to decrypt and decompile `.nx` files on-the-fly.
|
|
10
|
-
*/
|
|
11
8
|
private decompileFile;
|
|
12
9
|
/**
|
|
13
|
-
* Retrieve a specific page
|
|
10
|
+
* Retrieve a specific page safely from its .nx file.
|
|
14
11
|
*/
|
|
15
12
|
getPage(slug: string): Promise<any>;
|
|
16
13
|
/**
|
|
17
|
-
* Retrieve an entire collection from its specific .nx file.
|
|
14
|
+
* Retrieve an entire collection safely from its specific .nx file.
|
|
18
15
|
*/
|
|
19
16
|
getCollection(collectionId: string): Promise<any[] | null>;
|
|
20
17
|
/**
|
|
@@ -11,15 +11,19 @@ var getEnvConfig = () => {
|
|
|
11
11
|
const NEXT_PUBLIC_ID = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_NEXUS_ID : void 0;
|
|
12
12
|
const NEXT_PUBLIC_KEY = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_NEXUS_KEY : void 0;
|
|
13
13
|
const NEXT_PUBLIC_URL = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_NEXUS_API_URL : void 0;
|
|
14
|
+
const NEXT_PUBLIC_ANALYTICS_URL = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_NEXUS_ANALYTICS_URL : void 0;
|
|
14
15
|
const NODE_ID = typeof process !== "undefined" ? process.env.NEXUS_PROJECT_ID : void 0;
|
|
15
16
|
const NODE_KEY = typeof process !== "undefined" ? process.env.NEXUS_API_KEY : void 0;
|
|
16
17
|
const NODE_URL = typeof process !== "undefined" ? process.env.NEXUS_API_URL : void 0;
|
|
18
|
+
const NODE_ANALYTICS_URL = typeof process !== "undefined" ? process.env.NEXUS_ANALYTICS_URL : void 0;
|
|
17
19
|
const NODE_ENV = typeof process !== "undefined" ? process.env.NODE_ENV : "production";
|
|
18
20
|
const isDev = NODE_ENV === "development" || typeof window !== "undefined" && window.location.hostname === "localhost";
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
21
|
+
const runtime = typeof window !== "undefined" ? window.__GNAPEX__ ?? window.__NEXUS__ : void 0;
|
|
22
|
+
const meta = typeof document !== "undefined" ? (name) => document.querySelector(`meta[name="${name}"]`)?.getAttribute("content") ?? void 0 : (_name) => void 0;
|
|
23
|
+
const projectId = runtime?.projectId ?? meta("gnapex-project") ?? meta("nexus-project") ?? NEXT_PUBLIC_ID ?? NODE_ID;
|
|
24
|
+
const apiKey = runtime?.apiKey ?? meta("gnapex-key") ?? meta("nexus-key") ?? NEXT_PUBLIC_KEY ?? NODE_KEY;
|
|
25
|
+
const apiUrl = runtime?.apiUrl ?? meta("gnapex-api") ?? meta("nexus-api") ?? NEXT_PUBLIC_URL ?? NODE_URL ?? (isDev ? LOCAL_NEST_URL : DEFAULT_API_URL);
|
|
26
|
+
const analyticsUrl = runtime?.analyticsUrl ?? meta("gnapex-analytics") ?? meta("nexus-analytics") ?? NEXT_PUBLIC_ANALYTICS_URL ?? NODE_ANALYTICS_URL ?? (apiUrl.includes("localhost") ? LOCAL_RUST_URL : DEFAULT_ANALYTICS_URL);
|
|
23
27
|
return {
|
|
24
28
|
projectId,
|
|
25
29
|
apiKey,
|
|
@@ -126,6 +130,16 @@ BinaryCompiler.MAGIC_HEADER = "NEXS";
|
|
|
126
130
|
// 4-byte ASCII magic identifier
|
|
127
131
|
BinaryCompiler.ALGORITHM = "aes-256-cbc";
|
|
128
132
|
|
|
133
|
+
// src/content/utils.ts
|
|
134
|
+
function validateSlug(slug) {
|
|
135
|
+
if (!slug || typeof slug !== "string") {
|
|
136
|
+
throw new Error("Slug must be a non-empty string");
|
|
137
|
+
}
|
|
138
|
+
if (!/^[a-z0-9-_]+$/.test(slug)) {
|
|
139
|
+
throw new Error("Slug can only contain lowercase letters, numbers, hyphens, and underscores");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
129
143
|
// src/content/local-cache-server.ts
|
|
130
144
|
var LocalCache = class {
|
|
131
145
|
constructor(customPath, apiKey) {
|
|
@@ -137,9 +151,6 @@ var LocalCache = class {
|
|
|
137
151
|
isLoaded() {
|
|
138
152
|
return fs.existsSync(path.resolve(process.cwd(), this.baseDir));
|
|
139
153
|
}
|
|
140
|
-
/**
|
|
141
|
-
* Helper to decrypt and decompile `.nx` files on-the-fly.
|
|
142
|
-
*/
|
|
143
154
|
decompileFile(filePath) {
|
|
144
155
|
if (!this.apiKey) {
|
|
145
156
|
if (process.env.NODE_ENV === "development") {
|
|
@@ -168,9 +179,14 @@ var LocalCache = class {
|
|
|
168
179
|
}
|
|
169
180
|
}
|
|
170
181
|
/**
|
|
171
|
-
* Retrieve a specific page
|
|
182
|
+
* Retrieve a specific page safely from its .nx file.
|
|
172
183
|
*/
|
|
173
184
|
async getPage(slug) {
|
|
185
|
+
try {
|
|
186
|
+
validateSlug(slug);
|
|
187
|
+
} catch {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
174
190
|
const filePath = path.resolve(
|
|
175
191
|
process.cwd(),
|
|
176
192
|
this.baseDir,
|
|
@@ -189,9 +205,14 @@ var LocalCache = class {
|
|
|
189
205
|
return null;
|
|
190
206
|
}
|
|
191
207
|
/**
|
|
192
|
-
* Retrieve an entire collection from its specific .nx file.
|
|
208
|
+
* Retrieve an entire collection safely from its specific .nx file.
|
|
193
209
|
*/
|
|
194
210
|
async getCollection(collectionId) {
|
|
211
|
+
try {
|
|
212
|
+
validateSlug(collectionId);
|
|
213
|
+
} catch {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
195
216
|
const filePath = path.resolve(
|
|
196
217
|
process.cwd(),
|
|
197
218
|
this.baseDir,
|