import { type Ref, type ComputedRef } from '#imports'; import type { BlockDefinition, FragmentDefinition, ProviderDefinition } from '#blokkli-build/definitions'; import type { ValidFieldListTypes, BlockBundleWithNested, ValidProviderTypes } from '#blokkli-build/generated-types'; import type { DeepReadonly } from 'vue'; import type { BlockDefinitionOptionsInput } from '../../types/definitions.js'; import type { RuntimeBlockOptionArray } from '../../../global/types/blockOptions.js'; import type { RenderedFieldListItem } from '../types/field.js'; export type DefinitionProvider = { /** * Get the block definition for a specific context. * * Checks for context-specific definitions in this order: * 1. Field list type specific (e.g., bundle__field:canvas) * 2. Parent bundle specific (e.g., bundle__parent:accordion) * 3. Default bundle definition * * @param bundle - The block bundle name * @param fieldListType - The field list type context * @param parentBundle - Optional parent block bundle for nested blocks * @returns The block definition, or undefined if not found */ getBlockDefinition: (bundleOrBlock: string | RenderedFieldListItem, fieldListType: ValidFieldListTypes | null, parentBundle: BlockBundleWithNested | null) => BlockDefinition | undefined; /** * Get the default block definition for a bundle. * * Returns the base definition without considering context (field list type or parent). * * @param bundle - The block bundle name * @returns The default block definition, or undefined if not found */ getDefaultDefinition: (bundle: string) => BlockDefinition | undefined; /** * Get a fragment definition by name. * * @param name - The fragment name * @returns The fragment definition, or undefined if not found */ getFragmentDefinition: (name: string) => FragmentDefinition | undefined; /** * Get a provider definition for an entity type and bundle. * * @param entityType - The entity type (e.g., 'node', 'block_content') * @param entityBundle - The entity bundle (e.g., 'article', 'page') * @returns The provider definition, or undefined if not found */ getProviderDefinition: (entityType: string, entityBundle: string) => ProviderDefinition | undefined; /** * Get the icon name for a block bundle. * * @param bundle - The block bundle name * @returns The icon name, or undefined if no icon is defined */ getBlockIcon: (bundle: string) => string | undefined; /** * Get the image of a block. * * @param bundle - The block bundle name * @returns The url of the image. */ getBlockImage: (bundle: string) => string | undefined; /** * List of all registered fragment definitions. * * Updates automatically via HMR during development. */ fragmentDefinitions: ComputedRef; /** * List of all registered block definitions. * * Updates automatically via HMR during development. */ blockDefinitions: ComputedRef; /** * Global options that apply to all blocks. */ globalOptions: DeepReadonly>; /** * Runtime option values for all blocks. * * Maps block UUIDs to their option values. Structure: * - First level: block UUID * - Second level: option key → option value array * * Updates automatically via HMR during development. */ runtimeOptions: DeepReadonly>>>; /** * Render key that changes when definitions are updated. * * Use as a component key to force remounting when definitions change. * Automatically increments via HMR during development. */ renderKey: DeepReadonly>; /** * Block bundles that can be added automatically without showing the form. */ bundlesWithAutoAdd: ComputedRef; }; export default function (providerType: ValidProviderTypes): DefinitionProvider;