@nexushub/client 0.4.0 → 0.4.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/chunk-FMMFQP5O.cjs +2643 -0
- package/dist/chunk-G4SHBWAQ.js +2643 -0
- package/dist/cli.cjs +77 -80
- package/dist/content/local-cache-client.cjs +3 -1
- package/dist/content/local-cache-client.js +2 -0
- package/dist/content/local-cache-server.cjs +78 -72
- package/dist/content/local-cache-server.d.cts +5 -20
- package/dist/content/local-cache-server.d.ts +5 -20
- package/dist/content/local-cache-server.js +77 -71
- package/dist/index.cjs +3 -2568
- package/dist/index.d.cts +4 -359
- package/dist/index.d.ts +4 -359
- package/dist/index.js +23 -2588
- package/dist/react-C795ypnM.d.cts +386 -0
- package/dist/react-C795ypnM.d.ts +386 -0
- package/dist/react.cjs +17 -0
- package/dist/react.d.cts +3 -0
- package/dist/react.d.ts +3 -0
- package/dist/react.js +17 -0
- package/package.json +16 -2
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
+
|
|
3
|
+
// src/content/local-cache-client.ts
|
|
2
4
|
var LocalCache = class {
|
|
3
5
|
constructor(customPath) {
|
|
4
6
|
// Maintain private properties for type parity with the Server version
|
|
@@ -1,108 +1,114 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }"use client";
|
|
2
|
+
|
|
3
|
+
// src/content/local-cache-server.ts
|
|
2
4
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
3
5
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
4
6
|
var LocalCache = class {
|
|
5
7
|
constructor(customPath) {
|
|
6
|
-
this.
|
|
7
|
-
this.hasLoaded = false;
|
|
8
|
-
this.cachePath = customPath || ".nexus/cache.json";
|
|
8
|
+
this.baseDir = customPath || ".nexus/local";
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Returns true if the local cache file has been successfully
|
|
12
|
-
* loaded and parsed into memory.
|
|
13
|
-
*/
|
|
14
10
|
isLoaded() {
|
|
15
|
-
return this.
|
|
11
|
+
return _fs2.default.existsSync(_path2.default.resolve(process.cwd(), this.baseDir));
|
|
16
12
|
}
|
|
17
13
|
/**
|
|
18
|
-
*
|
|
19
|
-
* Internal method called lazily by the getters.
|
|
14
|
+
* Retrieve a specific page directly from its file.
|
|
20
15
|
*/
|
|
21
|
-
|
|
22
|
-
if (typeof window !== "undefined") return;
|
|
23
|
-
if (this.hasLoaded) return;
|
|
16
|
+
async getPage(slug) {
|
|
24
17
|
try {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
console.log(
|
|
36
|
-
` - Collections: ${Object.keys(this.data.collections || {}).length}`
|
|
37
|
-
);
|
|
38
|
-
console.log(
|
|
39
|
-
` - Globals: ${this.data.globals ? "Loaded" : "Not found"}`
|
|
40
|
-
);
|
|
41
|
-
}
|
|
18
|
+
const filePath = _path2.default.resolve(
|
|
19
|
+
process.cwd(),
|
|
20
|
+
this.baseDir,
|
|
21
|
+
"pages",
|
|
22
|
+
`${slug}.json`
|
|
23
|
+
);
|
|
24
|
+
if (_fs2.default.existsSync(filePath)) {
|
|
25
|
+
const fileContent = _fs2.default.readFileSync(filePath, "utf-8");
|
|
26
|
+
const pageData = JSON.parse(fileContent);
|
|
27
|
+
return pageData.data !== void 0 ? pageData.data : pageData;
|
|
42
28
|
}
|
|
43
29
|
} catch (error) {
|
|
44
|
-
if (
|
|
30
|
+
if (process.env.NODE_ENV === "development") {
|
|
45
31
|
console.warn(
|
|
46
|
-
`\u26A0\uFE0F
|
|
47
|
-
|
|
32
|
+
`\u26A0\uFE0F NexusHub: Failed to load local page '${slug}':`,
|
|
33
|
+
error
|
|
48
34
|
);
|
|
49
35
|
}
|
|
50
36
|
}
|
|
37
|
+
return null;
|
|
51
38
|
}
|
|
52
39
|
/**
|
|
53
|
-
* Retrieve
|
|
54
|
-
*/
|
|
55
|
-
async getPage(slug) {
|
|
56
|
-
this.load();
|
|
57
|
-
if (!_optionalChain([this, 'access', _4 => _4.data, 'optionalAccess', _5 => _5.pages])) return null;
|
|
58
|
-
const page = this.data.pages.find((p) => p.slug === slug);
|
|
59
|
-
if (!page) {
|
|
60
|
-
if (process.env.NODE_ENV === "development") {
|
|
61
|
-
console.warn(`\u26A0\uFE0F NexusHub: Page '${slug}' not found in local cache.`);
|
|
62
|
-
}
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
return page.data;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Retrieve an entire collection from the local collections map.
|
|
40
|
+
* Retrieve an entire collection from its specific collection file.
|
|
69
41
|
*/
|
|
70
42
|
async getCollection(collectionId) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
43
|
+
try {
|
|
44
|
+
const filePath = _path2.default.resolve(
|
|
45
|
+
process.cwd(),
|
|
46
|
+
this.baseDir,
|
|
47
|
+
"collections",
|
|
48
|
+
`${collectionId}.json`
|
|
49
|
+
);
|
|
50
|
+
if (_fs2.default.existsSync(filePath)) {
|
|
51
|
+
const fileContent = _fs2.default.readFileSync(filePath, "utf-8");
|
|
52
|
+
return JSON.parse(fileContent);
|
|
53
|
+
}
|
|
54
|
+
} catch (error) {
|
|
75
55
|
if (process.env.NODE_ENV === "development") {
|
|
76
56
|
console.warn(
|
|
77
|
-
`\u26A0\uFE0F
|
|
57
|
+
`\u26A0\uFE0F NexusHub: Failed to load local collection '${collectionId}':`,
|
|
58
|
+
error
|
|
78
59
|
);
|
|
79
60
|
}
|
|
80
|
-
return null;
|
|
81
61
|
}
|
|
82
|
-
return
|
|
62
|
+
return null;
|
|
83
63
|
}
|
|
84
64
|
/**
|
|
85
|
-
* Retrieve global settings from
|
|
65
|
+
* Retrieve global settings from its file.
|
|
86
66
|
*/
|
|
87
67
|
async getGlobals() {
|
|
88
|
-
|
|
89
|
-
|
|
68
|
+
try {
|
|
69
|
+
const filePath = _path2.default.resolve(
|
|
70
|
+
process.cwd(),
|
|
71
|
+
this.baseDir,
|
|
72
|
+
"globals.json"
|
|
73
|
+
);
|
|
74
|
+
if (_fs2.default.existsSync(filePath)) {
|
|
75
|
+
const fileContent = _fs2.default.readFileSync(filePath, "utf-8");
|
|
76
|
+
return JSON.parse(fileContent);
|
|
77
|
+
}
|
|
78
|
+
} catch (e) {
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
90
81
|
}
|
|
91
82
|
/**
|
|
92
|
-
* Returns the entire
|
|
83
|
+
* Returns a merged JSON of the entire workspace structure (for dev analytics/inspectors)
|
|
93
84
|
*/
|
|
94
85
|
async getAllData() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
86
|
+
const pages = {};
|
|
87
|
+
const collections = {};
|
|
88
|
+
let globals = {};
|
|
89
|
+
try {
|
|
90
|
+
const pagesDir = _path2.default.resolve(process.cwd(), this.baseDir, "pages");
|
|
91
|
+
if (_fs2.default.existsSync(pagesDir)) {
|
|
92
|
+
for (const file of _fs2.default.readdirSync(pagesDir)) {
|
|
93
|
+
if (file.endsWith(".json")) {
|
|
94
|
+
const slug = _path2.default.basename(file, ".json");
|
|
95
|
+
pages[slug] = await this.getPage(slug);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const colsDir = _path2.default.resolve(process.cwd(), this.baseDir, "collections");
|
|
100
|
+
if (_fs2.default.existsSync(colsDir)) {
|
|
101
|
+
for (const file of _fs2.default.readdirSync(colsDir)) {
|
|
102
|
+
if (file.endsWith(".json")) {
|
|
103
|
+
const id = _path2.default.basename(file, ".json");
|
|
104
|
+
collections[id] = await this.getCollection(id) || [];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
globals = await this.getGlobals() || {};
|
|
109
|
+
} catch (e2) {
|
|
110
|
+
}
|
|
111
|
+
return { pages, collections, globals };
|
|
106
112
|
}
|
|
107
113
|
};
|
|
108
114
|
|
|
@@ -1,40 +1,25 @@
|
|
|
1
1
|
import { I as ILocalCache } from '../cache-types-B39iNHfE.cjs';
|
|
2
2
|
|
|
3
3
|
declare class LocalCache implements ILocalCache {
|
|
4
|
-
private
|
|
5
|
-
private hasLoaded;
|
|
6
|
-
private cachePath;
|
|
4
|
+
private baseDir;
|
|
7
5
|
constructor(customPath?: string);
|
|
8
|
-
/**
|
|
9
|
-
* Returns true if the local cache file has been successfully
|
|
10
|
-
* loaded and parsed into memory.
|
|
11
|
-
*/
|
|
12
6
|
isLoaded(): boolean;
|
|
13
7
|
/**
|
|
14
|
-
*
|
|
15
|
-
* Internal method called lazily by the getters.
|
|
16
|
-
*/
|
|
17
|
-
private load;
|
|
18
|
-
/**
|
|
19
|
-
* Retrieve a specific page from the local pages array.
|
|
8
|
+
* Retrieve a specific page directly from its file.
|
|
20
9
|
*/
|
|
21
10
|
getPage(slug: string): Promise<any>;
|
|
22
11
|
/**
|
|
23
|
-
* Retrieve an entire collection from
|
|
12
|
+
* Retrieve an entire collection from its specific collection file.
|
|
24
13
|
*/
|
|
25
14
|
getCollection(collectionId: string): Promise<any[] | null>;
|
|
26
15
|
/**
|
|
27
|
-
* Retrieve global settings from
|
|
16
|
+
* Retrieve global settings from its file.
|
|
28
17
|
*/
|
|
29
18
|
getGlobals(): Promise<any>;
|
|
30
19
|
/**
|
|
31
|
-
* Returns the entire
|
|
20
|
+
* Returns a merged JSON of the entire workspace structure (for dev analytics/inspectors)
|
|
32
21
|
*/
|
|
33
22
|
getAllData(): Promise<any>;
|
|
34
|
-
/**
|
|
35
|
-
* Helper to determine if we should bother the user with a warning.
|
|
36
|
-
*/
|
|
37
|
-
private shouldWarnAboutMissingCache;
|
|
38
23
|
}
|
|
39
24
|
|
|
40
25
|
export { LocalCache };
|
|
@@ -1,40 +1,25 @@
|
|
|
1
1
|
import { I as ILocalCache } from '../cache-types-B39iNHfE.js';
|
|
2
2
|
|
|
3
3
|
declare class LocalCache implements ILocalCache {
|
|
4
|
-
private
|
|
5
|
-
private hasLoaded;
|
|
6
|
-
private cachePath;
|
|
4
|
+
private baseDir;
|
|
7
5
|
constructor(customPath?: string);
|
|
8
|
-
/**
|
|
9
|
-
* Returns true if the local cache file has been successfully
|
|
10
|
-
* loaded and parsed into memory.
|
|
11
|
-
*/
|
|
12
6
|
isLoaded(): boolean;
|
|
13
7
|
/**
|
|
14
|
-
*
|
|
15
|
-
* Internal method called lazily by the getters.
|
|
16
|
-
*/
|
|
17
|
-
private load;
|
|
18
|
-
/**
|
|
19
|
-
* Retrieve a specific page from the local pages array.
|
|
8
|
+
* Retrieve a specific page directly from its file.
|
|
20
9
|
*/
|
|
21
10
|
getPage(slug: string): Promise<any>;
|
|
22
11
|
/**
|
|
23
|
-
* Retrieve an entire collection from
|
|
12
|
+
* Retrieve an entire collection from its specific collection file.
|
|
24
13
|
*/
|
|
25
14
|
getCollection(collectionId: string): Promise<any[] | null>;
|
|
26
15
|
/**
|
|
27
|
-
* Retrieve global settings from
|
|
16
|
+
* Retrieve global settings from its file.
|
|
28
17
|
*/
|
|
29
18
|
getGlobals(): Promise<any>;
|
|
30
19
|
/**
|
|
31
|
-
* Returns the entire
|
|
20
|
+
* Returns a merged JSON of the entire workspace structure (for dev analytics/inspectors)
|
|
32
21
|
*/
|
|
33
22
|
getAllData(): Promise<any>;
|
|
34
|
-
/**
|
|
35
|
-
* Helper to determine if we should bother the user with a warning.
|
|
36
|
-
*/
|
|
37
|
-
private shouldWarnAboutMissingCache;
|
|
38
23
|
}
|
|
39
24
|
|
|
40
25
|
export { LocalCache };
|
|
@@ -1,108 +1,114 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
// src/content/local-cache-server.ts
|
|
2
4
|
import fs from "fs";
|
|
3
5
|
import path from "path";
|
|
4
6
|
var LocalCache = class {
|
|
5
7
|
constructor(customPath) {
|
|
6
|
-
this.
|
|
7
|
-
this.hasLoaded = false;
|
|
8
|
-
this.cachePath = customPath || ".nexus/cache.json";
|
|
8
|
+
this.baseDir = customPath || ".nexus/local";
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Returns true if the local cache file has been successfully
|
|
12
|
-
* loaded and parsed into memory.
|
|
13
|
-
*/
|
|
14
10
|
isLoaded() {
|
|
15
|
-
return this.
|
|
11
|
+
return fs.existsSync(path.resolve(process.cwd(), this.baseDir));
|
|
16
12
|
}
|
|
17
13
|
/**
|
|
18
|
-
*
|
|
19
|
-
* Internal method called lazily by the getters.
|
|
14
|
+
* Retrieve a specific page directly from its file.
|
|
20
15
|
*/
|
|
21
|
-
|
|
22
|
-
if (typeof window !== "undefined") return;
|
|
23
|
-
if (this.hasLoaded) return;
|
|
16
|
+
async getPage(slug) {
|
|
24
17
|
try {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
console.log(
|
|
36
|
-
` - Collections: ${Object.keys(this.data.collections || {}).length}`
|
|
37
|
-
);
|
|
38
|
-
console.log(
|
|
39
|
-
` - Globals: ${this.data.globals ? "Loaded" : "Not found"}`
|
|
40
|
-
);
|
|
41
|
-
}
|
|
18
|
+
const filePath = path.resolve(
|
|
19
|
+
process.cwd(),
|
|
20
|
+
this.baseDir,
|
|
21
|
+
"pages",
|
|
22
|
+
`${slug}.json`
|
|
23
|
+
);
|
|
24
|
+
if (fs.existsSync(filePath)) {
|
|
25
|
+
const fileContent = fs.readFileSync(filePath, "utf-8");
|
|
26
|
+
const pageData = JSON.parse(fileContent);
|
|
27
|
+
return pageData.data !== void 0 ? pageData.data : pageData;
|
|
42
28
|
}
|
|
43
29
|
} catch (error) {
|
|
44
|
-
if (
|
|
30
|
+
if (process.env.NODE_ENV === "development") {
|
|
45
31
|
console.warn(
|
|
46
|
-
`\u26A0\uFE0F
|
|
47
|
-
|
|
32
|
+
`\u26A0\uFE0F NexusHub: Failed to load local page '${slug}':`,
|
|
33
|
+
error
|
|
48
34
|
);
|
|
49
35
|
}
|
|
50
36
|
}
|
|
37
|
+
return null;
|
|
51
38
|
}
|
|
52
39
|
/**
|
|
53
|
-
* Retrieve
|
|
54
|
-
*/
|
|
55
|
-
async getPage(slug) {
|
|
56
|
-
this.load();
|
|
57
|
-
if (!this.data?.pages) return null;
|
|
58
|
-
const page = this.data.pages.find((p) => p.slug === slug);
|
|
59
|
-
if (!page) {
|
|
60
|
-
if (process.env.NODE_ENV === "development") {
|
|
61
|
-
console.warn(`\u26A0\uFE0F NexusHub: Page '${slug}' not found in local cache.`);
|
|
62
|
-
}
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
return page.data;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Retrieve an entire collection from the local collections map.
|
|
40
|
+
* Retrieve an entire collection from its specific collection file.
|
|
69
41
|
*/
|
|
70
42
|
async getCollection(collectionId) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
43
|
+
try {
|
|
44
|
+
const filePath = path.resolve(
|
|
45
|
+
process.cwd(),
|
|
46
|
+
this.baseDir,
|
|
47
|
+
"collections",
|
|
48
|
+
`${collectionId}.json`
|
|
49
|
+
);
|
|
50
|
+
if (fs.existsSync(filePath)) {
|
|
51
|
+
const fileContent = fs.readFileSync(filePath, "utf-8");
|
|
52
|
+
return JSON.parse(fileContent);
|
|
53
|
+
}
|
|
54
|
+
} catch (error) {
|
|
75
55
|
if (process.env.NODE_ENV === "development") {
|
|
76
56
|
console.warn(
|
|
77
|
-
`\u26A0\uFE0F
|
|
57
|
+
`\u26A0\uFE0F NexusHub: Failed to load local collection '${collectionId}':`,
|
|
58
|
+
error
|
|
78
59
|
);
|
|
79
60
|
}
|
|
80
|
-
return null;
|
|
81
61
|
}
|
|
82
|
-
return
|
|
62
|
+
return null;
|
|
83
63
|
}
|
|
84
64
|
/**
|
|
85
|
-
* Retrieve global settings from
|
|
65
|
+
* Retrieve global settings from its file.
|
|
86
66
|
*/
|
|
87
67
|
async getGlobals() {
|
|
88
|
-
|
|
89
|
-
|
|
68
|
+
try {
|
|
69
|
+
const filePath = path.resolve(
|
|
70
|
+
process.cwd(),
|
|
71
|
+
this.baseDir,
|
|
72
|
+
"globals.json"
|
|
73
|
+
);
|
|
74
|
+
if (fs.existsSync(filePath)) {
|
|
75
|
+
const fileContent = fs.readFileSync(filePath, "utf-8");
|
|
76
|
+
return JSON.parse(fileContent);
|
|
77
|
+
}
|
|
78
|
+
} catch {
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
90
81
|
}
|
|
91
82
|
/**
|
|
92
|
-
* Returns the entire
|
|
83
|
+
* Returns a merged JSON of the entire workspace structure (for dev analytics/inspectors)
|
|
93
84
|
*/
|
|
94
85
|
async getAllData() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
86
|
+
const pages = {};
|
|
87
|
+
const collections = {};
|
|
88
|
+
let globals = {};
|
|
89
|
+
try {
|
|
90
|
+
const pagesDir = path.resolve(process.cwd(), this.baseDir, "pages");
|
|
91
|
+
if (fs.existsSync(pagesDir)) {
|
|
92
|
+
for (const file of fs.readdirSync(pagesDir)) {
|
|
93
|
+
if (file.endsWith(".json")) {
|
|
94
|
+
const slug = path.basename(file, ".json");
|
|
95
|
+
pages[slug] = await this.getPage(slug);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const colsDir = path.resolve(process.cwd(), this.baseDir, "collections");
|
|
100
|
+
if (fs.existsSync(colsDir)) {
|
|
101
|
+
for (const file of fs.readdirSync(colsDir)) {
|
|
102
|
+
if (file.endsWith(".json")) {
|
|
103
|
+
const id = path.basename(file, ".json");
|
|
104
|
+
collections[id] = await this.getCollection(id) || [];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
globals = await this.getGlobals() || {};
|
|
109
|
+
} catch {
|
|
110
|
+
}
|
|
111
|
+
return { pages, collections, globals };
|
|
106
112
|
}
|
|
107
113
|
};
|
|
108
114
|
export {
|