@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.
@@ -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 = createLinkGraphView(context.index, context.scan.linkDiagnostics ?? []);
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 summarizeContentProjectFindings(findings);
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 = relative(cwd, file);
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.7.2",
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": "latest",
34
- "@tanstack/react-start": "latest",
35
- "@tanstack/router-plugin": "latest",
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.7.2",
52
- "@contentbit/core": "0.7.2",
53
- "@contentbit/react": "0.7.2"
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 '@/lib/utils'
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",
@@ -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 '@/components/ui/button'
24
- import { fetchDocument } from '@/lib/api'
25
- import type { StudioDocument, StudioFinding } from '@/server/types'
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
@@ -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 '@/components/ui/button'
18
- import { fetchGraph, fetchProject } from '@/lib/api'
19
- import type { StudioFileSummary, StudioGraph, StudioProject, StudioStatus } from '@/server/types'
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'
@@ -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
- alias: {
10
- '@': fileURLToPath(new URL('./src', import.meta.url)),
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
  })