UNPKG

@storybook/addon-svelte-csf

Version:
84 lines (83 loc) 3.68 kB
import url from 'node:url'; import type { SvelteAST } from '../parser/ast.js'; /** * Adopted from: {@link https://github.com/storybookjs/storybook/blob/next/code/lib/core-events/src/errors/storybook-error.ts} * Copied because is not exposed in the `storybook/internal/core-events` package, * and modified for this addon needs. */ export declare abstract class StorybookSvelteCSFError extends Error { static isStorybookCSFSvelteError: boolean; static packageName: any; static packageVersion: any; static readonly CATEGORY: { readonly parserExtractSvelte: "PARSER_EXTRACT_SVELTE"; readonly parserExtractCompiled: "PARSER_EXTRACT_COMPILED"; readonly parserAnalyseDefineMeta: "PARSER_ANALYSE_DEFINE_META"; readonly parserAnalyseStory: "PARSER_ANALYSE_STORY"; readonly compiler: "COMPILER"; readonly legacyAPI: "LEGACY_API"; }; /** * Category of the error. Used to classify the type of error, e.g., 'PREVIEW_API'. */ abstract readonly category: (typeof StorybookSvelteCSFError)['CATEGORY'][keyof (typeof StorybookSvelteCSFError)['CATEGORY']]; /** * Code representing the error. Used to uniquely identify the error, e.g., 1. */ abstract readonly code: number; /** * A properly written error message template for this error. * @see https://github.com/storybookjs/storybook/blob/next/code/lib/core-events/src/errors/README.md#how-to-write-a-proper-error-message */ abstract template(): string; /** * Data associated with the error. Used to provide additional information in the error message or to be passed to telemetry. */ readonly data: {}; /** * Specifies the documentation for the error. * - If `true`, links to a documentation page on the Storybook website (make sure it exists before enabling). * - If a string, uses the provided URL for documentation (external or FAQ links). * - If `false` (default), no documentation link is added. */ documentation: boolean | string | string[]; /** * Flag used to easily determine if the error originates from Storybook. */ readonly fromStorybook: true; /** * Any custom message to override the default error message. * Vite overrides the `Error.message` property, so we support that. */ private customMessage?; get fullErrorCode(): `SB_SVELTE_CSF_${this["category"]}_${string}`; /** * Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. */ get name(): string; /** * Generates the error message along with additional documentation link (if applicable). */ get message(): string; /** * Allows anyone to set Error.message after creation, mimicking the native Error behavior. * Vite does this sometimes. */ set message(message: string); /** * `*.stories.svelte` file path where the error has occurred. */ readonly filename?: string; /** * Name of the `<Story name=">...<" />` component which caused the error. */ readonly component?: SvelteAST.Component; constructor({ filename, component: component, }: { filename?: StorybookSvelteCSFError['filename']; component?: StorybookSvelteCSFError['component']; }, options?: ConstructorParameters<typeof Error>[1]); protected get storyNameFromAttribute(): string | number | bigint | boolean | RegExp | null | undefined; get filepathURL(): url.URL | "<path not specified>"; get quickStoryRawCodeIdentifier(): string; } export declare function isStorybookSvelteCSFError(error: unknown): error is StorybookSvelteCSFError;