1 | /// <reference path="./imba.types.d.ts" />
|
2 | /// <reference path="./imba.dom.d.ts" />
|
3 | /// <reference path="./imba.events.d.ts" />
|
4 | /// <reference path="./imba.router.d.ts" />
|
5 | /// <reference path="./imba.snippets.d.ts" />
|
6 |
|
7 | /// <reference path="./styles.d.ts" />
|
8 | /// <reference path="./styles.generated.d.ts" />
|
9 | /// <reference path="./styles.modifiers.d.ts" />
|
10 |
|
11 | declare namespace imba {
|
12 |
|
13 |
|
14 | interface Globals {
|
15 | /** The global clearInterval() method cancels a timed, repeating action which was previously established by a call to setInterval(). */
|
16 | clearInterval(handle?: number): void;
|
17 | /** The global clearTimeout() method cancels a timeout previously established by calling setTimeout(). */
|
18 | clearTimeout(handle?: number): void;
|
19 | fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
20 | queueMicrotask(callback: VoidFunction): void;
|
21 | /**
|
22 | * The setInterval() method, offered on the Window and Worker interfaces, repeatedly calls a function or executes a code snippet, with a fixed time delay between each call.
|
23 | */
|
24 | setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
|
25 | /** The global setTimeout() method sets a timer which executes a function or specified piece of code once the timer expires. */
|
26 | setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
|
27 |
|
28 | /**
|
29 | * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number).
|
30 | * @param number A numeric value.
|
31 | */
|
32 | isNaN(number: number): boolean;
|
33 |
|
34 | /**
|
35 | * Determines whether a supplied number is finite.
|
36 | * @param number Any numeric value.
|
37 | */
|
38 | isFinite(number: number): boolean;
|
39 |
|
40 | /** Reference to the current window */
|
41 | readonly window: Window;
|
42 |
|
43 | /** Reference to the current document */
|
44 | readonly document: Document;
|
45 |
|
46 | /** Reference to the current document */
|
47 | readonly process: any;
|
48 |
|
49 | /** Dirname */
|
50 | readonly __dirname: string;
|
51 |
|
52 | /** Filename */
|
53 | readonly __filename: string;
|
54 |
|
55 | /** Real filename */
|
56 | readonly __realname: string;
|
57 |
|
58 | /** Reference to the global object */
|
59 | readonly global: typeof globalThis;
|
60 |
|
61 | /**
|
62 | * Converts a string to an integer.
|
63 | * @param string A string to convert into a number.
|
64 | * @param radix A value between 2 and 36 that specifies the base of the number in `string`.
|
65 | * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
|
66 | * All other strings are considered decimal.
|
67 | */
|
68 | parseInt(string: string, radix?: number): number;
|
69 |
|
70 | /**
|
71 | * Converts a string to a floating-point number.
|
72 | * @param string A string that contains a floating-point number.
|
73 | */
|
74 | parseFloat(string: string): number;
|
75 |
|
76 | /** Access to the global console object */
|
77 | console: Console;
|
78 | }
|
79 |
|
80 | interface Context {
|
81 | [key: string]: any;
|
82 | }
|
83 |
|
84 | interface Flags {
|
85 | /**
|
86 | *
|
87 | * @summary Returns true if the list contains the given token, otherwise false.
|
88 | */
|
89 | contains(flag: string): boolean;
|
90 | /**
|
91 | *
|
92 | * @summary Adds the specified token to the list.
|
93 | */
|
94 | add(flag: string): void;
|
95 | /**
|
96 | *
|
97 | * @summary Removes the specified token from the list.
|
98 | */
|
99 | remove(flag: string): void;
|
100 | /**
|
101 | *
|
102 | * @summary Toggles specified token in the list.
|
103 | */
|
104 | toggle(flag: string, toggler?: any): void;
|
105 | /**
|
106 | *
|
107 | * @summary Adds the specified token to the list
|
108 | */
|
109 | incr(flag: string): number;
|
110 | /**
|
111 | *
|
112 | * @summary Removes the specified token from the list if zero increments remain
|
113 | */
|
114 | decr(flag: string): number;
|
115 | }
|
116 | }
|
117 |
|
118 | interface Node {
|
119 | /**
|
120 | * @custom
|
121 | * @summary Proxy to reference data on elements up the tree
|
122 | */
|
123 | readonly Ψcontext: imba.Context;
|
124 |
|
125 |
|
126 | /**
|
127 | * @custom
|
128 | * @summary Reference to the parentNode even before element has been attached
|
129 | */
|
130 | readonly Ψparent: Element;
|
131 | }
|
132 |
|
133 | interface Element {
|
134 |
|
135 | /**
|
136 | * @idl
|
137 | * @summary Default property for setting the data of an element
|
138 | */
|
139 | data: any;
|
140 |
|
141 | /**
|
142 | * @private
|
143 | */
|
144 | private route__: any;
|
145 |
|
146 | /**
|
147 | * @idl
|
148 | * @summary The path/route this element should be enabled for
|
149 | */
|
150 | route: string;
|
151 |
|
152 | /**
|
153 | * @idl
|
154 | * @summary The path/route to go to when clicking this element
|
155 | */
|
156 | routeΞto: string;
|
157 |
|
158 | /**
|
159 | * @summary Reference to the imba router
|
160 | * @custom
|
161 | */
|
162 | readonly router: imba.Router;
|
163 |
|
164 | /**
|
165 | * Gives elements a stable identity inside lists
|
166 | * @idl
|
167 | * @deprecated Use key instead
|
168 | */
|
169 | $key: any;
|
170 |
|
171 | /**
|
172 | * Gives elements a stable identity inside lists.
|
173 | * Any value (both objects and primitive values) may be used as a key.
|
174 | * @idl
|
175 | */
|
176 | key: any;
|
177 |
|
178 |
|
179 | /**
|
180 | * Sets whether `@hotkey` events inside of this element
|
181 | * is enabled or not. If explicitly set to true, only
|
182 | * `@hotkey` events inside this group will be triggered
|
183 | * when this element or a child has focus.
|
184 | * @summary Sets whether `@hotkey` events inside of this element
|
185 | * is enabled or not
|
186 | * @idl
|
187 | */
|
188 | hotkeys: boolean;
|
189 |
|
190 | /**
|
191 | * Enable transitions for when element is attached / detached
|
192 | * @see[Transitions](https://imba.io/css/transitions)
|
193 | * @idl
|
194 | */
|
195 | ease: any;
|
196 |
|
197 | // itemid: any;
|
198 | // itemprop: any;
|
199 | // itemref: any;
|
200 | // itemscope: any;
|
201 | // itemtype: any;
|
202 | // enterkeyhint: any;
|
203 | // autofocus: any;
|
204 | // autocapitalize: any;
|
205 | // autocomplete: any;
|
206 | // accesskey: any;
|
207 | // inputmode: any;
|
208 | // spellcheck: any;
|
209 | // translate: any;
|
210 | // is: any;
|
211 |
|
212 | /**
|
213 | * @summary Allows for manipulation of element's class content attribute
|
214 | */
|
215 | readonly flags: imba.Flags;
|
216 |
|
217 | /**
|
218 | * Emits event
|
219 | * @param event
|
220 | * @param params
|
221 | * @param options
|
222 | * @custom
|
223 | */
|
224 | emit(event: string, params?: any, options?: any): Event;
|
225 | focus(options?: any): void;
|
226 | blur(): void;
|
227 |
|
228 | // [key: string]: any;
|
229 |
|
230 | setAttribute(name: string, value: boolean): void;
|
231 | setAttribute(name: string, value: number): void;
|
232 |
|
233 | addEventListener(event: string, listener: (event: Event) => void, options?: {
|
234 | passive?: boolean;
|
235 | once?: boolean;
|
236 | capture?: boolean;
|
237 | });
|
238 |
|
239 | removeEventListener(event: string, listener: (event: Event) => void, options?: {
|
240 | passive?: boolean;
|
241 | once?: boolean;
|
242 | capture?: boolean;
|
243 | });
|
244 |
|
245 | log(...arguments: any[]): void;
|
246 | }
|
247 |
|
248 | interface Document {
|
249 | readonly flags: imba.Flags;
|
250 | }
|
251 |
|
252 | interface HTMLMetaElement {
|
253 | property?: string;
|
254 | charset?: string;
|
255 | }
|
256 |
|
257 | interface EventListenerOptions {
|
258 | passive?: boolean;
|
259 | once?: boolean;
|
260 | }
|
261 |
|
262 | interface Storage {
|
263 | setItem(key: string, value: number): void;
|
264 | }
|
265 |
|
266 | interface HTMLStyleElement {
|
267 | /**
|
268 | * The supplied path will be run through the imba bundler
|
269 | */
|
270 | src: ImbaAsset | string;
|
271 | }
|
272 |
|
273 |
|
274 | interface SVGSVGElement {
|
275 | /**
|
276 | * Reference to svg asset that will be inlined
|
277 | */
|
278 | src: ImbaAsset | string;
|
279 | }
|
280 |
|
281 | declare class ΤObject {
|
282 | [key: string]: any;
|
283 | }
|
284 |
|
285 | declare class ImbaElement extends imba.Component {
|
286 |
|
287 | }
|
288 |
|
289 | /** Portal to declare window/document event handlers from
|
290 | * inside custom tags.
|
291 | */
|
292 | declare class Γglobal extends HTMLElement {
|
293 |
|
294 | }
|
295 |
|
296 | declare class Γteleport extends HTMLElement {
|
297 | /** The element (or selector) you want to add listeners and content to */
|
298 | to: string | Element;
|
299 | }
|
300 |
|
301 | declare class Γany extends HTMLElement {
|
302 | [key: string]: any;
|
303 | }
|
304 |
|
305 | interface HTMLElementTagNameMap {
|
306 | "global": Γglobal,
|
307 | "teleport": Γteleport
|
308 | }
|
309 |
|
310 | interface ImbaAsset {
|
311 | body: string;
|
312 | url: string;
|
313 | absPath: string;
|
314 | path: string;
|
315 | }
|
316 |
|
317 | interface Event {
|
318 | detail: any;
|
319 | originalEvent: Event | null;
|
320 | }
|
321 |
|
322 | // interface Object {
|
323 | // [key: string]: any;
|
324 | // }
|
325 |
|
326 | declare namespace imba {
|
327 |
|
328 | namespace hotkeys {
|
329 | function trigger(combo: string): void;
|
330 |
|
331 | /**
|
332 | * Format combo as readable label
|
333 | */
|
334 | function humanize(combo: string, platform?: string): string;
|
335 |
|
336 | /**
|
337 | * Format combo as html (readable keys wrapped in <kbd> elements)
|
338 | */
|
339 | function htmlify(combo: string, platform?: string): string;
|
340 | }
|
341 |
|
342 | /**
|
343 | * @custom
|
344 | */
|
345 | class Component extends HTMLElement {
|
346 |
|
347 | /**
|
348 | * @summary Called to update the element and their children
|
349 | * @abstract
|
350 | * @lifecycle
|
351 | */
|
352 | render(): any;
|
353 |
|
354 | /**
|
355 | * @summary Called on client to hydrate SSR element
|
356 | * @abstract
|
357 | * @lifecycle
|
358 | */
|
359 | hydrate(): any;
|
360 |
|
361 |
|
362 | /**
|
363 | * @summary Called on server when stringifying a component
|
364 | * @abstract
|
365 | * @lifecycle
|
366 | */
|
367 | dehydrate(): any;
|
368 |
|
369 | /**
|
370 | * @summary Suspend rendering of component
|
371 | * @lifecycle
|
372 | */
|
373 | suspend(): this;
|
374 |
|
375 | /**
|
376 | * @summary Unsuspend rendering of component
|
377 | * @lifecycle
|
378 | */
|
379 | unsuspend(): this;
|
380 |
|
381 | /**
|
382 | * @summary Called to update element via scheduler
|
383 | * @lifecycle
|
384 | */
|
385 | tick(): this;
|
386 |
|
387 | /**
|
388 | * @summary Tells whether the component should render
|
389 | * @abstract
|
390 | * @lifecycle
|
391 | */
|
392 | get renderΦ(): boolean;
|
393 |
|
394 | /**
|
395 | * @readonly
|
396 | * @summary Tells whether the component is currently being mounted
|
397 | * @lifecycle
|
398 | */
|
399 | get mountingΦ(): boolean;
|
400 |
|
401 | /**
|
402 | * @readonly
|
403 | * @summary Tells whether the component is currently mounted in document
|
404 | * @lifecycle */
|
405 | get mountedΦ(): boolean;
|
406 |
|
407 | /**
|
408 | * @readonly
|
409 | * @summary Tells whether the component has been awakened
|
410 | * @lifecycle */
|
411 | get awakenedΦ(): boolean;
|
412 |
|
413 | /**
|
414 | * @readonly
|
415 | * @summary Tells whether the component has been rendered
|
416 | * @lifecycle */
|
417 | get renderedΦ(): boolean;
|
418 |
|
419 | /**
|
420 | * @readonly
|
421 | * @summary Tells whether the component has been suspended
|
422 | * @lifecycle */
|
423 | get suspendedΦ(): boolean;
|
424 |
|
425 | /**
|
426 | * @readonly
|
427 | * @summary Tells whether the component is currently rendering
|
428 | * @lifecycle */
|
429 | get renderingΦ(): boolean;
|
430 |
|
431 | /**
|
432 | * @readonly
|
433 | * @summary Tells whether the component is scheduled to automatically render
|
434 | * @lifecycle
|
435 | * */
|
436 | get scheduledΦ(): boolean;
|
437 |
|
438 | /**
|
439 | * @readonly
|
440 | * @summary Tells whether the component has been hydrated on the client
|
441 | * @lifecycle */
|
442 | get hydratedΦ(): boolean;
|
443 |
|
444 | /**
|
445 | * @readonly
|
446 | * @summary Tells whether the component was originally rendered on the server */
|
447 | get ssrΦ(): boolean;
|
448 |
|
449 | /**
|
450 | * @summary Start rendering the component on every imba.commit
|
451 | */
|
452 | schedule(): this;
|
453 |
|
454 | /**
|
455 | * @summary Stop rendering the component automatically on every imba.commit
|
456 | */
|
457 | unschedule(): this;
|
458 |
|
459 | /**
|
460 | * @summary Called before any properties are set
|
461 | * @lifecycle
|
462 | * @abstract
|
463 | */
|
464 | build(): any;
|
465 |
|
466 | /**
|
467 | * @summary Called before any properties are set
|
468 | * @lifecycle
|
469 | * @abstract
|
470 | */
|
471 | setup(): any;
|
472 |
|
473 | /**
|
474 | * @summary Called when element is *first* attached to document
|
475 | * @lifecycle
|
476 | * @abstract
|
477 | */
|
478 | awaken(): any;
|
479 |
|
480 | /**
|
481 | * @summary Called when element is attached to document
|
482 | * @lifecycle
|
483 | * @abstract
|
484 | */
|
485 | mount(): any;
|
486 |
|
487 | /**
|
488 | * @summary Called when element is detached from document
|
489 | * @lifecycle
|
490 | * @abstract
|
491 | */
|
492 | unmount(): any;
|
493 |
|
494 | /**
|
495 | * @summary Called after render
|
496 | * @lifecycle
|
497 | * @abstract
|
498 | */
|
499 | rendered(): any;
|
500 |
|
501 |
|
502 | /**
|
503 | Schedule the element to update itself
|
504 | yes = render on events / imba.commit
|
505 | no = force manual render
|
506 | null / undefined = render via parent
|
507 | (n)s = render every n s
|
508 | (n)ms = render every n ms
|
509 | (n)fps = render n times per second
|
510 |
|
511 | @summary Specify how / when the component should re-render
|
512 | @idl
|
513 | */
|
514 | autorender: boolean | number | null | `${number}ms` | `${number}s` | `${number}fps`;
|
515 | }
|
516 |
|
517 | function setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
|
518 | function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
|
519 | function clearInterval(handle?: number): void;
|
520 | function clearTimeout(handle?: number): void;
|
521 |
|
522 | /**
|
523 | * Schedule re-render
|
524 | */
|
525 | function commit(): Promise<void>;
|
526 |
|
527 | /**
|
528 | * Render elements in custom context
|
529 | */
|
530 | function render(func: Function, context?: any): any;
|
531 |
|
532 | /**
|
533 | * Attach an element to the dom
|
534 | * @param element
|
535 | * @param into
|
536 | */
|
537 | function mount<T>(element: T, into?: Element): T;
|
538 | function mount(func: Function, into?: Element): Element;
|
539 |
|
540 | /**
|
541 | * Detach element from document
|
542 | * @param element
|
543 | */
|
544 | function unmount<T>(element: T): T;
|
545 |
|
546 |
|
547 | /**
|
548 | * Mark field as observable
|
549 | */
|
550 | function αobservable(): void;
|
551 |
|
552 | /**
|
553 | * Mark getter as computed
|
554 | */
|
555 | function αcomputed(): void;
|
556 |
|
557 | /**
|
558 | * Runs the method immediately after instance is initialized
|
559 | * and re-runs whenever any of the referenced observables
|
560 | * change. Methods marked with autorun in tag declarations
|
561 | * will run immediately after mount, and automatically dispose
|
562 | * when element unmounts.
|
563 | */
|
564 | function αautorun(options?: any): void;
|
565 |
|
566 | /**
|
567 | * Mark getter as lazy. It will only be evaluated once,
|
568 | * and then return the resulting value forever after.
|
569 | */
|
570 | function αlazy(): void;
|
571 |
|
572 | let colors: string[];
|
573 |
|
574 | interface ImbaProcess {
|
575 | on(event:string,callback:Function);
|
576 | }
|
577 |
|
578 | let process: ImbaProcess;
|
579 |
|
580 | namespace types {
|
581 | let events: GlobalEventHandlersEventMap;
|
582 | let eventHandlers: GlobalEventHandlers;
|
583 |
|
584 | namespace html {
|
585 | let tags: HTMLElementTagNameMap;
|
586 | let events: GlobalEventHandlersEventMap;
|
587 | }
|
588 |
|
589 | namespace svg {
|
590 | let tags: SVGElementTagNameMap;
|
591 | let events: SVGElementEventMap;
|
592 | }
|
593 | }
|
594 |
|
595 | let Element: Component;
|
596 |
|
597 | /**
|
598 | * Class for scheduling
|
599 | * @custom
|
600 | */
|
601 | export interface Scheduler {
|
602 | add(target: any, force?: boolean): void;
|
603 | on(group: string, target: any): void;
|
604 | un(group: string, target: any): void;
|
605 |
|
606 | /** Milliseconds since previous tick */
|
607 | dt: number;
|
608 | }
|
609 |
|
610 | /**
|
611 | * Reference to global scheduler
|
612 | */
|
613 | let scheduler: Scheduler;
|
614 |
|
615 | function createIndexedFragment(...arguments: any[]): DocumentFragment;
|
616 | function createKeyedFragment(...arguments: any[]): DocumentFragment;
|
617 | function createLiveFragment(...arguments: any[]): DocumentFragment;
|
618 |
|
619 | function emit(source: any, event: string, params: any[]): void;
|
620 | function listen(target: any, event: string, listener: any, path?: any): void;
|
621 | function once(target: any, event: string, listener: any, path?: any): void;
|
622 | function unlisten(target: any, event: string, listener: any, path?: any): void;
|
623 | function indexOf(target: any, source: any): boolean;
|
624 |
|
625 | /**
|
626 | * Start an asset-aware server
|
627 | */
|
628 | function serve(target: any, options?: any): any;
|
629 |
|
630 | /*
|
631 | Observability
|
632 | TODO Complete & document types
|
633 | */
|
634 |
|
635 | interface Reaction {
|
636 | dispose(): this;
|
637 | }
|
638 |
|
639 | function observable<T>(value: T): T;
|
640 |
|
641 | function run(callback: any): void;
|
642 | function autorun(callback: any): Reaction;
|
643 | }
|
644 |
|
645 | declare module "data:text/asset;*" {
|
646 | const value: ImbaAsset;
|
647 | export default value;
|
648 | export const body: string;
|
649 | export const url: string;
|
650 | export const absPath: string;
|
651 | export const path: string;
|
652 | }
|
653 |
|
654 | declare module "imba/compiler" {
|
655 | export function compile(fileName: string, options: any): any;
|
656 | }
|
657 |
|
658 | declare module "imba" {
|
659 |
|
660 | } |
\ | No newline at end of file |