@nexushub/client 0.4.3 → 0.4.5

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/react.js CHANGED
@@ -1,3 +1,8 @@
1
+ import {
2
+ getFullConfig,
3
+ validateConfig
4
+ } from "./chunk-NOIMIIA5.js";
5
+
1
6
  // src/components/NexusProvider.tsx
2
7
  import React2, {
3
8
  createContext as createContext2,
@@ -10,54 +15,6 @@ import React2, {
10
15
  } from "react";
11
16
  import { usePathname, useSearchParams } from "next/navigation";
12
17
 
13
- // src/config.ts
14
- var DEFAULT_API_URL = "https://endpoints.gnexus.co.tz";
15
- var DEFAULT_ANALYTICS_URL = "https://sentry.gnexus.co.tz";
16
- var LOCAL_NEST_URL = "https://endpoints.gnexus.co.tz";
17
- var LOCAL_RUST_URL = "https://sentry.gnexus.co.tz";
18
- var getEnvConfig = () => {
19
- const NEXT_PUBLIC_ID = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_NEXUS_ID : void 0;
20
- const NEXT_PUBLIC_KEY = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_NEXUS_KEY : void 0;
21
- const NEXT_PUBLIC_URL = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_NEXUS_API_URL : void 0;
22
- const NODE_ID = typeof process !== "undefined" ? process.env.NEXUS_PROJECT_ID : void 0;
23
- const NODE_KEY = typeof process !== "undefined" ? process.env.NEXUS_API_KEY : void 0;
24
- const NODE_URL = typeof process !== "undefined" ? process.env.NEXUS_API_URL : void 0;
25
- const NODE_ENV = typeof process !== "undefined" ? process.env.NODE_ENV : "production";
26
- const isDev = NODE_ENV === "development" || typeof window !== "undefined" && window.location.hostname === "localhost";
27
- const projectId = NEXT_PUBLIC_ID ?? NODE_ID;
28
- const apiKey = NEXT_PUBLIC_KEY ?? NODE_KEY;
29
- const apiUrl = NEXT_PUBLIC_URL ?? NODE_URL ?? (isDev ? LOCAL_NEST_URL : DEFAULT_API_URL);
30
- const analyticsUrl = apiUrl.includes("localhost") ? LOCAL_RUST_URL : DEFAULT_ANALYTICS_URL;
31
- return {
32
- projectId,
33
- apiKey,
34
- apiUrl,
35
- analyticsUrl
36
- };
37
- };
38
- var mergeConfigs = (base, override) => {
39
- const mergedApiUrl = override.apiUrl || base.apiUrl || DEFAULT_API_URL;
40
- const mergedAnalyticsUrl = override.analyticsUrl || base.analyticsUrl || (mergedApiUrl.includes("localhost") ? LOCAL_RUST_URL : DEFAULT_ANALYTICS_URL);
41
- return {
42
- ...base,
43
- ...override,
44
- apiUrl: mergedApiUrl,
45
- analyticsUrl: mergedAnalyticsUrl,
46
- projectId: override.projectId || base.projectId,
47
- apiKey: override.apiKey || base.apiKey
48
- };
49
- };
50
- var getFullConfig = (partialConfig) => {
51
- const envConfig = getEnvConfig();
52
- return mergeConfigs(envConfig, partialConfig || {});
53
- };
54
- var validateConfig = (config) => {
55
- const errors = [];
56
- if (!config.projectId) errors.push("Missing projectId");
57
- if (!config.apiUrl) errors.push("Missing apiUrl");
58
- return errors;
59
- };
60
-
61
18
  // src/content/cache-implementations.ts
62
19
  var CacheTags = {
63
20
  project: (projectId) => `nexus_project_${projectId}`,
@@ -325,7 +282,7 @@ var LocalCacheProxy = class {
325
282
  async getInstance() {
326
283
  if (this.instance) return this.instance;
327
284
  if (typeof window === "undefined") {
328
- const mod = await import("./local-cache-server-DBJWR7HD.js");
285
+ const mod = await import("./local-cache-server-BNLLL4NR.js");
329
286
  this.instance = new mod.LocalCache(this.cachePath);
330
287
  } else {
331
288
  const mod = await import("./local-cache-client-I6UYVJJV.js");
@@ -2614,9 +2571,373 @@ var useNexusAnalytics = () => {
2614
2571
  reset: client.analytics.reset.bind(client.analytics)
2615
2572
  };
2616
2573
  };
2574
+
2575
+ // src/components/NexusRenders.tsx
2576
+ import { useState as useState3 } from "react";
2577
+ import * as LucideIcons from "lucide-react";
2578
+ import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
2579
+ function NexusRichText({ value, className = "" }) {
2580
+ if (!value) return null;
2581
+ return /* @__PURE__ */ jsx3(
2582
+ "div",
2583
+ {
2584
+ className: `prose dark:prose-invert max-w-none text-foreground leading-relaxed ${className}`,
2585
+ dangerouslySetInnerHTML: { __html: value }
2586
+ }
2587
+ );
2588
+ }
2589
+ function NexusLongText({ value, className = "" }) {
2590
+ if (!value) return null;
2591
+ return /* @__PURE__ */ jsx3(
2592
+ "p",
2593
+ {
2594
+ className: `text-sm text-muted-foreground whitespace-pre-line leading-relaxed ${className}`,
2595
+ dangerouslySetInnerHTML: { __html: value }
2596
+ }
2597
+ );
2598
+ }
2599
+ function NexusIcon({
2600
+ name,
2601
+ className = "",
2602
+ size = 20,
2603
+ strokeWidth = 2
2604
+ }) {
2605
+ if (!name) return null;
2606
+ const IconComponent = LucideIcons[name];
2607
+ if (!IconComponent) {
2608
+ const Fallback = LucideIcons.HelpCircle;
2609
+ return /* @__PURE__ */ jsx3(Fallback, { className, size, strokeWidth });
2610
+ }
2611
+ return /* @__PURE__ */ jsx3(
2612
+ IconComponent,
2613
+ {
2614
+ className,
2615
+ size,
2616
+ strokeWidth
2617
+ }
2618
+ );
2619
+ }
2620
+ function NexusImage({
2621
+ value,
2622
+ className = "",
2623
+ alt = "",
2624
+ ...props
2625
+ }) {
2626
+ if (!value) return null;
2627
+ const imageUrl = typeof value === "string" ? value : value.url;
2628
+ const imageAlt = typeof value === "string" ? alt : value.alt || alt;
2629
+ if (!imageUrl) return null;
2630
+ return (
2631
+ /* eslint-disable-next-line @next/next/no-img-element */
2632
+ /* @__PURE__ */ jsx3(
2633
+ "img",
2634
+ {
2635
+ src: imageUrl,
2636
+ alt: imageAlt,
2637
+ className: `max-w-full h-auto object-cover rounded-xl ${className}`,
2638
+ ...props
2639
+ }
2640
+ )
2641
+ );
2642
+ }
2643
+ function NexusGallery({
2644
+ value,
2645
+ className = "",
2646
+ imageClassName = ""
2647
+ }) {
2648
+ if (!value || value.length === 0) return null;
2649
+ return /* @__PURE__ */ jsx3(
2650
+ "div",
2651
+ {
2652
+ className: `grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 ${className}`,
2653
+ children: value.map((img, idx) => /* @__PURE__ */ jsx3(
2654
+ "div",
2655
+ {
2656
+ className: "overflow-hidden rounded-xl aspect-square bg-muted/20 border border-border",
2657
+ children: /* @__PURE__ */ jsx3(
2658
+ NexusImage,
2659
+ {
2660
+ value: img,
2661
+ className: `w-full h-full object-cover hover:scale-105 transition-transform duration-500 ${imageClassName}`
2662
+ }
2663
+ )
2664
+ },
2665
+ idx
2666
+ ))
2667
+ }
2668
+ );
2669
+ }
2670
+ function NexusVideo({
2671
+ value,
2672
+ className = "",
2673
+ autoplay = false
2674
+ }) {
2675
+ if (!value) return null;
2676
+ const isYouTube = value.includes("youtube.com") || value.includes("youtu.be");
2677
+ const isVimeo = value.includes("vimeo.com");
2678
+ if (isYouTube) {
2679
+ const videoId = value.includes("youtu.be") ? value.split("/").pop() : value.split("v=")[1]?.split("&")[0];
2680
+ return /* @__PURE__ */ jsx3(
2681
+ "iframe",
2682
+ {
2683
+ src: `https://www.youtube.com/embed/${videoId}?autoplay=${autoplay ? 1 : 0}`,
2684
+ className: `w-full aspect-video rounded-xl border-0 ${className}`,
2685
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
2686
+ allowFullScreen: true,
2687
+ title: "YouTube Video"
2688
+ }
2689
+ );
2690
+ }
2691
+ if (isVimeo) {
2692
+ const videoId = value.split("/").pop();
2693
+ return /* @__PURE__ */ jsx3(
2694
+ "iframe",
2695
+ {
2696
+ src: `https://player.vimeo.com/video/${videoId}?autoplay=${autoplay ? 1 : 0}`,
2697
+ className: `w-full aspect-video rounded-xl border-0 ${className}`,
2698
+ allow: "autoplay; fullscreen; picture-in-picture",
2699
+ allowFullScreen: true,
2700
+ title: "Vimeo Video"
2701
+ }
2702
+ );
2703
+ }
2704
+ return /* @__PURE__ */ jsx3(
2705
+ "video",
2706
+ {
2707
+ src: value,
2708
+ controls: true,
2709
+ autoPlay: autoplay,
2710
+ muted: autoplay,
2711
+ playsInline: true,
2712
+ className: `w-full rounded-xl border border-border object-contain ${className}`
2713
+ }
2714
+ );
2715
+ }
2716
+ function NexusMap({ value, className = "" }) {
2717
+ if (!value || !value.lat || !value.lng) return null;
2718
+ const query = encodeURIComponent(
2719
+ value.address || `${value.lat},${value.lng}`
2720
+ );
2721
+ const embedUrl = `https://maps.google.com/maps?q=${query}&t=&z=13&ie=UTF8&iwloc=&output=embed`;
2722
+ return /* @__PURE__ */ jsx3(
2723
+ "div",
2724
+ {
2725
+ className: `overflow-hidden rounded-xl border border-border aspect-video w-full ${className}`,
2726
+ children: /* @__PURE__ */ jsx3(
2727
+ "iframe",
2728
+ {
2729
+ title: "Embedded Map",
2730
+ width: "100%",
2731
+ height: "100%",
2732
+ src: embedUrl,
2733
+ className: "border-0",
2734
+ allowFullScreen: true,
2735
+ loading: "lazy"
2736
+ }
2737
+ )
2738
+ }
2739
+ );
2740
+ }
2741
+ function NexusColor({
2742
+ value,
2743
+ className = "",
2744
+ showHexLabel = true
2745
+ }) {
2746
+ if (!value) return null;
2747
+ return /* @__PURE__ */ jsxs2("div", { className: `flex items-center gap-2.5 ${className}`, children: [
2748
+ /* @__PURE__ */ jsx3(
2749
+ "div",
2750
+ {
2751
+ className: "h-6 w-6 rounded-full border border-border/80 shadow-xs shrink-0",
2752
+ style: { backgroundColor: value }
2753
+ }
2754
+ ),
2755
+ showHexLabel && /* @__PURE__ */ jsx3("span", { className: "font-mono text-xs font-semibold text-foreground/80 uppercase", children: value })
2756
+ ] });
2757
+ }
2758
+ function NexusGradient({
2759
+ value,
2760
+ children,
2761
+ className = "",
2762
+ asTextMask = false
2763
+ }) {
2764
+ if (!value) return /* @__PURE__ */ jsx3(Fragment, { children });
2765
+ if (asTextMask) {
2766
+ return /* @__PURE__ */ jsx3(
2767
+ "span",
2768
+ {
2769
+ className: `bg-clip-text text-transparent font-bold ${className}`,
2770
+ style: { backgroundImage: value, WebkitBackgroundClip: "text" },
2771
+ children
2772
+ }
2773
+ );
2774
+ }
2775
+ return /* @__PURE__ */ jsx3(
2776
+ "div",
2777
+ {
2778
+ className: `rounded-xl ${className}`,
2779
+ style: { backgroundImage: value },
2780
+ children
2781
+ }
2782
+ );
2783
+ }
2784
+ function NexusAddress({ value, className = "" }) {
2785
+ if (!value) return null;
2786
+ const lines = [
2787
+ value.street,
2788
+ [value.city, value.state, value.postalCode].filter(Boolean).join(", "),
2789
+ value.country
2790
+ ].filter(Boolean);
2791
+ if (lines.length === 0) return null;
2792
+ return /* @__PURE__ */ jsxs2(
2793
+ "div",
2794
+ {
2795
+ className: `flex items-start gap-2.5 p-3 rounded-xl border border-border bg-card/50 ${className}`,
2796
+ children: [
2797
+ /* @__PURE__ */ jsx3(LucideIcons.MapPin, { className: "h-4 w-4 text-muted-foreground shrink-0 mt-0.5" }),
2798
+ /* @__PURE__ */ jsx3("div", { className: "text-xs text-foreground/80 leading-relaxed font-medium", children: lines.map((line, i) => /* @__PURE__ */ jsx3("div", { children: line }, i)) })
2799
+ ]
2800
+ }
2801
+ );
2802
+ }
2803
+ function NexusKeyValue({ value, className = "" }) {
2804
+ if (!value || Object.keys(value).length === 0) return null;
2805
+ return /* @__PURE__ */ jsx3(
2806
+ "div",
2807
+ {
2808
+ className: `border border-border rounded-xl overflow-hidden bg-card/30 divide-y divide-border ${className}`,
2809
+ children: Object.entries(value).map(([k, v]) => /* @__PURE__ */ jsxs2("div", { className: "flex text-xs px-4 py-3 gap-4", children: [
2810
+ /* @__PURE__ */ jsx3("div", { className: "w-1/3 font-bold text-muted-foreground select-none uppercase tracking-wider text-[10px]", children: k }),
2811
+ /* @__PURE__ */ jsx3("div", { className: "flex-1 font-medium text-foreground", children: v })
2812
+ ] }, k))
2813
+ }
2814
+ );
2815
+ }
2816
+ function NexusTags({
2817
+ value,
2818
+ className = "",
2819
+ badgeClassName = ""
2820
+ }) {
2821
+ if (!value || value.length === 0) return null;
2822
+ return /* @__PURE__ */ jsx3("div", { className: `flex flex-wrap gap-1.5 ${className}`, children: value.map((tag) => /* @__PURE__ */ jsx3(
2823
+ "span",
2824
+ {
2825
+ className: `inline-flex items-center rounded-lg border border-border bg-muted/40 px-2.5 py-1 text-xs font-semibold text-foreground/80 ${badgeClassName}`,
2826
+ children: tag
2827
+ },
2828
+ tag
2829
+ )) });
2830
+ }
2831
+ function NexusProgress({
2832
+ value,
2833
+ max = 100,
2834
+ className = "",
2835
+ color = "bg-primary"
2836
+ }) {
2837
+ if (value === null) return null;
2838
+ const percent = Math.min(value / max * 100, 100);
2839
+ return /* @__PURE__ */ jsx3("div", { className: `w-full ${className}`, children: /* @__PURE__ */ jsx3("div", { className: "h-2 w-full rounded-full bg-muted overflow-hidden border border-border/30", children: /* @__PURE__ */ jsx3(
2840
+ "div",
2841
+ {
2842
+ className: `h-full rounded-full transition-all duration-500 ${color}`,
2843
+ style: { width: `${percent}%` }
2844
+ }
2845
+ ) }) });
2846
+ }
2847
+ function NexusBlendContainer({
2848
+ mode,
2849
+ children,
2850
+ className = ""
2851
+ }) {
2852
+ const blendStyle = mode ? { mixBlendMode: mode } : {};
2853
+ return /* @__PURE__ */ jsx3("div", { className, style: blendStyle, children });
2854
+ }
2855
+ function NexusCode({
2856
+ value,
2857
+ language = "json",
2858
+ className = "",
2859
+ showLineNumbers = false
2860
+ }) {
2861
+ const [copied, setCopied] = useState3(false);
2862
+ if (!value) return null;
2863
+ const handleCopy = () => {
2864
+ navigator.clipboard.writeText(value);
2865
+ setCopied(true);
2866
+ setTimeout(() => setCopied(false), 2e3);
2867
+ };
2868
+ const lines = value.split("\n");
2869
+ return /* @__PURE__ */ jsxs2(
2870
+ "div",
2871
+ {
2872
+ className: `relative rounded-xl border border-border bg-[#090A0F] overflow-hidden ${className}`,
2873
+ children: [
2874
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between px-4 py-2 border-b border-border bg-white/2 select-none", children: [
2875
+ /* @__PURE__ */ jsx3("span", { className: "text-[10px] font-black uppercase text-muted-foreground tracking-wider", children: language }),
2876
+ /* @__PURE__ */ jsx3(
2877
+ "button",
2878
+ {
2879
+ onClick: handleCopy,
2880
+ className: "flex items-center gap-1.5 text-[10px] font-bold text-muted-foreground hover:text-primary transition-colors cursor-pointer",
2881
+ children: copied ? /* @__PURE__ */ jsxs2(Fragment, { children: [
2882
+ /* @__PURE__ */ jsx3(LucideIcons.Check, { className: "h-3 w-3 text-emerald-400" }),
2883
+ /* @__PURE__ */ jsx3("span", { className: "text-emerald-400", children: "Copied!" })
2884
+ ] }) : /* @__PURE__ */ jsxs2(Fragment, { children: [
2885
+ /* @__PURE__ */ jsx3(LucideIcons.Copy, { className: "h-3 w-3" }),
2886
+ /* @__PURE__ */ jsx3("span", { children: "Copy Code" })
2887
+ ] })
2888
+ }
2889
+ )
2890
+ ] }),
2891
+ /* @__PURE__ */ jsxs2("div", { className: "flex overflow-x-auto p-4 font-mono text-[11px] leading-relaxed text-emerald-400 select-text", children: [
2892
+ showLineNumbers && /* @__PURE__ */ jsx3("div", { className: "flex flex-col text-right text-gray-600 select-none pr-3.5 border-r border-border/30 mr-3.5", children: lines.map((_, i) => /* @__PURE__ */ jsx3("span", { children: i + 1 }, i)) }),
2893
+ /* @__PURE__ */ jsx3("pre", { className: "flex-1 whitespace-pre", children: value })
2894
+ ] })
2895
+ ]
2896
+ }
2897
+ );
2898
+ }
2899
+ function NexusBoolean({
2900
+ value,
2901
+ className = "",
2902
+ trueLabel = "Active",
2903
+ falseLabel = "Inactive"
2904
+ }) {
2905
+ if (value === null) return null;
2906
+ return /* @__PURE__ */ jsxs2(
2907
+ "span",
2908
+ {
2909
+ className: `inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[10px] font-black uppercase tracking-wider border shadow-sm ${value ? "border-emerald-500/20 bg-emerald-500/10 text-emerald-400" : "border-muted-foreground/20 bg-muted-foreground/10 text-muted-foreground"} ${className}`,
2910
+ children: [
2911
+ /* @__PURE__ */ jsx3(
2912
+ "span",
2913
+ {
2914
+ className: `h-1.5 w-1.5 rounded-full ${value ? "bg-emerald-500 animate-pulse" : "bg-muted-foreground"}`
2915
+ }
2916
+ ),
2917
+ value ? trueLabel : falseLabel
2918
+ ]
2919
+ }
2920
+ );
2921
+ }
2617
2922
  export {
2618
2923
  AuthProvider,
2924
+ NexusAddress,
2925
+ NexusBlendContainer,
2926
+ NexusBoolean,
2927
+ NexusCode,
2928
+ NexusColor,
2929
+ NexusGallery,
2930
+ NexusGradient,
2931
+ NexusIcon,
2932
+ NexusImage,
2933
+ NexusKeyValue,
2934
+ NexusLongText,
2935
+ NexusMap,
2936
+ NexusProgress,
2619
2937
  NexusProvider,
2938
+ NexusRichText,
2939
+ NexusTags,
2940
+ NexusVideo,
2620
2941
  useNexus,
2621
2942
  useNexusAnalytics,
2622
2943
  useNexusAuth,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nexushub/client",
3
3
  "private": false,
4
- "version": "0.4.3",
4
+ "version": "0.4.5",
5
5
  "description": "The God-Tier NexusHub SDK",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",
@@ -100,6 +100,7 @@
100
100
  "fs-extra": "^11.3.3",
101
101
  "gradient-string": "^3.0.0",
102
102
  "inquirer": "^14.0.2",
103
+ "lucide-react": "^1.21.0",
103
104
  "node-fetch": "^3.3.2",
104
105
  "ora": "^9.0.0",
105
106
  "semver": "^7.8.5",
@@ -1,114 +0,0 @@
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);
4
- var LocalCache = class {
5
- constructor(customPath) {
6
- this.baseDir = customPath || ".nexus/local";
7
- }
8
- isLoaded() {
9
- return _fs2.default.existsSync(_path2.default.resolve(process.cwd(), this.baseDir));
10
- }
11
- /**
12
- * Retrieve a specific page directly from its file.
13
- */
14
- async getPage(slug) {
15
- try {
16
- const filePath = _path2.default.resolve(
17
- process.cwd(),
18
- this.baseDir,
19
- "pages",
20
- `${slug}.json`
21
- );
22
- if (_fs2.default.existsSync(filePath)) {
23
- const fileContent = _fs2.default.readFileSync(filePath, "utf-8");
24
- const pageData = JSON.parse(fileContent);
25
- return pageData.data !== void 0 ? pageData.data : pageData;
26
- }
27
- } catch (error) {
28
- if (process.env.NODE_ENV === "development") {
29
- console.warn(
30
- `\u26A0\uFE0F NexusHub: Failed to load local page '${slug}':`,
31
- error
32
- );
33
- }
34
- }
35
- return null;
36
- }
37
- /**
38
- * Retrieve an entire collection from its specific collection file.
39
- */
40
- async getCollection(collectionId) {
41
- try {
42
- const filePath = _path2.default.resolve(
43
- process.cwd(),
44
- this.baseDir,
45
- "collections",
46
- `${collectionId}.json`
47
- );
48
- if (_fs2.default.existsSync(filePath)) {
49
- const fileContent = _fs2.default.readFileSync(filePath, "utf-8");
50
- return JSON.parse(fileContent);
51
- }
52
- } catch (error) {
53
- if (process.env.NODE_ENV === "development") {
54
- console.warn(
55
- `\u26A0\uFE0F NexusHub: Failed to load local collection '${collectionId}':`,
56
- error
57
- );
58
- }
59
- }
60
- return null;
61
- }
62
- /**
63
- * Retrieve global settings from its file.
64
- */
65
- async getGlobals() {
66
- try {
67
- const filePath = _path2.default.resolve(
68
- process.cwd(),
69
- this.baseDir,
70
- "globals.json"
71
- );
72
- if (_fs2.default.existsSync(filePath)) {
73
- const fileContent = _fs2.default.readFileSync(filePath, "utf-8");
74
- return JSON.parse(fileContent);
75
- }
76
- } catch (e) {
77
- }
78
- return null;
79
- }
80
- /**
81
- * Returns a merged JSON of the entire workspace structure (for dev analytics/inspectors)
82
- */
83
- async getAllData() {
84
- const pages = {};
85
- const collections = {};
86
- let globals = {};
87
- 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)) {
91
- if (file.endsWith(".json")) {
92
- const slug = _path2.default.basename(file, ".json");
93
- pages[slug] = await this.getPage(slug);
94
- }
95
- }
96
- }
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)) {
100
- if (file.endsWith(".json")) {
101
- const id = _path2.default.basename(file, ".json");
102
- collections[id] = await this.getCollection(id) || [];
103
- }
104
- }
105
- }
106
- globals = await this.getGlobals() || {};
107
- } catch (e2) {
108
- }
109
- return { pages, collections, globals };
110
- }
111
- };
112
-
113
-
114
- exports.LocalCache = LocalCache;
@@ -1,114 +0,0 @@
1
- // src/content/local-cache-server.ts
2
- import fs from "fs";
3
- import path from "path";
4
- var LocalCache = class {
5
- constructor(customPath) {
6
- this.baseDir = customPath || ".nexus/local";
7
- }
8
- isLoaded() {
9
- return fs.existsSync(path.resolve(process.cwd(), this.baseDir));
10
- }
11
- /**
12
- * Retrieve a specific page directly from its file.
13
- */
14
- async getPage(slug) {
15
- try {
16
- const filePath = path.resolve(
17
- process.cwd(),
18
- this.baseDir,
19
- "pages",
20
- `${slug}.json`
21
- );
22
- if (fs.existsSync(filePath)) {
23
- const fileContent = fs.readFileSync(filePath, "utf-8");
24
- const pageData = JSON.parse(fileContent);
25
- return pageData.data !== void 0 ? pageData.data : pageData;
26
- }
27
- } catch (error) {
28
- if (process.env.NODE_ENV === "development") {
29
- console.warn(
30
- `\u26A0\uFE0F NexusHub: Failed to load local page '${slug}':`,
31
- error
32
- );
33
- }
34
- }
35
- return null;
36
- }
37
- /**
38
- * Retrieve an entire collection from its specific collection file.
39
- */
40
- async getCollection(collectionId) {
41
- try {
42
- const filePath = path.resolve(
43
- process.cwd(),
44
- this.baseDir,
45
- "collections",
46
- `${collectionId}.json`
47
- );
48
- if (fs.existsSync(filePath)) {
49
- const fileContent = fs.readFileSync(filePath, "utf-8");
50
- return JSON.parse(fileContent);
51
- }
52
- } catch (error) {
53
- if (process.env.NODE_ENV === "development") {
54
- console.warn(
55
- `\u26A0\uFE0F NexusHub: Failed to load local collection '${collectionId}':`,
56
- error
57
- );
58
- }
59
- }
60
- return null;
61
- }
62
- /**
63
- * Retrieve global settings from its file.
64
- */
65
- async getGlobals() {
66
- try {
67
- const filePath = path.resolve(
68
- process.cwd(),
69
- this.baseDir,
70
- "globals.json"
71
- );
72
- if (fs.existsSync(filePath)) {
73
- const fileContent = fs.readFileSync(filePath, "utf-8");
74
- return JSON.parse(fileContent);
75
- }
76
- } catch {
77
- }
78
- return null;
79
- }
80
- /**
81
- * Returns a merged JSON of the entire workspace structure (for dev analytics/inspectors)
82
- */
83
- async getAllData() {
84
- const pages = {};
85
- const collections = {};
86
- let globals = {};
87
- try {
88
- const pagesDir = path.resolve(process.cwd(), this.baseDir, "pages");
89
- if (fs.existsSync(pagesDir)) {
90
- for (const file of fs.readdirSync(pagesDir)) {
91
- if (file.endsWith(".json")) {
92
- const slug = path.basename(file, ".json");
93
- pages[slug] = await this.getPage(slug);
94
- }
95
- }
96
- }
97
- const colsDir = path.resolve(process.cwd(), this.baseDir, "collections");
98
- if (fs.existsSync(colsDir)) {
99
- for (const file of fs.readdirSync(colsDir)) {
100
- if (file.endsWith(".json")) {
101
- const id = path.basename(file, ".json");
102
- collections[id] = await this.getCollection(id) || [];
103
- }
104
- }
105
- }
106
- globals = await this.getGlobals() || {};
107
- } catch {
108
- }
109
- return { pages, collections, globals };
110
- }
111
- };
112
- export {
113
- LocalCache
114
- };