radiant-docs 0.1.65 → 0.1.67
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/index.js +53 -10
- package/package.json +1 -1
- package/template/astro.config.mjs +21 -1
- package/template/package-lock.json +4 -4
- package/template/package.json +1 -1
- package/template/src/components/MdxPage.astro +12 -2
- package/template/src/components/OpenApiPage.astro +13 -3
- package/template/src/components/PageAiActions.astro +715 -0
- package/template/src/layouts/Layout.astro +6 -1
- package/template/src/lib/ai-artifacts.ts +295 -13
- package/template/src/pages/{[...slug]/index.md.ts → [...slug].md.ts} +1 -1
package/dist/index.js
CHANGED
|
@@ -8,10 +8,14 @@ import chokidar from "chokidar";
|
|
|
8
8
|
import { fileURLToPath } from "url";
|
|
9
9
|
import envPaths from "env-paths";
|
|
10
10
|
import crypto from "crypto";
|
|
11
|
+
import net from "net";
|
|
11
12
|
var __filename = fileURLToPath(import.meta.url);
|
|
12
13
|
var __dirname = path.dirname(__filename);
|
|
13
14
|
var paths = envPaths("radiant", { suffix: "" });
|
|
14
15
|
var VERSION = "0.1.0";
|
|
16
|
+
var DEV_SERVER_HOST = "localhost";
|
|
17
|
+
var DEV_SERVER_PORT = 3e3;
|
|
18
|
+
var MAX_PORT = 65535;
|
|
15
19
|
var lastErrorMessage = "";
|
|
16
20
|
var lastErrorTime = 0;
|
|
17
21
|
var ERROR_DEDUPE_MS = 2e3;
|
|
@@ -187,17 +191,33 @@ async function runAstroSync(cacheDir) {
|
|
|
187
191
|
} catch {
|
|
188
192
|
}
|
|
189
193
|
}
|
|
190
|
-
function startDevServer(cacheDir) {
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
async function startDevServer(cacheDir) {
|
|
195
|
+
const port = await findAvailablePort(DEV_SERVER_PORT);
|
|
196
|
+
if (port !== DEV_SERVER_PORT) {
|
|
197
|
+
log.info(`Port ${DEV_SERVER_PORT} is busy, using port ${port}...`);
|
|
198
|
+
}
|
|
199
|
+
const child = spawn(
|
|
200
|
+
"npm",
|
|
201
|
+
[
|
|
202
|
+
"run",
|
|
203
|
+
"dev",
|
|
204
|
+
"--",
|
|
205
|
+
"--host",
|
|
206
|
+
DEV_SERVER_HOST,
|
|
207
|
+
"--port",
|
|
208
|
+
String(port)
|
|
209
|
+
],
|
|
210
|
+
{
|
|
211
|
+
cwd: cacheDir,
|
|
212
|
+
shell: true,
|
|
213
|
+
env: {
|
|
214
|
+
...process.env,
|
|
215
|
+
FORCE_COLOR: "1"
|
|
216
|
+
}
|
|
197
217
|
}
|
|
198
|
-
|
|
218
|
+
);
|
|
199
219
|
let serverStarted = false;
|
|
200
|
-
let serverUrl =
|
|
220
|
+
let serverUrl = `http://${DEV_SERVER_HOST}:${port}`;
|
|
201
221
|
const processOutput = (data, isError = false) => {
|
|
202
222
|
const output = data.toString();
|
|
203
223
|
const lines = output.split("\n");
|
|
@@ -244,6 +264,29 @@ function startDevServer(cacheDir) {
|
|
|
244
264
|
});
|
|
245
265
|
return child;
|
|
246
266
|
}
|
|
267
|
+
async function findAvailablePort(startPort) {
|
|
268
|
+
for (let port = startPort; port <= MAX_PORT; port++) {
|
|
269
|
+
if (await isPortAvailable(port)) {
|
|
270
|
+
return port;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
throw new Error(`No available port found from ${startPort} to ${MAX_PORT}`);
|
|
274
|
+
}
|
|
275
|
+
function isPortAvailable(port) {
|
|
276
|
+
return new Promise((resolve) => {
|
|
277
|
+
const server = net.createServer();
|
|
278
|
+
server.unref();
|
|
279
|
+
server.once("error", () => {
|
|
280
|
+
resolve(false);
|
|
281
|
+
});
|
|
282
|
+
server.once("listening", () => {
|
|
283
|
+
server.close(() => {
|
|
284
|
+
resolve(true);
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
server.listen(port, DEV_SERVER_HOST);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
247
290
|
function watchUserContent(docsDir, contentDir, _onSync) {
|
|
248
291
|
const watcher = chokidar.watch(docsDir, {
|
|
249
292
|
ignored: [
|
|
@@ -334,7 +377,7 @@ async function run() {
|
|
|
334
377
|
await runAstroSync(cacheDir);
|
|
335
378
|
log.success("Content synced.");
|
|
336
379
|
log.info("Starting dev server...");
|
|
337
|
-
const devServer = startDevServer(cacheDir);
|
|
380
|
+
const devServer = await startDevServer(cacheDir);
|
|
338
381
|
const watcher = watchUserContent(docsDir, contentDir, async () => {
|
|
339
382
|
await runAstroSync(cacheDir);
|
|
340
383
|
});
|
package/package.json
CHANGED
|
@@ -311,6 +311,24 @@ function resolveDocsSiteConfig() {
|
|
|
311
311
|
const docsSiteConfig = resolveDocsSiteConfig();
|
|
312
312
|
globalThis.__RADIANT_DOCS_BASE_PATH__ = docsSiteConfig.base;
|
|
313
313
|
|
|
314
|
+
function isInternalDocsRoutePathname(pathname) {
|
|
315
|
+
const basePath = docsSiteConfig.base === "/" ? "" : docsSiteConfig.base;
|
|
316
|
+
const relativePath =
|
|
317
|
+
basePath && pathname.startsWith(`${basePath}/`)
|
|
318
|
+
? pathname.slice(basePath.length)
|
|
319
|
+
: pathname;
|
|
320
|
+
|
|
321
|
+
return relativePath === "/-" || relativePath.startsWith("/-/");
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function shouldIncludeSitemapPage(page) {
|
|
325
|
+
try {
|
|
326
|
+
return !isInternalDocsRoutePathname(new URL(page).pathname);
|
|
327
|
+
} catch {
|
|
328
|
+
return !page.startsWith("/-/");
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
314
332
|
const markdownProcessor = unified({
|
|
315
333
|
remarkPlugins: [
|
|
316
334
|
remarkGfm,
|
|
@@ -387,7 +405,9 @@ export default defineConfig({
|
|
|
387
405
|
assetsPrefix: configuredAssetsPrefix,
|
|
388
406
|
},
|
|
389
407
|
integrations: [
|
|
390
|
-
sitemap(
|
|
408
|
+
sitemap({
|
|
409
|
+
filter: shouldIncludeSitemapPage,
|
|
410
|
+
}),
|
|
391
411
|
preact({
|
|
392
412
|
compat: true,
|
|
393
413
|
}),
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@fontsource-variable/source-serif-4": "^5.2.9",
|
|
29
29
|
"@iconify-json/fluent": "^1.2.47",
|
|
30
30
|
"@iconify-json/lucide": "^1.2.79",
|
|
31
|
-
"@iconify-json/simple-icons": "^1.2.
|
|
31
|
+
"@iconify-json/simple-icons": "^1.2.87",
|
|
32
32
|
"@iconify/react": "^6.0.2",
|
|
33
33
|
"@paper-design/shaders": "^0.0.76",
|
|
34
34
|
"@preact/preset-vite": "^2.10.3",
|
|
@@ -2343,9 +2343,9 @@
|
|
|
2343
2343
|
}
|
|
2344
2344
|
},
|
|
2345
2345
|
"node_modules/@iconify-json/simple-icons": {
|
|
2346
|
-
"version": "1.2.
|
|
2347
|
-
"resolved": "https://registry.npmjs.org/@iconify-json/simple-icons/-/simple-icons-1.2.
|
|
2348
|
-
"integrity": "sha512-
|
|
2346
|
+
"version": "1.2.87",
|
|
2347
|
+
"resolved": "https://registry.npmjs.org/@iconify-json/simple-icons/-/simple-icons-1.2.87.tgz",
|
|
2348
|
+
"integrity": "sha512-8YciStObhSji3OZFmWAWK6kBujyqO5bLCxeDwLxf3CR3F4PVelq7keC2LBvgTqviWzSTysj5/g4PCFLiAMVGsw==",
|
|
2349
2349
|
"license": "CC0-1.0",
|
|
2350
2350
|
"dependencies": {
|
|
2351
2351
|
"@iconify/types": "*"
|
package/template/package.json
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@fontsource-variable/source-serif-4": "^5.2.9",
|
|
28
28
|
"@iconify-json/fluent": "^1.2.47",
|
|
29
29
|
"@iconify-json/lucide": "^1.2.79",
|
|
30
|
-
"@iconify-json/simple-icons": "^1.2.
|
|
30
|
+
"@iconify-json/simple-icons": "^1.2.87",
|
|
31
31
|
"@iconify/react": "^6.0.2",
|
|
32
32
|
"@paper-design/shaders": "^0.0.76",
|
|
33
33
|
"@preact/preset-vite": "^2.10.3",
|
|
@@ -19,6 +19,7 @@ import ComponentPreview from "./user/ComponentPreview.astro";
|
|
|
19
19
|
import ComponentPreviewBlock from "./user/ComponentPreviewBlock.astro";
|
|
20
20
|
import type { MdxRoute, Route } from "../lib/routes";
|
|
21
21
|
import PagePagination from "./PagePagination.astro";
|
|
22
|
+
import PageAiActions from "./PageAiActions.astro";
|
|
22
23
|
import { PREVIEW_HEADING_ID_PREFIX } from "../lib/mdx/rehype-prefix-preview-heading-ids";
|
|
23
24
|
|
|
24
25
|
interface Props {
|
|
@@ -67,10 +68,19 @@ const tocHeadings = headings.filter(
|
|
|
67
68
|
<Layout pageTitle={title} pageDescription={description}>
|
|
68
69
|
<div class="flex w-full min-w-0 justify-between gap-x-10">
|
|
69
70
|
<div class="mx-auto max-w-3xl w-full">
|
|
70
|
-
<header
|
|
71
|
-
|
|
71
|
+
<header
|
|
72
|
+
class="mb-8 flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between"
|
|
73
|
+
>
|
|
74
|
+
<h1
|
|
75
|
+
class="rd-document-heading min-w-0 text-4xl font-semibold tracking-tight"
|
|
76
|
+
>
|
|
72
77
|
{title}
|
|
73
78
|
</h1>
|
|
79
|
+
<PageAiActions
|
|
80
|
+
title={title}
|
|
81
|
+
routeSlug={route.slug}
|
|
82
|
+
description={description}
|
|
83
|
+
/>
|
|
74
84
|
</header>
|
|
75
85
|
<article class="prose-rules">
|
|
76
86
|
<Content components={components} />
|
|
@@ -10,6 +10,7 @@ import ResponseFieldTree from "./endpoint/ResponseFieldTree.astro";
|
|
|
10
10
|
import PlaygroundBar from "./endpoint/PlaygroundBar.astro";
|
|
11
11
|
import PlaygroundForm from "./endpoint/PlaygroundForm.astro";
|
|
12
12
|
import PlaygroundButton from "./endpoint/PlaygroundButton.astro";
|
|
13
|
+
import PageAiActions from "./PageAiActions.astro";
|
|
13
14
|
import { getConfig } from "../lib/validation";
|
|
14
15
|
import {
|
|
15
16
|
getOpenApiOperationDoc,
|
|
@@ -59,11 +60,20 @@ const snippetStickyClass = hasTopbarNavigationTabs
|
|
|
59
60
|
---
|
|
60
61
|
|
|
61
62
|
<Layout pageTitle={title}>
|
|
62
|
-
<article>
|
|
63
|
-
<header
|
|
64
|
-
|
|
63
|
+
<article class="mx-auto w-full max-w-7xl">
|
|
64
|
+
<header
|
|
65
|
+
class="mb-8 flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between"
|
|
66
|
+
>
|
|
67
|
+
<h1
|
|
68
|
+
class="rd-document-heading min-w-0 text-4xl font-semibold tracking-tight"
|
|
69
|
+
>
|
|
65
70
|
{title}
|
|
66
71
|
</h1>
|
|
72
|
+
<PageAiActions
|
|
73
|
+
title={title}
|
|
74
|
+
routeSlug={route.slug}
|
|
75
|
+
description={description}
|
|
76
|
+
/>
|
|
67
77
|
</header>
|
|
68
78
|
<div class="flex flex-row-reverse justify-between gap-6 w-full">
|
|
69
79
|
<aside class="flex-1 min-w-0 hidden xl:block">
|