All files / coherent.js/packages/runtime/types index.d.ts

0% Statements 0/118
0% Branches 0/1
0% Functions 0/1
0% Lines 0/118

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119                                                                                                                                                                                                                                             

/**
 * Type definitions for @coherentjs/runtime
 */

export * from '@coherentjs/core';
export * from '@coherentjs/client'; 
export * from '@coherentjs/web-components';

// Runtime environments
export enum RuntimeEnvironment {
  BROWSER = 'browser',
  NODE = 'node',
  EDGE = 'edge', 
  CLOUDFLARE = 'cloudflare',
  DENO = 'deno',
  BUN = 'bun',
  ELECTRON = 'electron',
  TAURI = 'tauri',
  STATIC = 'static'
}

// Runtime capabilities
export interface RuntimeCapabilities {
  dom: boolean;
  ssr: boolean;
  filesystem: boolean;
  fetch: boolean;
  websockets: boolean;
  workers: boolean;
  storage: boolean;
  crypto: boolean;
  streams: boolean;
}

// Runtime info
export interface RuntimeInfo {
  environment: RuntimeEnvironment;
  capabilities: RuntimeCapabilities;
  version: string | null;
  features: string[];
  userAgent: string | null;
  platform: any;
}

// App creation
export interface AppOptions {
  environment?: RuntimeEnvironment;
  autoHydrate?: boolean;
  enableWebComponents?: boolean;
  enablePerformanceMonitoring?: boolean;
  routingMode?: 'hash' | 'history' | 'memory' | 'none';
  [key: string]: any;
}

export interface CoherentApp {
  component(name: string, component: Function, options?: any): Function;
  route?(path: string, handler: Function): void;
  navigate?(path: string): void;
  render(component: Function | string, props?: any, target?: string | Element): Promise<any>;
  mount(component: Function | string, target?: string | Element): Promise<any>;
  unmount(target?: string | Element): void;
  getRuntime(): any;
}

// Main factory functions
export function createCoherentApp(options?: AppOptions): Promise<CoherentApp>;
export function renderApp(component: Function | string, props?: any, target?: string | Element): any;
export function detectRuntime(): RuntimeEnvironment;
export function createRuntime(options?: AppOptions): Promise<any>;
export function getRuntimeCapabilities(environment?: RuntimeEnvironment): RuntimeCapabilities;
export function getRuntimeInfo(): RuntimeInfo;

// Runtime classes
export class BrowserRuntime {
  constructor(options?: any);
  initialize(): Promise<void>;
  registerComponent(name: string, component: Function, options?: any): Function;
  createApp(options?: any): Promise<CoherentApp>;
  static createQuickApp(components?: Record<string, Function>, options?: any): Promise<CoherentApp>;
}

export class EdgeRuntime {
  constructor(options?: any);
  createApp(options?: any): any;
  handleRequest(request: Request): Promise<Response>;
  static createApp(options?: any): any;
}

export class StaticRuntime {
  constructor(options?: any);
  createApp(options?: any): any;
  build(): Promise<any>;
  static buildSite(pages?: any, components?: Record<string, Function>, options?: any): Promise<any>;
}

// Utility functions
export class RuntimeDetector {
  static detect(): RuntimeEnvironment;
  static getCapabilities(environment?: RuntimeEnvironment): RuntimeCapabilities;
}

// Global window interface (for script tag usage)
declare global {
  interface Window {
    Coherent?: {
      renderToString(obj: any): Promise<string>;
      hydrate(element: Element, component: Function, props?: any): Promise<any>;
      defineComponent(name: string, component: Function, options?: any): Promise<any>;
      createApp(options?: AppOptions): Promise<CoherentApp>;
      renderApp(component: Function | string, props?: any, target?: string | Element): any;
      VERSION: string;
    };
    componentRegistry?: Record<string, Function>;
  }
}

export const VERSION: string;