@nexushub/client 0.9.0 → 1.1.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/README.md +36 -1078
- package/dist/chunk-OP3LNZPC.cjs +116 -0
- package/dist/chunk-PB3YCBFH.js +116 -0
- package/dist/cli.cjs +259 -428
- package/dist/content/local-cache-server.cjs +36 -15
- 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 +36 -15
- package/dist/index.cjs +662 -341
- package/dist/index.d.cts +221 -32
- package/dist/index.d.ts +221 -32
- package/dist/index.js +652 -341
- package/dist/{local-cache-server-KUGMBMJP.cjs → local-cache-server-EKRKNL6N.cjs} +16 -8
- package/dist/{local-cache-server-RM7T456Z.js → local-cache-server-POO2S6OU.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 +34 -28
- package/dist/chunk-3TDCUTZR.cjs +0 -53
- package/dist/chunk-VQ6IEN4I.js +0 -53
|
@@ -1,6 +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 }; }
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
var _chunkOP3LNZPCcjs = require('./chunk-OP3LNZPC.cjs');
|
|
4
5
|
|
|
5
6
|
// src/content/local-cache-server.ts
|
|
6
7
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
@@ -109,15 +110,12 @@ var LocalCache = class {
|
|
|
109
110
|
constructor(customPath, apiKey) {
|
|
110
111
|
this.apiKey = "";
|
|
111
112
|
this.baseDir = customPath || ".nexus/local";
|
|
112
|
-
const config =
|
|
113
|
+
const config = _chunkOP3LNZPCcjs.getEnvConfig.call(void 0, );
|
|
113
114
|
this.apiKey = apiKey || config.apiKey || "";
|
|
114
115
|
}
|
|
115
116
|
isLoaded() {
|
|
116
117
|
return _fs2.default.existsSync(_path2.default.resolve(process.cwd(), this.baseDir));
|
|
117
118
|
}
|
|
118
|
-
/**
|
|
119
|
-
* Helper to decrypt and decompile `.nx` files on-the-fly.
|
|
120
|
-
*/
|
|
121
119
|
decompileFile(filePath) {
|
|
122
120
|
if (!this.apiKey) {
|
|
123
121
|
if (process.env.NODE_ENV === "development") {
|
|
@@ -146,9 +144,14 @@ var LocalCache = class {
|
|
|
146
144
|
}
|
|
147
145
|
}
|
|
148
146
|
/**
|
|
149
|
-
* Retrieve a specific page
|
|
147
|
+
* Retrieve a specific page safely from its .nx file.
|
|
150
148
|
*/
|
|
151
149
|
async getPage(slug) {
|
|
150
|
+
try {
|
|
151
|
+
_chunkOP3LNZPCcjs.validateSlug.call(void 0, slug);
|
|
152
|
+
} catch (e) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
152
155
|
const filePath = _path2.default.resolve(
|
|
153
156
|
process.cwd(),
|
|
154
157
|
this.baseDir,
|
|
@@ -167,9 +170,14 @@ var LocalCache = class {
|
|
|
167
170
|
return null;
|
|
168
171
|
}
|
|
169
172
|
/**
|
|
170
|
-
* Retrieve an entire collection from its specific .nx file.
|
|
173
|
+
* Retrieve an entire collection safely from its specific .nx file.
|
|
171
174
|
*/
|
|
172
175
|
async getCollection(collectionId) {
|
|
176
|
+
try {
|
|
177
|
+
_chunkOP3LNZPCcjs.validateSlug.call(void 0, collectionId);
|
|
178
|
+
} catch (e2) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
173
181
|
const filePath = _path2.default.resolve(
|
|
174
182
|
process.cwd(),
|
|
175
183
|
this.baseDir,
|
|
@@ -218,7 +226,7 @@ var LocalCache = class {
|
|
|
218
226
|
}
|
|
219
227
|
}
|
|
220
228
|
globals = await this.getGlobals() || {};
|
|
221
|
-
} catch (
|
|
229
|
+
} catch (e3) {
|
|
222
230
|
}
|
|
223
231
|
return { pages, collections, globals };
|
|
224
232
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
getEnvConfig
|
|
3
|
-
|
|
2
|
+
getEnvConfig,
|
|
3
|
+
validateSlug
|
|
4
|
+
} from "./chunk-PB3YCBFH.js";
|
|
4
5
|
|
|
5
6
|
// src/content/local-cache-server.ts
|
|
6
7
|
import fs from "fs";
|
|
@@ -115,9 +116,6 @@ var LocalCache = class {
|
|
|
115
116
|
isLoaded() {
|
|
116
117
|
return fs.existsSync(path.resolve(process.cwd(), this.baseDir));
|
|
117
118
|
}
|
|
118
|
-
/**
|
|
119
|
-
* Helper to decrypt and decompile `.nx` files on-the-fly.
|
|
120
|
-
*/
|
|
121
119
|
decompileFile(filePath) {
|
|
122
120
|
if (!this.apiKey) {
|
|
123
121
|
if (process.env.NODE_ENV === "development") {
|
|
@@ -146,9 +144,14 @@ var LocalCache = class {
|
|
|
146
144
|
}
|
|
147
145
|
}
|
|
148
146
|
/**
|
|
149
|
-
* Retrieve a specific page
|
|
147
|
+
* Retrieve a specific page safely from its .nx file.
|
|
150
148
|
*/
|
|
151
149
|
async getPage(slug) {
|
|
150
|
+
try {
|
|
151
|
+
validateSlug(slug);
|
|
152
|
+
} catch {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
152
155
|
const filePath = path.resolve(
|
|
153
156
|
process.cwd(),
|
|
154
157
|
this.baseDir,
|
|
@@ -167,9 +170,14 @@ var LocalCache = class {
|
|
|
167
170
|
return null;
|
|
168
171
|
}
|
|
169
172
|
/**
|
|
170
|
-
* Retrieve an entire collection from its specific .nx file.
|
|
173
|
+
* Retrieve an entire collection safely from its specific .nx file.
|
|
171
174
|
*/
|
|
172
175
|
async getCollection(collectionId) {
|
|
176
|
+
try {
|
|
177
|
+
validateSlug(collectionId);
|
|
178
|
+
} catch {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
173
181
|
const filePath = path.resolve(
|
|
174
182
|
process.cwd(),
|
|
175
183
|
this.baseDir,
|