@lastshotlabs/slingshot-ssg
npm install @lastshotlabs/slingshot-ssg
Functions
Section titled “Functions”collectSsgRoutes
Section titled “collectSsgRoutes”Scans the server routes directory for files that are candidates for static site generation, then returns the full list of URL paths to pre-render.
Detection strategy (in order):
- If the route file source contains
export async function staticPathsorexport function staticPaths, the file is a dynamic SSG route.staticPaths()is called to enumerate all parameter combinations and each combination is expanded into a concrete URL path. - If the route file source contains a top-level
export.*revalidate.*falsepattern (static route, no dynamic segments required), the route URL itself is returned directly.
Source-level detection avoids executing untrusted modules at discovery time.
The actual staticPaths() function is called via import() only for files
that passed the source check, limiting the execution surface.
async function collectSsgRoutes(config: SsgConfig): Promise<string[]>Source: packages/slingshot-ssg/src/crawler.ts
parseSsgConfig
Section titled “parseSsgConfig”Zod schema for SsgConfig.
Validates at the public API boundary before any filesystem operations begin.
Unknown keys are stripped (Zod default) and a warning is emitted by
validatePluginConfig for each unrecognised field.
function parseSsgConfig(rawConfig: unknown): SsgConfigSource: packages/slingshot-ssg/src/config.schema.ts
renderSsgPage
Section titled “renderSsgPage”Internal: execute a single render attempt, wrapping with timeout.
Returns a SsgPageResult regardless of success or failure — the result
carries an error field when the attempt failed.
async function renderSsgPage(urlPath: string, renderer: SlingshotSsrRenderer, config: SsgConfig, assetTagsHtml: string = '',): Promise<SsgPageResult>Source: packages/slingshot-ssg/src/renderer.ts
renderSsgPages
Section titled “renderSsgPages”Internal: execute a single render attempt, wrapping with timeout.
Returns a SsgPageResult regardless of success or failure — the result
carries an error field when the attempt failed.
async function renderSsgPages(paths: readonly string[], renderer: SlingshotSsrRenderer, config: SsgConfig, assetTagsHtml: string = '',): Promise<SsgResult>Source: packages/slingshot-ssg/src/renderer.ts
resolveExitCode
Section titled “resolveExitCode”Parse and validate a positive integer CLI argument.
Rejects NaN, non-finite, and non-integer values with an explicit error
naming the flag. Optionally clamps the parsed value into [min, max] so
callers cannot supply pathological values (negative, zero, or absurdly
large) that would crash or hang the renderer.
function resolveExitCode(succeeded: number, failed: number): SsgExitCode; export function resolveExitCode(result:Source: packages/slingshot-ssg/src/cli.ts
Constants
Section titled “Constants”ssgConfigSchema
Section titled “ssgConfigSchema”Zod schema for SsgConfig.
Validates at the public API boundary before any filesystem operations begin.
Unknown keys are stripped (Zod default) and a warning is emitted by
validatePluginConfig for each unrecognised field.
Config Fields
Section titled “Config Fields”| Field | Description |
|---|---|
circuitBreaker | Circuit breaker configuration for external HTTP fetches during rendering. |
retry | Retry configuration for transient render failures. |
Source: packages/slingshot-ssg/src/config.schema.ts
Classes
Section titled “Classes”SsgCliArgError
Section titled “SsgCliArgError”Errors thrown by the SSG package.
Source: packages/slingshot-ssg/src/errors.ts
SsgConfigError
Section titled “SsgConfigError”Errors thrown by the SSG package.
Source: packages/slingshot-ssg/src/errors.ts
SsgCrawlError
Section titled “SsgCrawlError”Errors thrown by the SSG package.
Source: packages/slingshot-ssg/src/errors.ts
SsgError
Section titled “SsgError”Errors thrown by the SSG package.
Source: packages/slingshot-ssg/src/errors.ts
SsgRenderError
Section titled “SsgRenderError”Errors thrown by the SSG package.
Source: packages/slingshot-ssg/src/errors.ts
Interfaces
Section titled “Interfaces”CircuitBreakerConfig
Section titled “CircuitBreakerConfig”Retry configuration for transient render failures.
When a page render fails with a transient error (timeout, renderer throws),
the SSG renderer retries up to maxAttempts times with exponential backoff
and jitter before recording the page as failed.
Source: packages/slingshot-ssg/src/types.ts
RetryConfig
Section titled “RetryConfig”Retry configuration for transient render failures.
When a page render fails with a transient error (timeout, renderer throws),
the SSG renderer retries up to maxAttempts times with exponential backoff
and jitter before recording the page as failed.
Source: packages/slingshot-ssg/src/types.ts
SsgConfig
Section titled “SsgConfig”Retry configuration for transient render failures.
When a page render fails with a transient error (timeout, renderer throws),
the SSG renderer retries up to maxAttempts times with exponential backoff
and jitter before recording the page as failed.
Source: packages/slingshot-ssg/src/types.ts
SsgPageError
Section titled “SsgPageError”Retry configuration for transient render failures.
When a page render fails with a transient error (timeout, renderer throws),
the SSG renderer retries up to maxAttempts times with exponential backoff
and jitter before recording the page as failed.
Source: packages/slingshot-ssg/src/types.ts
SsgPageResult
Section titled “SsgPageResult”Retry configuration for transient render failures.
When a page render fails with a transient error (timeout, renderer throws),
the SSG renderer retries up to maxAttempts times with exponential backoff
and jitter before recording the page as failed.
Source: packages/slingshot-ssg/src/types.ts
SsgResult
Section titled “SsgResult”Retry configuration for transient render failures.
When a page render fails with a transient error (timeout, renderer throws),
the SSG renderer retries up to maxAttempts times with exponential backoff
and jitter before recording the page as failed.
Source: packages/slingshot-ssg/src/types.ts
SsgConfigParsed
Section titled “SsgConfigParsed”Zod schema for SsgConfig.
Validates at the public API boundary before any filesystem operations begin.
Unknown keys are stripped (Zod default) and a warning is emitted by
validatePluginConfig for each unrecognised field.
Source: packages/slingshot-ssg/src/config.schema.ts
SsgExitCode
Section titled “SsgExitCode”Parse and validate a positive integer CLI argument.
Rejects NaN, non-finite, and non-integer values with an explicit error
naming the flag. Optionally clamps the parsed value into [min, max] so
callers cannot supply pathological values (negative, zero, or absurdly
large) that would crash or hang the renderer.
Source: packages/slingshot-ssg/src/cli.ts
SsgStaticPathsFn
Section titled “SsgStaticPathsFn”A TanStack Query cache entry to pre-seed during SSR.
The queryKey array must match exactly the key used by the corresponding
client-side useQuery() hook. On hydration, the client reads this entry
from the dehydrated state and skips the network request.
Source: packages/slingshot-ssr/src/types.ts