nine-9 1.7.0 → 1.8.1

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/index.d.ts CHANGED
@@ -1,19 +1,22 @@
1
1
  import { IntrinsicElementAttributes, Events } from '@vue/runtime-dom';
2
2
 
3
- interface SubcriberCallback<T extends unknown[]> {
4
- (...data: T): void;
3
+ interface SubcriberCallback<T extends unknown[], R> {
4
+ (...data: T): R;
5
5
  }
6
- declare class EventSubcriber<T extends unknown[]> {
6
+ declare class EventSubcriber<T extends unknown[], R = void> {
7
7
  private subcribers;
8
8
  private emitting;
9
- subcribe(callback: SubcriberCallback<T>, once?: boolean): void;
10
- emit(...data: T): void;
9
+ subcribe(callback: SubcriberCallback<T, R>, once?: boolean): void;
10
+ emit(...data: T): R[] | void;
11
11
  }
12
12
 
13
13
  type EmptyValue = undefined | null | void | never;
14
14
  type Normalize<T extends Record<string, unknown>> = T extends Record<infer K, infer R> ? Record<K, Required<R>> : never;
15
15
  type Valueof<T> = T[keyof T];
16
16
  type KebabToCamel<S extends string> = S extends `${infer First}-${infer Rest}` ? `${First}${Capitalize<KebabToCamel<Rest>>}` : S;
17
+ type ObjectToEntryUnion<T> = {
18
+ [K in keyof T]: [K, T[K]];
19
+ }[keyof T];
17
20
 
18
21
  type Wrapper<T> = {
19
22
  get(): T;
@@ -36,17 +39,24 @@ type StyleSet = {
36
39
  };
37
40
  declare function styleSet(selector?: string): StyleSet;
38
41
 
39
- type HTMLEventAttributes = keyof Events;
42
+ type VueEventAttributes = keyof Events;
43
+ type HTMLEventName<V extends string> = V extends `on${infer R extends string}` ? Uncapitalize<R> : never;
40
44
  type SupportedHTMLElements = keyof HTMLElementTagNameMap & keyof IntrinsicElementAttributes;
41
45
  type SupportedHTMLRawAttributes = {
42
- [K in SupportedHTMLElements]: Omit<IntrinsicElementAttributes[K], HTMLEventAttributes>;
46
+ [K in SupportedHTMLElements]: Omit<IntrinsicElementAttributes[K], VueEventAttributes>;
47
+ };
48
+ type SupportedEventHandlerMap = {
49
+ [K in VueEventAttributes as HTMLEventName<K>]: (event: Events[K]) => void;
43
50
  };
44
51
 
45
52
  interface HostTreeHooks {
46
- update: [newTrees: HostTree[], oldTrees: HostTree[]];
53
+ treeUpdated: [newTrees: HostTree[], oldTrees: HostTree[]];
54
+ attributeUpdated: [attribute: string, newValue: unknown, oldValue: unknown];
55
+ initialized: [rootTree: HostTree];
56
+ $preventEvent: [ObjectToEntryUnion<SupportedEventHandlerMap>, boolean | void];
47
57
  }
48
58
  type HostTreeHookStore = {
49
- [K in keyof HostTreeHooks]: EventSubcriber<HostTreeHooks[K]>;
59
+ [K in keyof HostTreeHooks as K extends `$${infer R}` ? R : K]: K extends `$${string}` ? HostTreeHooks[K] extends [infer E extends unknown[], infer R] ? EventSubcriber<E, R> : EventSubcriber<HostTreeHooks[K]> : EventSubcriber<HostTreeHooks[K]>;
50
60
  };
51
61
  type HostTree<E extends SupportedHTMLElements = SupportedHTMLElements, T = HTMLElementTagNameMap[E], A = SupportedHTMLRawAttributes[E]> = {
52
62
  [K in string & keyof A as KebabToCamel<K>]-?: (data: A[K] | Wrapper<A[K]>) => HostTree<E>;
@@ -55,7 +65,7 @@ type HostTree<E extends SupportedHTMLElements = SupportedHTMLElements, T = HTMLE
55
65
  hooks: HostTreeHookStore;
56
66
  append(...children: (RawSourceTree | HostTree | RawSourceTree[] | HostTree[] | (RawSourceTree | HostTree)[] | Wrapper<HostTree> | Wrapper<RawSourceTree> | Wrapper<RawSourceTree | HostTree> | Wrapper<(RawSourceTree | HostTree)[]> | Wrapper<RawSourceTree | RawSourceTree[]>)[]): HostTree<E>;
57
67
  use(styleSet: StyleSet | Wrapper<StyleSet>): HostTree<E>;
58
- on<K extends keyof HTMLElementEventMap>(key: K, handler: (data: HTMLElementEventMap[K]) => void, options?: AddEventListenerOptions): HostTree<E>;
68
+ on<K extends keyof SupportedEventHandlerMap>(key: K, handler: SupportedEventHandlerMap[K], options?: AddEventListenerOptions): HostTree<E>;
59
69
  on(key: string, handler: (...args: unknown[]) => unknown, options?: AddEventListenerOptions): HostTree<E>;
60
70
  };
61
71
  declare function tree<E extends SupportedHTMLElements>(data: E | Node): HostTree<E, HTMLElementTagNameMap[E], SupportedHTMLRawAttributes[E]>;
@@ -137,7 +147,7 @@ declare function camelToHyphen<T extends string>(str: T): T;
137
147
  declare function hyphenToCamel<T extends string>(str: T): T;
138
148
 
139
149
  declare function typedIsArray<T>(arr: unknown[]): arr is T[];
140
- declare function putIn<T>(data: T): T extends (infer R)[] ? R[] : [T];
150
+ declare function putIntoArray<T>(data: T): T extends (infer R)[] ? R[] : [T];
141
151
  declare function createArray<T>(length: number, filler: () => T): T[];
142
152
 
143
153
  declare namespace logo {
@@ -179,4 +189,4 @@ declare const _default: {
179
189
  }, (EventDescriptor<number, "select"> | EventDescriptor<boolean, "toggleState">)[]>;
180
190
  };
181
191
 
182
- export { $, type Component, type ComponentEventStore, type ComponentInstance, type ComponentInternalRender, type ComponentOption, type ComponentPropertyDescriptor, type ComponentPropertyInputDict, type ComponentPropertyOutputDict, type ComponentPropertyStore, type ComponentRenderEntry, type EmptyValue, type EventDescriptor, type EventOptions, EventSubcriber, type HostTree, type HostTreeHookStore, type HostTreeHooks, type KebabToCamel, type Normalize, type PropertyTransformer, type RawSlotInput, type RawSourceTree, type SlotInput, type SlotOutput, type SourceTree, type StyleSet, type Valueof, type Wrapper, index as assets, attachUUID, camelToHyphen, createArray, createComponent, defineEvent, _default as examples, flagment, hostdown, hyphenToCamel, normalizePropertyDescriptor, pipeExtract, putIn, rawProperty, render, styleSet, sync, tree, typedIsArray, validateStore, when, wrap };
192
+ export { $, type Component, type ComponentEventStore, type ComponentInstance, type ComponentInternalRender, type ComponentOption, type ComponentPropertyDescriptor, type ComponentPropertyInputDict, type ComponentPropertyOutputDict, type ComponentPropertyStore, type ComponentRenderEntry, type EmptyValue, type EventDescriptor, type EventOptions, EventSubcriber, type HostTree, type HostTreeHookStore, type HostTreeHooks, type KebabToCamel, type Normalize, type ObjectToEntryUnion, type PropertyTransformer, type RawSlotInput, type RawSourceTree, type SlotInput, type SlotOutput, type SourceTree, type StyleSet, type Valueof, type Wrapper, index as assets, attachUUID, camelToHyphen, createArray, createComponent, defineEvent, _default as examples, flagment, hostdown, hyphenToCamel, normalizePropertyDescriptor, pipeExtract, putIntoArray, rawProperty, render, styleSet, sync, tree, typedIsArray, validateStore, when, wrap };