starcounter-jack-haunted
Advanced tools
Comparing version 6.0.3 to 6.0.4
@@ -29,2 +29,1 @@ import { ComponentCreator } from './component.js'; | ||
export * from "./ref.js"; | ||
export * from "./haunted-lit-element.js"; |
@@ -22,3 +22,2 @@ import { makeComponent } from './component.js'; | ||
export * from "./ref.js"; | ||
export * from "./haunted-lit-element.js"; | ||
//# sourceMappingURL=core.js.map |
@@ -1,48 +0,56 @@ | ||
import { LitElement } from 'lit-element'; | ||
import { State } from 'haunted/core.js'; | ||
const defer = Promise.resolve().then.bind(Promise.resolve()); | ||
export class HauntedLitElement extends LitElement { | ||
haunted; | ||
constructor() { | ||
super(); | ||
this.haunted = new State(() => this.requestUpdate(), this); | ||
} | ||
connectedCallback() { | ||
// console.warn("connecting", this); | ||
super.connectedCallback(); | ||
} | ||
update(_changedProperties) { | ||
this.haunted.run(() => { | ||
super.update(_changedProperties); | ||
}); | ||
} | ||
updated(_changedProperties) { | ||
super.updated(_changedProperties); | ||
this.haunted.runLayoutEffects(); | ||
defer(() => this.haunted.runEffects()); | ||
} | ||
disconnectedCallback() { | ||
this.haunted.teardown(); | ||
super.disconnectedCallback(); | ||
} | ||
} | ||
export const component = (renderer, propsOrBaseCls = HauntedLitElement, props = {}) => { | ||
const localProps = typeof propsOrBaseCls === 'object' ? propsOrBaseCls : props; | ||
const localBaseClass = typeof propsOrBaseCls === 'function' ? propsOrBaseCls : HauntedLitElement; | ||
const retCls = class extends localBaseClass { | ||
render() { | ||
//console.warn("rendering", this); | ||
return renderer.call(this, this); | ||
} | ||
}; | ||
Object.entries(localProps).forEach(([key, val]) => { | ||
retCls[key] = val; | ||
}); | ||
return retCls; | ||
}; | ||
export const comp = (tag, renderer, prop) => { | ||
let constructor = component(renderer, prop); | ||
customElements.define(tag, constructor); | ||
return constructor; | ||
}; | ||
"use strict"; | ||
// import { LitElement } from 'lit-element'; | ||
// import { State } from 'haunted/core.js'; | ||
// import { Renderer } from "./component.js" | ||
// const defer = Promise.resolve().then.bind(Promise.resolve()); | ||
// type Component<P extends object> = HTMLElement & P; | ||
// type Constructor<P extends object> = new (...args: unknown[]) => Component<P>; | ||
// export class HauntedLitElement extends LitElement { | ||
// haunted: State; | ||
// constructor() { | ||
// super(); | ||
// this.haunted = new State(() => this.requestUpdate(), this); | ||
// } | ||
// connectedCallback(): void { | ||
// // console.warn("connecting", this); | ||
// super.connectedCallback(); | ||
// } | ||
// update(_changedProperties: any) { | ||
// this.haunted.run(() => { | ||
// super.update(_changedProperties); | ||
// }); | ||
// } | ||
// updated(_changedProperties: any) { | ||
// super.updated(_changedProperties); | ||
// this.haunted.runLayoutEffects(); | ||
// defer(() => this.haunted.runEffects()); | ||
// } | ||
// disconnectedCallback() { | ||
// this.haunted.teardown(); | ||
// super.disconnectedCallback(); | ||
// } | ||
// } | ||
// export const component = <P extends object>(renderer: any, propsOrBaseCls: P | (typeof HauntedLitElement) = HauntedLitElement, props: P = {} as any): Constructor<P> => { | ||
// const localProps = typeof propsOrBaseCls === 'object' ? propsOrBaseCls : props; | ||
// const localBaseClass = typeof propsOrBaseCls === 'function' ? (propsOrBaseCls as (typeof HauntedLitElement)) : HauntedLitElement; | ||
// const retCls = class extends localBaseClass { | ||
// render() { | ||
// //console.warn("rendering", this); | ||
// return renderer.call(this, this); | ||
// } | ||
// }; | ||
// Object.entries(localProps).forEach(([key, val]: [string, any]) => { | ||
// (retCls as any)[key] = val; | ||
// }); | ||
// return retCls as unknown as Constructor<P>; | ||
// }; | ||
// export const comp: Comp = <P extends object>(tag: string, renderer: Renderer<P>, prop?: P) => { | ||
// let constructor = component<P>(renderer, prop); | ||
// customElements.define(tag, constructor); | ||
// return constructor; | ||
// } | ||
// export interface Comp { | ||
// <P extends object>(tag: string, renderer: Renderer<P>, prop?: P): Constructor<P>; | ||
// <P extends object>(tag: string, renderer: Renderer<any>, prop?: P): Constructor<any>; | ||
// } | ||
//# sourceMappingURL=haunted-lit-element.js.map |
export { html, render, component, createContext, virtual } from './lit-haunted.js'; | ||
export * from './core.js'; | ||
export { default } from './core.js'; | ||
export { Component } from "./component.js"; | ||
export { comp } from "./comp.js"; |
export { html, render, component, createContext, virtual } from './lit-haunted.js'; | ||
export * from './core.js'; | ||
export { default } from './core.js'; | ||
export { comp } from "./comp.js"; | ||
//# sourceMappingURL=haunted.js.map |
@@ -9,3 +9,3 @@ import { State, Callable } from './state.js'; | ||
*/ | ||
declare const useEffect: (callback: (this: State<unknown>, self: HTMLElement) => void | Promise<void> | VoidFunction, values?: unknown[] | undefined) => void; | ||
declare const useEffect: (callback: (this: State<unknown>, self: HTMLElement) => void | VoidFunction | Promise<void>, values?: unknown[] | undefined) => void; | ||
export { setEffects, useEffect }; |
@@ -8,3 +8,3 @@ import { State } from './state.js'; | ||
*/ | ||
declare const useLayoutEffect: (callback: (this: State<unknown>, self: HTMLElement) => void | Promise<void> | VoidFunction, values?: unknown[] | undefined) => void; | ||
declare const useLayoutEffect: (callback: (this: State<unknown>, self: HTMLElement) => void | VoidFunction | Promise<void>, values?: unknown[] | undefined) => void; | ||
export { useLayoutEffect }; |
{ | ||
"name": "starcounter-jack-haunted", | ||
"repository": "git://github.com/starcounter-jack/haunted.git", | ||
"version": "6.0.3", | ||
"version": "6.0.4", | ||
"description": "Hooks for web components", | ||
@@ -6,0 +6,0 @@ "main": "lib/haunted.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82952
75
1324