dothtml-interfaces 0.3.12 → 0.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { IDotDocument } from "./i-dot";
|
|
3
|
-
import IDotCss from "./styles/i-dot-css";
|
|
2
|
+
import { IDotCore, IDotDocument } from "./i-dot";
|
|
4
3
|
|
|
5
4
|
// export type EventNames<T> = T extends { allowedEvents: infer E } ? E : never;
|
|
6
5
|
|
|
@@ -18,7 +17,7 @@ export interface FrameworkItems {
|
|
|
18
17
|
readonly shadowRoot: ShadowRoot;
|
|
19
18
|
readonly isRendered: boolean;
|
|
20
19
|
readonly tagName: string;
|
|
21
|
-
readonly styles: Array<string>;
|
|
20
|
+
// readonly styles: Array<string>; // Can't have this anymore because it's a memory leak.
|
|
22
21
|
readonly args: Array<any>;
|
|
23
22
|
// readonly styleElement: HTMLStyleElement;
|
|
24
23
|
readonly sharedStyles: CSSStyleSheet[];
|
|
@@ -31,7 +30,7 @@ export interface FrameworkItems {
|
|
|
31
30
|
// TODO: there's a weird problem where if a constructor is not provided, it's not possible have a custom builder.
|
|
32
31
|
// It should be the contsructor that depends on the builder, not the other way around. If we can't get this working,
|
|
33
32
|
// it might just be better to rethink how stuff gets passed into components.
|
|
34
|
-
export default interface
|
|
33
|
+
export default interface IDotComponent/*<TProps extends Array<string> = [], TEvents extends Array<string> = []>*/ {
|
|
35
34
|
|
|
36
35
|
readonly _?: FrameworkItems;
|
|
37
36
|
|
|
@@ -44,8 +43,9 @@ export default interface IComponent/*<TProps extends Array<string> = [], TEvents
|
|
|
44
43
|
|
|
45
44
|
/**
|
|
46
45
|
* A function returning DOThtml (required). The `build` hook is called once per component instance, and constructs the component's virtual DOM.
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
* @param dot - The DOThtml core object passed in for DI purposes. You can also just use the main .
|
|
47
|
+
* @returns The DOThtml document representing the component's virtual DOM. */
|
|
48
|
+
build(dot: IDotCore): IDotDocument;
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* An optional function called after the component is built. Is only called once per component instance.
|
|
@@ -73,12 +73,12 @@ export default interface IComponent/*<TProps extends Array<string> = [], TEvents
|
|
|
73
73
|
unmounted?(): void;
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*
|
|
76
|
+
* A function that returns a string containing CSS rules to be applied to all instances of the component.
|
|
77
|
+
* It will only be called exactly once per component. We use a function so that you can return a potentially
|
|
78
|
+
* large string containing CSS without introducing a memory leak. The reason it's not static is so that
|
|
79
|
+
* it will work in JavaScript, and because static members are not valid in DI interfaces. All styles are scoped
|
|
80
|
+
* to the component's shadow DOM.
|
|
81
|
+
* @returns A string (or array of strings) containing imported CSS rules.
|
|
82
82
|
*/
|
|
83
|
-
|
|
83
|
+
stylize?(): string|Array<string>;
|
|
84
84
|
}
|
package/src/i-dot.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
import
|
|
2
|
+
import IDotComponent from "./i-dot-component";
|
|
3
3
|
import IDotCss from "./styles/i-dot-css";
|
|
4
4
|
import IEventBus from "./i-event-bus";
|
|
5
5
|
import {IReactive} from "./i-reactive";
|
|
6
6
|
import IDotcssProp from "./styles/i-css-prop";
|
|
7
7
|
|
|
8
8
|
type DotContentPrimitive = string | number | boolean;
|
|
9
|
-
type DotContentBasic = DotContentPrimitive | Node | Element | NodeList |
|
|
9
|
+
type DotContentBasic = DotContentPrimitive | Node | Element | NodeList | IDotComponent | IDotDocument//typeof DotDocument;
|
|
10
10
|
export type DotContent = DotContentBasic | Array<DotContent> | IReactive;//|(()=>DotContent);
|
|
11
11
|
|
|
12
12
|
type AttrVal<T = string | number | boolean> = T | IReactive<T>;
|
|
@@ -55,7 +55,7 @@ export interface IDotDocument {
|
|
|
55
55
|
* Mounts a component.
|
|
56
56
|
* TODO: add second arg.
|
|
57
57
|
*/
|
|
58
|
-
mount<T extends
|
|
58
|
+
mount<T extends IDotComponent>(component: T): IDotDocument;
|
|
59
59
|
// mount<T extends IComponent>(init: (c: IMountedComponent<T>) => IMountedComponent<T> | void, component: T): IDotDocument;
|
|
60
60
|
// mount(component: IComponent, init: (init=>IMountedComponent): IMountedComponent|void): IDotDocument;
|
|
61
61
|
/**
|
|
@@ -382,8 +382,8 @@ export interface IDotCore extends IDotDocument {
|
|
|
382
382
|
// Works but doesn't infer types from the component.
|
|
383
383
|
// There's room for improvement here but it's not clear to me how to do it.
|
|
384
384
|
// What I'd like to do is have the types tied to the IComponent interface rather than the component factory function.
|
|
385
|
-
component<TProps extends string[] = [], TEvents extends string[] = []>(Base: new () =>
|
|
386
|
-
: new (attrs?: ComponentArgs<TProps, TEvents>) =>
|
|
385
|
+
component<TProps extends string[] = [], TEvents extends string[] = []>(Base: new () => IDotComponent, styles?: string|IDotcssProp|Array<string|IDotcssProp>)
|
|
386
|
+
: new (attrs?: ComponentArgs<TProps, TEvents>) => IDotComponent & { new (attrs?: ComponentArgs<TProps, TEvents>): IDotComponent };
|
|
387
387
|
|
|
388
388
|
useStyles(document: Document, styles: Styles): HTMLStyleElement;
|
|
389
389
|
}
|
|
@@ -399,7 +399,7 @@ export interface IDotWindowWrapper{
|
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
export interface IDotWindowBuilder {
|
|
402
|
-
(options: {content: IDotDocument, width?: number, height?: number, title?: string}): IDotWindowWrapper;
|
|
402
|
+
(options: {content: IDotComponent|IDotDocument, width?: number, height?: number, title?: string}): IDotWindowWrapper;
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
export interface IDotConditionalDocument extends IDotDocument {
|
package/src/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { default as IDotCss } from "./styles/i-dot-css";
|
|
|
6
6
|
export * from "./styles/i-dot-css";
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
export { default as
|
|
9
|
+
export { default as IDotComponent, FrameworkItems } from "./i-dot-component";
|
|
10
10
|
|
|
11
11
|
export { IReactive, IReactiveWatcher } from "./i-reactive";
|
|
12
12
|
export { default as IEventBus } from "./i-event-bus";
|