@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.
@@ -1,4 +1,28 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/content/local-cache-client.ts
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/content/local-cache-client.ts
21
+ var local_cache_client_exports = {};
22
+ __export(local_cache_client_exports, {
23
+ LocalCache: () => LocalCache
24
+ });
25
+ module.exports = __toCommonJS(local_cache_client_exports);
2
26
  var LocalCache = class {
3
27
  constructor(customPath) {
4
28
  // Maintain private properties for type parity with the Server version
@@ -54,6 +78,7 @@ var LocalCache = class {
54
78
  return !isMissing || isMalformed;
55
79
  }
56
80
  };
57
-
58
-
59
- exports.LocalCache = LocalCache;
81
+ // Annotate the CommonJS export names for ESM import in node:
82
+ 0 && (module.exports = {
83
+ LocalCache
84
+ });
@@ -1,26 +1,60 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/content/local-cache-server.ts
2
- var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
3
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
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 __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/content/local-cache-server.ts
31
+ var local_cache_server_exports = {};
32
+ __export(local_cache_server_exports, {
33
+ LocalCache: () => LocalCache
34
+ });
35
+ module.exports = __toCommonJS(local_cache_server_exports);
36
+ var import_fs = __toESM(require("fs"), 1);
37
+ var import_path = __toESM(require("path"), 1);
4
38
  var LocalCache = class {
5
39
  constructor(customPath) {
6
40
  this.baseDir = customPath || ".nexus/local";
7
41
  }
8
42
  isLoaded() {
9
- return _fs2.default.existsSync(_path2.default.resolve(process.cwd(), this.baseDir));
43
+ return import_fs.default.existsSync(import_path.default.resolve(process.cwd(), this.baseDir));
10
44
  }
11
45
  /**
12
46
  * Retrieve a specific page directly from its file.
13
47
  */
14
48
  async getPage(slug) {
15
49
  try {
16
- const filePath = _path2.default.resolve(
50
+ const filePath = import_path.default.resolve(
17
51
  process.cwd(),
18
52
  this.baseDir,
19
53
  "pages",
20
54
  `${slug}.json`
21
55
  );
22
- if (_fs2.default.existsSync(filePath)) {
23
- const fileContent = _fs2.default.readFileSync(filePath, "utf-8");
56
+ if (import_fs.default.existsSync(filePath)) {
57
+ const fileContent = import_fs.default.readFileSync(filePath, "utf-8");
24
58
  const pageData = JSON.parse(fileContent);
25
59
  return pageData.data !== void 0 ? pageData.data : pageData;
26
60
  }
@@ -39,14 +73,14 @@ var LocalCache = class {
39
73
  */
40
74
  async getCollection(collectionId) {
41
75
  try {
42
- const filePath = _path2.default.resolve(
76
+ const filePath = import_path.default.resolve(
43
77
  process.cwd(),
44
78
  this.baseDir,
45
79
  "collections",
46
80
  `${collectionId}.json`
47
81
  );
48
- if (_fs2.default.existsSync(filePath)) {
49
- const fileContent = _fs2.default.readFileSync(filePath, "utf-8");
82
+ if (import_fs.default.existsSync(filePath)) {
83
+ const fileContent = import_fs.default.readFileSync(filePath, "utf-8");
50
84
  return JSON.parse(fileContent);
51
85
  }
52
86
  } catch (error) {
@@ -64,16 +98,16 @@ var LocalCache = class {
64
98
  */
65
99
  async getGlobals() {
66
100
  try {
67
- const filePath = _path2.default.resolve(
101
+ const filePath = import_path.default.resolve(
68
102
  process.cwd(),
69
103
  this.baseDir,
70
104
  "globals.json"
71
105
  );
72
- if (_fs2.default.existsSync(filePath)) {
73
- const fileContent = _fs2.default.readFileSync(filePath, "utf-8");
106
+ if (import_fs.default.existsSync(filePath)) {
107
+ const fileContent = import_fs.default.readFileSync(filePath, "utf-8");
74
108
  return JSON.parse(fileContent);
75
109
  }
76
- } catch (e) {
110
+ } catch {
77
111
  }
78
112
  return null;
79
113
  }
@@ -85,30 +119,31 @@ var LocalCache = class {
85
119
  const collections = {};
86
120
  let globals = {};
87
121
  try {
88
- const pagesDir = _path2.default.resolve(process.cwd(), this.baseDir, "pages");
89
- if (_fs2.default.existsSync(pagesDir)) {
90
- for (const file of _fs2.default.readdirSync(pagesDir)) {
122
+ const pagesDir = import_path.default.resolve(process.cwd(), this.baseDir, "pages");
123
+ if (import_fs.default.existsSync(pagesDir)) {
124
+ for (const file of import_fs.default.readdirSync(pagesDir)) {
91
125
  if (file.endsWith(".json")) {
92
- const slug = _path2.default.basename(file, ".json");
126
+ const slug = import_path.default.basename(file, ".json");
93
127
  pages[slug] = await this.getPage(slug);
94
128
  }
95
129
  }
96
130
  }
97
- const colsDir = _path2.default.resolve(process.cwd(), this.baseDir, "collections");
98
- if (_fs2.default.existsSync(colsDir)) {
99
- for (const file of _fs2.default.readdirSync(colsDir)) {
131
+ const colsDir = import_path.default.resolve(process.cwd(), this.baseDir, "collections");
132
+ if (import_fs.default.existsSync(colsDir)) {
133
+ for (const file of import_fs.default.readdirSync(colsDir)) {
100
134
  if (file.endsWith(".json")) {
101
- const id = _path2.default.basename(file, ".json");
135
+ const id = import_path.default.basename(file, ".json");
102
136
  collections[id] = await this.getCollection(id) || [];
103
137
  }
104
138
  }
105
139
  }
106
140
  globals = await this.getGlobals() || {};
107
- } catch (e2) {
141
+ } catch {
108
142
  }
109
143
  return { pages, collections, globals };
110
144
  }
111
145
  };
112
-
113
-
114
- exports.LocalCache = LocalCache;
146
+ // Annotate the CommonJS export names for ESM import in node:
147
+ 0 && (module.exports = {
148
+ LocalCache
149
+ });