@contentbit/studio 0.7.2 → 1.0.0-rc.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/server/index.js +9 -8
- package/package.json +7 -7
- package/src/components/ui/button.tsx +1 -1
- package/src/routes/document.tsx +3 -3
- package/src/routes/index.tsx +3 -3
- package/src/server/scan.test.ts +23 -0
- package/vite.config.ts +3 -4
package/dist/server/index.js
CHANGED
|
@@ -8,17 +8,18 @@ import { createServer, searchForWorkspaceRoot } from "vite";
|
|
|
8
8
|
// src/server/scan.ts
|
|
9
9
|
import {
|
|
10
10
|
compareContentProjectFindings,
|
|
11
|
-
createLinkGraphView,
|
|
11
|
+
createLinkGraphView as createLinkGraphView2,
|
|
12
12
|
createSeoBrief,
|
|
13
13
|
readContentPageFacts,
|
|
14
|
-
summarizeContentProjectFindings
|
|
14
|
+
summarizeContentProjectFindings as summarizeContentProjectFindings2
|
|
15
15
|
} from "@contentbit/core";
|
|
16
16
|
|
|
17
17
|
// ../project/dist/index.js
|
|
18
18
|
import { genericBlocks } from "@contentbit/blocks";
|
|
19
|
-
import { createBlockRegistry, scanContentProject } from "@contentbit/core";
|
|
19
|
+
import { createBlockRegistry, createLinkGraphView, discoverContentProject, scanContentProject, summarizeContentProjectFindings } from "@contentbit/core";
|
|
20
|
+
import { createHash } from "node:crypto";
|
|
20
21
|
import { readFile } from "node:fs/promises";
|
|
21
|
-
import { isAbsolute, join } from "node:path";
|
|
22
|
+
import { isAbsolute, join, relative } from "node:path";
|
|
22
23
|
import { pathToFileURL } from "node:url";
|
|
23
24
|
import { glob } from "tinyglobby";
|
|
24
25
|
var ProjectLoadError = class extends Error {
|
|
@@ -84,7 +85,7 @@ async function loadContentProject(input) {
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
// src/server/scan.ts
|
|
87
|
-
import { basename, relative } from "node:path";
|
|
88
|
+
import { basename, relative as relative2 } from "node:path";
|
|
88
89
|
|
|
89
90
|
// src/server/preview.ts
|
|
90
91
|
import { ContentBlocks } from "@contentbit/react";
|
|
@@ -202,7 +203,7 @@ async function scanGraph(options) {
|
|
|
202
203
|
const context = await scanContext(options);
|
|
203
204
|
if (!context.index) return { nodes: [], edges: [] };
|
|
204
205
|
const summaryByPath = new Map(context.summaries.map((summary) => [summary.path, summary]));
|
|
205
|
-
const view =
|
|
206
|
+
const view = createLinkGraphView2(context.index, context.scan.linkDiagnostics ?? []);
|
|
206
207
|
const nodes = view.nodes.map((node) => ({
|
|
207
208
|
id: node.id,
|
|
208
209
|
label: node.label,
|
|
@@ -295,7 +296,7 @@ function titleFor(file, frontmatter, stats) {
|
|
|
295
296
|
return stringValue(frontmatter.title) ?? stats.outline[0]?.text ?? basename(file);
|
|
296
297
|
}
|
|
297
298
|
function summarize(findings) {
|
|
298
|
-
return
|
|
299
|
+
return summarizeContentProjectFindings2(findings);
|
|
299
300
|
}
|
|
300
301
|
function statusFor(findings) {
|
|
301
302
|
if (findings.errors > 0) return "error";
|
|
@@ -315,7 +316,7 @@ function stringValue(value) {
|
|
|
315
316
|
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
316
317
|
}
|
|
317
318
|
function relativePath(cwd, file) {
|
|
318
|
-
const rel =
|
|
319
|
+
const rel = relative2(cwd, file);
|
|
319
320
|
return rel.startsWith("..") ? file : rel;
|
|
320
321
|
}
|
|
321
322
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentbit/studio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
4
|
"description": "Local read-only content studio for contentbit projects.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@fontsource-variable/inter": "^5.2.8",
|
|
32
32
|
"@tailwindcss/vite": "^4",
|
|
33
|
-
"@tanstack/react-router": "
|
|
34
|
-
"@tanstack/react-start": "
|
|
35
|
-
"@tanstack/router-plugin": "
|
|
33
|
+
"@tanstack/react-router": "1.170.17",
|
|
34
|
+
"@tanstack/react-start": "1.168.27",
|
|
35
|
+
"@tanstack/router-plugin": "1.168.19",
|
|
36
36
|
"@vitejs/plugin-react": "^6",
|
|
37
37
|
"class-variance-authority": "^0.7.1",
|
|
38
38
|
"clsx": "^2.1.1",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"tinyglobby": "^0.2.10",
|
|
49
49
|
"tw-animate-css": "^1.4.0",
|
|
50
50
|
"vite": "^8",
|
|
51
|
-
"@contentbit/blocks": "0.
|
|
52
|
-
"@contentbit/core": "0.
|
|
53
|
-
"@contentbit/react": "0.
|
|
51
|
+
"@contentbit/blocks": "1.0.0-rc.0",
|
|
52
|
+
"@contentbit/core": "1.0.0-rc.0",
|
|
53
|
+
"@contentbit/react": "1.0.0-rc.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@testing-library/dom": "^10.4.1",
|
|
@@ -2,7 +2,7 @@ import * as React from 'react'
|
|
|
2
2
|
import { cva, type VariantProps } from 'class-variance-authority'
|
|
3
3
|
import { Slot } from 'radix-ui'
|
|
4
4
|
|
|
5
|
-
import { cn } from '
|
|
5
|
+
import { cn } from '../../lib/utils'
|
|
6
6
|
|
|
7
7
|
const buttonVariants = cva(
|
|
8
8
|
"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
package/src/routes/document.tsx
CHANGED
|
@@ -20,9 +20,9 @@ import {
|
|
|
20
20
|
import type { ReactNode } from 'react'
|
|
21
21
|
import { useEffect, useMemo, useState } from 'react'
|
|
22
22
|
|
|
23
|
-
import { Button } from '
|
|
24
|
-
import { fetchDocument } from '
|
|
25
|
-
import type { StudioDocument, StudioFinding } from '
|
|
23
|
+
import { Button } from '../components/ui/button'
|
|
24
|
+
import { fetchDocument } from '../lib/api'
|
|
25
|
+
import type { StudioDocument, StudioFinding } from '../server/types'
|
|
26
26
|
|
|
27
27
|
interface DocumentSearch {
|
|
28
28
|
path: string
|
package/src/routes/index.tsx
CHANGED
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
import type { ReactNode } from 'react'
|
|
15
15
|
import { useEffect, useMemo, useState } from 'react'
|
|
16
16
|
|
|
17
|
-
import { Button } from '
|
|
18
|
-
import { fetchGraph, fetchProject } from '
|
|
19
|
-
import type { StudioFileSummary, StudioGraph, StudioProject, StudioStatus } from '
|
|
17
|
+
import { Button } from '../components/ui/button'
|
|
18
|
+
import { fetchGraph, fetchProject } from '../lib/api'
|
|
19
|
+
import type { StudioFileSummary, StudioGraph, StudioProject, StudioStatus } from '../server/types'
|
|
20
20
|
|
|
21
21
|
type StatusFilter = 'all' | StudioStatus
|
|
22
22
|
type SortKey = 'document' | 'status' | 'blocks' | 'keywords' | 'findings'
|
package/src/server/scan.test.ts
CHANGED
|
@@ -444,6 +444,29 @@ slug: alpha
|
|
|
444
444
|
expect(document.previewHtml).not.toContain('data-cb-custom="quote"')
|
|
445
445
|
})
|
|
446
446
|
|
|
447
|
+
test('startStudio resolves copied renderers using the consuming project aliases', async () => {
|
|
448
|
+
const dir = await fixture({
|
|
449
|
+
'tsconfig.json': JSON.stringify({
|
|
450
|
+
compilerOptions: { paths: { '@/*': ['./src/*'] } },
|
|
451
|
+
include: ['src/**/*.tsx'],
|
|
452
|
+
}),
|
|
453
|
+
'src/components/content-blocks/content-renderer.tsx': `import { Callout } from '@/components/ui/project-callout'
|
|
454
|
+
export const styledComponents = { callout: Callout }
|
|
455
|
+
`,
|
|
456
|
+
'src/components/ui/project-callout.tsx': `import { createElement } from 'react'
|
|
457
|
+
export function Callout() { return createElement('aside', { 'data-project-styled': 'callout' }, 'Project callout') }
|
|
458
|
+
`,
|
|
459
|
+
'content/a.md': '# Alpha\n\n:::callout{type="tip"}\nUseful body.\n:::\n',
|
|
460
|
+
})
|
|
461
|
+
await linkContentbitCore(dir)
|
|
462
|
+
const server = await startStudio({ globs: ['content/*.md'], cwd: dir, port: 0, open: false })
|
|
463
|
+
runningServers.push(server)
|
|
464
|
+
const document = (await fetchJson(new URL('/api/document?path=content/a.md', server.url))) as {
|
|
465
|
+
previewHtml: string
|
|
466
|
+
}
|
|
467
|
+
expect(document.previewHtml).toContain('data-project-styled="callout"')
|
|
468
|
+
})
|
|
469
|
+
|
|
447
470
|
async function fixture(files: Record<string, string>): Promise<string> {
|
|
448
471
|
const dir = await mkdtemp(join(tmpdir(), 'cb-studio-'))
|
|
449
472
|
for (const [path, content] of Object.entries(files)) {
|
package/vite.config.ts
CHANGED
|
@@ -2,13 +2,12 @@ import { defineConfig } from 'vite'
|
|
|
2
2
|
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
|
|
3
3
|
import viteReact from '@vitejs/plugin-react'
|
|
4
4
|
import tailwindcss from '@tailwindcss/vite'
|
|
5
|
-
import { fileURLToPath } from 'node:url'
|
|
6
5
|
|
|
7
6
|
const config = defineConfig({
|
|
8
7
|
resolve: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
// Project preview components use their own tsconfig paths. Studio keeps its
|
|
9
|
+
// imports relative so the two applications do not share an alias namespace.
|
|
10
|
+
tsconfigPaths: true,
|
|
12
11
|
},
|
|
13
12
|
plugins: [tailwindcss(), tanstackStart(), viteReact()],
|
|
14
13
|
})
|