@neurodevs/node-tdd 0.2.5 → 1.0.0
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/.vscode/launch.json +52 -57
- package/.vscode/settings.json +61 -66
- package/.vscode/tasks.json +98 -129
- package/README.md +1 -0
- package/build/.spruce/settings.json +3 -10
- package/build/__tests__/MockFetch.d.ts +18 -0
- package/build/__tests__/MockFetch.js +55 -0
- package/build/__tests__/MockFetch.js.map +1 -0
- package/build/__tests__/{impl → behavioral}/AbstractModuleTest.test.d.ts +2 -3
- package/build/__tests__/{impl → behavioral}/AbstractModuleTest.test.js +3 -12
- package/build/__tests__/behavioral/AbstractModuleTest.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.d.ts +5 -0
- package/build/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.js +34 -0
- package/build/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/Assert.test.d.ts +45 -0
- package/build/__tests__/behavioral/utilities/Assert.test.js +645 -0
- package/build/__tests__/behavioral/utilities/Assert.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.js +23 -0
- package/build/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/MockFetch.test.d.ts +28 -0
- package/build/__tests__/behavioral/utilities/MockFetch.test.js +211 -0
- package/build/__tests__/behavioral/utilities/MockFetch.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/StackCleaner.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/StackCleaner.test.js +46 -0
- package/build/__tests__/behavioral/utilities/StackCleaner.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.d.ts +7 -0
- package/build/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.js +32 -0
- package/build/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.js +19 -0
- package/build/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/Stringify.test.d.ts +5 -0
- package/build/__tests__/behavioral/utilities/Stringify.test.js +127 -0
- package/build/__tests__/behavioral/utilities/Stringify.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestDecoratorResolver.test.d.ts +7 -0
- package/build/__tests__/behavioral/utilities/TestDecoratorResolver.test.js +38 -0
- package/build/__tests__/behavioral/utilities/TestDecoratorResolver.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnBasic.test.d.ts +12 -0
- package/build/__tests__/behavioral/utilities/TestOnBasic.test.js +68 -0
- package/build/__tests__/behavioral/utilities/TestOnBasic.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnInstance.test.d.ts +28 -0
- package/build/__tests__/behavioral/utilities/TestOnInstance.test.js +289 -0
- package/build/__tests__/behavioral/utilities/TestOnInstance.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.d.ts +9 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.js +118 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.d.ts +5 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.js +78 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.js +23 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.js +24 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestResolver.test.d.ts +7 -0
- package/build/__tests__/behavioral/utilities/TestResolver.test.js +38 -0
- package/build/__tests__/behavioral/utilities/TestResolver.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestResolverOnStatic.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/TestResolverOnStatic.test.js +20 -0
- package/build/__tests__/behavioral/utilities/TestResolverOnStatic.test.js.map +1 -0
- package/build/__tests__/behavioral/workspace/JestJsonParser.test.d.ts +18 -0
- package/build/__tests__/behavioral/workspace/JestJsonParser.test.js +267 -0
- package/build/__tests__/behavioral/workspace/JestJsonParser.test.js.map +1 -0
- package/build/__tests__/behavioral/workspace/TestReporter.test.d.ts +16 -0
- package/build/__tests__/behavioral/workspace/TestReporter.test.js +227 -0
- package/build/__tests__/behavioral/workspace/TestReporter.test.js.map +1 -0
- package/build/__tests__/behavioral/workspace/TestRunner.test.d.ts +15 -0
- package/build/__tests__/behavioral/workspace/TestRunner.test.js +99 -0
- package/build/__tests__/behavioral/workspace/TestRunner.test.js.map +1 -0
- package/build/__tests__/behavioral/workspace/Widgets.test.d.ts +13 -0
- package/build/__tests__/behavioral/workspace/Widgets.test.js +99 -0
- package/build/__tests__/behavioral/workspace/Widgets.test.js.map +1 -0
- package/build/__tests__/mock-terminal-kit.d.ts +79 -0
- package/build/__tests__/mock-terminal-kit.js +103 -0
- package/build/__tests__/mock-terminal-kit.js.map +1 -0
- package/build/__tests__/support/AbstractForInstanceTest.d.ts +4 -0
- package/build/__tests__/support/AbstractForInstanceTest.js +9 -0
- package/build/__tests__/support/AbstractForInstanceTest.js.map +1 -0
- package/build/__tests__/support/AbstractLevelOneTest.d.ts +3 -0
- package/build/__tests__/support/AbstractLevelOneTest.js +4 -0
- package/build/__tests__/support/AbstractLevelOneTest.js.map +1 -0
- package/build/__tests__/support/AbstractLevelTwoTest.d.ts +7 -0
- package/build/__tests__/support/AbstractLevelTwoTest.js +14 -0
- package/build/__tests__/support/AbstractLevelTwoTest.js.map +1 -0
- package/build/__tests__/support/AbstractStaticTest.d.ts +7 -0
- package/build/__tests__/support/AbstractStaticTest.js +14 -0
- package/build/__tests__/support/AbstractStaticTest.js.map +1 -0
- package/build/__tests__/support/AbstractTestOnInstanceTest.d.ts +22 -0
- package/build/__tests__/support/AbstractTestOnInstanceTest.js +23 -0
- package/build/__tests__/support/AbstractTestOnInstanceTest.js.map +1 -0
- package/build/__tests__/support/AbstractTestOnInstanceWithHooks.d.ts +26 -0
- package/build/__tests__/support/AbstractTestOnInstanceWithHooks.js +59 -0
- package/build/__tests__/support/AbstractTestOnInstanceWithHooks.js.map +1 -0
- package/build/__tests__/support/jest.setup.d.ts +1 -0
- package/build/__tests__/support/jest.setup.js +4 -0
- package/build/__tests__/support/jest.setup.js.map +1 -0
- package/build/__tests__/support/onTestFileResult.d.ts +244 -0
- package/build/__tests__/support/onTestFileResult.js +980 -0
- package/build/__tests__/support/onTestFileResult.js.map +1 -0
- package/build/impl/AbstractModuleTest.d.ts +18 -4
- package/build/impl/AbstractModuleTest.js +47 -9
- package/build/impl/AbstractModuleTest.js.map +1 -1
- package/build/index.d.ts +4 -4
- package/build/index.js +4 -4
- package/build/index.js.map +1 -1
- package/build/utilities/AssertionError.d.ts +3 -0
- package/build/utilities/AssertionError.js +12 -0
- package/build/utilities/AssertionError.js.map +1 -0
- package/build/utilities/StackCleaner.d.ts +4 -0
- package/build/utilities/StackCleaner.js +10 -0
- package/build/utilities/StackCleaner.js.map +1 -0
- package/build/utilities/TestDecoratorResolver.d.ts +35 -0
- package/build/utilities/TestDecoratorResolver.js +93 -0
- package/build/utilities/TestDecoratorResolver.js.map +1 -0
- package/build/utilities/assert.d.ts +49 -0
- package/build/utilities/assert.js +255 -0
- package/build/utilities/assert.js.map +1 -0
- package/build/utilities/assert.utility.d.ts +28 -0
- package/build/utilities/assert.utility.js +185 -0
- package/build/utilities/assert.utility.js.map +1 -0
- package/build/utilities/decorators.d.ts +9 -0
- package/build/utilities/decorators.js +133 -0
- package/build/utilities/decorators.js.map +1 -0
- package/build/workspace/CommandService.d.ts +49 -0
- package/build/workspace/CommandService.js +179 -0
- package/build/workspace/CommandService.js.map +1 -0
- package/build/workspace/JestJsonParser.d.ts +15 -0
- package/build/workspace/JestJsonParser.js +149 -0
- package/build/workspace/JestJsonParser.js.map +1 -0
- package/build/workspace/TKButtonWidget.d.ts +13 -0
- package/build/workspace/TKButtonWidget.js +37 -0
- package/build/workspace/TKButtonWidget.js.map +1 -0
- package/build/workspace/TestLogItemGenerator.d.ts +15 -0
- package/build/workspace/TestLogItemGenerator.js +142 -0
- package/build/workspace/TestLogItemGenerator.js.map +1 -0
- package/build/workspace/TestReporter.d.ts +103 -0
- package/build/workspace/TestReporter.js +677 -0
- package/build/workspace/TestReporter.js.map +1 -0
- package/build/workspace/TestRunner.d.ts +24 -0
- package/build/workspace/TestRunner.js +95 -0
- package/build/workspace/TestRunner.js.map +1 -0
- package/build/workspace/TkBaseWidget.d.ts +37 -0
- package/build/workspace/TkBaseWidget.js +185 -0
- package/build/workspace/TkBaseWidget.js.map +1 -0
- package/build/workspace/TkInputWidget.d.ts +16 -0
- package/build/workspace/TkInputWidget.js +64 -0
- package/build/workspace/TkInputWidget.js.map +1 -0
- package/build/workspace/TkLayoutCellWidget.d.ts +18 -0
- package/build/workspace/TkLayoutCellWidget.js +32 -0
- package/build/workspace/TkLayoutCellWidget.js.map +1 -0
- package/build/workspace/TkLayoutWidget.d.ts +34 -0
- package/build/workspace/TkLayoutWidget.js +130 -0
- package/build/workspace/TkLayoutWidget.js.map +1 -0
- package/build/workspace/TkMenuBarWidget.d.ts +13 -0
- package/build/workspace/TkMenuBarWidget.js +71 -0
- package/build/workspace/TkMenuBarWidget.js.map +1 -0
- package/build/workspace/TkPopupWidget.d.ts +16 -0
- package/build/workspace/TkPopupWidget.js +36 -0
- package/build/workspace/TkPopupWidget.js.map +1 -0
- package/build/workspace/TkProgressBarWidget.d.ts +10 -0
- package/build/workspace/TkProgressBarWidget.js +39 -0
- package/build/workspace/TkProgressBarWidget.js.map +1 -0
- package/build/workspace/TkTextWidget.d.ts +20 -0
- package/build/workspace/TkTextWidget.js +115 -0
- package/build/workspace/TkTextWidget.js.map +1 -0
- package/build/workspace/TkWindowWidget.d.ts +22 -0
- package/build/workspace/TkWindowWidget.js +88 -0
- package/build/workspace/TkWindowWidget.js.map +1 -0
- package/build/workspace/WidgetFactory.d.ts +6 -0
- package/build/workspace/WidgetFactory.js +21 -0
- package/build/workspace/WidgetFactory.js.map +1 -0
- package/build/workspace/button.types.d.ts +15 -0
- package/build/workspace/button.types.js +6 -0
- package/build/workspace/button.types.js.map +1 -0
- package/build/workspace/duration.utility.d.ts +4 -0
- package/build/workspace/duration.utility.js +26 -0
- package/build/workspace/duration.utility.js.map +1 -0
- package/build/workspace/factory.types.d.ts +89 -0
- package/build/workspace/factory.types.js +37 -0
- package/build/workspace/factory.types.js.map +1 -0
- package/build/workspace/input.types.d.ts +18 -0
- package/build/workspace/input.types.js +7 -0
- package/build/workspace/input.types.js.map +1 -0
- package/build/workspace/keySelectChoices.d.ts +517 -0
- package/build/workspace/keySelectChoices.js +2 -0
- package/build/workspace/keySelectChoices.js.map +1 -0
- package/build/workspace/layout.types.d.ts +33 -0
- package/build/workspace/layout.types.js +2 -0
- package/build/workspace/layout.types.js.map +1 -0
- package/build/workspace/menuBar.types.d.ts +19 -0
- package/build/workspace/menuBar.types.js +6 -0
- package/build/workspace/menuBar.types.js.map +1 -0
- package/build/workspace/popup.types.d.ts +13 -0
- package/build/workspace/popup.types.js +6 -0
- package/build/workspace/popup.types.js.map +1 -0
- package/build/workspace/progressBar.types.d.ts +10 -0
- package/build/workspace/progressBar.types.js +2 -0
- package/build/workspace/progressBar.types.js.map +1 -0
- package/build/workspace/table.types.d.ts +6 -0
- package/build/workspace/table.types.js +2 -0
- package/build/workspace/table.types.js.map +1 -0
- package/build/workspace/termKit.utility.d.ts +12 -0
- package/build/workspace/termKit.utility.js +128 -0
- package/build/workspace/termKit.utility.js.map +1 -0
- package/build/workspace/test.types.d.ts +24 -0
- package/build/workspace/test.types.js +2 -0
- package/build/workspace/test.types.js.map +1 -0
- package/build/workspace/testRunner.cli.d.ts +1 -0
- package/build/workspace/testRunner.cli.js +149 -0
- package/build/workspace/testRunner.cli.js.map +1 -0
- package/build/workspace/text.types.d.ts +20 -0
- package/build/workspace/text.types.js +7 -0
- package/build/workspace/text.types.js.map +1 -0
- package/build/workspace/widget.utilities.d.ts +5 -0
- package/build/workspace/widget.utilities.js +20 -0
- package/build/workspace/widget.utilities.js.map +1 -0
- package/build/workspace/widgets.types.d.ts +66 -0
- package/build/workspace/widgets.types.js +2 -0
- package/build/workspace/widgets.types.js.map +1 -0
- package/build/workspace/window.types.d.ts +18 -0
- package/build/workspace/window.types.js +9 -0
- package/build/workspace/window.types.js.map +1 -0
- package/eslint.config.js +3 -0
- package/package.json +30 -37
- package/prettier.config.js +3 -0
- package/src/.spruce/settings.json +3 -10
- package/src/__tests__/MockFetch.ts +100 -0
- package/src/__tests__/behavioral/AbstractModuleTest.test.ts +15 -0
- package/src/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.ts +31 -0
- package/src/__tests__/behavioral/utilities/Assert.test.ts +826 -0
- package/src/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.ts +14 -0
- package/src/__tests__/behavioral/utilities/MockFetch.test.ts +240 -0
- package/src/__tests__/behavioral/utilities/StackCleaner.test.ts +46 -0
- package/src/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.ts +34 -0
- package/src/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.ts +11 -0
- package/src/__tests__/behavioral/utilities/Stringify.test.ts +169 -0
- package/src/__tests__/behavioral/utilities/TestDecoratorResolver.test.ts +51 -0
- package/src/__tests__/behavioral/utilities/TestOnBasic.test.ts +62 -0
- package/src/__tests__/behavioral/utilities/TestOnInstance.test.ts +439 -0
- package/src/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.ts +237 -0
- package/src/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.ts +85 -0
- package/src/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.ts +14 -0
- package/src/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.ts +16 -0
- package/src/__tests__/behavioral/utilities/TestResolver.test.ts +48 -0
- package/src/__tests__/behavioral/utilities/TestResolverOnStatic.test.ts +12 -0
- package/src/__tests__/behavioral/workspace/JestJsonParser.test.ts +357 -0
- package/src/__tests__/behavioral/workspace/TestReporter.test.ts +257 -0
- package/src/__tests__/behavioral/workspace/TestRunner.test.ts +87 -0
- package/src/__tests__/behavioral/workspace/Widgets.test.ts +90 -0
- package/src/__tests__/mock-terminal-kit.ts +115 -0
- package/src/__tests__/support/AbstractForInstanceTest.ts +12 -0
- package/src/__tests__/support/AbstractLevelOneTest.ts +3 -0
- package/src/__tests__/support/AbstractLevelTwoTest.ts +16 -0
- package/src/__tests__/support/AbstractStaticTest.ts +16 -0
- package/src/__tests__/support/AbstractTestOnInstanceTest.ts +30 -0
- package/src/__tests__/support/AbstractTestOnInstanceWithHooks.ts +138 -0
- package/src/__tests__/support/jest.setup.ts +2 -0
- package/src/__tests__/support/onTestFileResult.ts +1008 -0
- package/src/impl/AbstractModuleTest.ts +59 -10
- package/src/index.ts +4 -4
- package/src/utilities/AssertionError.ts +14 -0
- package/src/utilities/StackCleaner.ts +14 -0
- package/src/utilities/TestDecoratorResolver.ts +118 -0
- package/src/utilities/assert.ts +583 -0
- package/src/utilities/assert.utility.ts +295 -0
- package/src/utilities/decorators.ts +167 -0
- package/src/workspace/CommandService.ts +256 -0
- package/src/workspace/JestJsonParser.ts +255 -0
- package/src/workspace/TKButtonWidget.ts +54 -0
- package/src/workspace/TestLogItemGenerator.ts +184 -0
- package/src/workspace/TestReporter.ts +865 -0
- package/src/workspace/TestRunner.ts +128 -0
- package/src/workspace/TkBaseWidget.ts +249 -0
- package/src/workspace/TkInputWidget.ts +83 -0
- package/src/workspace/TkLayoutCellWidget.ts +46 -0
- package/src/workspace/TkLayoutWidget.ts +181 -0
- package/src/workspace/TkMenuBarWidget.ts +95 -0
- package/src/workspace/TkPopupWidget.ts +47 -0
- package/src/workspace/TkProgressBarWidget.ts +54 -0
- package/src/workspace/TkTextWidget.ts +158 -0
- package/src/workspace/TkWindowWidget.ts +122 -0
- package/src/workspace/WidgetFactory.ts +33 -0
- package/src/workspace/button.types.ts +19 -0
- package/src/workspace/duration.utility.ts +34 -0
- package/src/workspace/factory.types.ts +101 -0
- package/src/workspace/input.types.ts +22 -0
- package/src/workspace/keySelectChoices.ts +134 -0
- package/src/workspace/layout.types.ts +40 -0
- package/src/workspace/menuBar.types.ts +24 -0
- package/src/workspace/popup.types.ts +17 -0
- package/src/workspace/progressBar.types.ts +13 -0
- package/src/workspace/table.types.ts +9 -0
- package/src/workspace/termKit.utility.ts +130 -0
- package/src/workspace/terminal-kit.d.ts +28 -0
- package/src/workspace/test.types.ts +34 -0
- package/src/workspace/testRunner.cli.ts +159 -0
- package/src/workspace/text.types.ts +26 -0
- package/src/workspace/widget.utilities.ts +35 -0
- package/src/workspace/widgets.types.ts +102 -0
- package/src/workspace/window.types.ts +22 -0
- package/tsconfig.json +23 -27
- package/build/__tests__/AbstractPackageTest.d.ts +0 -4
- package/build/__tests__/AbstractPackageTest.js +0 -7
- package/build/__tests__/AbstractPackageTest.js.map +0 -1
- package/build/__tests__/functions/assertFunction.test.d.ts +0 -5
- package/build/__tests__/functions/assertFunction.test.js +0 -23
- package/build/__tests__/functions/assertFunction.test.js.map +0 -1
- package/build/__tests__/functions/testFunction.test.d.ts +0 -5
- package/build/__tests__/functions/testFunction.test.js +0 -23
- package/build/__tests__/functions/testFunction.test.js.map +0 -1
- package/build/__tests__/impl/AbstractModuleTest.test.js.map +0 -1
- package/build/functions/assert.d.ts +0 -3
- package/build/functions/assert.js +0 -4
- package/build/functions/assert.js.map +0 -1
- package/build/functions/test.d.ts +0 -3
- package/build/functions/test.js +0 -4
- package/build/functions/test.js.map +0 -1
- package/eslint.config.mjs +0 -3
- package/src/__tests__/AbstractPackageTest.ts +0 -7
- package/src/__tests__/functions/assertFunction.test.ts +0 -22
- package/src/__tests__/functions/testFunction.test.ts +0 -22
- package/src/__tests__/impl/AbstractModuleTest.test.ts +0 -34
- package/src/functions/assert.ts +0 -4
- package/src/functions/test.ts +0 -4
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import terminal_kit from 'terminal-kit'
|
|
2
|
+
const termKit = terminal_kit as any
|
|
3
|
+
import {
|
|
4
|
+
MenuBarWidget,
|
|
5
|
+
MenuBarWidgetItem,
|
|
6
|
+
MenuBarWidgetOptions,
|
|
7
|
+
} from './menuBar.types.js'
|
|
8
|
+
import termKitUtil from './termKit.utility.js'
|
|
9
|
+
import TkBaseWidget, { TkWidgetOptions } from './TkBaseWidget.js'
|
|
10
|
+
|
|
11
|
+
export default class TkMenuBarWidget
|
|
12
|
+
extends TkBaseWidget
|
|
13
|
+
implements MenuBarWidget
|
|
14
|
+
{
|
|
15
|
+
public readonly type = 'menuBar'
|
|
16
|
+
|
|
17
|
+
private menu: any
|
|
18
|
+
|
|
19
|
+
public constructor(options: TkWidgetOptions & MenuBarWidgetOptions) {
|
|
20
|
+
super(options)
|
|
21
|
+
|
|
22
|
+
const frame = termKitUtil.buildFrame(options, options.parent)
|
|
23
|
+
const items = this.mapItemsToTkItems(options.items)
|
|
24
|
+
|
|
25
|
+
this.menu = new termKit.DropDownMenu({
|
|
26
|
+
parent: options.parent.getTermKitElement(),
|
|
27
|
+
separator: '|',
|
|
28
|
+
items,
|
|
29
|
+
backgroundAttr: { bgColor: 'black', color: 'white' },
|
|
30
|
+
buttonBlurAttr: { bgColor: 'black', color: 'yellow' },
|
|
31
|
+
buttonFocusAttr: { bgColor: 'yellow', color: 'black' },
|
|
32
|
+
separatorAttr: { bgColor: 'black', color: 'yellow' },
|
|
33
|
+
...frame,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
this.calculateSizeLockDeltas()
|
|
37
|
+
|
|
38
|
+
this.menu.__widget = this
|
|
39
|
+
this.menu.on('submit', this.handleMenuSubmit.bind(this))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public setTextForItem(value: string, text: string): void {
|
|
43
|
+
let buttonItem = this.getButtonByValue(value, this.menu.buttons)
|
|
44
|
+
|
|
45
|
+
if (!buttonItem) {
|
|
46
|
+
for (const item of this.menu.itemsDef) {
|
|
47
|
+
for (const subItem of item.items ?? []) {
|
|
48
|
+
if (subItem.value === value) {
|
|
49
|
+
subItem.content = this.buildItemText(text)
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!buttonItem) {
|
|
57
|
+
throw new Error(`No menu item with value of ${value}`)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
buttonItem.setContent(this.buildItemText(text), true)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private getButtonByValue(value: string, buttons: any[]) {
|
|
64
|
+
let button: any
|
|
65
|
+
for (const button of buttons) {
|
|
66
|
+
if (button.def.value === value) {
|
|
67
|
+
return button
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return button
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private handleMenuSubmit(value: string) {
|
|
75
|
+
this.menu.clearColumnMenu()
|
|
76
|
+
void (this as MenuBarWidget).emit('select', { value })
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public getTermKitElement() {
|
|
80
|
+
return this.menu
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private mapItemsToTkItems(items: MenuBarWidgetItem[]): any {
|
|
84
|
+
return items.map((item) => ({
|
|
85
|
+
value: item.value,
|
|
86
|
+
content: this.buildItemText(item.label),
|
|
87
|
+
topSubmit: !item.items || item.items.length === 0,
|
|
88
|
+
items: item.items ? this.mapItemsToTkItems(item.items) : undefined,
|
|
89
|
+
}))
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private buildItemText(text: string): string {
|
|
93
|
+
return ` ${text} `
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import terminal_kit from 'terminal-kit'
|
|
2
|
+
import { PopupWidget, PopupWidgetOptions } from './popup.types.js'
|
|
3
|
+
import termKitUtil from './termKit.utility.js'
|
|
4
|
+
import TkBaseWidget, { TkWidgetOptions } from './TkBaseWidget.js'
|
|
5
|
+
const termKit = terminal_kit as any
|
|
6
|
+
|
|
7
|
+
export default class TkPopupWidget extends TkBaseWidget implements PopupWidget {
|
|
8
|
+
private popup: any
|
|
9
|
+
|
|
10
|
+
public readonly type = 'popup'
|
|
11
|
+
|
|
12
|
+
public constructor(
|
|
13
|
+
options: TkWidgetOptions & PopupWidgetOptions & { termKitElement: any }
|
|
14
|
+
) {
|
|
15
|
+
super({
|
|
16
|
+
shouldLockHeightWithParent: true,
|
|
17
|
+
shouldLockWidthWithParent: true,
|
|
18
|
+
...options,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const { parent, ...rest } = options
|
|
22
|
+
|
|
23
|
+
const frame = termKitUtil.buildFrame(options, parent)
|
|
24
|
+
|
|
25
|
+
this.popup = new termKit.Window({
|
|
26
|
+
parent: parent ? parent.getTermKitElement() : undefined,
|
|
27
|
+
movable: true,
|
|
28
|
+
...rest,
|
|
29
|
+
...frame,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
this.popup.__widget = this
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public getTermKitElement() {
|
|
36
|
+
return this.popup
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public getFrame() {
|
|
40
|
+
return {
|
|
41
|
+
left: this.popup.outputDst.x,
|
|
42
|
+
top: this.popup.outputDst.y,
|
|
43
|
+
width: this.popup.inputWidth,
|
|
44
|
+
height: this.popup.inputHeight,
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import terminal_kit from 'terminal-kit'
|
|
2
|
+
import {
|
|
3
|
+
ProgressBarWidget,
|
|
4
|
+
ProgressBarWidgetOptions,
|
|
5
|
+
} from './progressBar.types.js'
|
|
6
|
+
import TkBaseWidget, { TkWidgetOptions } from './TkBaseWidget.js'
|
|
7
|
+
const termKit = terminal_kit as any
|
|
8
|
+
|
|
9
|
+
export default class TkProgressBarWidget
|
|
10
|
+
extends TkBaseWidget
|
|
11
|
+
implements ProgressBarWidget
|
|
12
|
+
{
|
|
13
|
+
public readonly type = 'progressBar'
|
|
14
|
+
|
|
15
|
+
private bar: any
|
|
16
|
+
|
|
17
|
+
public constructor(options: TkWidgetOptions & ProgressBarWidgetOptions) {
|
|
18
|
+
super(options)
|
|
19
|
+
|
|
20
|
+
const { parent, label, left, top, progress, ...barOptions } = options
|
|
21
|
+
|
|
22
|
+
this.bar = new termKit.Bar({
|
|
23
|
+
parent: parent?.getTermKitElement(),
|
|
24
|
+
content: label ? ` ${label}` : undefined,
|
|
25
|
+
x: left,
|
|
26
|
+
y: top,
|
|
27
|
+
barChars: 'solid',
|
|
28
|
+
bodyAttr: { bgColor: 'yellow', dim: false, color: 'yellow' },
|
|
29
|
+
overTextFullAttr: { bgColor: 'yellow', color: 'black', dim: false },
|
|
30
|
+
overTextEmptyAttr: {
|
|
31
|
+
bgColor: 'yellow',
|
|
32
|
+
color: 'black',
|
|
33
|
+
dim: false,
|
|
34
|
+
},
|
|
35
|
+
value: progress,
|
|
36
|
+
...barOptions,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
this.bar.__widget = this
|
|
40
|
+
this.calculateSizeLockDeltas()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public setProgress(progress: number): void {
|
|
44
|
+
this.bar.setValue(progress)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public setLabel(label?: string): void {
|
|
48
|
+
this.bar.setContent(label ? ` ${label}` : '')
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public getTermKitElement() {
|
|
52
|
+
return this.bar
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import terminal_kit from 'terminal-kit'
|
|
2
|
+
import { TextWidget, TextWidgetOptions } from './text.types.js'
|
|
3
|
+
import { WidgetFrame } from './widgets.types.js'
|
|
4
|
+
import widgetUtil from './widget.utilities.js'
|
|
5
|
+
import termKitUtil from './termKit.utility.js'
|
|
6
|
+
import TkBaseWidget, { TkWidgetOptions } from './TkBaseWidget.js'
|
|
7
|
+
const termKit = terminal_kit as any
|
|
8
|
+
|
|
9
|
+
export default class TkTextWidget extends TkBaseWidget implements TextWidget {
|
|
10
|
+
public readonly type = 'text'
|
|
11
|
+
|
|
12
|
+
private text: any
|
|
13
|
+
private shouldAutoScrollWhenAppendingContent: boolean
|
|
14
|
+
|
|
15
|
+
public constructor(options: TkWidgetOptions & TextWidgetOptions) {
|
|
16
|
+
super(options)
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
parent,
|
|
20
|
+
text,
|
|
21
|
+
isScrollEnabled: enableScroll = false,
|
|
22
|
+
shouldAutoScrollWhenAppendingContent = true,
|
|
23
|
+
...rest
|
|
24
|
+
} = options
|
|
25
|
+
|
|
26
|
+
this.shouldAutoScrollWhenAppendingContent =
|
|
27
|
+
shouldAutoScrollWhenAppendingContent
|
|
28
|
+
|
|
29
|
+
const frame = termKitUtil.buildFrame(options, parent)
|
|
30
|
+
|
|
31
|
+
this.text = new termKit.TextBox({
|
|
32
|
+
parent: parent ? parent.getTermKitElement() : undefined,
|
|
33
|
+
scrollable: enableScroll,
|
|
34
|
+
vScrollBar: enableScroll,
|
|
35
|
+
hScrollBar: enableScroll && !rest.wordWrap,
|
|
36
|
+
content: text,
|
|
37
|
+
wordWrap: true,
|
|
38
|
+
...termKitUtil.mapWidgetOptionsToTermKitOptions(rest),
|
|
39
|
+
...frame,
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
this.calculateSizeLockDeltas()
|
|
43
|
+
|
|
44
|
+
this.text.__widget = this
|
|
45
|
+
this.text.on('click', this.handleMouseDown.bind(this))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private async handleMouseDown(position: { x: number; y: number }) {
|
|
49
|
+
const { x, y } = position
|
|
50
|
+
|
|
51
|
+
const line = this.text.content.split('\n')[y]
|
|
52
|
+
|
|
53
|
+
await (this as TextWidget).emit('click', {
|
|
54
|
+
text: line,
|
|
55
|
+
row: y,
|
|
56
|
+
column: x,
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public getTermKitElement() {
|
|
61
|
+
return this.text
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public setFrame(frame: WidgetFrame) {
|
|
65
|
+
const oldFrame = this.getFrame()
|
|
66
|
+
const newFrame = widgetUtil.buildFrame(frame, this.parent)
|
|
67
|
+
|
|
68
|
+
this.text.setSizeAndPosition({
|
|
69
|
+
x: newFrame.left ?? oldFrame.left,
|
|
70
|
+
y: newFrame.top ?? oldFrame.top,
|
|
71
|
+
width: newFrame.width ?? oldFrame.width,
|
|
72
|
+
height: newFrame.height ?? oldFrame.height,
|
|
73
|
+
})
|
|
74
|
+
this.text.draw()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public getText(): string {
|
|
78
|
+
return this.text.content
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private isLogScrolledAllTheWay() {
|
|
82
|
+
const scrollDistance = this.getScrollY() * -1
|
|
83
|
+
const contentHeight = this.text.textBuffer.cy
|
|
84
|
+
const visibleHeight = this.text.textAreaHeight
|
|
85
|
+
const maxScrollDistance =
|
|
86
|
+
Math.max(contentHeight, visibleHeight) - visibleHeight
|
|
87
|
+
const isScrolledAllTheWay = scrollDistance >= maxScrollDistance
|
|
88
|
+
|
|
89
|
+
return isScrolledAllTheWay
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public getScrollY() {
|
|
93
|
+
return this.text.scrollY
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public getScrollX() {
|
|
97
|
+
return this.text.scrollX
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public setText(content: string): void {
|
|
101
|
+
if (this.getText() === content) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const isScrolledAllTheWay = this.isLogScrolledAllTheWay()
|
|
106
|
+
const markupType = this.markupType(content)
|
|
107
|
+
const normalizedContent =
|
|
108
|
+
markupType === 'ansi' ? this.padAnsiSegments(content) : content
|
|
109
|
+
|
|
110
|
+
this.text.setContent(normalizedContent, markupType)
|
|
111
|
+
|
|
112
|
+
if (this.shouldAutoScrollWhenAppendingContent && isScrolledAllTheWay) {
|
|
113
|
+
this.text.scrollToBottom()
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private markupType(content: string) {
|
|
118
|
+
const match = /\x1b\[[0-9;]+m/.exec(content)
|
|
119
|
+
const markupType = match ? 'ansi' : true
|
|
120
|
+
return markupType
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private padAnsiSegments(content: string): string {
|
|
124
|
+
const sgrPattern = /\[[0-9;]+m/g
|
|
125
|
+
let result = ''
|
|
126
|
+
let lastIndex = 0
|
|
127
|
+
|
|
128
|
+
let match: RegExpExecArray | null
|
|
129
|
+
|
|
130
|
+
while ((match = sgrPattern.exec(content))) {
|
|
131
|
+
const segment = content.slice(lastIndex, match.index)
|
|
132
|
+
if (segment) {
|
|
133
|
+
result += this.padSegment(segment)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
result += match[0]
|
|
137
|
+
lastIndex = match.index + match[0].length
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (lastIndex < content.length) {
|
|
141
|
+
result += this.padSegment(content.slice(lastIndex))
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return result
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private padSegment(segment: string): string {
|
|
148
|
+
if (segment.length !== 1) {
|
|
149
|
+
return segment
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (segment.trim().length > 0) {
|
|
153
|
+
return `${segment}`
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return segment
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import terminal_kit from 'terminal-kit'
|
|
2
|
+
import { Key } from './keySelectChoices.js'
|
|
3
|
+
import { BaseWidget } from './widgets.types.js'
|
|
4
|
+
import { WindowWidget, WindowWidgetOptions } from './window.types.js'
|
|
5
|
+
import TkBaseWidget, { TkWidgetOptions } from './TkBaseWidget.js'
|
|
6
|
+
const termKit = terminal_kit as any
|
|
7
|
+
|
|
8
|
+
export default class TkWindowWidget
|
|
9
|
+
extends TkBaseWidget
|
|
10
|
+
implements WindowWidget
|
|
11
|
+
{
|
|
12
|
+
public readonly type = 'window'
|
|
13
|
+
|
|
14
|
+
private document: any
|
|
15
|
+
|
|
16
|
+
public constructor(options: TkWidgetOptions & WindowWidgetOptions) {
|
|
17
|
+
super(options)
|
|
18
|
+
|
|
19
|
+
//@ts-ignore
|
|
20
|
+
this.document = this.term.createDocument({
|
|
21
|
+
palette: new termKit.Palette(),
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
this.document.eventSource.on('resize', async () => {
|
|
25
|
+
this.handleParentResize()
|
|
26
|
+
const frame = this.getFrame()
|
|
27
|
+
await (this as WindowWidget).emit('resize', {
|
|
28
|
+
width: frame.width,
|
|
29
|
+
height: frame.height,
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
this.document.__widget = this
|
|
34
|
+
|
|
35
|
+
options.term.on('key', this.handleKeyPress.bind(this))
|
|
36
|
+
|
|
37
|
+
process.on('exit', (code: number) => {
|
|
38
|
+
void (this as WindowWidget).emit('kill', { code })
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
process.on('SIGQUIT', (code: number) => {
|
|
42
|
+
void (this as WindowWidget).emit('kill', { code })
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
process.on('kill' as any, (code: number) => {
|
|
46
|
+
void (this as WindowWidget).emit('kill', { code })
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
process.on('SIGINT', (code: number) => {
|
|
50
|
+
void (this as WindowWidget).emit('kill', { code })
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
process.on('SIGTERM', (code: number) => {
|
|
54
|
+
void (this as WindowWidget).emit('kill', { code })
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
process.on('SIGUSR1', (code: number) => {
|
|
58
|
+
void (this as WindowWidget).emit('kill', { code })
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
process.on('SIGUSR2', (code: number) => {
|
|
62
|
+
void (this as WindowWidget).emit('kill', { code })
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
process.on('uncaughtException', (code: number) => {
|
|
66
|
+
void (this as WindowWidget).emit('kill', { code })
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public getFocusedWidget(): BaseWidget<any> | null {
|
|
71
|
+
return this.document.focusElement.__widget
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private async handleKeyPress(key: Key) {
|
|
75
|
+
await (this as WindowWidget).emit('key', { key })
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
protected handleParentResize() {
|
|
79
|
+
this.sizeLockedChildren()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public setTitle(title: string) {
|
|
83
|
+
this.term.windowTitle(title)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public hideCursor() {
|
|
87
|
+
this.term.hideCursor(true)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public showCursor() {
|
|
91
|
+
this.term.hideCursor(false)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public getFrame() {
|
|
95
|
+
return {
|
|
96
|
+
left: 0,
|
|
97
|
+
top: 0,
|
|
98
|
+
width: this.document.inputWidth,
|
|
99
|
+
height: this.document.inputHeight,
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public getTermKitElement() {
|
|
104
|
+
return this.document
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public async destroy() {
|
|
108
|
+
this.showCursor()
|
|
109
|
+
//@ts-ignore
|
|
110
|
+
this.term.removeAllListeners()
|
|
111
|
+
|
|
112
|
+
this.term.styleReset()
|
|
113
|
+
|
|
114
|
+
await this.term.grabInput(false, true)
|
|
115
|
+
|
|
116
|
+
this.document.destroy()
|
|
117
|
+
|
|
118
|
+
this.term.clear()
|
|
119
|
+
|
|
120
|
+
this.term(`\n`)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import terminal_kit, { Terminal } from 'terminal-kit'
|
|
2
|
+
import {
|
|
3
|
+
contractRegistry,
|
|
4
|
+
FactoryOptions,
|
|
5
|
+
widgetRegistry,
|
|
6
|
+
WidgetRegistry,
|
|
7
|
+
WidgetType,
|
|
8
|
+
} from './factory.types.js'
|
|
9
|
+
const termKit = terminal_kit as any
|
|
10
|
+
|
|
11
|
+
export default class WidgetFactory {
|
|
12
|
+
private term: Terminal
|
|
13
|
+
public constructor() {
|
|
14
|
+
this.term = termKit.terminal
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public Widget<T extends WidgetType>(
|
|
18
|
+
type: T,
|
|
19
|
+
options: FactoryOptions<T>
|
|
20
|
+
): WidgetRegistry[T] {
|
|
21
|
+
const Class = widgetRegistry[type]
|
|
22
|
+
|
|
23
|
+
//@ts-ignore
|
|
24
|
+
const instance = new Class({
|
|
25
|
+
...options,
|
|
26
|
+
term: this.term,
|
|
27
|
+
eventContract: contractRegistry[type] as any,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
//@ts-ignore
|
|
31
|
+
return instance
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseWidget } from './widgets.types.js'
|
|
2
|
+
|
|
3
|
+
export const buttonEventContract = {
|
|
4
|
+
eventSignatures: {
|
|
5
|
+
click: {},
|
|
6
|
+
},
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type ButtonEventContract = typeof buttonEventContract
|
|
10
|
+
|
|
11
|
+
export interface ButtonWidgetOptions {
|
|
12
|
+
text?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ButtonWidget extends BaseWidget<ButtonEventContract> {
|
|
16
|
+
readonly type: 'button'
|
|
17
|
+
getText(): string
|
|
18
|
+
setText(content: string): void
|
|
19
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const durationUtil = {
|
|
2
|
+
msToFriendly(duration: number): string {
|
|
3
|
+
let milliseconds = duration % 1000,
|
|
4
|
+
seconds = Math.floor((duration / 1000) % 60),
|
|
5
|
+
minutes = Math.floor((duration / (1000 * 60)) % 60),
|
|
6
|
+
hours = Math.floor((duration / (1000 * 60 * 60)) % 24)
|
|
7
|
+
|
|
8
|
+
let durationStr = ''
|
|
9
|
+
|
|
10
|
+
if (hours > 0) {
|
|
11
|
+
durationStr += `${hours}h `
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (hours > 0 || minutes > 0) {
|
|
15
|
+
durationStr += `${minutes}m `
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (durationStr.length > 0 || seconds > 0) {
|
|
19
|
+
durationStr += `${seconds}s `
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (hours === 0 && minutes === 0) {
|
|
23
|
+
if (seconds > 0) {
|
|
24
|
+
durationStr = `${seconds}.${milliseconds}s`
|
|
25
|
+
} else {
|
|
26
|
+
durationStr += `${milliseconds}ms`
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return durationStr.trim()
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default durationUtil
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import TKButtonWidget from './TKButtonWidget.js'
|
|
2
|
+
import TkInputWidget from './TkInputWidget.js'
|
|
3
|
+
import TkLayoutCellWidget from './TkLayoutCellWidget.js'
|
|
4
|
+
import TkLayoutWidget from './TkLayoutWidget.js'
|
|
5
|
+
import TkMenuBarWidget from './TkMenuBarWidget.js'
|
|
6
|
+
import TkPopupWidget from './TkPopupWidget.js'
|
|
7
|
+
import TkProgressBarWidget from './TkProgressBarWidget.js'
|
|
8
|
+
import TkTextWidget from './TkTextWidget.js'
|
|
9
|
+
import TkWindowWidget from './TkWindowWidget.js'
|
|
10
|
+
import {
|
|
11
|
+
buttonEventContract,
|
|
12
|
+
ButtonWidget,
|
|
13
|
+
ButtonWidgetOptions,
|
|
14
|
+
} from './button.types.js'
|
|
15
|
+
import {
|
|
16
|
+
inputEventContract,
|
|
17
|
+
InputWidget,
|
|
18
|
+
InputWidgetOptions,
|
|
19
|
+
} from './input.types.js'
|
|
20
|
+
import {
|
|
21
|
+
LayoutWidgetOptions,
|
|
22
|
+
LayoutWidget,
|
|
23
|
+
LayoutCellWidgetOptions,
|
|
24
|
+
LayoutCellWidget,
|
|
25
|
+
} from './layout.types.js'
|
|
26
|
+
import {
|
|
27
|
+
MenuBarWidgetOptions,
|
|
28
|
+
MenuBarWidget,
|
|
29
|
+
menuBarEventContract,
|
|
30
|
+
} from './menuBar.types.js'
|
|
31
|
+
import { PopupWidget, PopupWidgetOptions } from './popup.types.js'
|
|
32
|
+
import {
|
|
33
|
+
ProgressBarWidgetOptions,
|
|
34
|
+
ProgressBarWidget,
|
|
35
|
+
} from './progressBar.types.js'
|
|
36
|
+
import {
|
|
37
|
+
TextWidgetOptions,
|
|
38
|
+
TextWidget,
|
|
39
|
+
textEventContract,
|
|
40
|
+
} from './text.types.js'
|
|
41
|
+
import { UniversalWidgetOptions } from './widgets.types.js'
|
|
42
|
+
import {
|
|
43
|
+
WindowWidgetOptions,
|
|
44
|
+
WindowWidget,
|
|
45
|
+
windowEventContract,
|
|
46
|
+
} from './window.types.js'
|
|
47
|
+
|
|
48
|
+
export type WidgetType = keyof WidgetRegistry
|
|
49
|
+
|
|
50
|
+
export type Widget<T extends WidgetType = WidgetType> = WidgetRegistry[T]
|
|
51
|
+
|
|
52
|
+
export type FactoryOptions<T extends WidgetType> = UniversalWidgetOptions &
|
|
53
|
+
OptionsMap[T]
|
|
54
|
+
|
|
55
|
+
interface OptionsMap {
|
|
56
|
+
text: TextWidgetOptions
|
|
57
|
+
window: WindowWidgetOptions
|
|
58
|
+
layout: LayoutWidgetOptions
|
|
59
|
+
layoutCell: LayoutCellWidgetOptions
|
|
60
|
+
progressBar: ProgressBarWidgetOptions
|
|
61
|
+
menuBar: MenuBarWidgetOptions
|
|
62
|
+
popup: PopupWidgetOptions
|
|
63
|
+
button: ButtonWidgetOptions
|
|
64
|
+
input: InputWidgetOptions
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface WidgetRegistry {
|
|
68
|
+
text: TextWidget
|
|
69
|
+
window: WindowWidget
|
|
70
|
+
layout: LayoutWidget
|
|
71
|
+
layoutCell: LayoutCellWidget
|
|
72
|
+
progressBar: ProgressBarWidget
|
|
73
|
+
menuBar: MenuBarWidget
|
|
74
|
+
popup: PopupWidget
|
|
75
|
+
button: ButtonWidget
|
|
76
|
+
input: InputWidget
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const widgetRegistry = {
|
|
80
|
+
window: TkWindowWidget,
|
|
81
|
+
text: TkTextWidget,
|
|
82
|
+
layout: TkLayoutWidget,
|
|
83
|
+
layoutCell: TkLayoutCellWidget,
|
|
84
|
+
progressBar: TkProgressBarWidget,
|
|
85
|
+
menuBar: TkMenuBarWidget,
|
|
86
|
+
popup: TkPopupWidget,
|
|
87
|
+
button: TKButtonWidget,
|
|
88
|
+
input: TkInputWidget,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const contractRegistry = {
|
|
92
|
+
window: windowEventContract,
|
|
93
|
+
text: textEventContract,
|
|
94
|
+
layout: null,
|
|
95
|
+
layoutCell: null,
|
|
96
|
+
progressBar: null,
|
|
97
|
+
menuBar: menuBarEventContract,
|
|
98
|
+
popup: null,
|
|
99
|
+
button: buttonEventContract,
|
|
100
|
+
input: inputEventContract,
|
|
101
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseWidget } from './widgets.types.js'
|
|
2
|
+
|
|
3
|
+
export const inputEventContract = {
|
|
4
|
+
eventSignatures: {
|
|
5
|
+
submit: {},
|
|
6
|
+
cancel: {},
|
|
7
|
+
},
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type InputEventContract = typeof inputEventContract
|
|
11
|
+
|
|
12
|
+
export interface InputWidgetOptions {
|
|
13
|
+
value?: string
|
|
14
|
+
label?: string
|
|
15
|
+
placeholder?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface InputWidget extends BaseWidget<InputEventContract> {
|
|
19
|
+
readonly type: 'input'
|
|
20
|
+
getValue(): string | undefined
|
|
21
|
+
setValue(value: string): void
|
|
22
|
+
}
|