Skip to content

Commit fc6707c

Browse files
authored
refactor: remove unused (#23)
1 parent e1b7d6d commit fc6707c

File tree

17 files changed

+16
-92
lines changed

17 files changed

+16
-92
lines changed

packages/cli/src/commands/dev/index.ts

-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { createServer } from 'vite'
44
import { resolve } from 'path'
55
import { startHMRServer } from './websocket'
66

7-
const WSS_FALLBACK_PORT = Number(process.env.PORT) || 3000
8-
97
export async function runDevServer(entryFile: string = 'src/main.ts') {
108
const server = await createServer({
119
logLevel: 'error',
@@ -49,14 +47,8 @@ export async function runDevServer(entryFile: string = 'src/main.ts') {
4947
}
5048

5149
const hotModulesMap = new Map<string, HotModule>()
52-
const disposeMap = new Map<string, (data: any) => void | Promise<void>>()
5350
const pruneMap = new Map<string, (data: any) => void | Promise<void>>()
5451
const dataMap = new Map<string, any>()
55-
const customListenersMap = new Map<string, ((data: any) => void)[]>()
56-
const ctxToListenersMap = new Map<
57-
string,
58-
Map<string, ((data: any) => void)[]>
59-
>()
6052

6153
function createHotContext(ownerPath: string) {
6254
const fullPath = resolve('.' + ownerPath)

packages/core/src/components/App.ts

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
useRootNode,
2020
} from '../injectionSymbols'
2121
import { stdoutSymbol } from '../composables/writeStreams'
22-
import { onResize } from '../composables/screen'
2322
// TODO: useSettings()
2423

2524
export const TuiApp = defineComponent({

packages/core/src/components/TextTransform.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chalk, { ForegroundColor } from 'chalk'
1+
import chalk from 'chalk'
22
import { h, inject, FunctionalComponent } from '@vue/runtime-core'
33
import { scheduleUpdateSymbol } from '../injectionSymbols'
44
import type { OutputTransformer } from '../renderer/Output'

packages/core/src/composables/keyboard.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
KeyDataEventKey,
77
KeyDataEventRawHandlerFn,
88
} from '../input/types'
9-
import { checkCurrentInstance, LiteralUnion, noop } from '../utils'
9+
import { checkCurrentInstance, noop } from '../utils'
1010

1111
export type RemoveListener = () => void
1212

packages/core/src/composables/utils.ts

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { onMounted, onUnmounted, ref } from '@vue/runtime-core'
1+
import { onMounted, onUnmounted } from '@vue/runtime-core'
22

33
export function useInterval(fn: () => void, interval?: number) {
44
let handle: ReturnType<typeof setInterval>
@@ -26,18 +26,3 @@ export function useTimeout(fn: () => void, delay?: number) {
2626
clearTimeout(handle)
2727
})
2828
}
29-
30-
function useTimeFunction<RT = any>(
31-
fn: (cb: () => void, time?: number) => RT,
32-
clear: (id?: RT) => void
33-
) {
34-
return (cb: () => void, time?: number) => {
35-
let handle: RT
36-
onMounted(() => {
37-
handle = fn(cb, time)
38-
})
39-
onUnmounted(() => {
40-
clear(handle)
41-
})
42-
}
43-
}

packages/core/src/focus/FocusManager.spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { createFocusManager } from './FocusManager'
2-
import { DOMElement, DOMNode, TextNode, CommentNode } from '../renderer/dom'
2+
import { DOMElement, DOMNode, TextNode } from '../renderer/dom'
33
import {
44
ComponentInternalInstance,
55
VNode,
66
ref,
77
ComputedRef,
8-
h,
98
} from '@vue/runtime-core'
109
import { Focusable } from './types'
1110

packages/core/src/focus/FocusManager.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
ComponentInternalInstance,
32
inject,
43
InjectionKey,
54
ShallowRef,
@@ -11,10 +10,9 @@ import {
1110
previousDeepSibling,
1211
nextDeepSibling,
1312
} from '../renderer/nodeOpts'
14-
import { DOMElement, DOMNode, isDOMElement } from '../renderer/dom'
13+
import { DOMElement, DOMNode } from '../renderer/dom'
1514
import { checkCurrentInstance, getElementFromInstance, noop } from '../utils'
1615
import { Focusable, FocusId } from './types'
17-
import { indentHTML } from '../utils/indentHTML'
1816

1917
export interface FocusManager {
2018
activeElement: ShallowRef<Focusable | null | undefined>

packages/core/src/index.spec.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import cliTruncate from 'cli-truncate'
2-
import sliceAnsi from 'slice-ansi'
31
import {
42
createApp,
53
defineComponent,

packages/core/src/input/inputSequences.ts

-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { inputDataToString } from './debug'
21
import { defineKeypressEvent, defineMouseEvent } from './keyEvents'
32
import {
43
KeyDataEventKeyCode,
@@ -52,13 +51,6 @@ const MOUSE_SEQ_START = '\x1b[M' // Mouse click
5251
const MOUSE_ENCODE_OFFSET = 32 // mouse values are encoded as numeric values + 040 (32 in octal)
5352
const MOUSE_EXTENDED_SEQ_START = '\x1b[<' // Ends with M/m
5453

55-
const enum InputSequenceParserState {
56-
xterm,
57-
vt_keycode_and_modifier,
58-
vt_keycode_drop,
59-
vt_modifier_end_letter,
60-
}
61-
6254
type CSISeqParsed = Array<string | number>
6355

6456
type MouseExtendedCSISeq = [number, number, number, string]

packages/core/src/input/types.ts

-14
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,6 @@ export type KeyDataEventKeyCode =
158158
*/
159159
export type KeyDataEventKey = LiteralUnion<KeyDataEventKeyCode, string>
160160

161-
function defineKeypressEvent(
162-
key: KeyDataEventKeyCode,
163-
modifiers?: Partial<_InputDataEventModifiers>
164-
): KeyDataEvent {
165-
return {
166-
key,
167-
altKey: false,
168-
shiftKey: false,
169-
ctrlKey: false,
170-
metaKey: false,
171-
...modifiers,
172-
}
173-
}
174-
175161
export const enum MouseEventButton {
176162
/**
177163
* Also known as `main`.

packages/core/src/renderer/LogUpdate.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { Writable } from 'stream'
22
import ansiEscapes from 'ansi-escapes'
33
import cliCursor from 'cli-cursor'
4-
import { DOMElement } from './dom'
5-
import { applyStyles } from './styles'
6-
import type { OutputTransformer } from './Output'
74

85
export interface LogUpdate {
96
clear: () => void

packages/core/src/renderer/renderNodeToOutput.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Yoga from 'yoga-layout-prebuilt'
2-
import { DOMElement, DOMNode, getMaxWidth } from './dom'
2+
import { DOMNode, getMaxWidth } from './dom'
33
import widestLine from 'widest-line'
44
import indentString from 'indent-string'
55
import { wrapText, squashTextNodes } from './text'

packages/domino/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"test:dev": "vitest"
1414
},
1515
"dependencies": {
16+
"mitt": "^3.0.0",
1617
"vue-termui": "workspace:*"
1718
},
1819
"devDependencies": {

packages/domino/src/engine/Emitter.ts

-21
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
EventType,
66
Handler,
77
WildCardEventHandlerList,
8-
// WildcardHandler,
98
} from 'mitt'
109

1110
type GenericEventHandler<Events extends Record<EventType, unknown>> =
@@ -26,9 +25,6 @@ type WW<T extends Record<string, unknown>> = <K extends keyof T>(
2625
// <K extends keyof T>(type: K, event: T[K]) => void;
2726

2827
type E = { a: { isA: boolean }; b: { isB: boolean } }
29-
type A = WildcardHandler<E>
30-
type B = WildcardHandler<E>
31-
type C = WW<E>
3228

3329
function on<E extends Record<string, unknown>>(handler: WW<E>) {}
3430
on<E>((type, event) => {
@@ -125,20 +121,3 @@ export class EventEmitter<Events extends Record<EventType, unknown>> {
125121
}
126122
}
127123
}
128-
129-
function test() {
130-
// const emitter = mitt<{ a: string, b: number }>()
131-
const emitter = new EventEmitter<{
132-
a: { isA: boolean }
133-
b: { isB: boolean }
134-
}>()
135-
136-
emitter.on('a', (event) => {})
137-
138-
emitter.on('*', (type, event) => {
139-
if (type === 'a') {
140-
type
141-
event
142-
}
143-
})
144-
}

packages/playground/src/components/GlobalEvents.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
defineComponent,
3-
onMounted,
4-
onBeforeUnmount,
5-
ref,
6-
onActivated,
7-
onDeactivated,
8-
} from 'vue'
1+
import { defineComponent, ref, onActivated, onDeactivated } from 'vue'
92
import type { PropType, VNodeProps } from 'vue'
103
import type { KeyDataEventRawHandlerFn } from 'vue-termui'
114
import { onKeyData } from 'vue-termui'
@@ -96,8 +89,6 @@ export const GlobalEventsImpl = defineComponent({
9689
}
9790
)
9891

99-
const options = extractEventOptions(modifiersRaw)
100-
10192
handlers.forEach((handler) => {
10293
// TODO: filter based on eventName
10394
onKeyData(handler)

pnpm-lock.yaml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"paths": {
1515
"vue-termui": ["packages/core/src/index.ts"],
1616
"vite-plugin-vue-termui": ["packages/vite-plugin-vue-termui/src/index.ts"]
17-
}
17+
},
18+
"skipLibCheck": true
1819
},
1920
"include": [
2021
"auto-imports.d.ts",

0 commit comments

Comments
 (0)