woby
Version:
A high-performance framework with fine-grained observable/signal-based reactivity for building rich applications.
166 lines • 5.96 kB
TypeScript
/**
* SSR Custom Element Implementation for Woby Framework
*
* This module provides a mock implementation of custom elements for server-side rendering
* environments where browser APIs like customElements, window, and document are not available.
*
* @module customElement.ssr
*/
type EventListener = (evt: Event) => void;
type EventListenerObject = {
handleEvent(object: Event): void;
};
type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
type AddEventListenerOptions = boolean | {
capture?: boolean;
once?: boolean;
passive?: boolean;
};
declare class SimpleNodeList {
private nodes;
constructor(nodes?: any[]);
get length(): number;
item(index: number): any;
[Symbol.iterator](): ArrayIterator<any>;
}
interface MutationObserverInit {
childList?: boolean;
attributes?: boolean;
characterData?: boolean;
subtree?: boolean;
attributeOldValue?: boolean;
characterDataOldValue?: boolean;
attributeFilter?: string[];
}
interface MutationRecord {
type: string;
target: any;
addedNodes: SimpleNodeList;
removedNodes: SimpleNodeList;
previousSibling: any | null;
nextSibling: any | null;
attributeName: string | null;
attributeNamespace: string | null;
oldValue: string | null;
}
type MutationCallback = (mutations: MutationRecord[], observer: MutationObserver) => void;
export declare class BaseNode {
nodeType: number;
attributes: Record<string, string>;
childNodes: any[];
parentNode: any | null;
_mutations: MutationRecord[];
_observers: Array<{
observer: MutationObserver;
options: MutationObserverInit;
}>;
constructor(nodeType: number);
appendChild(child: any): any;
insertBefore(newNode: any, referenceNode: any): any;
removeChild(child: any): any;
setAttribute(name: string, value: any): void;
removeAttribute(name: string): void;
_notifyMutation(mutation: MutationRecord): void;
_addObserver(observer: MutationObserver, options: MutationObserverInit): void;
_removeObserver(observer: MutationObserver): void;
}
export declare class MutationObserver {
private callback;
private observedElements;
private pendingMutations;
constructor(callback: MutationCallback);
observe(target: BaseNode, options?: MutationObserverInit): void;
disconnect(): void;
takeRecords(): MutationRecord[];
private _filterMutations;
static simulateMutation(target: BaseNode, record: MutationRecord): void;
}
export declare const customElements: {
define: (tagName: string, component: CustomElementConstructor) => void;
get: (tagName: string) => CustomElementConstructor;
whenDefined: (tagName: string) => Promise<void>;
};
export declare class ElementNode extends BaseNode {
tagName: string;
style: any;
className: string;
constructor(tag: string);
append(...nodes: any[]): void;
before(...nodes: any[]): void;
set textContent(value: string);
get innerHTML(): string;
get outerHTML(): string;
}
declare class DocumentNode extends BaseNode {
head: ElementNode;
body: ElementNode;
styleSheets: any[];
_eventListeners: Map<string, Array<{
listener: EventListenerOrEventListenerObject;
options?: boolean | AddEventListenerOptions;
}>>;
constructor();
createComment(content?: string): CommentNode;
createElement(tagName: string): ElementNode;
createElementNS(namespaceURI: string, qualifiedName: string): {
tagName: string;
isSVG: boolean;
style: any;
get outerHTML(): string;
nodeType: number;
attributes: Record<string, string>;
childNodes: any[];
parentNode: any | null;
_mutations: MutationRecord[];
_observers: Array<{
observer: MutationObserver;
options: MutationObserverInit;
}>;
appendChild(child: any): any;
insertBefore(newNode: any, referenceNode: any): any;
removeChild(child: any): any;
setAttribute(name: string, value: any): void;
removeAttribute(name: string): void;
_notifyMutation(mutation: MutationRecord): void;
_addObserver(observer: MutationObserver, options: MutationObserverInit): void;
_removeObserver(observer: MutationObserver): void;
};
createTextNode(text: string): TextNode;
createDocumentFragment(): {
nodeType: number;
attributes: Record<string, string>;
childNodes: any[];
parentNode: any | null;
_mutations: MutationRecord[];
_observers: Array<{
observer: MutationObserver;
options: MutationObserverInit;
}>;
appendChild(child: any): any;
insertBefore(newNode: any, referenceNode: any): any;
removeChild(child: any): any;
setAttribute(name: string, value: any): void;
removeAttribute(name: string): void;
_notifyMutation(mutation: MutationRecord): void;
_addObserver(observer: MutationObserver, options: MutationObserverInit): void;
_removeObserver(observer: MutationObserver): void;
};
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
_getEventListeners(type: string): {
listener: EventListenerOrEventListenerObject;
options?: boolean | AddEventListenerOptions;
}[];
}
export declare const document: DocumentNode;
export declare const HTMLElement: any;
export declare class TextNode extends BaseNode {
textContent: string;
constructor(text: string);
}
export declare class CommentNode extends BaseNode {
textContent: string;
constructor(content: string);
}
export {};
//# sourceMappingURL=ssr.obj.d.ts.map