/** * Studio SDK surface (S3-02 + S3-03 + early S4-07 prep). * * Pure helpers for Studio extension authors: * - `makeFormProxy` / `applyFormAlterHooks` — form-alter pipeline that * `
` renderers in core Studio call before render. Hooks add * fields, hide fields, reorder, attach validators. * - `sortSlotContributions` — stable priority-asc sort used by * `` to order extension contributions. * * The reactive registries themselves (Svelte 5 `$state`) live in * `packages/studio/src/lib/extension-api.svelte.ts`. They import this * module so the algorithm is one source of truth, while the studio side * owns the runtime state. * * Exported via `@zveltio/sdk/studio`. Extension Svelte bundles can * import-and-call too — useful for advanced authors who want to apply * alters against their own custom forms. */ import type { FormAlterAPI, FormAlterHook, FormSchema, SlotContribution, StudioRoute, StudioFieldType, AssetPreviewHandler } from '../extension/index.js'; interface FormProxy extends FormAlterAPI { /** Commit the mutated schema after all hooks ran. */ commit(): FormSchema; } export declare function makeFormProxy(initial: FormSchema): FormProxy; /** * Run every registered hook against the schema and return the result. * Exception-safe: a throwing hook is logged and skipped, the rest still run. */ export declare function applyFormAlterHooks(hooks: FormAlterHook[], schema: FormSchema, ctx?: Record): FormSchema; /** * Sort slot contributions deterministically: priority asc (lower first), * then registration order (stable sort). */ export declare function sortSlotContributions(items: T[]): T[]; /** Register a top-level Studio page contributed by this extension. */ export declare function registerRoute(route: StudioRoute): void; /** * Register a Svelte component into a named composition slot (S3-03). * * @example * import { registerSlot } from '@zveltio/sdk/studio'; * import RevenueWidget from './widgets/RevenueWidget.svelte'; * * registerSlot('dashboard.widgets', { * component: RevenueWidget, * priority: 10, * visible: (ctx) => (ctx.user as any)?.roles?.includes('finance'), * }); */ export declare function registerSlot(name: string, contribution: SlotContribution): void; /** * Register a Drupal-style form-alter hook (S3-02). * * @example * import { registerFormAlter } from '@zveltio/sdk/studio'; * * registerFormAlter('core:user-edit', (form) => { * form.addField({ after: 'email', field: { name: 'phone', type: 'tel' } }); * form.hideField('legacy_pin'); * }); */ export declare function registerFormAlter(formId: string, hook: FormAlterHook): void; /** Register a custom Studio field type contributed by this extension. */ export declare function registerFieldType(ft: StudioFieldType): void; /** * Register a custom preview handler for asset URLs / MIME types. * * @example * import { registerAssetPreview } from '@zveltio/sdk/studio'; * import PdfPreview from './PdfPreview.svelte'; * * registerAssetPreview({ * match: (a) => a.mimeType === 'application/pdf', * component: PdfPreview, * }); */ export declare function registerAssetPreview(handler: AssetPreviewHandler): void; /** Engine base URL — pre-installed by Studio for cross-origin fetches. */ export declare function getEngineUrl(): string; export type { StudioExtensionAPI, StudioRoute, StudioFieldType, AssetPreviewHandler, SlotContribution, FormAlterHook, FormAlterAPI, FormSchema, FormField, } from '../extension/index.js'; //# sourceMappingURL=index.d.ts.map