blume 1.1.2 → 1.1.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/cli/index.js +284 -109
  3. package/dist/cli/index.js.map +33 -33
  4. package/dist/types/ai/component-markdown.d.ts +10 -0
  5. package/dist/types/core/config-input.d.ts +44 -0
  6. package/dist/types/core/data.d.ts +2 -0
  7. package/dist/types/core/i18n-ui.d.ts +24 -24
  8. package/dist/types/core/schema.d.ts +282 -114
  9. package/dist/types/core/types.d.ts +14 -0
  10. package/dist/types/openapi/references.d.ts +5 -0
  11. package/docs/advanced/api-reference.mdx +20 -0
  12. package/docs/configuration/index.mdx +27 -0
  13. package/package.json +1 -1
  14. package/src/ai/component-markdown.ts +28 -0
  15. package/src/ai/llms.ts +11 -2
  16. package/src/ai/markdown.ts +12 -6
  17. package/src/ai/mcp/server.ts +29 -6
  18. package/src/astro/examples.ts +13 -0
  19. package/src/astro/generate.ts +141 -58
  20. package/src/astro/templates.ts +65 -21
  21. package/src/audit/checks/duplicates.ts +15 -6
  22. package/src/audit/checks/indexability.ts +11 -2
  23. package/src/audit/checks/network.ts +22 -8
  24. package/src/audit/checks/sitemap.ts +42 -16
  25. package/src/audit/redirects.ts +12 -1
  26. package/src/audit/run.ts +13 -3
  27. package/src/audit/url.ts +21 -2
  28. package/src/cli/commands/audit.ts +21 -6
  29. package/src/cli/commands/dev.ts +19 -2
  30. package/src/components/content/Frame.astro +4 -1
  31. package/src/components/content/Prompt.astro +4 -1
  32. package/src/components/content/Tooltip.astro +4 -1
  33. package/src/components/content/Update.astro +45 -0
  34. package/src/components/islands/ask-ai.tsx +19 -2
  35. package/src/components/islands/hooks.ts +38 -11
  36. package/src/components/layout/Logo.astro +2 -2
  37. package/src/components/layout/RootLayout.astro +27 -7
  38. package/src/components/layout/Search.astro +5 -1
  39. package/src/components/layout/head-scripts.ts +22 -5
  40. package/src/components/openapi/ApiTagOperations.astro +17 -8
  41. package/src/core/config-input.ts +45 -0
  42. package/src/core/data.ts +2 -0
  43. package/src/core/date-format.ts +17 -0
  44. package/src/core/deployment-env.ts +7 -2
  45. package/src/core/graph.ts +7 -1
  46. package/src/core/i18n.ts +10 -2
  47. package/src/core/navigation.ts +7 -3
  48. package/src/core/project-graph.ts +9 -0
  49. package/src/core/schema.ts +64 -0
  50. package/src/core/sources/normalize.ts +69 -8
  51. package/src/core/sources/notion.ts +4 -2
  52. package/src/core/sources/sanity.ts +5 -3
  53. package/src/core/types.ts +16 -0
  54. package/src/markdown/code-title.ts +7 -1
  55. package/src/openapi/model.ts +31 -2
  56. package/src/openapi/references.ts +6 -0
  57. package/src/openapi/render-mdx.ts +12 -7
  58. package/src/openapi/scalar.ts +4 -0
  59. package/src/registry/eject.ts +6 -3
  60. package/src/theme/entry.ts +7 -0
  61. package/src/theme/twoslash.ts +10 -0
@@ -42,6 +42,11 @@ export interface ReferenceSource {
42
42
  spec: string;
43
43
  /** Per-block Scalar theme name override, if any (Scalar renderer only). */
44
44
  theme?: string;
45
+ /**
46
+ * Arbitrary Scalar config forwarded to `<ScalarComponent>` (Scalar renderer
47
+ * only). Takes precedence over Blume's derived spec/theme config.
48
+ */
49
+ scalar?: Record<string, unknown>;
45
50
  /** Display options carried through to the Blume renderer. */
46
51
  display: ReferenceDisplay;
47
52
  /**
@@ -117,6 +122,7 @@ const referencesFor = (
117
122
  label,
118
123
  renderer,
119
124
  route,
125
+ scalar: block.scalar,
120
126
  slug: routeSlug(route),
121
127
  spec: source.spec,
122
128
  theme: block.theme,
@@ -11,13 +11,14 @@ import type { ApiOperationRef, ApiSpecData } from "./model.ts";
11
11
  * omit their own top heading.
12
12
  */
13
13
 
14
- // Neutralize the few characters MDX treats specially (`{` expressions, `<` JSX)
15
- // so an arbitrary spec description can be embedded in the body verbatim without
16
- // breaking compilation. They render as their literal selves.
17
- const MDX_UNSAFE = /[<>{}]/gu;
14
+ // Neutralize the few characters MDX treats specially (`{` expressions, `<`
15
+ // JSX) so an arbitrary spec description can be embedded in the body verbatim
16
+ // without breaking compilation. They render as their literal selves. `>` is
17
+ // deliberately not escaped: it isn't MDX-special on its own, and escaping it
18
+ // turns a `> Note:` blockquote into literal "&gt; Note:" text.
19
+ const MDX_UNSAFE = /[<{}]/gu;
18
20
  const ENTITIES: Record<string, string> = {
19
21
  "<": "&lt;",
20
- ">": "&gt;",
21
22
  "{": "&#123;",
22
23
  "}": "&#125;",
23
24
  };
@@ -28,8 +29,12 @@ const MDX_ESM_KEYWORD = /^(?<keyword>import|export)\b/gmu;
28
29
  // Backtick code — inline spans and fences alike — is already literal in MDX,
29
30
  // and entities are NOT decoded inside it, so escaping there would render the
30
31
  // entity text verbatim (`/pets/&#123;petId&#125;`). Matching any balanced
31
- // backtick run covers `code`, ``code``, and ```fences``` in one shot.
32
- const BACKTICK_CODE = /(?<bt>`+)[\s\S]*?\k<bt>/gu;
32
+ // backtick run covers `code`, ``code``, and ```fences``` in one shot. Both
33
+ // runs are pinned by the backtick lookarounds: CommonMark pairs a span only
34
+ // with an *equal-length* run, so without them a lone backtick would "close" on
35
+ // the first backtick of a longer fence run — leaving `{` in the real prose
36
+ // unescaped (a compile error) and escaping entities into the fence body.
37
+ const BACKTICK_CODE = /(?<!`)(?<bt>`+)(?!`)[\s\S]*?(?<!`)\k<bt>(?!`)/gu;
33
38
 
34
39
  const escapeProse = (text: string): string =>
35
40
  text
@@ -161,6 +161,10 @@ export const buildReferenceFiles = async (options: {
161
161
  configuration: {
162
162
  ...spec.config,
163
163
  ...themeConfiguration(config, ref.theme),
164
+ // Author-supplied Scalar options win outright — a full escape hatch
165
+ // over Blume's derived spec/theme config (localization, agent,
166
+ // hideTestRequestButton, orderSchemaPropertiesBy, and the rest).
167
+ ...ref.scalar,
164
168
  },
165
169
  dataImport: `${"../".repeat(depth + 1)}generated/data.json`,
166
170
  route: ref.route,
@@ -9,7 +9,7 @@ import { buildRawMarkdown } from "../ai/markdown.ts";
9
9
  import { buildMcpData } from "../ai/mcp/data.ts";
10
10
  import { buildMcpDiscovery, buildMcpServerCard } from "../ai/mcp/discovery.ts";
11
11
  import { planComponentSlots } from "../astro/component-slots.ts";
12
- import { discoverExamples } from "../astro/examples.ts";
12
+ import { discoverExamples, exampleMarkdownLookup } from "../astro/examples.ts";
13
13
  import {
14
14
  buildRuntimeData,
15
15
  collectStaged,
@@ -292,6 +292,11 @@ export const eject = async (
292
292
  const exportPdf = config.export.pdf;
293
293
  const exportEpub = config.export.epub;
294
294
 
295
+ // Discover examples first and expose them on the project, so the agent-facing
296
+ // Markdown built below (raw `.md`, MCP) downlevels `<Component>` to its source.
297
+ const examples = await discoverExamples(root, config.examples.source);
298
+ project.examples = exampleMarkdownLookup(examples.examples);
299
+
295
300
  const [
296
301
  pages,
297
302
  needsReactRaw,
@@ -300,7 +305,6 @@ export const eject = async (
300
305
  userExamplesCss,
301
306
  rawMarkdown,
302
307
  islands,
303
- examples,
304
308
  ] = await Promise.all([
305
309
  context.pagesRoot ? discoverPages(context.pagesRoot) : Promise.resolve([]),
306
310
  detectNeedsReact(root),
@@ -311,7 +315,6 @@ export const eject = async (
311
315
  readExamplesCss(root, config.examples.css),
312
316
  buildRawMarkdown(project),
313
317
  discoverIslands(root),
314
- discoverExamples(root, config.examples.source),
315
318
  ]);
316
319
  // Island/example frameworks drive which Astro renderers the ejected config
317
320
  // wires in; React also switches on for project `.tsx`/`.jsx` and Ask AI.
@@ -247,6 +247,13 @@ ${THEME_MAPPING}
247
247
  letter-spacing: 0;
248
248
  }
249
249
 
250
+ /* A heading can carry one long unbreakable token — an OpenAPI operation's title
251
+ is \`METHOD /very/long/{path}\` when the spec sets no summary — which would run
252
+ off the content column. Break it across lines instead of overflowing. */
253
+ .prose :where(h1, h2, h3, h4, h5, h6) {
254
+ overflow-wrap: break-word;
255
+ }
256
+
250
257
  .prose :where(h1) {
251
258
  font-size: 3rem;
252
259
  line-height: 1.1;
@@ -43,6 +43,16 @@ const OVERRIDES = `
43
43
  padding-right: 1.25rem;
44
44
  }
45
45
 
46
+ /* Twoslash blocks keep \`overflow: visible\` so popups can escape, which means
47
+ long lines can't scroll — they'd push past the viewport on narrow screens.
48
+ Wrap them on mobile instead; hover popups still position against the token. */
49
+ @media (max-width: 640px) {
50
+ .prose pre.twoslash code {
51
+ white-space: pre-wrap;
52
+ overflow-wrap: anywhere;
53
+ }
54
+ }
55
+
46
56
  /* The rich renderer renders each popup's type signature as a nested Shiki
47
57
  pre. Strip the code-block chrome (border, radius, padding, background) so it
48
58
  sits flush inside the popup, which owns the frame. */