Skip to content
Svartz v2.6.0

@svartz/core

173 exported symbols.

Classes

c PluginAggregateError
c PluginHookError
c PluginValidationError
c ProtectedSessionKeep decrypted group data and non-exportable keys only for this page session.
c ProtectionAuthenticationError
c ProtectionFormatError
c ThemeValidationError

Interfaces

i Artifact
i AssetRecord
i BrowserResourceBrowser import contributed by an active content plugin. Script modules export `mount(pathname)` and return an optional disposer.
i BrowserScriptContextWhere the site is served, for scripts that build URLs, such as a server plugin's `<base>/_svartz/<id>/`.
i BrowserScriptLoader
i BrowserScriptModuleLifecycle contract for a script contributed by a content plugin.
i ChangeEvent
i CompilerContributionsCompiler steps and browser imports collected afresh for each pipeline run.
i ContentViewHTML shown through a page's content components, from `BrowserScriptContext.mountContent`.
i DashboardContributionWhat a plugin adds to the dashboard: a heading for its panels, and the panels.
i DashboardPanelA tool or settings screen a plugin adds to the site's dashboard, at `/-/dashboard/<plugin id>/<panel id>/`. The dashboard shows it only to viewers who hold `permission` on the vault, and checks that again on every render.
i DashboardSectionOne plugin's panels, as `ServerContext.dashboard` lists them.
i DefaultThemeOverrideHintsDefault Tailwind theme override keys for better tab completion / IntelliSense when customizing theme. Schema validation accepts any Tailwind theme keys; this type hints the common ones. Theme packages (e.g. @svartz/theme-minimal) can export their own override type for even better hints. To narrow the `theme` property, add a JSDoc
i EnvReferenceNames a server environment variable in place of an inlined secret.
i FolderIndexEntry
i GraphTargetRich graph node for UI consumers (projection of Index).
i HookExecutionResult
i IndexCanonical index artifact produced by `core:index`. Single source of truth for search, backlinks, and graph projections.
i IndexEntry
i IndexLink
i NormalizedSvartzPlugin
i PageContextPer-request facilities handed to a plugin's page renderer.
i PermissionDeclarationA permission a plugin checks with `can()` from `@svartz/auth/server`. `defaults` are the site-wide grants to the built-in actors (`guest` is everyone, `signed-in` everyone with an account) until a stored grant says otherwise.
i PluginContext
i PluginPageA plugin page's content. The theme shell renders `html` as the page body, under its header and beside its explorer.
i ProcessedFileA file passing through the plugin pipeline.
i ProtectedEnvelope
i ProtectedGroupPayloadBrowser session state for independently unlocked password groups.
i RawLinkA link extracted from markdown before resolution. Mirrors vault's LinkMatch — kept Effect-free for plugin authors.
i ResolvedBuildConfig
i ResolvedConfigCanonical single-vault build config consumed by the runner and @svartz/vite.
i ResolvedDiscoveryConfig
i ResolvedFrontmatterConfig
i ResolvedSiteConfig
i ResolvedThemeConfig
i ResolvedVaultDefaults
i RouteIndex
i RunnerResult
i RuntimeRouteInput
i RuntimeRouteMatch
i SearchDocument
i ServerContextPer-request facilities handed to a server plugin's handler.
i ServerHandleEventThe parts of SvelteKit's `RequestEvent` the router reads.
i ServerHandleRuntimeRuntime inputs SvelteKit supplies to the generated registry.
i ServerModuleWhat a server factory builds when it renders pages or panels: its request handler, its page renderer and its panels.
i ServerModuleSpecA plugin's server module and the JSON options its factory receives.
i ServerRegistryWhat a build knows about its server plugins; `virtual:svartz/server` exports one per vault.
i ServerRouteOne active server plugin in a generated registry.
i ServerVaultSettingsPublic settings of the vault a server plugin belongs to.
i SiteVaultsEvery vault in the config, and the one a `SvartzPlugin.forVault` call resolves the plugin for.
i SocialImageMetadataPublic metadata a theme may place on a generated social preview.
i SvartzPlugin
i SvartzServerServes a vault's server plugins: SvelteKit's `handle`, and the `load` of the route that renders plugin pages.
i SvartzTheme
i TagIndexEntry
i TargetConfig
i ThemeArtifactRequirementsDeclares which pipeline artifacts the theme needs. `search` and `toc` are derived from the canonical `index` — not independent.
i ThemeComponentRegistryNamed component entries the theme provides for the runner/shell. All entries are optional; custom components extend via the index signature.
i ThemeLayoutMapMaps named layout slots to component loaders. Required: `defaultPage` and `notePage`. Custom slots are extensible via the index signature.
i ThemePluginPresetPlugins the theme ships with. Merged into the pipeline using standard plugin merge semantics: replace by id if existing, append if new.
i ThemeRenderCapabilitiesDeclarative flags indicating what the theme can render.
i ThemeRouteDefinition
i TocEntry
i VaultNoteView
i VaultViewPublished, vault-scoped data for SvelteKit loaders and theme components.

Types

t AnalyticsConfigPublic analytics settings shipped to the browser only when selected by a consumer.
t ArtifactBag
t CustomDomainRoute
t DateSource
t DevBindingsWhat `svartz dev` stores in `DEV_BINDINGS`: resolves the bindings, vars and `.dev.vars` of the app's Wrangler config.
t Graph
t HookOptions
t LinkResolutionStrategy
t MaybePromise
t PageRendererRenders a GET of one of the plugin's pages; `undefined` answers 404. Pages render on every request and are never prerendered or cached. Forms on them post to the plugin's `/_svartz/<id>/` routes, which redirect back.
t PageResultWhat a page renderer answers: the page, or a same-site path to send the reader to instead.
t PermissionActionWhat a permission lets someone do.
t PermissionSlug`namespace:feature:action`, where the namespace is the declaring plugin's id: `annotations:comments:delete`.
t PluginChangeHook
t PluginChangeHookInput
t PluginError
t PluginFactory
t PluginHook
t PluginHookInput
t RunnerPlugin
t ServerHandlerAnswers a request under the plugin's prefix. `undefined` answers 404.
t ServerModuleFactoryA server module's default export: builds the handler once from the plugin's options and the build data its hooks set in `getCompilerContributions(ctx).serverData` (`undefined` when they set none). A plugin with `pages` answers `{ handle, page }`.
t StageName
t TailwindThemeConfig
t ThemeComponentLoaderReference to a Svelte component — sync or lazy.
t ThemeError
t ThemeFactory
t ThemeRequiredFeature
t WranglerAssets
t WranglerBuild
t WranglerConfig
t WranglerConfigFields
t WranglerEnvRecord
t WranglerLimits
t WranglerObservability
t WranglerPlacement
t WranglerRoute
t WranglerTriggers
t ZoneIdRoute
t ZoneNameRoute

Functions

f createProtectionSaltGenerate a fresh salt once per password group and build.
f createServerBuild a vault's `SvartzServer`. Each factory runs once: on its plugin's first request or page, or for an `eager` plugin before the handle answers its first request of any kind.
f createServerHandleThe SvelteKit `handle` of `createServer`, for apps that render no plugin pages.
f createVaultEntryViewApply the deployment base to one published entry, including a newly unlocked hidden note.
f createVaultViewCompose SvelteKit's deployment base with the index's vault-mounted URLs once.
f decodeRoutePathDecode a percent-encoded URL pathname once; preserve slashes and return undefined for malformed escapes.
f definePluginWrap a plugin factory with runtime validation and hook normalization. The returned factory produces normalized plugins ready for the runner.
f defineThemeDefine a theme with runtime validation. Accepts either a static theme object or a factory function. Returns a callable factory that validates the manifest on each invocation.
f deriveProtectionKeyDerive a non-exportable session key from a password and the group's public salt.
f executeHandleChange
f executeStage
f getCompilerContributions
f isPluginEnabled
f markdownCopyForThe emitted Markdown copy of the page at a request `pathname`, if it has one. Map keys are decoded and end in a slash; request paths arrive percent-encoded, and without the slash under `trailingSlash: 'never'`.
f matchThemeRoute
f materializeThemeLoad every theme component before server rendering or hydration begins.
f mergePluginsLayered merge of plugin lists.
f mergeProtectedIndexMerge only unlocked, listed group discovery into a browser-local vault index.
f mountBrowserScriptsMount active scripts and return one disposer for the current route.
f normalizePathname
f normalizePluginNormalize a plugin: validate shape + convert function shorthand hooks to object form. Throws PluginValidationError on invalid plugins. Warnings emitted via console.warn for unknown keys and disabled-with-hooks.
f openProtectedPayloadAuthenticate before returning bytes. Wrong passwords and altered bytes reject.
f resolveProtectedBridgeImportsSubstitute only generated bridge specifiers before importing decrypted JS.
f resolveThemeRouteToArtifactKey
f runLifecycleHooks
f runStages
f sealProtectedPayloadSeal one group-owned payload. The ID is authenticated, so route swaps fail.
f sortPluginsForStageSort normalized plugins for a specific stage by enforce tier. Within each tier, config array order is preserved (stable sort). Only returns plugins that have a hook for the given stage.
f validatePluginShapeValidate a plugin against the Effect Schema. On failure, inspects the raw input to throw PluginValidationError with message parity to the legacy manual validation path.
f validateTheme

Variables

v CONTRACT_VERSIONCurrent contract version. Themes must declare a contractVersion and plugins may; `defineTheme` and plugin normalization fail one whose semver major differs from this constant.
v CustomDomainRouteSchemaRoute = string | ZoneIdRoute | ZoneNameRoute | CustomDomainRoute
v DEV_BINDINGS`globalThis` slot through which `svartz dev` hands server plugins local Cloudflare bindings. The dev server (Node) sets it to a function resolving the bindings; the router (SSR, same process) reads it per request in dev.
v FnSchemaEffect Schema definitions for SvartzPlugin shape validation. Canonical source of truth for the plugin contract structure. Author-facing types remain plain TS — these schemas are internal.
v HOOK_PARALLEL_DEFAULTS
v HookInputSchema
v HookObjectSchema
v HookOptionsSchema
v KNOWN_PLUGIN_KEYS
v PAGE_ROUTE_SEGMENTPath segment under which plugin pages render in the theme shell: `<base><mount>/-/<page>/`.
v PluginSchema
v SEARCH_INDEX_OPTIONSShared MiniSearch schema for artifact generation and browser search.
v SECRET_ENV_NAME_PATTERNServer-only environment variable names. Client-public `PUBLIC_` and `VITE_` names are refused.
v SERVER_PLUGIN_ID_PATTERNPlugin ids that serve requests, and the page names plugins claim, double as one URL path segment.
v SERVER_ROUTE_SEGMENTPath segment under which every server plugin answers: `<base><mount>/_svartz/<plugin-id>/`.
v STAGE_NAMES
v TailwindThemeConfigPropertyRecordSchemaGeneric theme property: map of name to value (or nested). All theme keys use this shape; extend per-key when needed (e.g. theme-minimal).
v TailwindThemeConfigSchema
v THEME_FEATURE_STAGESExplicit feature requirements are distinct from rendering capabilities.
v WranglerAssetsSchemaAssets config; main/assets can be auto-populated at build from vault outDir.
v WranglerBuildSchemaCustom build (inheritable).
v WranglerConfigFieldsSchemaWrangler config fields shared by root and env.<name>. Covers inheritable and non-inheritable keys from the config; no nested env. A `cloudflare-workers` target is its Worker's Wrangler config, so keys this doesn't list (newer bindings such as `images`) pass through untyped and Wrangler validates them.
v WranglerConfigSchemaFull top-level wrangler config. Users can set env (e.g. dev, prod) per vault; each env key holds a partial config (inheritable keys only) merged with the top-level by wrangler.
v WranglerEnvRecordSchema
v WranglerLimitsSchemaLimits (inheritable).
v WranglerObservabilitySchema
v WranglerPlacementSchemaPlacement (inheritable).
v WranglerRouteSchema
v WranglerTriggersSchemaTriggers / cron (inheritable).
v ZoneIdRouteSchema
v ZoneNameRouteSchema