Skip to content

API

ogygia/plugin/utils

Small helpers that plugins share, such as hashing, escaping and schema types.

On this page

This page is generated from the package’s own .d.ts files on every build, so the signatures, descriptions and examples below always match the source.

import { … } from 'ogygia/plugin/utils';

Exports content_css_key · content_css_key · escape_amp_quot · escape_text · fnv1a32 · source_tag_of · SizedLru · StandardIssue · StandardSchemaV1 · StandardResult

content_css_key

function

The stable cross-build key for a markup module's own scoped CSS (a .svx body with a <style>): the path from the first /src/ segment, POSIX (/…/proj/src/content/docs/x.svx → content/docs/x.svx). The preprocessor that bakes the key into the module and the build that emits the CSS and writes the handoff compute it identically from the same absolute filename.

function content_css_key(abs: string): string;

content_css_key

function

The stable cross-build key for a markup module's own scoped CSS (a .svx body with a <style>): the path from the first /src/ segment, POSIX (/…/proj/src/content/docs/x.svx → content/docs/x.svx). The preprocessor that bakes the key into the module and the build that emits the CSS and writes the handoff compute it identically from the same absolute filename.

function content_css_key(abs: string): string;

escape_amp_quot

function

& and " only (a value re-emitted into a double-quoted attribute exactly as it was, < kept).

function escape_amp_quot(s: string): string;

escape_text

function

Text content: &, <, > escaped. Text with none of them comes back as itself, no copy.

function escape_text(s: string): string;

fnv1a32

function

FNV-1a 32-bit over a string → uint32. The NUMERIC sibling for callers that bucket/mod rather than compare (experiment splits, build-cache keys) — no BigInt, no hex round-trip. This is THE one shared implementation; the driver/vite copies were folded into it.

function fnv1a32(s: string): number;

source_tag_of

function

The receipt tag one (source, args) call files, or null when fn is not a declared source.

function source_tag_of(fn: SourceFn, args?: unknown[]): string | null;

SizedLru

class

class SizedLru<V> {/*…*/}

SizedLru.max_bytes

readonly max_bytes: number;

SizedLru.max_entries

readonly max_entries: number;

SizedLru.get

The live value for key (an LRU touch), or null on a miss or past expires.

get(key: string, now: number): V | null;

SizedLru.has

has(key: string): boolean;

SizedLru.set

Store value (bytes big, live until expires), evicting the least recently used entries to make room. A value larger than the whole budget is not stored.

set(key: string, value: V, bytes: number, expires: number): void;

SizedLru.delete

delete(key: string): boolean;

SizedLru.keys

Every live key (insertion order — least recently used first).

keys(): IterableIterator<string>;

SizedLru.sweep

Drop everything past expires (harness counts want live entries only).

sweep(now: number): void;

SizedLru.clear

clear(): void;

SizedLru.size

get size(): number;

SizedLru.bytes

get bytes(): number;

StandardIssue

interface

interface StandardIssue {/*…*/}

StandardIssue.message

readonly message: string;

StandardIssue.path

readonly path?: ReadonlyArray<PropertyKey | {
    readonly key: PropertyKey;
  }>;

StandardSchemaV1

interface

The Standard Schema interface (standardschema.dev): the ~standard spec Zod / Valibot / ArkType all implement, the very thing Kit's remote functions consume. Validate a value with any schema library. Types only.

interface StandardSchemaV1<Output = unknown> {/*…*/}

StandardSchemaV1."~standard"

readonly "~standard": {
    readonly version: 1;
    readonly vendor: string;
    readonly validate: (value: unknown) => StandardResult<Output> | Promise<StandardResult<Output>>;
    readonly types?: {
      readonly output: Output;
    };
  };

StandardResult

type

type StandardResult<Output> = {
  readonly value: Output;
  readonly issues?: undefined;
} | {
  readonly issues: ReadonlyArray<StandardIssue>;
};