@jasonshimmy/custom-elements-runtime 0.2.0 → 0.2.2

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/dist/router.d.ts CHANGED
@@ -50,6 +50,7 @@ export interface RouterLinkProps {
50
50
  ariaCurrentValue: string;
51
51
  disabled: boolean;
52
52
  external: boolean;
53
+ class?: string;
53
54
  style: string;
54
55
  }
55
56
  export interface RouterLinkComputed {
@@ -41,19 +41,26 @@ export interface WatcherState {
41
41
  export type WatchConfig<S> = {
42
42
  [K in keyof S]?: WatchCallback<S[K]> | [WatchCallback<S[K]>, WatchOptions?];
43
43
  } | Record<string, WatchCallback | [WatchCallback, WatchOptions?]>;
44
+ type DropLast<T extends any[]> = T extends [...infer Rest, any] ? Rest : T;
45
+ type WrapMethod<F> = F extends (...args: infer A) => infer R ? (...args: DropLast<A>) => R : never;
44
46
  export type InferMethods<T> = {
45
- [K in keyof T as K extends LifecycleKeys ? never : K]: T[K] extends Function ? T[K] : never;
47
+ [K in keyof T as K extends LifecycleKeys ? never : K]: T[K] extends (...args: any[]) => any ? WrapMethod<T[K]> : never;
46
48
  };
47
49
  export interface Refs {
48
50
  refs: Record<string, HTMLElement | undefined>;
49
51
  }
50
- export type ComponentContext<S extends object, C extends object, P extends object, T extends object = any> = S & C & P & InferMethods<T> & Refs & {
52
+ export type ComponentContext<S extends object, C extends object, P extends object, T extends object = {}> = S & C & P & InferMethods<T> & Refs & {
51
53
  requestRender?: () => void;
52
54
  error?: Error | null;
53
55
  hasError?: boolean;
54
56
  isLoading?: boolean;
57
+ /**
58
+ * Dispatch a DOM CustomEvent from the host element.
59
+ * Returns true when the event was not defaultPrevented.
60
+ */
61
+ emit: <D = any>(eventName: string, detail?: D, options?: CustomEventInit) => boolean;
55
62
  };
56
- export interface ComponentConfig<S extends object, C extends object = {}, P extends object = {}, T extends object = any> {
63
+ export type ComponentConfig<S extends object, C extends object = {}, P extends object = {}, T extends object = {}> = {
57
64
  state?: S;
58
65
  computed?: {
59
66
  [K in keyof C]: (context: ComponentContext<S, C, P, T>) => C[K];
@@ -72,5 +79,7 @@ export interface ComponentConfig<S extends object, C extends object = {}, P exte
72
79
  onAttributeChanged?: (name: string, oldValue: string | null, newValue: string | null, context: ComponentContext<S, C, P, T>) => void;
73
80
  onError?: (error: Error | null, context: ComponentContext<S, C, P, T>) => void;
74
81
  errorFallback?: (error: Error | null, context: ComponentContext<S, C, P, T>) => string;
75
- [key: string]: any;
76
- }
82
+ } & {
83
+ [K in keyof T as K extends LifecycleKeys ? never : K]: T[K] extends Function ? T[K] : never;
84
+ };
85
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jasonshimmy/custom-elements-runtime",
3
3
  "description": "A powerful, modern, and lightweight runtime for creating reactive web components with TypeScript",
4
- "version": "0.2.0",
4
+ "version": "0.2.2",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "web-components",