nucleus-core-ts 0.9.3 β†’ 0.9.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleus-core-ts",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
5
5
  "author": "Hidayet Can Γ–zcan <hidayetcan@gmail.com>",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -1,187 +1,194 @@
1
- import { useEffect, useMemo } from 'react'
2
- import { docsData } from './docsData'
1
+ import { useEffect } from "react";
2
+ import { docsData } from "./docsData";
3
3
 
4
4
  declare global {
5
- interface Window {
6
- mermaid?: {
7
- initialize: (config: Record<string, unknown>) => void
8
- run: (config?: { nodes?: NodeListOf<Element> }) => Promise<void>
9
- }
10
- }
5
+ interface Window {
6
+ mermaid?: {
7
+ initialize: (config: Record<string, unknown>) => void;
8
+ run: (config?: { nodes?: NodeListOf<Element> }) => Promise<void>;
9
+ };
10
+ }
11
11
  }
12
12
 
13
13
  interface DocsContentProps {
14
- activeSection: string
15
- activeItem: string
16
- activeSubItem: string
17
- onSubItemClick: (subItemId: string) => void
14
+ activeSection: string;
15
+ activeItem: string;
16
+ activeSubItem: string;
17
+ onSubItemClick: (subItemId: string) => void;
18
18
  }
19
19
 
20
20
  function parseMarkdown(content: string): string {
21
- const codeBlocks: string[] = []
22
- const mermaidBlocks: string[] = []
23
- const tables: string[] = []
24
-
25
- let result = content
26
- .replace(/```mermaid\n([\s\S]*?)```/g, (_m, code) => {
27
- const idx = mermaidBlocks.length
28
- mermaidBlocks.push(
29
- `<div class="mermaid-wrapper"><pre class="mermaid">${code.trim()}</pre></div>`
30
- )
31
- return `__MERMAID_${idx}__`
32
- })
33
- .replace(/```(\w*)\n([\s\S]*?)```/g, (_m, lang, code) => {
34
- const idx = codeBlocks.length
35
- const escaped = code.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
36
- codeBlocks.push(
37
- `<pre class="code-block"><code class="language-${lang || 'text'}">${escaped}</code></pre>`
38
- )
39
- return `__CODE_${idx}__`
40
- })
41
-
42
- const tableRegex = /(\|.+\|[\r\n]+\|[-| :]+\|[\r\n]+(?:\|.+\|[\r\n]*)+)/g
43
- result = result.replace(tableRegex, (match) => {
44
- const lines = match
45
- .trim()
46
- .split('\n')
47
- .filter((l) => l.trim())
48
- const headerLine = lines[0]
49
- if (lines.length < 2 || !headerLine) return match
50
-
51
- const headerCells = headerLine
52
- .split('|')
53
- .filter((c) => c.trim())
54
- .map((c) => c.trim())
55
- const rows = lines.slice(2).map((line) =>
56
- line
57
- .split('|')
58
- .filter((c) => c.trim())
59
- .map((c) => c.trim())
60
- )
61
-
62
- const tableHtml = `<table>
63
- <thead><tr>${headerCells.map((c) => `<th>${c}</th>`).join('')}</tr></thead>
64
- <tbody>${rows.map((r) => `<tr>${r.map((c) => `<td>${c}</td>`).join('')}</tr>`).join('')}</tbody>
65
- </table>`
66
-
67
- const idx = tables.length
68
- tables.push(tableHtml)
69
- return `__TABLE_${idx}__`
70
- })
71
-
72
- result = result
73
- .replace(/`([^`]+)`/g, '<code class="inline-code">$1</code>')
74
- .replace(/^### (.+)$/gm, '<h3>$1</h3>')
75
- .replace(/^## (.+)$/gm, '<h2>$1</h2>')
76
- .replace(/^# (.+)$/gm, '<h1>$1</h1>')
77
- .replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')
78
- .replace(/\*([^*]+)\*/g, '<em>$1</em>')
79
- .replace(/^> (.+)$/gm, '<blockquote>$1</blockquote>')
80
-
81
- result = result.replace(/^(\d+)\. (.+)$/gm, '<li class="ol-item" data-num="$1">$2</li>')
82
- result = result.replace(/^- (.+)$/gm, '<li class="ul-item">$1</li>')
83
-
84
- result = result.replace(/(<li class="ol-item"[^>]*>[\s\S]*?<\/li>\n?)+/g, (m) => `<ol>${m}</ol>`)
85
- result = result.replace(/(<li class="ul-item">[\s\S]*?<\/li>\n?)+/g, (m) => `<ul>${m}</ul>`)
86
-
87
- result = result.replace(/\n\n+/g, '</p><p>')
88
-
89
- for (let i = 0; i < codeBlocks.length; i++) {
90
- result = result.replace(`__CODE_${i}__`, codeBlocks[i] || '')
91
- }
92
- for (let i = 0; i < mermaidBlocks.length; i++) {
93
- result = result.replace(`__MERMAID_${i}__`, mermaidBlocks[i] || '')
94
- }
95
- for (let i = 0; i < tables.length; i++) {
96
- result = result.replace(`__TABLE_${i}__`, tables[i] || '')
97
- }
98
-
99
- return `<p>${result}</p>`
100
- .replace(/<p>\s*<\/p>/g, '')
101
- .replace(/<p>(\s*<[houltbd])/gi, '$1')
102
- .replace(/<\/[houltbd][^>]*>(\s*)<\/p>/gi, (m, _space) => m.replace('</p>', ''))
21
+ const codeBlocks: string[] = [];
22
+ const mermaidBlocks: string[] = [];
23
+ const tables: string[] = [];
24
+
25
+ let result = content
26
+ .replace(/```mermaid\n([\s\S]*?)```/g, (_m, code) => {
27
+ const idx = mermaidBlocks.length;
28
+ mermaidBlocks.push(
29
+ `<div class="mermaid-wrapper"><pre class="mermaid">${code.trim()}</pre></div>`,
30
+ );
31
+ return `__MERMAID_${idx}__`;
32
+ })
33
+ .replace(/```(\w*)\n([\s\S]*?)```/g, (_m, lang, code) => {
34
+ const idx = codeBlocks.length;
35
+ const escaped = code
36
+ .replace(/&/g, "&amp;")
37
+ .replace(/</g, "&lt;")
38
+ .replace(/>/g, "&gt;");
39
+ codeBlocks.push(
40
+ `<pre class="code-block"><code class="language-${lang || "text"}">${escaped}</code></pre>`,
41
+ );
42
+ return `__CODE_${idx}__`;
43
+ });
44
+
45
+ const tableRegex = /(\|.+\|[\r\n]+\|[-| :]+\|[\r\n]+(?:\|.+\|[\r\n]*)+)/g;
46
+ result = result.replace(tableRegex, (match) => {
47
+ const lines = match
48
+ .trim()
49
+ .split("\n")
50
+ .filter((l) => l.trim());
51
+ const headerLine = lines[0];
52
+ if (lines.length < 2 || !headerLine) return match;
53
+
54
+ const headerCells = headerLine
55
+ .split("|")
56
+ .filter((c) => c.trim())
57
+ .map((c) => c.trim());
58
+ const rows = lines.slice(2).map((line) =>
59
+ line
60
+ .split("|")
61
+ .filter((c) => c.trim())
62
+ .map((c) => c.trim()),
63
+ );
64
+
65
+ const tableHtml = `<table>
66
+ <thead><tr>${headerCells.map((c) => `<th>${c}</th>`).join("")}</tr></thead>
67
+ <tbody>${rows.map((r) => `<tr>${r.map((c) => `<td>${c}</td>`).join("")}</tr>`).join("")}</tbody>
68
+ </table>`;
69
+
70
+ const idx = tables.length;
71
+ tables.push(tableHtml);
72
+ return `__TABLE_${idx}__`;
73
+ });
74
+
75
+ result = result
76
+ .replace(/`([^`]+)`/g, '<code class="inline-code">$1</code>')
77
+ .replace(/^### (.+)$/gm, "<h3>$1</h3>")
78
+ .replace(/^## (.+)$/gm, "<h2>$1</h2>")
79
+ .replace(/^# (.+)$/gm, "<h1>$1</h1>")
80
+ .replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>")
81
+ .replace(/\*([^*]+)\*/g, "<em>$1</em>")
82
+ .replace(/^> (.+)$/gm, "<blockquote>$1</blockquote>");
83
+
84
+ result = result.replace(
85
+ /^(\d+)\. (.+)$/gm,
86
+ '<li class="ol-item" data-num="$1">$2</li>',
87
+ );
88
+ result = result.replace(/^- (.+)$/gm, '<li class="ul-item">$1</li>');
89
+
90
+ result = result.replace(
91
+ /(<li class="ol-item"[^>]*>[\s\S]*?<\/li>\n?)+/g,
92
+ (m) => `<ol>${m}</ol>`,
93
+ );
94
+ result = result.replace(
95
+ /(<li class="ul-item">[\s\S]*?<\/li>\n?)+/g,
96
+ (m) => `<ul>${m}</ul>`,
97
+ );
98
+
99
+ result = result.replace(/\n\n+/g, "</p><p>");
100
+
101
+ for (let i = 0; i < codeBlocks.length; i++) {
102
+ result = result.replace(`__CODE_${i}__`, codeBlocks[i] || "");
103
+ }
104
+ for (let i = 0; i < mermaidBlocks.length; i++) {
105
+ result = result.replace(`__MERMAID_${i}__`, mermaidBlocks[i] || "");
106
+ }
107
+ for (let i = 0; i < tables.length; i++) {
108
+ result = result.replace(`__TABLE_${i}__`, tables[i] || "");
109
+ }
110
+
111
+ return `<p>${result}</p>`
112
+ .replace(/<p>\s*<\/p>/g, "")
113
+ .replace(/<p>(\s*<[houltbd])/gi, "$1")
114
+ .replace(/<\/[houltbd][^>]*>(\s*)<\/p>/gi, (m, _space) =>
115
+ m.replace("</p>", ""),
116
+ );
103
117
  }
104
118
 
105
119
  export function DocsContent({
106
- activeSection,
107
- activeItem,
108
- activeSubItem,
109
- onSubItemClick,
120
+ activeSection,
121
+ activeItem,
122
+ activeSubItem,
123
+ onSubItemClick,
110
124
  }: DocsContentProps) {
111
- const currentSection = useMemo(
112
- () => docsData.find((s) => s.id === activeSection),
113
- [activeSection]
114
- )
115
-
116
- const currentItem = useMemo(
117
- () => currentSection?.items.find((i) => i.id === activeItem),
118
- [currentSection, activeItem]
119
- )
120
-
121
- const currentSubItem = useMemo(
122
- () => currentItem?.subItems.find((s) => s.id === activeSubItem),
123
- [currentItem, activeSubItem]
124
- )
125
-
126
- useEffect(() => {
127
- if (window.mermaid) {
128
- window.mermaid.run()
129
- }
130
- }, [activeSubItem, currentSubItem])
131
-
132
- if (!currentSection || !currentItem) {
133
- return (
134
- <div className="docs-content">
135
- <div className="docs-content-empty">
136
- <span className="docs-content-empty-icon">πŸ“š</span>
137
- <p>Select a topic from the sidebar to get started.</p>
138
- </div>
139
- </div>
140
- )
141
- }
142
-
143
- return (
144
- <div className="docs-content">
145
- <div className="docs-content-header">
146
- <div className="docs-breadcrumb">
147
- <span className="docs-breadcrumb-section">{currentSection.title}</span>
148
- <span className="docs-breadcrumb-sep">/</span>
149
- <span className="docs-breadcrumb-item">{currentItem.title}</span>
150
- </div>
151
- <h1 className="docs-content-title">{currentItem.title}</h1>
152
- </div>
153
-
154
- <div className="docs-content-body">
155
- {currentSubItem ? (
156
- <article
157
- className="docs-article"
158
- dangerouslySetInnerHTML={{
159
- __html: parseMarkdown(currentSubItem.content),
160
- }}
161
- />
162
- ) : (
163
- <div className="docs-cards-grid">
164
- {currentItem.subItems.map((subItem) => (
165
- <button
166
- key={subItem.id}
167
- type="button"
168
- className="docs-card"
169
- onClick={() => onSubItemClick(subItem.id)}
170
- >
171
- <h3 className="docs-card-title">{subItem.title}</h3>
172
- <p className="docs-card-desc">
173
- {subItem.content
174
- .slice(0, 120)
175
- .replace(/[#*`\n]/g, ' ')
176
- .trim()}
177
- ...
178
- </p>
179
- <span className="docs-card-arrow">β†’</span>
180
- </button>
181
- ))}
182
- </div>
183
- )}
184
- </div>
185
- </div>
186
- )
125
+ const currentSection = docsData.find((s) => s.id === activeSection);
126
+ const currentItem = currentSection?.items.find((i) => i.id === activeItem);
127
+ const currentSubItem = currentItem?.subItems.find(
128
+ (s) => s.id === activeSubItem,
129
+ );
130
+
131
+ useEffect(() => {
132
+ if (window.mermaid) {
133
+ window.mermaid.run();
134
+ }
135
+ }, [activeSubItem, currentSubItem]);
136
+
137
+ if (!currentSection || !currentItem) {
138
+ return (
139
+ <div className="docs-content">
140
+ <div className="docs-content-empty">
141
+ <span className="docs-content-empty-icon">πŸ“š</span>
142
+ <p>Select a topic from the sidebar to get started.</p>
143
+ </div>
144
+ </div>
145
+ );
146
+ }
147
+
148
+ return (
149
+ <div className="docs-content">
150
+ <div className="docs-content-header">
151
+ <div className="docs-breadcrumb">
152
+ <span className="docs-breadcrumb-section">
153
+ {currentSection.title}
154
+ </span>
155
+ <span className="docs-breadcrumb-sep">/</span>
156
+ <span className="docs-breadcrumb-item">{currentItem.title}</span>
157
+ </div>
158
+ <h1 className="docs-content-title">{currentItem.title}</h1>
159
+ </div>
160
+
161
+ <div className="docs-content-body">
162
+ {currentSubItem ? (
163
+ <article
164
+ className="docs-article"
165
+ dangerouslySetInnerHTML={{
166
+ __html: parseMarkdown(currentSubItem.content),
167
+ }}
168
+ />
169
+ ) : (
170
+ <div className="docs-cards-grid">
171
+ {currentItem.subItems.map((subItem) => (
172
+ <button
173
+ key={subItem.id}
174
+ type="button"
175
+ className="docs-card"
176
+ onClick={() => onSubItemClick(subItem.id)}
177
+ >
178
+ <h3 className="docs-card-title">{subItem.title}</h3>
179
+ <p className="docs-card-desc">
180
+ {subItem.content
181
+ .slice(0, 120)
182
+ .replace(/[#*`\n]/g, " ")
183
+ .trim()}
184
+ ...
185
+ </p>
186
+ <span className="docs-card-arrow">β†’</span>
187
+ </button>
188
+ ))}
189
+ </div>
190
+ )}
191
+ </div>
192
+ </div>
193
+ );
187
194
  }