Skip to content

Commit

Permalink
refactor!: remove *.enhanceDebugger, Watcher.{on,off}
Browse files Browse the repository at this point in the history
- DOMProxy.enhanceDebugger is removed
- Watcher.enhanceDebugger is removed
- Watcher no longer extends from @servie/events.EventEmitter, but use it internally.

Internal changes:

- Remove jest
  • Loading branch information
Jack-Works committed May 20, 2022
1 parent 7c3d0d0 commit 02352b0
Show file tree
Hide file tree
Showing 59 changed files with 936 additions and 3,594 deletions.
11 changes: 0 additions & 11 deletions api-documents/kit.domproxy.enhancedebugger.md

This file was deleted.

45 changes: 40 additions & 5 deletions api-documents/kit.domproxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,52 @@

[Home](./index.md) > [@holoflows/kit](./kit.md) > [DOMProxy](./kit.domproxy.md)

## DOMProxy namespace
## DOMProxy interface

DOMProxy provide an interface that be stable even dom is changed.

<b>Signature:</b>

```typescript
export declare namespace DOMProxy
export interface DOMProxy<ProxiedElement extends Node = HTMLElement, Before extends Element = HTMLSpanElement, After extends Element = HTMLSpanElement> extends Omit<Emitter<DOMProxyEvents<ProxiedElement>>, '_' | '$'>
```
<b>Extends:</b> Omit&lt;Emitter&lt;[DOMProxyEvents](./kit.domproxyevents.md)
## Remarks
DOMProxy provide 3 nodes. `before`<!-- -->, `current` and `after`<!-- -->. `current` is a fake dom node powered by Proxy, it will forward all your operations to the `realCurrent`<!-- -->.
`before` and `after` is a true `span` that always point to before and after of `realCurrent`
Special Handlers:
\*forward\*: forward to current `realCurrent`
\*undo\*: undo effect when `realCurrent` changes
\*move\*: move effect to new `realCurrent`
- style (forward, undo, move) - addEventListener (forward, undo, move) - appendChild (forward, undo, move)
## Properties
| Property | Type | Description |
| --- | --- | --- |
| [after](./kit.domproxy.after.md) | After | Returns the <code>after</code> element, if it doesn't exist, create it implicitly. |
| [afterShadow](./kit.domproxy.aftershadow.md) | ShadowRoot | Returns the <code>ShadowRoot</code> of the <code>after</code> element. |
| [before](./kit.domproxy.before.md) | Before | Returns the <code>before</code> element, if it doesn't exist, create it implicitly. |
| [beforeShadow](./kit.domproxy.beforeshadow.md) | ShadowRoot | Returns the <code>ShadowRoot</code> of the <code>before</code> element. |
| [current](./kit.domproxy.current.md) | ProxiedElement | A proxy that always point to <code>realCurrent</code>, and if <code>realCurrent</code> changes, all action will be forwarded to new <code>realCurrent</code> |
| [destroyed](./kit.domproxy.destroyed.md) | boolean | |
| [observer](./kit.domproxy.observer.md) | { readonly observer: MutationObserver \| null; callback: MutationCallback \| undefined; init: MutationObserverInit \| undefined; } | Observer for the current node. You need to set callback and init to activate it. |
| [realCurrent](./kit.domproxy.realcurrent.md) | ProxiedElement \| null | The real current of the <code>current</code> |
## Variables
## Methods
| Variable | Description |
| Method | Description |
| --- | --- |
| [enhanceDebugger](./kit.domproxy.enhancedebugger.md) | |
| [destroy()](./kit.domproxy.destroy.md) | Destroy the DOMProxy |
| [has(type)](./kit.domproxy.has.md) | Get weak reference to <code>before</code> node |
| [has(type)](./kit.domproxy.has_1.md) | Get weak reference to <code>after</code> node |
| [has(type)](./kit.domproxy.has_2.md) | Get weak reference to <code>beforeShadow</code> or <code>afterShadow</code> node |
3 changes: 1 addition & 2 deletions api-documents/kit.eventwatcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ A Watcher based on event handlers.
```typescript
export declare class EventWatcher<T, Before extends Element = HTMLSpanElement, After extends Element = HTMLSpanElement, SingleMode extends boolean = false> extends Watcher<T, Before, After, SingleMode>
```
<b>Extends:</b> [Watcher](./kit.watcher.md)<!-- -->&lt;T, Before, After, SingleMode&gt;
<b>Extends:</b> [Watcher](./kit.watcher.md)
## Example
```ts
const e = new EventWatcher(ls).useForeach(node => console.log(node))
document.addEventListener('event', e.eventListener)

```
## Constructors
Expand Down
3 changes: 1 addition & 2 deletions api-documents/kit.intervalwatcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A watcher based on time interval.
```typescript
export declare class IntervalWatcher<T, Before extends Element = HTMLSpanElement, After extends Element = HTMLSpanElement, SingleMode extends boolean = false> extends Watcher<T, Before, After, SingleMode>
```
<b>Extends:</b> [Watcher](./kit.watcher.md)<!-- -->&lt;T, Before, After, SingleMode&gt;
<b>Extends:</b> [Watcher](./kit.watcher.md)
## Example
Expand All @@ -22,7 +22,6 @@ new IntervalWatcher(ls)
console.log(node)
})
.startWatch(1000)

```
## Methods
Expand Down
2 changes: 1 addition & 1 deletion api-documents/kit.liveselector._constructor_.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ constructor(initialElements?: readonly T[]);

| Parameter | Type | Description |
| --- | --- | --- |
| initialElements | readonly T\[\] | provides initial results, equals to <code>.replace(() =&gt; initialElements)</code> |
| initialElements | readonly T\[\] | <i>(Optional)</i> provides initial results, equals to <code>.replace(() =&gt; initialElements)</code> |

1 change: 0 additions & 1 deletion api-documents/kit.liveselector.at.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ at(n: SingleMode extends true ? 'LiveSelector.nth() is not available in SingleMo

```ts
ls.at(-1)

```

1 change: 0 additions & 1 deletion api-documents/kit.liveselector.clone.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ a new LiveSelector with same action

```ts
ls.clone()

```

1 change: 0 additions & 1 deletion api-documents/kit.liveselector.closest.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ closest<T>(parentOfNth: number): LiveSelector<T, SingleMode>;

```ts
ls.closest(2) // parentElement.parentElement

```

1 change: 0 additions & 1 deletion api-documents/kit.liveselector.closest_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ closest<K extends keyof HTMLElementTagNameMap>(selectors: K): LiveSelector<HTMLE
```ts
ls.closest('div')

```
1 change: 0 additions & 1 deletion api-documents/kit.liveselector.concat.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ concat<NextType>(newEle: LiveSelector<NextType, SingleMode>): LiveSelector<T | N

```ts
ls.concat(new LiveSelector().querySelector('#root'))

```

19 changes: 0 additions & 19 deletions api-documents/kit.liveselector.enhancedebugger.md

This file was deleted.

1 change: 0 additions & 1 deletion api-documents/kit.liveselector.filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ filter(f: (value: T, index: number, array: T[]) => any): LiveSelector<NonNullabl

```ts
ls.filter(x => x.innerText.match('hello'))

```

1 change: 0 additions & 1 deletion api-documents/kit.liveselector.flat.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ flat(): LiveSelector<T extends ArrayLike<infer U> ? U : never, SingleMode>;

```ts
ls.flat()

```

1 change: 0 additions & 1 deletion api-documents/kit.liveselector.getelementsbyclassname.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ Equal to ls.querySelectorAll('.a .b')
```ts
ls.getElementsByClassName('a').getElementsByClassName('b')

```
1 change: 0 additions & 1 deletion api-documents/kit.liveselector.getelementsbytagname.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ Equal to ls.querySelectorAll('a b')
```ts
ls.getElementsByTagName('a').getElementsByTagName('b')

```
1 change: 0 additions & 1 deletion api-documents/kit.liveselector.map.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ map<NextType>(callbackfn: (element: T, index: number, array: T[]) => NextType):

```ts
ls.map(x => x.parentElement)

```

2 changes: 0 additions & 2 deletions api-documents/kit.liveselector.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Call [\#evaluate](./kit.liveselector.evaluate.md) to evaluate the element. Falsy
```ts
const ls = new LiveSelector().querySelectorAll('a').map(x => x.href)
ls.evaluate() // returns all urls at the current time.

```

## Constructors
Expand All @@ -49,7 +48,6 @@ ls.evaluate() // returns all urls at the current time.
| [closest(selectors)](./kit.liveselector.closest_3.md) | | |
| [concat(newEle)](./kit.liveselector.concat.md) | | Combines two LiveSelector. |
| [enableSingleMode()](./kit.liveselector.enablesinglemode.md) | | Enable single mode. Only 1 result will be emitted. |
| [enhanceDebugger()](./kit.liveselector.enhancedebugger.md) | <code>static</code> | Call this function to enhance the debug experience in the Chrome DevTools<!-- -->You need to open "Enable custom formatters" in your DevTools settings. |
| [evaluate()](./kit.liveselector.evaluate.md) | | Evaluate selector expression |
| [filter(f)](./kit.liveselector.filter.md) | | Select the elements of a LiveSelector that meet the condition specified in a callback function. |
| [flat()](./kit.liveselector.flat.md) | | Flat T\[\]\[\] to T\[\] |
Expand Down
2 changes: 0 additions & 2 deletions api-documents/kit.liveselector.queryselector.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ querySelector<K extends keyof HTMLElementTagNameMap>(selector: K): LiveSelector<
```ts
ls.querySelector('div#root')

```
About chain on querySelector
```ts
ls.querySelector('a').querySelector('b')
// equals to
ls.querySelector('a b')

```
2 changes: 0 additions & 2 deletions api-documents/kit.liveselector.queryselectorall.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ querySelectorAll<K extends keyof HTMLElementTagNameMap>(selector: K): LiveSelect
```ts
ls.querySelector('div > div')

```
About chain on querySelector
```ts
ls.querySelectorAll('a').querySelectorAll('b')
// equals to
ls.querySelectorAll('a b')

```
1 change: 0 additions & 1 deletion api-documents/kit.liveselector.replace.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ replace<NextType>(f: (arr: T[]) => NextType[]): LiveSelector<NextType, SingleMod

```ts
ls.replace(x => lodash.dropRight(x, 2))

```

1 change: 0 additions & 1 deletion api-documents/kit.liveselector.reverse.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ reverse(): LiveSelector<T, SingleMode>;

```ts
ls.reverse()

```

5 changes: 2 additions & 3 deletions api-documents/kit.liveselector.slice.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ slice(start?: number, end?: number): LiveSelector<T, SingleMode>;

| Parameter | Type | Description |
| --- | --- | --- |
| start | number | The beginning of the specified portion of the array. |
| end | number | The end of the specified portion of the array. |
| start | number | <i>(Optional)</i> The beginning of the specified portion of the array. |
| end | number | <i>(Optional)</i> The end of the specified portion of the array. |

<b>Returns:</b>

Expand All @@ -28,6 +28,5 @@ slice(start?: number, end?: number): LiveSelector<T, SingleMode>;

```ts
ls.slice(2, 4)

```

3 changes: 1 addition & 2 deletions api-documents/kit.liveselector.sort.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sort(compareFn?: (a: T, b: T) => number): LiveSelector<T, SingleMode>;

| Parameter | Type | Description |
| --- | --- | --- |
| compareFn | (a: T, b: T) =&gt; number | The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. |
| compareFn | (a: T, b: T) =&gt; number | <i>(Optional)</i> The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. |

<b>Returns:</b>

Expand All @@ -27,6 +27,5 @@ sort(compareFn?: (a: T, b: T) => number): LiveSelector<T, SingleMode>;

```ts
ls.sort((a, b) => a.innerText.length - b.innerText.length)

```

1 change: 0 additions & 1 deletion api-documents/kit.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ A toolkit for browser extension developing.
| --- | --- |
| [assertEnvironment](./kit.assertenvironment.md) | |
| [assertNotEnvironment](./kit.assertnotenvironment.md) | |
| [DOMProxy](./kit.domproxy.md) | |
| [isEnvironment](./kit.isenvironment.md) | |

## Type Aliases
Expand Down
4 changes: 2 additions & 2 deletions api-documents/kit.mutationobserverwatcher._constructor_.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ constructor(
| Parameter | Type | Description |
| --- | --- | --- |
| liveSelector | [LiveSelector](./kit.liveselector.md)<!-- -->&lt;T, SingleMode&gt; | |
| consistentWatchRoot | Node | |
| stopWatchOnDisconnected | boolean | |
| consistentWatchRoot | Node | <i>(Optional)</i> |
| stopWatchOnDisconnected | boolean | <i>(Optional)</i> |

3 changes: 1 addition & 2 deletions api-documents/kit.mutationobserverwatcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A watcher based on MutationObserver
```typescript
export declare class MutationObserverWatcher<T, Before extends Element = HTMLSpanElement, After extends Element = HTMLSpanElement, SingleMode extends boolean = false> extends Watcher<T, Before, After, SingleMode>
```
<b>Extends:</b> [Watcher](./kit.watcher.md)<!-- -->&lt;T, Before, After, SingleMode&gt;
<b>Extends:</b> [Watcher](./kit.watcher.md)
## Example
Expand All @@ -22,7 +22,6 @@ new MutationObserverWatcher(ls)
console.log(node)
})
.startWatch()

```
## Constructors
Expand Down
2 changes: 1 addition & 1 deletion api-documents/kit.printenvironment.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export declare function printEnvironment(e?: Environment): string;

| Parameter | Type | Description |
| --- | --- | --- |
| e | [Environment](./kit.environment.md) | Printing environment bit flag |
| e | [Environment](./kit.environment.md) | <i>(Optional)</i> Printing environment bit flag |

<b>Returns:</b>

Expand Down
2 changes: 1 addition & 1 deletion api-documents/kit.targetboundeventregistry.on.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on(callback: (data: T) => void, options?: TargetBoundEventListenerOptions): () =
| Parameter | Type | Description |
| --- | --- | --- |
| callback | (data: T) =&gt; void | |
| options | [TargetBoundEventListenerOptions](./kit.targetboundeventlisteneroptions.md) | |
| options | [TargetBoundEventListenerOptions](./kit.targetboundeventlisteneroptions.md) | <i>(Optional)</i> |

<b>Returns:</b>

Expand Down
2 changes: 1 addition & 1 deletion api-documents/kit.unboundedregistry.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
```typescript
export interface UnboundedRegistry<T> extends Omit<TargetBoundEventRegistry<T>, 'send'>, AsyncIterable<T>
```
<b>Extends:</b> Omit&lt;[TargetBoundEventRegistry](./kit.targetboundeventregistry.md)<!-- -->&lt;T&gt;, 'send'&gt;, AsyncIterable&lt;T&gt;
<b>Extends:</b> Omit&lt;[TargetBoundEventRegistry](./kit.targetboundeventregistry.md)<!-- -->&lt;T&gt;, 'send'&gt;, AsyncIterable
## Methods
Expand Down
2 changes: 1 addition & 1 deletion api-documents/kit.valueref._constructor_.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ constructor(_value: T, isEqual?: (a: T, b: T) => boolean);
| Parameter | Type | Description |
| --- | --- | --- |
| \_value | T | The internal value |
| isEqual | (a: T, b: T) =&gt; boolean | The comparer function |
| isEqual | (a: T, b: T) =&gt; boolean | <i>(Optional)</i> The comparer function |

1 change: 0 additions & 1 deletion api-documents/kit.valueref.addlistener.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ addListener(fn: (newVal: T, oldVal: T) => void): () => void;

```ts
React.useEffect(() => ref.addListener(setState))

```

1 change: 0 additions & 1 deletion api-documents/kit.valueref.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ function useValueRef<T>(ref: ValueRef<T>) {
return value
}
ref.value = 42 // useRef will receive the new value

```

## Constructors
Expand Down
1 change: 0 additions & 1 deletion api-documents/kit.watcher.assignkeys.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@ this
```ts
watcher.assignKeys(node => node.innerText)

```
Loading

0 comments on commit 02352b0

Please sign in to comment.