import type { ReactNode, CSSProperties } from 'react'; import type { CSSObject } from '@emotion/react'; import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; export type NTMonaco = typeof monaco; export type NTMonacoLanguage = typeof monaco.languages.typescript; export type NTMonacoUri = monaco.Uri; export type NTMonacoEditor = monaco.editor.IStandaloneCodeEditor; export type NTMonacoModel = monaco.editor.ITextModel; export type NTMonacoCompilerOptions = monaco.languages.typescript.CompilerOptions; export type NTThemeSettingsMultiplier = number; export type NTThemeSettingsStyle = CSSProperties[]; export type NTThemeSettingsColorValue = [number, number, number, number?]; export type NTThemeSettingsColorPatch = Array; export type NTThemeSettingsColor = (index: number, patch?: NTThemeSettingsColorPatch) => NTThemeSettingsColorValue; export type NTThemeMultiplier = (index: number) => number; export type NTThemeStyleValue = CSSProperties; export type NTThemeStyle = (index: number) => NTThemeStyleValue; export type NTThemeColor = (index: number) => string; export type NTThemeColorScheme = 'dark' | 'light'; export interface NTThemePalette { text: NTThemeColor; textHigh: NTThemeColor; deco: NTThemeColor; decoHigh: NTThemeColor; level: NTThemeColor; levelHigh: NTThemeColor; bg: NTThemeColor; } export interface NTTheme { space: NTThemeMultiplier; typography: { heading: NTThemeStyle; body: NTThemeStyle; cta: NTThemeStyle; code: NTThemeStyle; }; colorScheme: NTThemeColorScheme; colors: { primary: NTThemePalette; secondary: NTThemePalette; }; } export interface NTBreakpoints { medium: { down: string; up: string; }; large: { down: string; up: string; }; xlarge: { down: string; up: string; }; xxlarge: { down: string; up: string; }; } export type NTStyle = CSSObject; export type NTStyles = Record; export type NTRouterURLOptionControl = 'type' | 'sandbox' | 'code'; export type NTRouterURLOptionBoolean = 'explorer' | 'editor' | 'preview' | 'dark'; export type NTRouterURLOption = NTRouterURLOptionControl | NTRouterURLOptionBoolean; export type NTRouterOptionsControls = { type: 'predefined' | 'custom'; sandbox: string[]; code: string; }; export type NTRouterOptionsBooleans = Record; export type NTRouterOptions = Record; export type NTRouterOptionsUpdate = Partial & Partial; export interface NTSandbox { name: string; code?: string; children?: NTSandbox[]; } export interface NTSandboxDependency { name: string; pkg: unknown; slug: string; } export interface NTSandboxImportRef { values: string; dependencyName: string; dependencySlug: string; } export interface NTTypeDefinition { filename: string; code: string; } export interface NTTranspilation { importsLines: string[]; code: string; error: string; } export type NTSetupTheme = Partial<{ typographyCommons: Partial<{ heading: CSSProperties; body: CSSProperties; cta: CSSProperties; code: CSSProperties; }>; colorHues: Partial<{ primary: number; secondary: number; }>; colorSchemeDefault: NTThemeColorScheme; colorSchemeDisabled: boolean; }>; export interface NTSetupUI { small?: ReactNode; medium?: ReactNode; } export interface NTSetup { element: HTMLElement; basePath: string; assetsPath: string; playgroundPath: string; sandboxPath: string; codeLanguage: 'javascript' | 'typescript'; newCustomSandboxCode: string; newCustomSandboxMessage: string; theme: NTSetupTheme; title: NTSetupUI; header: NTSetupUI; toolbar: NTSetupUI; links: { small?: ReactNode[][]; medium?: ReactNode[][]; }; getSandboxes: () => Promise | NTSandbox[]; getTypeDefinitions?: () => Promise | NTTypeDefinition[]; onRouteChange?: () => void; onSandboxChange?: (sandbox: NTSandbox | null) => void; } export type NTStoreSetup = NTSetup; export interface NTStoreRouter { options: NTRouterOptions; optionsControls: NTRouterOptionsControls; optionsBooleans: NTRouterOptionsBooleans; } export interface NTStoreDependencies { isLoading: boolean; error: string; monaco: NTMonaco; model: NTMonacoModel; sandboxes: NTSandbox[]; typeDefinitions: NTTypeDefinition[]; } export type NTStoreSandboxSelected = NTSandbox | null; export interface NTStoreTranspilation extends NTTranspilation { isLoading: boolean; sandboxURLParams: string; } export type NTAppPlaygroundSettings = Partial; export interface NTAppSandboxSettingsDependency { name: string; pkg: unknown; } export interface NTAppSandboxSettings { dependencies?: NTAppSandboxSettingsDependency[]; }