@nexushub/client 0.0.8 → 0.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/dist/cache-types-B39iNHfE.d.cts +9 -0
- package/dist/cache-types-B39iNHfE.d.ts +9 -0
- package/dist/cli.cjs +0 -1
- package/dist/content/local-cache-client.cjs +12 -10
- package/dist/content/local-cache-client.d.cts +7 -8
- package/dist/content/local-cache-client.d.ts +7 -8
- package/dist/content/local-cache-client.js +11 -9
- package/dist/content/local-cache-server.cjs +7 -9
- package/dist/content/local-cache-server.d.cts +5 -5
- package/dist/content/local-cache-server.d.ts +5 -5
- package/dist/content/local-cache-server.js +6 -8
- package/dist/index.cjs +65 -43
- package/dist/index.d.cts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.js +46 -24
- package/package.json +1 -1
- package/dist/cache-CtPpNvIZ.d.cts +0 -11
- package/dist/cache-CtPpNvIZ.d.ts +0 -11
- package/dist/chunk-3RG5ZIWI.js +0 -10
- package/dist/chunk-OBGZSXTJ.cjs +0 -10
package/dist/cli.cjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
2
|
-
|
|
3
|
-
// src/content/local-cache-client.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/content/local-cache-client.ts
|
|
4
2
|
var LocalCache = class {
|
|
5
3
|
constructor(customPath) {
|
|
4
|
+
// Maintain private properties for type parity with the Server version
|
|
6
5
|
this.data = null;
|
|
7
6
|
this.hasLoaded = false;
|
|
8
7
|
this.cachePath = customPath || ".nexus/cache.json";
|
|
@@ -15,7 +14,7 @@ var LocalCache = class {
|
|
|
15
14
|
return false;
|
|
16
15
|
}
|
|
17
16
|
/**
|
|
18
|
-
* No-op method to maintain API compatibility
|
|
17
|
+
* No-op method to maintain internal API compatibility.
|
|
19
18
|
*/
|
|
20
19
|
load() {
|
|
21
20
|
return;
|
|
@@ -24,32 +23,35 @@ var LocalCache = class {
|
|
|
24
23
|
* Returns null. Browsers should fetch pages from the Remote API
|
|
25
24
|
* or the Memory/Browser cache.
|
|
26
25
|
*/
|
|
27
|
-
getPage(_slug) {
|
|
26
|
+
async getPage(_slug) {
|
|
28
27
|
return null;
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
30
|
* Returns null. Browsers should fetch collections from the Remote API.
|
|
32
31
|
*/
|
|
33
|
-
getCollection(_collectionId) {
|
|
32
|
+
async getCollection(_collectionId) {
|
|
34
33
|
return null;
|
|
35
34
|
}
|
|
36
35
|
/**
|
|
37
36
|
* Returns null.
|
|
38
37
|
*/
|
|
39
|
-
getGlobals() {
|
|
38
|
+
async getGlobals() {
|
|
40
39
|
return null;
|
|
41
40
|
}
|
|
42
41
|
/**
|
|
43
42
|
* Returns null.
|
|
44
43
|
*/
|
|
45
|
-
getAllData() {
|
|
44
|
+
async getAllData() {
|
|
46
45
|
return null;
|
|
47
46
|
}
|
|
48
47
|
/**
|
|
49
48
|
* Dummy helper to match Node implementation.
|
|
50
49
|
*/
|
|
51
|
-
shouldWarnAboutMissingCache(
|
|
52
|
-
|
|
50
|
+
shouldWarnAboutMissingCache(error) {
|
|
51
|
+
const isMissing = error.code === "ENOENT";
|
|
52
|
+
const isMalformed = error instanceof SyntaxError;
|
|
53
|
+
if (process.env.NODE_ENV !== "development") return false;
|
|
54
|
+
return !isMissing || isMalformed;
|
|
53
55
|
}
|
|
54
56
|
};
|
|
55
57
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as ILocalCache } from '../cache-
|
|
1
|
+
import { I as ILocalCache } from '../cache-types-B39iNHfE.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* NexusHub LocalCache (Browser Implementation)
|
|
@@ -7,10 +7,9 @@ import { I as ILocalCache } from '../cache-CtPpNvIZ.cjs';
|
|
|
7
7
|
* Since the browser has no access to the Node.js File System (fs), this
|
|
8
8
|
* implementation returns null for all operations.
|
|
9
9
|
*
|
|
10
|
-
* The real logic is located in local-cache.
|
|
10
|
+
* The real logic is located in local-cache-server.ts and is swapped
|
|
11
11
|
* automatically by the bundler via the "browser" field in package.json.
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
13
|
declare class LocalCache implements ILocalCache {
|
|
15
14
|
private data;
|
|
16
15
|
private hasLoaded;
|
|
@@ -22,26 +21,26 @@ declare class LocalCache implements ILocalCache {
|
|
|
22
21
|
*/
|
|
23
22
|
isLoaded(): boolean;
|
|
24
23
|
/**
|
|
25
|
-
* No-op method to maintain API compatibility
|
|
24
|
+
* No-op method to maintain internal API compatibility.
|
|
26
25
|
*/
|
|
27
26
|
private load;
|
|
28
27
|
/**
|
|
29
28
|
* Returns null. Browsers should fetch pages from the Remote API
|
|
30
29
|
* or the Memory/Browser cache.
|
|
31
30
|
*/
|
|
32
|
-
getPage(_slug: string): any
|
|
31
|
+
getPage(_slug: string): Promise<any>;
|
|
33
32
|
/**
|
|
34
33
|
* Returns null. Browsers should fetch collections from the Remote API.
|
|
35
34
|
*/
|
|
36
|
-
getCollection(_collectionId: string): any[] | null
|
|
35
|
+
getCollection(_collectionId: string): Promise<any[] | null>;
|
|
37
36
|
/**
|
|
38
37
|
* Returns null.
|
|
39
38
|
*/
|
|
40
|
-
getGlobals(): any
|
|
39
|
+
getGlobals(): Promise<any>;
|
|
41
40
|
/**
|
|
42
41
|
* Returns null.
|
|
43
42
|
*/
|
|
44
|
-
getAllData(): any
|
|
43
|
+
getAllData(): Promise<any>;
|
|
45
44
|
/**
|
|
46
45
|
* Dummy helper to match Node implementation.
|
|
47
46
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as ILocalCache } from '../cache-
|
|
1
|
+
import { I as ILocalCache } from '../cache-types-B39iNHfE.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* NexusHub LocalCache (Browser Implementation)
|
|
@@ -7,10 +7,9 @@ import { I as ILocalCache } from '../cache-CtPpNvIZ.js';
|
|
|
7
7
|
* Since the browser has no access to the Node.js File System (fs), this
|
|
8
8
|
* implementation returns null for all operations.
|
|
9
9
|
*
|
|
10
|
-
* The real logic is located in local-cache.
|
|
10
|
+
* The real logic is located in local-cache-server.ts and is swapped
|
|
11
11
|
* automatically by the bundler via the "browser" field in package.json.
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
13
|
declare class LocalCache implements ILocalCache {
|
|
15
14
|
private data;
|
|
16
15
|
private hasLoaded;
|
|
@@ -22,26 +21,26 @@ declare class LocalCache implements ILocalCache {
|
|
|
22
21
|
*/
|
|
23
22
|
isLoaded(): boolean;
|
|
24
23
|
/**
|
|
25
|
-
* No-op method to maintain API compatibility
|
|
24
|
+
* No-op method to maintain internal API compatibility.
|
|
26
25
|
*/
|
|
27
26
|
private load;
|
|
28
27
|
/**
|
|
29
28
|
* Returns null. Browsers should fetch pages from the Remote API
|
|
30
29
|
* or the Memory/Browser cache.
|
|
31
30
|
*/
|
|
32
|
-
getPage(_slug: string): any
|
|
31
|
+
getPage(_slug: string): Promise<any>;
|
|
33
32
|
/**
|
|
34
33
|
* Returns null. Browsers should fetch collections from the Remote API.
|
|
35
34
|
*/
|
|
36
|
-
getCollection(_collectionId: string): any[] | null
|
|
35
|
+
getCollection(_collectionId: string): Promise<any[] | null>;
|
|
37
36
|
/**
|
|
38
37
|
* Returns null.
|
|
39
38
|
*/
|
|
40
|
-
getGlobals(): any
|
|
39
|
+
getGlobals(): Promise<any>;
|
|
41
40
|
/**
|
|
42
41
|
* Returns null.
|
|
43
42
|
*/
|
|
44
|
-
getAllData(): any
|
|
43
|
+
getAllData(): Promise<any>;
|
|
45
44
|
/**
|
|
46
45
|
* Dummy helper to match Node implementation.
|
|
47
46
|
*/
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import "../chunk-3RG5ZIWI.js";
|
|
2
|
-
|
|
3
1
|
// src/content/local-cache-client.ts
|
|
4
2
|
var LocalCache = class {
|
|
5
3
|
constructor(customPath) {
|
|
4
|
+
// Maintain private properties for type parity with the Server version
|
|
6
5
|
this.data = null;
|
|
7
6
|
this.hasLoaded = false;
|
|
8
7
|
this.cachePath = customPath || ".nexus/cache.json";
|
|
@@ -15,7 +14,7 @@ var LocalCache = class {
|
|
|
15
14
|
return false;
|
|
16
15
|
}
|
|
17
16
|
/**
|
|
18
|
-
* No-op method to maintain API compatibility
|
|
17
|
+
* No-op method to maintain internal API compatibility.
|
|
19
18
|
*/
|
|
20
19
|
load() {
|
|
21
20
|
return;
|
|
@@ -24,32 +23,35 @@ var LocalCache = class {
|
|
|
24
23
|
* Returns null. Browsers should fetch pages from the Remote API
|
|
25
24
|
* or the Memory/Browser cache.
|
|
26
25
|
*/
|
|
27
|
-
getPage(_slug) {
|
|
26
|
+
async getPage(_slug) {
|
|
28
27
|
return null;
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
30
|
* Returns null. Browsers should fetch collections from the Remote API.
|
|
32
31
|
*/
|
|
33
|
-
getCollection(_collectionId) {
|
|
32
|
+
async getCollection(_collectionId) {
|
|
34
33
|
return null;
|
|
35
34
|
}
|
|
36
35
|
/**
|
|
37
36
|
* Returns null.
|
|
38
37
|
*/
|
|
39
|
-
getGlobals() {
|
|
38
|
+
async getGlobals() {
|
|
40
39
|
return null;
|
|
41
40
|
}
|
|
42
41
|
/**
|
|
43
42
|
* Returns null.
|
|
44
43
|
*/
|
|
45
|
-
getAllData() {
|
|
44
|
+
async getAllData() {
|
|
46
45
|
return null;
|
|
47
46
|
}
|
|
48
47
|
/**
|
|
49
48
|
* Dummy helper to match Node implementation.
|
|
50
49
|
*/
|
|
51
|
-
shouldWarnAboutMissingCache(
|
|
52
|
-
|
|
50
|
+
shouldWarnAboutMissingCache(error) {
|
|
51
|
+
const isMissing = error.code === "ENOENT";
|
|
52
|
+
const isMalformed = error instanceof SyntaxError;
|
|
53
|
+
if (process.env.NODE_ENV !== "development") return false;
|
|
54
|
+
return !isMissing || isMalformed;
|
|
53
55
|
}
|
|
54
56
|
};
|
|
55
57
|
export {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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
|
-
|
|
3
|
-
// src/content/local-cache-server.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; }// src/content/local-cache-server.ts
|
|
4
2
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
5
3
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
6
4
|
var LocalCache = class {
|
|
@@ -45,8 +43,8 @@ var LocalCache = class {
|
|
|
45
43
|
} catch (error) {
|
|
46
44
|
if (this.shouldWarnAboutMissingCache(error)) {
|
|
47
45
|
console.warn(
|
|
48
|
-
`\u26A0\uFE0F NexusHub: Local cache
|
|
49
|
-
Run \`npx nexus pull\` to
|
|
46
|
+
`\u26A0\uFE0F NexusHub: Local cache invalid at ${this.cachePath}
|
|
47
|
+
Run \`npx nexus pull\` to fix your seed data.`
|
|
50
48
|
);
|
|
51
49
|
}
|
|
52
50
|
}
|
|
@@ -54,7 +52,7 @@ var LocalCache = class {
|
|
|
54
52
|
/**
|
|
55
53
|
* Retrieve a specific page from the local pages array.
|
|
56
54
|
*/
|
|
57
|
-
getPage(slug) {
|
|
55
|
+
async getPage(slug) {
|
|
58
56
|
this.load();
|
|
59
57
|
if (!_optionalChain([this, 'access', _4 => _4.data, 'optionalAccess', _5 => _5.pages])) return null;
|
|
60
58
|
const page = this.data.pages.find((p) => p.slug === slug);
|
|
@@ -69,7 +67,7 @@ var LocalCache = class {
|
|
|
69
67
|
/**
|
|
70
68
|
* Retrieve an entire collection from the local collections map.
|
|
71
69
|
*/
|
|
72
|
-
getCollection(collectionId) {
|
|
70
|
+
async getCollection(collectionId) {
|
|
73
71
|
this.load();
|
|
74
72
|
if (!_optionalChain([this, 'access', _6 => _6.data, 'optionalAccess', _7 => _7.collections])) return null;
|
|
75
73
|
const collection = this.data.collections[collectionId];
|
|
@@ -86,14 +84,14 @@ var LocalCache = class {
|
|
|
86
84
|
/**
|
|
87
85
|
* Retrieve global settings from the local cache.
|
|
88
86
|
*/
|
|
89
|
-
getGlobals() {
|
|
87
|
+
async getGlobals() {
|
|
90
88
|
this.load();
|
|
91
89
|
return _optionalChain([this, 'access', _8 => _8.data, 'optionalAccess', _9 => _9.globals]) || null;
|
|
92
90
|
}
|
|
93
91
|
/**
|
|
94
92
|
* Returns the entire raw JSON data structure from the cache file.
|
|
95
93
|
*/
|
|
96
|
-
getAllData() {
|
|
94
|
+
async getAllData() {
|
|
97
95
|
this.load();
|
|
98
96
|
return this.data;
|
|
99
97
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as ILocalCache } from '../cache-
|
|
1
|
+
import { I as ILocalCache } from '../cache-types-B39iNHfE.cjs';
|
|
2
2
|
|
|
3
3
|
declare class LocalCache implements ILocalCache {
|
|
4
4
|
private data;
|
|
@@ -18,19 +18,19 @@ declare class LocalCache implements ILocalCache {
|
|
|
18
18
|
/**
|
|
19
19
|
* Retrieve a specific page from the local pages array.
|
|
20
20
|
*/
|
|
21
|
-
getPage(slug: string): any
|
|
21
|
+
getPage(slug: string): Promise<any>;
|
|
22
22
|
/**
|
|
23
23
|
* Retrieve an entire collection from the local collections map.
|
|
24
24
|
*/
|
|
25
|
-
getCollection(collectionId: string): any[] | null
|
|
25
|
+
getCollection(collectionId: string): Promise<any[] | null>;
|
|
26
26
|
/**
|
|
27
27
|
* Retrieve global settings from the local cache.
|
|
28
28
|
*/
|
|
29
|
-
getGlobals(): any
|
|
29
|
+
getGlobals(): Promise<any>;
|
|
30
30
|
/**
|
|
31
31
|
* Returns the entire raw JSON data structure from the cache file.
|
|
32
32
|
*/
|
|
33
|
-
getAllData(): any
|
|
33
|
+
getAllData(): Promise<any>;
|
|
34
34
|
/**
|
|
35
35
|
* Helper to determine if we should bother the user with a warning.
|
|
36
36
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as ILocalCache } from '../cache-
|
|
1
|
+
import { I as ILocalCache } from '../cache-types-B39iNHfE.js';
|
|
2
2
|
|
|
3
3
|
declare class LocalCache implements ILocalCache {
|
|
4
4
|
private data;
|
|
@@ -18,19 +18,19 @@ declare class LocalCache implements ILocalCache {
|
|
|
18
18
|
/**
|
|
19
19
|
* Retrieve a specific page from the local pages array.
|
|
20
20
|
*/
|
|
21
|
-
getPage(slug: string): any
|
|
21
|
+
getPage(slug: string): Promise<any>;
|
|
22
22
|
/**
|
|
23
23
|
* Retrieve an entire collection from the local collections map.
|
|
24
24
|
*/
|
|
25
|
-
getCollection(collectionId: string): any[] | null
|
|
25
|
+
getCollection(collectionId: string): Promise<any[] | null>;
|
|
26
26
|
/**
|
|
27
27
|
* Retrieve global settings from the local cache.
|
|
28
28
|
*/
|
|
29
|
-
getGlobals(): any
|
|
29
|
+
getGlobals(): Promise<any>;
|
|
30
30
|
/**
|
|
31
31
|
* Returns the entire raw JSON data structure from the cache file.
|
|
32
32
|
*/
|
|
33
|
-
getAllData(): any
|
|
33
|
+
getAllData(): Promise<any>;
|
|
34
34
|
/**
|
|
35
35
|
* Helper to determine if we should bother the user with a warning.
|
|
36
36
|
*/
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "../chunk-3RG5ZIWI.js";
|
|
2
|
-
|
|
3
1
|
// src/content/local-cache-server.ts
|
|
4
2
|
import fs from "fs";
|
|
5
3
|
import path from "path";
|
|
@@ -45,8 +43,8 @@ var LocalCache = class {
|
|
|
45
43
|
} catch (error) {
|
|
46
44
|
if (this.shouldWarnAboutMissingCache(error)) {
|
|
47
45
|
console.warn(
|
|
48
|
-
`\u26A0\uFE0F NexusHub: Local cache
|
|
49
|
-
Run \`npx nexus pull\` to
|
|
46
|
+
`\u26A0\uFE0F NexusHub: Local cache invalid at ${this.cachePath}
|
|
47
|
+
Run \`npx nexus pull\` to fix your seed data.`
|
|
50
48
|
);
|
|
51
49
|
}
|
|
52
50
|
}
|
|
@@ -54,7 +52,7 @@ var LocalCache = class {
|
|
|
54
52
|
/**
|
|
55
53
|
* Retrieve a specific page from the local pages array.
|
|
56
54
|
*/
|
|
57
|
-
getPage(slug) {
|
|
55
|
+
async getPage(slug) {
|
|
58
56
|
this.load();
|
|
59
57
|
if (!this.data?.pages) return null;
|
|
60
58
|
const page = this.data.pages.find((p) => p.slug === slug);
|
|
@@ -69,7 +67,7 @@ var LocalCache = class {
|
|
|
69
67
|
/**
|
|
70
68
|
* Retrieve an entire collection from the local collections map.
|
|
71
69
|
*/
|
|
72
|
-
getCollection(collectionId) {
|
|
70
|
+
async getCollection(collectionId) {
|
|
73
71
|
this.load();
|
|
74
72
|
if (!this.data?.collections) return null;
|
|
75
73
|
const collection = this.data.collections[collectionId];
|
|
@@ -86,14 +84,14 @@ var LocalCache = class {
|
|
|
86
84
|
/**
|
|
87
85
|
* Retrieve global settings from the local cache.
|
|
88
86
|
*/
|
|
89
|
-
getGlobals() {
|
|
87
|
+
async getGlobals() {
|
|
90
88
|
this.load();
|
|
91
89
|
return this.data?.globals || null;
|
|
92
90
|
}
|
|
93
91
|
/**
|
|
94
92
|
* Returns the entire raw JSON data structure from the cache file.
|
|
95
93
|
*/
|
|
96
|
-
getAllData() {
|
|
94
|
+
async getAllData() {
|
|
97
95
|
this.load();
|
|
98
96
|
return this.data;
|
|
99
97
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
|
-
|
|
3
|
-
var _chunkOBGZSXTJcjs = require('./chunk-OBGZSXTJ.cjs');
|
|
4
|
-
|
|
5
|
-
// src/config.ts
|
|
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; }// src/config.ts
|
|
6
2
|
var DEFAULT_API_URL = "http://localhost:3001";
|
|
7
3
|
var DEFAULT_ANALYTICS_URL = "http://localhost:3002";
|
|
8
4
|
var LOCAL_NEST_URL = "http://localhost:3001";
|
|
@@ -308,20 +304,42 @@ var BrowserCache = class {
|
|
|
308
304
|
};
|
|
309
305
|
|
|
310
306
|
// src/content/cache.ts
|
|
311
|
-
var
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
LocalCacheConstructor = _chunkOBGZSXTJcjs.__require.call(void 0, serverPath).LocalCache;
|
|
316
|
-
} catch (e) {
|
|
317
|
-
LocalCacheConstructor = class Dummy {
|
|
318
|
-
};
|
|
307
|
+
var LocalCacheProxy = class {
|
|
308
|
+
constructor(cachePath) {
|
|
309
|
+
this.instance = null;
|
|
310
|
+
this.cachePath = cachePath;
|
|
319
311
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
312
|
+
async getInstance() {
|
|
313
|
+
if (this.instance) return this.instance;
|
|
314
|
+
if (typeof window === "undefined") {
|
|
315
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./content/local-cache-server.cjs")));
|
|
316
|
+
this.instance = new mod.LocalCache(this.cachePath);
|
|
317
|
+
} else {
|
|
318
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./content/local-cache-client.cjs")));
|
|
319
|
+
this.instance = new mod.LocalCache(this.cachePath);
|
|
320
|
+
}
|
|
321
|
+
return this.instance;
|
|
322
|
+
}
|
|
323
|
+
isLoaded() {
|
|
324
|
+
return _optionalChain([this, 'access', _7 => _7.instance, 'optionalAccess', _8 => _8.isLoaded, 'call', _9 => _9()]) || false;
|
|
325
|
+
}
|
|
326
|
+
async getPage(slug) {
|
|
327
|
+
const inst = await this.getInstance();
|
|
328
|
+
return inst.getPage(slug);
|
|
329
|
+
}
|
|
330
|
+
async getCollection(id) {
|
|
331
|
+
const inst = await this.getInstance();
|
|
332
|
+
return inst.getCollection(id);
|
|
333
|
+
}
|
|
334
|
+
async getGlobals() {
|
|
335
|
+
const inst = await this.getInstance();
|
|
336
|
+
return inst.getGlobals();
|
|
337
|
+
}
|
|
338
|
+
async getAllData() {
|
|
339
|
+
const inst = await this.getInstance();
|
|
340
|
+
return inst.getAllData();
|
|
341
|
+
}
|
|
342
|
+
};
|
|
325
343
|
|
|
326
344
|
// src/content/strategies.ts
|
|
327
345
|
var RateLimiter = class {
|
|
@@ -391,10 +409,10 @@ var ExponentialBackoff = class {
|
|
|
391
409
|
return delay;
|
|
392
410
|
}
|
|
393
411
|
isClientError(error) {
|
|
394
|
-
return _optionalChain([error, 'optionalAccess',
|
|
412
|
+
return _optionalChain([error, 'optionalAccess', _10 => _10.status]) >= 400 && _optionalChain([error, 'optionalAccess', _11 => _11.status]) < 500;
|
|
395
413
|
}
|
|
396
414
|
isRateLimitError(error) {
|
|
397
|
-
return _optionalChain([error, 'optionalAccess',
|
|
415
|
+
return _optionalChain([error, 'optionalAccess', _12 => _12.status]) === 429;
|
|
398
416
|
}
|
|
399
417
|
};
|
|
400
418
|
var CircuitBreaker = class {
|
|
@@ -508,10 +526,10 @@ function buildQueryString(query) {
|
|
|
508
526
|
if (query.sort) params.append("sort", query.sort);
|
|
509
527
|
if (query.order) params.append("order", query.order);
|
|
510
528
|
if (query.search) params.append("search", query.search);
|
|
511
|
-
if (_optionalChain([query, 'access',
|
|
529
|
+
if (_optionalChain([query, 'access', _13 => _13.include, 'optionalAccess', _14 => _14.length])) {
|
|
512
530
|
params.append("include", query.include.join(","));
|
|
513
531
|
}
|
|
514
|
-
if (_optionalChain([query, 'access',
|
|
532
|
+
if (_optionalChain([query, 'access', _15 => _15.fields, 'optionalAccess', _16 => _16.length])) {
|
|
515
533
|
params.append("fields", query.fields.join(","));
|
|
516
534
|
}
|
|
517
535
|
if (query.filter) {
|
|
@@ -534,7 +552,7 @@ var ContentEngine = class {
|
|
|
534
552
|
constructor(config) {
|
|
535
553
|
this.config = config;
|
|
536
554
|
this.isServer = typeof window === "undefined";
|
|
537
|
-
this.localCache = new
|
|
555
|
+
this.localCache = new LocalCacheProxy();
|
|
538
556
|
this.memoryCache = new MemoryCache({
|
|
539
557
|
maxSize: 500,
|
|
540
558
|
ttl: 5 * 60 * 1e3
|
|
@@ -585,7 +603,11 @@ var ContentEngine = class {
|
|
|
585
603
|
includeMetadata = false
|
|
586
604
|
} = options;
|
|
587
605
|
const cacheKey = `page:${slug}`;
|
|
588
|
-
const cached = this.checkCaches(
|
|
606
|
+
const cached = await this.checkCaches(
|
|
607
|
+
cacheKey,
|
|
608
|
+
forceRefresh,
|
|
609
|
+
includeMetadata
|
|
610
|
+
);
|
|
589
611
|
if (cached) {
|
|
590
612
|
if (this.config.debug) console.log(`[NexusHub] \u26A1 Cache hit: ${slug}`);
|
|
591
613
|
return includeMetadata ? cached : cached.data;
|
|
@@ -650,7 +672,7 @@ var ContentEngine = class {
|
|
|
650
672
|
} = options;
|
|
651
673
|
const queryString = buildQueryString(normalizedQuery);
|
|
652
674
|
const cacheKey = `collection:${collectionId}:${queryString}`;
|
|
653
|
-
const cached = this.checkCaches(
|
|
675
|
+
const cached = await this.checkCaches(
|
|
654
676
|
cacheKey,
|
|
655
677
|
forceRefresh,
|
|
656
678
|
includeMetadata
|
|
@@ -664,7 +686,7 @@ var ContentEngine = class {
|
|
|
664
686
|
return includeMetadata ? cached : cached.data;
|
|
665
687
|
}
|
|
666
688
|
if (!forceRefresh && process.env.NODE_ENV === "development") {
|
|
667
|
-
const localCollection = this.localCache.getCollection(collectionId);
|
|
689
|
+
const localCollection = await this.localCache.getCollection(collectionId);
|
|
668
690
|
if (localCollection) {
|
|
669
691
|
const result = this.applyLocalQuery(
|
|
670
692
|
localCollection,
|
|
@@ -789,7 +811,7 @@ var ContentEngine = class {
|
|
|
789
811
|
}
|
|
790
812
|
return this.requestBatcher.schedule(cacheKey, async () => {
|
|
791
813
|
const params = new URLSearchParams();
|
|
792
|
-
if (_optionalChain([options, 'access',
|
|
814
|
+
if (_optionalChain([options, 'access', _17 => _17.include, 'optionalAccess', _18 => _18.length])) {
|
|
793
815
|
params.append("include", options.include.join(","));
|
|
794
816
|
}
|
|
795
817
|
const url = `${this.config.apiUrl}/content/${this.config.projectId}/collection/${collectionId}/${itemId}?${params}`;
|
|
@@ -822,10 +844,10 @@ var ContentEngine = class {
|
|
|
822
844
|
q: query,
|
|
823
845
|
limit: (options.limit || 20).toString()
|
|
824
846
|
});
|
|
825
|
-
if (_optionalChain([options, 'access',
|
|
847
|
+
if (_optionalChain([options, 'access', _19 => _19.collections, 'optionalAccess', _20 => _20.length])) {
|
|
826
848
|
params.append("collections", options.collections.join(","));
|
|
827
849
|
}
|
|
828
|
-
if (_optionalChain([options, 'access',
|
|
850
|
+
if (_optionalChain([options, 'access', _21 => _21.fields, 'optionalAccess', _22 => _22.length])) {
|
|
829
851
|
params.append("fields", options.fields.join(","));
|
|
830
852
|
}
|
|
831
853
|
const url = `${this.config.apiUrl}/content/${this.config.projectId}/search?${params}`;
|
|
@@ -886,7 +908,7 @@ var ContentEngine = class {
|
|
|
886
908
|
}
|
|
887
909
|
};
|
|
888
910
|
eventSource.onerror = () => {
|
|
889
|
-
_optionalChain([eventSource, 'optionalAccess',
|
|
911
|
+
_optionalChain([eventSource, 'optionalAccess', _23 => _23.close, 'call', _24 => _24()]);
|
|
890
912
|
if (isClosed) return;
|
|
891
913
|
const timeout = Math.min(1e3 * Math.pow(2, retryCount), 1e4);
|
|
892
914
|
retryCount++;
|
|
@@ -899,14 +921,14 @@ var ContentEngine = class {
|
|
|
899
921
|
connect();
|
|
900
922
|
return () => {
|
|
901
923
|
isClosed = true;
|
|
902
|
-
_optionalChain([eventSource, 'optionalAccess',
|
|
924
|
+
_optionalChain([eventSource, 'optionalAccess', _25 => _25.close, 'call', _26 => _26()]);
|
|
903
925
|
};
|
|
904
926
|
}
|
|
905
927
|
// --- CACHE MANAGEMENT ---
|
|
906
928
|
/**
|
|
907
929
|
* Check all caches in order of speed
|
|
908
930
|
*/
|
|
909
|
-
checkCaches(key, forceRefresh, includeMetadata) {
|
|
931
|
+
async checkCaches(key, forceRefresh, includeMetadata) {
|
|
910
932
|
if (forceRefresh) return null;
|
|
911
933
|
if (this.cacheStrategy === "memory") {
|
|
912
934
|
const cached = this.memoryCache.get(key);
|
|
@@ -931,7 +953,7 @@ var ContentEngine = class {
|
|
|
931
953
|
if (process.env.NODE_ENV === "development") {
|
|
932
954
|
if (key.startsWith("page:")) {
|
|
933
955
|
const slug = key.split(":")[1];
|
|
934
|
-
const local = this.localCache.getPage(slug);
|
|
956
|
+
const local = await this.localCache.getPage(slug);
|
|
935
957
|
if (local) {
|
|
936
958
|
return {
|
|
937
959
|
data: local,
|
|
@@ -1588,8 +1610,8 @@ var AnalyticsEngine = class {
|
|
|
1588
1610
|
navigator.share = (data) => {
|
|
1589
1611
|
this.tracker.send("social_share", {
|
|
1590
1612
|
method: "native_share_menu",
|
|
1591
|
-
url: _optionalChain([data, 'optionalAccess',
|
|
1592
|
-
title: _optionalChain([data, 'optionalAccess',
|
|
1613
|
+
url: _optionalChain([data, 'optionalAccess', _27 => _27.url]) || window.location.href,
|
|
1614
|
+
title: _optionalChain([data, 'optionalAccess', _28 => _28.title])
|
|
1593
1615
|
});
|
|
1594
1616
|
return originalShare.apply(navigator, [data]);
|
|
1595
1617
|
};
|
|
@@ -1720,7 +1742,7 @@ var AnalyticsEngine = class {
|
|
|
1720
1742
|
this.tracker.send("click", {
|
|
1721
1743
|
element_type: "link",
|
|
1722
1744
|
href: link.href,
|
|
1723
|
-
text: _optionalChain([link, 'access',
|
|
1745
|
+
text: _optionalChain([link, 'access', _29 => _29.innerText, 'optionalAccess', _30 => _30.substring, 'call', _31 => _31(0, 50)]),
|
|
1724
1746
|
id: link.id,
|
|
1725
1747
|
classes: link.className,
|
|
1726
1748
|
dataset: { ...link.dataset }
|
|
@@ -1730,7 +1752,7 @@ var AnalyticsEngine = class {
|
|
|
1730
1752
|
if (button) {
|
|
1731
1753
|
this.tracker.send("click", {
|
|
1732
1754
|
element_type: "button",
|
|
1733
|
-
text: _optionalChain([button, 'access',
|
|
1755
|
+
text: _optionalChain([button, 'access', _32 => _32.innerText, 'optionalAccess', _33 => _33.substring, 'call', _34 => _34(0, 50)]),
|
|
1734
1756
|
id: button.id,
|
|
1735
1757
|
classes: button.className,
|
|
1736
1758
|
coordinates: { x: e.clientX, y: e.clientY }
|
|
@@ -1800,11 +1822,11 @@ var NexusClient = class {
|
|
|
1800
1822
|
constructor(config) {
|
|
1801
1823
|
const fullConfig = getFullConfig(config);
|
|
1802
1824
|
this.config = {
|
|
1803
|
-
debug: _optionalChain([config, 'optionalAccess',
|
|
1804
|
-
cacheStrategy: _optionalChain([config, 'optionalAccess',
|
|
1805
|
-
revalidateTime: _optionalChain([config, 'optionalAccess',
|
|
1806
|
-
timeout: _optionalChain([config, 'optionalAccess',
|
|
1807
|
-
retries: _optionalChain([config, 'optionalAccess',
|
|
1825
|
+
debug: _optionalChain([config, 'optionalAccess', _35 => _35.debug]) || false,
|
|
1826
|
+
cacheStrategy: _optionalChain([config, 'optionalAccess', _36 => _36.cacheStrategy]) || "memory",
|
|
1827
|
+
revalidateTime: _optionalChain([config, 'optionalAccess', _37 => _37.revalidateTime]) || 60,
|
|
1828
|
+
timeout: _optionalChain([config, 'optionalAccess', _38 => _38.timeout]) || 1e4,
|
|
1829
|
+
retries: _optionalChain([config, 'optionalAccess', _39 => _39.retries]) || 3,
|
|
1808
1830
|
...fullConfig
|
|
1809
1831
|
};
|
|
1810
1832
|
this.content = new ContentEngine(this.config);
|
|
@@ -2084,4 +2106,4 @@ var VERSION = "0.0.1";
|
|
|
2084
2106
|
|
|
2085
2107
|
|
|
2086
2108
|
|
|
2087
|
-
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 =
|
|
2109
|
+
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.useNexusAuth = useNexusAuth; exports.validateConfig = validateConfig;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
|
|
3
|
+
import { I as ILocalCache } from './cache-types-B39iNHfE.cjs';
|
|
4
4
|
|
|
5
5
|
interface MinimalNexusConfig {
|
|
6
6
|
apiUrl?: string;
|
|
@@ -397,6 +397,18 @@ declare class BrowserCache {
|
|
|
397
397
|
private evictOldest;
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
+
declare class LocalCacheProxy implements ILocalCache {
|
|
401
|
+
private instance;
|
|
402
|
+
private cachePath?;
|
|
403
|
+
constructor(cachePath?: string);
|
|
404
|
+
private getInstance;
|
|
405
|
+
isLoaded(): boolean;
|
|
406
|
+
getPage(slug: string): Promise<any>;
|
|
407
|
+
getCollection(id: string): Promise<any[] | null>;
|
|
408
|
+
getGlobals(): Promise<any>;
|
|
409
|
+
getAllData(): Promise<any>;
|
|
410
|
+
}
|
|
411
|
+
|
|
400
412
|
declare const VERSION = "0.0.1";
|
|
401
413
|
|
|
402
|
-
export { AnalyticsEngine, type AuthContextType, type AuthError, AuthProvider, type AuthState, BrowserCache, type CacheEntry, type CacheMetadata, CacheTags, type CollectionQuery, type CollectionResponse, ContentEngine, type ContentResponse, DEFAULT_ANALYTICS_URL, DEFAULT_API_URL, type ErrorResponse, LOCAL_NEST_URL, LOCAL_RUST_URL, type LoginCredentials, MemoryCache, type MinimalNexusConfig, NexusClient, type NexusConfig, NexusProvider, type RegisterCredentials, type SiteUser, VERSION, createNexusClient, getEnvConfig, getFullConfig, mergeConfigs, nexus, useNexusAuth, validateConfig };
|
|
414
|
+
export { AnalyticsEngine, type AuthContextType, type AuthError, AuthProvider, type AuthState, BrowserCache, type CacheEntry, type CacheMetadata, CacheTags, type CollectionQuery, type CollectionResponse, ContentEngine, type ContentResponse, DEFAULT_ANALYTICS_URL, DEFAULT_API_URL, type ErrorResponse, LOCAL_NEST_URL, LOCAL_RUST_URL, LocalCacheProxy as LocalCache, type LoginCredentials, MemoryCache, type MinimalNexusConfig, NexusClient, type NexusConfig, NexusProvider, type RegisterCredentials, type SiteUser, VERSION, createNexusClient, getEnvConfig, getFullConfig, mergeConfigs, nexus, useNexusAuth, validateConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
|
|
3
|
+
import { I as ILocalCache } from './cache-types-B39iNHfE.js';
|
|
4
4
|
|
|
5
5
|
interface MinimalNexusConfig {
|
|
6
6
|
apiUrl?: string;
|
|
@@ -397,6 +397,18 @@ declare class BrowserCache {
|
|
|
397
397
|
private evictOldest;
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
+
declare class LocalCacheProxy implements ILocalCache {
|
|
401
|
+
private instance;
|
|
402
|
+
private cachePath?;
|
|
403
|
+
constructor(cachePath?: string);
|
|
404
|
+
private getInstance;
|
|
405
|
+
isLoaded(): boolean;
|
|
406
|
+
getPage(slug: string): Promise<any>;
|
|
407
|
+
getCollection(id: string): Promise<any[] | null>;
|
|
408
|
+
getGlobals(): Promise<any>;
|
|
409
|
+
getAllData(): Promise<any>;
|
|
410
|
+
}
|
|
411
|
+
|
|
400
412
|
declare const VERSION = "0.0.1";
|
|
401
413
|
|
|
402
|
-
export { AnalyticsEngine, type AuthContextType, type AuthError, AuthProvider, type AuthState, BrowserCache, type CacheEntry, type CacheMetadata, CacheTags, type CollectionQuery, type CollectionResponse, ContentEngine, type ContentResponse, DEFAULT_ANALYTICS_URL, DEFAULT_API_URL, type ErrorResponse, LOCAL_NEST_URL, LOCAL_RUST_URL, type LoginCredentials, MemoryCache, type MinimalNexusConfig, NexusClient, type NexusConfig, NexusProvider, type RegisterCredentials, type SiteUser, VERSION, createNexusClient, getEnvConfig, getFullConfig, mergeConfigs, nexus, useNexusAuth, validateConfig };
|
|
414
|
+
export { AnalyticsEngine, type AuthContextType, type AuthError, AuthProvider, type AuthState, BrowserCache, type CacheEntry, type CacheMetadata, CacheTags, type CollectionQuery, type CollectionResponse, ContentEngine, type ContentResponse, DEFAULT_ANALYTICS_URL, DEFAULT_API_URL, type ErrorResponse, LOCAL_NEST_URL, LOCAL_RUST_URL, LocalCacheProxy as LocalCache, type LoginCredentials, MemoryCache, type MinimalNexusConfig, NexusClient, type NexusConfig, NexusProvider, type RegisterCredentials, type SiteUser, VERSION, createNexusClient, getEnvConfig, getFullConfig, mergeConfigs, nexus, useNexusAuth, validateConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__require
|
|
3
|
-
} from "./chunk-3RG5ZIWI.js";
|
|
4
|
-
|
|
5
1
|
// src/config.ts
|
|
6
2
|
var DEFAULT_API_URL = "http://localhost:3001";
|
|
7
3
|
var DEFAULT_ANALYTICS_URL = "http://localhost:3002";
|
|
@@ -308,20 +304,42 @@ var BrowserCache = class {
|
|
|
308
304
|
};
|
|
309
305
|
|
|
310
306
|
// src/content/cache.ts
|
|
311
|
-
var
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
LocalCacheConstructor = __require(serverPath).LocalCache;
|
|
316
|
-
} catch (e) {
|
|
317
|
-
LocalCacheConstructor = class Dummy {
|
|
318
|
-
};
|
|
307
|
+
var LocalCacheProxy = class {
|
|
308
|
+
constructor(cachePath) {
|
|
309
|
+
this.instance = null;
|
|
310
|
+
this.cachePath = cachePath;
|
|
319
311
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
312
|
+
async getInstance() {
|
|
313
|
+
if (this.instance) return this.instance;
|
|
314
|
+
if (typeof window === "undefined") {
|
|
315
|
+
const mod = await import("./content/local-cache-server.js");
|
|
316
|
+
this.instance = new mod.LocalCache(this.cachePath);
|
|
317
|
+
} else {
|
|
318
|
+
const mod = await import("./content/local-cache-client.js");
|
|
319
|
+
this.instance = new mod.LocalCache(this.cachePath);
|
|
320
|
+
}
|
|
321
|
+
return this.instance;
|
|
322
|
+
}
|
|
323
|
+
isLoaded() {
|
|
324
|
+
return this.instance?.isLoaded() || false;
|
|
325
|
+
}
|
|
326
|
+
async getPage(slug) {
|
|
327
|
+
const inst = await this.getInstance();
|
|
328
|
+
return inst.getPage(slug);
|
|
329
|
+
}
|
|
330
|
+
async getCollection(id) {
|
|
331
|
+
const inst = await this.getInstance();
|
|
332
|
+
return inst.getCollection(id);
|
|
333
|
+
}
|
|
334
|
+
async getGlobals() {
|
|
335
|
+
const inst = await this.getInstance();
|
|
336
|
+
return inst.getGlobals();
|
|
337
|
+
}
|
|
338
|
+
async getAllData() {
|
|
339
|
+
const inst = await this.getInstance();
|
|
340
|
+
return inst.getAllData();
|
|
341
|
+
}
|
|
342
|
+
};
|
|
325
343
|
|
|
326
344
|
// src/content/strategies.ts
|
|
327
345
|
var RateLimiter = class {
|
|
@@ -534,7 +552,7 @@ var ContentEngine = class {
|
|
|
534
552
|
constructor(config) {
|
|
535
553
|
this.config = config;
|
|
536
554
|
this.isServer = typeof window === "undefined";
|
|
537
|
-
this.localCache = new
|
|
555
|
+
this.localCache = new LocalCacheProxy();
|
|
538
556
|
this.memoryCache = new MemoryCache({
|
|
539
557
|
maxSize: 500,
|
|
540
558
|
ttl: 5 * 60 * 1e3
|
|
@@ -585,7 +603,11 @@ var ContentEngine = class {
|
|
|
585
603
|
includeMetadata = false
|
|
586
604
|
} = options;
|
|
587
605
|
const cacheKey = `page:${slug}`;
|
|
588
|
-
const cached = this.checkCaches(
|
|
606
|
+
const cached = await this.checkCaches(
|
|
607
|
+
cacheKey,
|
|
608
|
+
forceRefresh,
|
|
609
|
+
includeMetadata
|
|
610
|
+
);
|
|
589
611
|
if (cached) {
|
|
590
612
|
if (this.config.debug) console.log(`[NexusHub] \u26A1 Cache hit: ${slug}`);
|
|
591
613
|
return includeMetadata ? cached : cached.data;
|
|
@@ -650,7 +672,7 @@ var ContentEngine = class {
|
|
|
650
672
|
} = options;
|
|
651
673
|
const queryString = buildQueryString(normalizedQuery);
|
|
652
674
|
const cacheKey = `collection:${collectionId}:${queryString}`;
|
|
653
|
-
const cached = this.checkCaches(
|
|
675
|
+
const cached = await this.checkCaches(
|
|
654
676
|
cacheKey,
|
|
655
677
|
forceRefresh,
|
|
656
678
|
includeMetadata
|
|
@@ -664,7 +686,7 @@ var ContentEngine = class {
|
|
|
664
686
|
return includeMetadata ? cached : cached.data;
|
|
665
687
|
}
|
|
666
688
|
if (!forceRefresh && process.env.NODE_ENV === "development") {
|
|
667
|
-
const localCollection = this.localCache.getCollection(collectionId);
|
|
689
|
+
const localCollection = await this.localCache.getCollection(collectionId);
|
|
668
690
|
if (localCollection) {
|
|
669
691
|
const result = this.applyLocalQuery(
|
|
670
692
|
localCollection,
|
|
@@ -906,7 +928,7 @@ var ContentEngine = class {
|
|
|
906
928
|
/**
|
|
907
929
|
* Check all caches in order of speed
|
|
908
930
|
*/
|
|
909
|
-
checkCaches(key, forceRefresh, includeMetadata) {
|
|
931
|
+
async checkCaches(key, forceRefresh, includeMetadata) {
|
|
910
932
|
if (forceRefresh) return null;
|
|
911
933
|
if (this.cacheStrategy === "memory") {
|
|
912
934
|
const cached = this.memoryCache.get(key);
|
|
@@ -931,7 +953,7 @@ var ContentEngine = class {
|
|
|
931
953
|
if (process.env.NODE_ENV === "development") {
|
|
932
954
|
if (key.startsWith("page:")) {
|
|
933
955
|
const slug = key.split(":")[1];
|
|
934
|
-
const local = this.localCache.getPage(slug);
|
|
956
|
+
const local = await this.localCache.getPage(slug);
|
|
935
957
|
if (local) {
|
|
936
958
|
return {
|
|
937
959
|
data: local,
|
|
@@ -2072,7 +2094,7 @@ export {
|
|
|
2072
2094
|
DEFAULT_API_URL,
|
|
2073
2095
|
LOCAL_NEST_URL,
|
|
2074
2096
|
LOCAL_RUST_URL,
|
|
2075
|
-
LocalCache,
|
|
2097
|
+
LocalCacheProxy as LocalCache,
|
|
2076
2098
|
MemoryCache,
|
|
2077
2099
|
NexusClient,
|
|
2078
2100
|
NexusProvider,
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
interface ILocalCache {
|
|
2
|
-
isLoaded(): boolean;
|
|
3
|
-
getPage(slug: string): any;
|
|
4
|
-
getCollection(collectionId: string): any[] | null;
|
|
5
|
-
getGlobals(): any;
|
|
6
|
-
getAllData(): any;
|
|
7
|
-
}
|
|
8
|
-
declare const LocalCache: any;
|
|
9
|
-
type LocalCache = ILocalCache;
|
|
10
|
-
|
|
11
|
-
export { type ILocalCache as I, LocalCache as L };
|
package/dist/cache-CtPpNvIZ.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
interface ILocalCache {
|
|
2
|
-
isLoaded(): boolean;
|
|
3
|
-
getPage(slug: string): any;
|
|
4
|
-
getCollection(collectionId: string): any[] | null;
|
|
5
|
-
getGlobals(): any;
|
|
6
|
-
getAllData(): any;
|
|
7
|
-
}
|
|
8
|
-
declare const LocalCache: any;
|
|
9
|
-
type LocalCache = ILocalCache;
|
|
10
|
-
|
|
11
|
-
export { type ILocalCache as I, LocalCache as L };
|
package/dist/chunk-3RG5ZIWI.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
__require
|
|
10
|
-
};
|
package/dist/chunk-OBGZSXTJ.cjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.__require = __require;
|