@charmland/gem-vite 0.1.0 → 0.2.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/og.d.ts CHANGED
@@ -1,2 +1,33 @@
1
1
  import type { Page, SiteDocument } from "@charmland/gem-compiler/types";
2
- export declare function renderOgImage(site: SiteDocument, page: Page | null, root: string): Promise<Buffer | null>;
2
+ import type { ContainerNode } from "@takumi-rs/core";
3
+ type Warn = (message: string) => void;
4
+ interface ResolvedFont {
5
+ path: string;
6
+ data: Buffer;
7
+ mtime: number;
8
+ name: string;
9
+ weight: number | null;
10
+ style: "normal" | "italic" | null;
11
+ }
12
+ type DefaultFont = (warn: Warn) => Promise<ResolvedFont | null>;
13
+ export type CoverImage = string | Uint8Array;
14
+ export interface CoverNodeOptions {
15
+ /** The family the registered fonts answer to. */
16
+ family: string;
17
+ /** Resolve one image node source; `null` skips the node. */
18
+ loadImage: (src: string) => Promise<CoverImage | null>;
19
+ warn?: Warn;
20
+ }
21
+ /**
22
+ * Build the cover node tree. Pure apart from image resolution, so tests can
23
+ * assert the layout with a stub loader and never touch the network.
24
+ */
25
+ export declare function coverNode(site: SiteDocument, page: Page | null, options: CoverNodeOptions): Promise<ContainerNode>;
26
+ /**
27
+ * Resolve image bytes once per source. Local paths are project-relative with
28
+ * the Vite public dir as a fallback root; remote URLs are fetched with a
29
+ * timeout so a flaky host cannot hang the build.
30
+ */
31
+ export declare function coverImageLoader(root: string, warn: Warn, publicDir?: string): (src: string) => Promise<CoverImage | null>;
32
+ export declare function renderOgImage(site: SiteDocument, page: Page | null, root: string, onWarn?: Warn, loadImage?: (src: string) => Promise<CoverImage | null>, loadDefaultFont?: DefaultFont): Promise<Buffer | null>;
33
+ export {};
package/dist/output.d.ts CHANGED
@@ -5,13 +5,49 @@ export interface OutputContext {
5
5
  }
6
6
  export declare function markdownFile(route: string): string;
7
7
  export declare function markdownRoute(route: string): string;
8
- export declare function absoluteUrl(origin: string | null, route: string): string | null;
8
+ /**
9
+ * Mount a base-free route under the deployment base. `base` is `"/"` or
10
+ * `"/sub/"`; the route always starts with `"/"`. Filesystem helpers stay
11
+ * base-free and never call this.
12
+ */
13
+ export declare function withBase(base: string, route: string): string;
14
+ /**
15
+ * The origin of a configured URL, dropping any path. A deploy path belongs in
16
+ * Vite's `base`, not in `site.url`, so a path here is ignored by the caller.
17
+ */
18
+ export declare function originOnly(raw: string): string | null;
19
+ export declare function absoluteUrl(origin: string | null, route: string, base?: string): string | null;
20
+ /**
21
+ * Resolve a configured asset (favicon, share image). External and
22
+ * protocol-relative URLs pass through; any local path is root-absolute and
23
+ * base-free like a route ID, so it takes the deployment base and, when known,
24
+ * the origin.
25
+ */
26
+ export declare function assetUrl(origin: string | null, path: string, base?: string): string;
27
+ /** Whether a configured deployed asset exists. Unknown when the public dir is off. */
28
+ export declare function localAssetExists(publicDir: string, value: string): boolean;
29
+ /** Bytes of a deployed asset, for sniffing its dimensions. */
30
+ export declare function readLocalAsset(publicDir: string, value: string): Buffer | null;
31
+ export interface ImageSize {
32
+ width: number;
33
+ height: number;
34
+ }
35
+ /** Wrap a warning sink so one message reaches it once per build. */
36
+ export declare function warnOnce(warn: (message: string) => void): (message: string) => void;
37
+ /** PNG, GIF, JPEG and WebP dimensions from the file header. */
38
+ export declare function imageSize(data: Buffer): ImageSize | null;
9
39
  export declare function ogFile(route: string): string;
10
40
  export declare function ogRoute(route: string): string;
11
- export declare function sitemapXml(pages: Page[], origin: string | null): string;
12
- export declare function robotsTxt(origin: string | null): string;
13
- export declare function llmsTxt(site: SiteDocument, origin: string | null): string;
14
- export declare function jsonLd(site: SiteDocument, page: Page | null, origin: string | null): string;
41
+ export declare function sitemapXml(pages: Page[], origin: string | null, base?: string): string;
42
+ export declare function robotsTxt(origin: string | null, base?: string): string;
43
+ export declare function llmsTxt(site: SiteDocument, origin: string | null, base?: string): string;
44
+ /**
45
+ * `llms-full.txt`: the same nav order as `llms.txt`, but with each page's
46
+ * markdown body inlined. `bodies` is keyed by route; a route without one is
47
+ * skipped so the file never carries an empty heading.
48
+ */
49
+ export declare function llmsFullTxt(site: SiteDocument, bodies: Map<string, string>, origin: string | null, base?: string): string;
50
+ export declare function jsonLd(site: SiteDocument, page: Page | null, origin: string | null, base?: string, image?: string | null): string;
15
51
  /**
16
52
  * A site whose landing page sits under its prefix still has to answer at the
17
53
  * build root, both locally and under a mount. A relative redirect does that
@@ -0,0 +1 @@
1
+ export declare function joinBase(base: string, file: string): string;
@@ -0,0 +1,8 @@
1
+ import type { Connect } from "vite";
2
+ /**
3
+ * The HTML a preview request answers with: the emitted file for its route, or
4
+ * the build's `404.html`. Mounted after Vite's static and base middlewares, so
5
+ * assets are already served and `req.url` no longer carries the deployment
6
+ * base. `routeFile` is the same naming the build wrote, so they cannot drift.
7
+ */
8
+ export declare function previewHtml(outDir: string): Connect.NextHandleFunction;
@@ -0,0 +1,6 @@
1
+ import type { SiteDocument } from "@charmland/gem-compiler/types";
2
+ export declare const THEME_JS = "@charmland/gem/theme.js";
3
+ export declare const THEME_CSS = "@charmland/gem/theme.css";
4
+ export declare const FONT_ORIGIN = "https://stuff.charm.land";
5
+ export declare const FONT_CSS = "https://stuff.charm.land/fonts/charmform/charmform.css";
6
+ export declare function devStyles(content: SiteDocument, root: string, configuredEntry?: string): string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@charmland/gem-vite",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "The Vite plugin that turns a markdown directory into a prerendered docs site.",
5
5
  "keywords": ["gem", "vite", "vite-plugin", "documentation", "prerender"],
6
6
  "homepage": "https://github.com/charmbracelet/gem/tree/main/packages/vite",
@@ -39,13 +39,12 @@
39
39
  "prepack": "bun run build"
40
40
  },
41
41
  "dependencies": {
42
- "@charmland/gem-compiler": "0.1.0",
43
- "@resvg/resvg-js": "^2.6.2",
44
- "jsdom": "^30.1.3",
45
- "satori": "^0.63.2"
42
+ "@charmland/gem-compiler": "0.2.0",
43
+ "@takumi-rs/core": "^2.20.0",
44
+ "jsdom": "^30.1.3"
46
45
  },
47
46
  "peerDependencies": {
48
- "@charmland/gem": "^0.1.0",
47
+ "@charmland/gem": "^0.2.0",
49
48
  "vite": ">=6"
50
49
  },
51
50
  "peerDependenciesMeta": {