dothtml-interfaces 0.3.13 → 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,6 @@
1
1
  {
2
2
  "name": "dothtml-interfaces",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
4
4
  "description": "Dependency injection interfaces for DOTHtml.",
5
5
  "main": "src/index.d.ts",
6
6
  "types": "src/index.d.ts",
@@ -1,6 +1,5 @@
1
1
 
2
2
  import { IDotCore, IDotDocument } from "./i-dot";
3
- import IDotCss from "./styles/i-dot-css";
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 IComponent/*<TProps extends Array<string> = [], TEvents extends Array<string> = []>*/ {
33
+ export default interface IDotComponent/*<TProps extends Array<string> = [], TEvents extends Array<string> = []>*/ {
35
34
 
36
35
  readonly _?: FrameworkItems;
37
36
 
@@ -77,8 +76,9 @@ export default interface IComponent/*<TProps extends Array<string> = [], TEvents
77
76
  * A function that returns a string containing CSS rules to be applied to all instances of the component.
78
77
  * It will only be called exactly once per component. We use a function so that you can return a potentially
79
78
  * large string containing CSS without introducing a memory leak. The reason it's not static is so that
80
- * it will work in JavaScript, and because static members are not valid in DI interfaces.
81
- * @returns A string containing CSS rules.
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
- stylize?(): string;
83
+ stylize?(): string|Array<string>;
84
84
  }
package/src/i-dot.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
 
2
- import IComponent, { FrameworkItems } from "./i-component";
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 | IComponent | IDotDocument//typeof DotDocument;
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 IComponent>(component: T): IDotDocument;
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 () => IComponent, styles?: string|IDotcssProp|Array<string|IDotcssProp>)
386
- : new (attrs?: ComponentArgs<TProps, TEvents>) => IComponent & { new (attrs?: ComponentArgs<TProps, TEvents>): IComponent };
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 IComponent, FrameworkItems } from "./i-component";
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";