Skip to content

Commit cd6c745

Browse files
committed
d.ts generated
1 parent 78b4ddd commit cd6c745

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

fetch-element.d.ts

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
* @returns Promise resolved when updated DOM is rendered by calling [requestIdleCallback](https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback)
3+
* @param cb callback invoked on dom rendered, its return value passed back to wait4DomUpdated promise
4+
*/
5+
export function wait4DomUpdated<T>(cb: ()=>T): Promise<T>;
6+
7+
/**
8+
* @returns string lovercased with spaces replaces with dash '-'
9+
* @param s string to convert
10+
*/
11+
export function toKebbabCase(s: string): string;
12+
13+
/**
14+
* webcomponent renders JSON and other content types retrieved by interruptible
15+
* [ fetch() ](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) api
16+
* [more...](https://github.com/sashafirsov/slotted-element#fetch-element)
17+
*/
18+
export class FetchElement extends HTMLElement {
19+
/**
20+
* @see [using custom elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements)
21+
*/
22+
static get observedAttributes(): string[];
23+
24+
/**
25+
* override this map the content type to module loader function
26+
* @see [json remdering module](https://github.com/sashafirsov/slotted-element/blob/main/render/json.js) sample
27+
*/
28+
static get mime2mod(): {
29+
'application/json': () => Promise<typeof import("./render/json.js").default>;
30+
'text/html': () => (data: any, contentType: any, httpCode: any, responseHeaders: any, ...args: any[]) => Promise<void>;
31+
'text/xml': () => (data: any, contentType: any, httpCode: any, responseHeaders: any, ...args: any[]) => Promise<void>;
32+
'application/xml': () => (data: any, contentType: any, httpCode: any, responseHeaders: any, ...args: any[]) => Promise<void>;
33+
'image/svg+xml': () => (data: any, contentType: any, httpCode: any, responseHeaders: any, ...args: any[]) => Promise<void>;
34+
};
35+
36+
/**
37+
* override to override the request headers
38+
*/
39+
get headers(): {[key:string]:string};
40+
41+
/**
42+
* interrupt current request
43+
* @see [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)
44+
*/
45+
abort(): void;
46+
47+
/**
48+
* @see [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
49+
* @param args
50+
*/
51+
fetch( url:Request | string, options ): Promise<any>;
52+
53+
/**
54+
* private
55+
*/
56+
_fetch: (url: any, options: any) => Promise<any>;
57+
/**
58+
* string representing the loading to rendering life cycle
59+
*/
60+
state: 'loading'|'rendering'|'loaded'|'error';
61+
/**
62+
* response.status, set by onResponse() handler, matching http error code
63+
*/
64+
status: string;
65+
66+
/**
67+
* @see [web component lifecycle](
68+
*/
69+
connectedCallback(): void;
70+
initialized: boolean;
71+
attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
72+
onResponse(response: any): Promise<any>;
73+
error: string;
74+
contentType: any;
75+
responseHeaders: any;
76+
setContent(html: any): void;
77+
onResult(result: any): Promise<any>;
78+
render(data: any, contentType: any, httpCode: any, responseHeaders: any): void;
79+
renderHtml(data: any, contentType: any, httpCode: any, responseHeaders: any, ...args: any[]): Promise<void>;
80+
onError(error: any): any;
81+
getKeys(obj: any): string[];
82+
}
83+
export default FetchElement;

render/json.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default function render(data: any, contentType: any, status: any, responseHeaders: any): Promise<void>;
2+
export default class render {
3+
constructor(data: any, contentType: any, status: any, responseHeaders: any);
4+
json2table: typeof json2table;
5+
}
6+
export function json2table(data: any, path: any): any;

render/xml.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function render(data: any, contentType: any, status: any, responseHeaders: any): Promise<void>;
2+
export function getXml(url: any, callback: any): void;
3+
export function Json2Xml(o: any, tag: any): any;

0 commit comments

Comments
 (0)