freewind-ts-utils 0.18.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/README.md +60 -0
- package/antd/CopyButton/CopyButton.d.ts +7 -0
- package/antd/CopyButton/CopyButton.js +29 -0
- package/antd/CopyButton/index.d.ts +1 -0
- package/antd/CopyButton/index.js +2 -0
- package/antd/FloatLabel/FloatLabel.css +18 -0
- package/antd/FloatLabel/FloatLabel.d.ts +8 -0
- package/antd/FloatLabel/FloatLabel.js +50 -0
- package/antd/FloatLabel/index.d.ts +1 -0
- package/antd/FloatLabel/index.js +2 -0
- package/antd/FuzzyAutoComplete/FuzzyAutoComplete.d.ts +17 -0
- package/antd/FuzzyAutoComplete/FuzzyAutoComplete.js +73 -0
- package/antd/FuzzyAutoComplete/index.d.ts +1 -0
- package/antd/FuzzyAutoComplete/index.js +2 -0
- package/antd/FuzzyPathSelect/FuzzyPathSelect.d.ts +8 -0
- package/antd/FuzzyPathSelect/FuzzyPathSelect.js +48 -0
- package/antd/FuzzyPathSelect/defaultIgnoreNames.d.ts +1 -0
- package/antd/FuzzyPathSelect/defaultIgnoreNames.js +28 -0
- package/antd/FuzzyPathSelect/index.d.ts +1 -0
- package/antd/FuzzyPathSelect/index.js +2 -0
- package/antd/FuzzyStringSelect/FuzzyStringSelect.d.ts +6 -0
- package/antd/FuzzyStringSelect/FuzzyStringSelect.js +12 -0
- package/antd/FuzzyStringSelect/index.d.ts +1 -0
- package/antd/FuzzyStringSelect/index.js +2 -0
- package/antd/HoverSwap/HoverSwap.css +3 -0
- package/antd/HoverSwap/HoverSwap.d.ts +8 -0
- package/antd/HoverSwap/HoverSwap.js +18 -0
- package/antd/HoverSwap/index.d.ts +1 -0
- package/antd/HoverSwap/index.js +2 -0
- package/antd/InputLabel/InputLabel.css +10 -0
- package/antd/InputLabel/InputLabel.d.ts +4 -0
- package/antd/InputLabel/InputLabel.js +11 -0
- package/antd/InputLabel/index.d.ts +1 -0
- package/antd/InputLabel/index.js +2 -0
- package/antd/JsonPreviewer/JsonPreviewer.css +74 -0
- package/antd/JsonPreviewer/JsonPreviewer.d.ts +11 -0
- package/antd/JsonPreviewer/JsonPreviewer.js +69 -0
- package/antd/JsonPreviewer/index.d.ts +1 -0
- package/antd/JsonPreviewer/index.js +2 -0
- package/antd/_internal/HighlightParts.d.ts +6 -0
- package/antd/_internal/HighlightParts.js +12 -0
- package/antd/index.d.ts +8 -0
- package/antd/index.js +17 -0
- package/common/SimpleType.d.ts +2 -0
- package/common/SimpleType.js +0 -0
- package/common/_internal/createObjectReferenceTracker.d.ts +5 -0
- package/common/_internal/createObjectReferenceTracker.js +11 -0
- package/common/anyToString/anyToString.d.ts +27 -0
- package/common/anyToString/anyToString.js +23 -0
- package/common/anyToString/createCircularStackTracker.d.ts +5 -0
- package/common/anyToString/createCircularStackTracker.js +14 -0
- package/common/anyToString/formatters/formatArray.d.ts +2 -0
- package/common/anyToString/formatters/formatArray.js +11 -0
- package/common/anyToString/formatters/formatArrayBufferView.d.ts +2 -0
- package/common/anyToString/formatters/formatArrayBufferView.js +14 -0
- package/common/anyToString/formatters/formatDocumentObject.d.ts +1 -0
- package/common/anyToString/formatters/formatDocumentObject.js +7 -0
- package/common/anyToString/formatters/formatElementObject.d.ts +1 -0
- package/common/anyToString/formatters/formatElementObject.js +15 -0
- package/common/anyToString/formatters/formatError.d.ts +1 -0
- package/common/anyToString/formatters/formatError.js +7 -0
- package/common/anyToString/formatters/formatFunction.d.ts +1 -0
- package/common/anyToString/formatters/formatFunction.js +6 -0
- package/common/anyToString/formatters/formatMap.d.ts +2 -0
- package/common/anyToString/formatters/formatMap.js +17 -0
- package/common/anyToString/formatters/formatObject.d.ts +2 -0
- package/common/anyToString/formatters/formatObject.js +44 -0
- package/common/anyToString/formatters/formatObjectKey.d.ts +1 -0
- package/common/anyToString/formatters/formatObjectKey.js +8 -0
- package/common/anyToString/formatters/formatRecordLike.d.ts +2 -0
- package/common/anyToString/formatters/formatRecordLike.js +39 -0
- package/common/anyToString/formatters/formatSet.d.ts +2 -0
- package/common/anyToString/formatters/formatSet.js +17 -0
- package/common/anyToString/formatters/formatString.d.ts +1 -0
- package/common/anyToString/formatters/formatString.js +8 -0
- package/common/anyToString/formatters/formatValue.d.ts +11 -0
- package/common/anyToString/formatters/formatValue.js +20 -0
- package/common/anyToString/formatters/formatWindowObject.d.ts +1 -0
- package/common/anyToString/formatters/formatWindowObject.js +6 -0
- package/common/anyToString/formatters/getConstructorName.d.ts +1 -0
- package/common/anyToString/formatters/getConstructorName.js +7 -0
- package/common/anyToString/formatters/joinBlock.d.ts +1 -0
- package/common/anyToString/formatters/joinBlock.js +9 -0
- package/common/anyToString/formatters/withCircularGuard.d.ts +2 -0
- package/common/anyToString/formatters/withCircularGuard.js +11 -0
- package/common/anyToString/index.d.ts +1 -0
- package/common/anyToString/index.js +2 -0
- package/common/assertsType.d.ts +12 -0
- package/common/assertsType.js +4 -0
- package/common/buildSequence.d.ts +6 -0
- package/common/buildSequence.js +8 -0
- package/common/deepClone.d.ts +12 -0
- package/common/deepClone.js +55 -0
- package/common/deepEqual.d.ts +12 -0
- package/common/deepEqual.js +46 -0
- package/common/deepParseJsonStrings.d.ts +1 -0
- package/common/deepParseJsonStrings.js +22 -0
- package/common/dependsOn.d.ts +12 -0
- package/common/dependsOn.js +4 -0
- package/common/doExpr.d.ts +14 -0
- package/common/doExpr.js +6 -0
- package/common/flatChildren.d.ts +1 -0
- package/common/flatChildren.js +14 -0
- package/common/formatDecimal.d.ts +12 -0
- package/common/formatDecimal.js +11 -0
- package/common/formatFriendlyTime.d.ts +1 -0
- package/common/formatFriendlyTime.js +10 -0
- package/common/formatSize.d.ts +13 -0
- package/common/formatSize.js +19 -0
- package/common/fuzzy/fuzzyMatch.d.ts +25 -0
- package/common/fuzzy/fuzzyMatch.js +19 -0
- package/common/fuzzy/fuzzyMatchPath.d.ts +23 -0
- package/common/fuzzy/fuzzyMatchPath.js +102 -0
- package/common/fuzzy/types.d.ts +10 -0
- package/common/fuzzy/types.js +0 -0
- package/common/fuzzy/utils/buildHighlightParts.d.ts +4 -0
- package/common/fuzzy/utils/buildHighlightParts.js +21 -0
- package/common/fuzzy/utils/buildHighlightRanges.d.ts +1 -0
- package/common/fuzzy/utils/buildHighlightRanges.js +20 -0
- package/common/fuzzy/utils/index.d.ts +5 -0
- package/common/fuzzy/utils/index.js +6 -0
- package/common/fuzzy/utils/normalizePathSeparators.d.ts +1 -0
- package/common/fuzzy/utils/normalizePathSeparators.js +7 -0
- package/common/fuzzy/utils/rankFuzzyCandidates.d.ts +2 -0
- package/common/fuzzy/utils/rankFuzzyCandidates.js +26 -0
- package/common/fuzzy/utils/scoreLooseFuzzyMatch.d.ts +2 -0
- package/common/fuzzy/utils/scoreLooseFuzzyMatch.js +126 -0
- package/common/getEnumerableOwnDescriptors.d.ts +1 -0
- package/common/getEnumerableOwnDescriptors.js +11 -0
- package/common/index.d.ts +49 -0
- package/common/index.js +48 -0
- package/common/isEmptyRecord.d.ts +10 -0
- package/common/isEmptyRecord.js +7 -0
- package/common/isNil.d.ts +13 -0
- package/common/isNil.js +6 -0
- package/common/isNonNil.d.ts +11 -0
- package/common/isNonNil.js +6 -0
- package/common/isRecord.d.ts +12 -0
- package/common/isRecord.js +8 -0
- package/common/jsonRecord/filterJsonRecord.d.ts +16 -0
- package/common/jsonRecord/filterJsonRecord.js +19 -0
- package/common/jsonRecord/isJsonRecord.d.ts +16 -0
- package/common/jsonRecord/isJsonRecord.js +16 -0
- package/common/jsonRecord/jsonRecordDiff.d.ts +13 -0
- package/common/jsonRecord/jsonRecordDiff.js +26 -0
- package/common/jsonRecord/mapJsonRecord.d.ts +13 -0
- package/common/jsonRecord/mapJsonRecord.js +14 -0
- package/common/jsonRecord/modifyJsonRecord.d.ts +14 -0
- package/common/jsonRecord/modifyJsonRecord.js +24 -0
- package/common/jsonRecord/walkJsonRecord.d.ts +15 -0
- package/common/jsonRecord/walkJsonRecord.js +16 -0
- package/common/onlyUnique.d.ts +10 -0
- package/common/onlyUnique.js +6 -0
- package/common/pipe.d.ts +9 -0
- package/common/pipe.js +6 -0
- package/common/pipeNonNil.d.ts +16 -0
- package/common/pipeNonNil.js +7 -0
- package/common/safeJsonStringify.d.ts +28 -0
- package/common/safeJsonStringify.js +105 -0
- package/common/simpleInt/isSimpleInt.d.ts +6 -0
- package/common/simpleInt/isSimpleInt.js +6 -0
- package/common/simpleInt/isSimpleIntInputing.d.ts +6 -0
- package/common/simpleInt/isSimpleIntInputing.js +7 -0
- package/common/simpleInt/isSimpleNumber.d.ts +10 -0
- package/common/simpleInt/isSimpleNumber.js +6 -0
- package/common/simpleInt/isSimpleNumberInputing.d.ts +6 -0
- package/common/simpleInt/isSimpleNumberInputing.js +7 -0
- package/common/simpleInt/parseSimpleInt.d.ts +6 -0
- package/common/simpleInt/parseSimpleInt.js +11 -0
- package/common/simpleInt/parseSimpleIntOrNil.d.ts +6 -0
- package/common/simpleInt/parseSimpleIntOrNil.js +9 -0
- package/common/simpleInt/parseSimpleNumber.d.ts +6 -0
- package/common/simpleInt/parseSimpleNumber.js +11 -0
- package/common/simpleInt/parseSimpleNumberOrNil.d.ts +4 -0
- package/common/simpleInt/parseSimpleNumberOrNil.js +7 -0
- package/common/tap.d.ts +9 -0
- package/common/tap.js +6 -0
- package/common/tree/buildTree.d.ts +6 -0
- package/common/tree/buildTree.js +13 -0
- package/common/tree/flatTree.d.ts +2 -0
- package/common/tree/flatTree.js +7 -0
- package/common/tree/mapTree.d.ts +2 -0
- package/common/tree/mapTree.js +11 -0
- package/common/tree/pruneTree.d.ts +2 -0
- package/common/tree/pruneTree.js +15 -0
- package/common/tree/sortTree.d.ts +2 -0
- package/common/tree/sortTree.js +11 -0
- package/common/tree/treeToArray.d.ts +2 -0
- package/common/tree/treeToArray.js +12 -0
- package/common/tree/treeToRows.d.ts +5 -0
- package/common/tree/treeToRows.js +19 -0
- package/common/tree/treeTypes.d.ts +7 -0
- package/common/tree/treeTypes.js +0 -0
- package/common/tree/walkTree.d.ts +2 -0
- package/common/tree/walkTree.js +13 -0
- package/common/truncateJsonStrings.d.ts +14 -0
- package/common/truncateJsonStrings.js +7 -0
- package/common/truncateString.d.ts +13 -0
- package/common/truncateString.js +7 -0
- package/common/tryParsePartialJson.d.ts +11 -0
- package/common/tryParsePartialJson.js +156 -0
- package/eslint-config/eslintPreset.d.ts +2 -0
- package/eslint-config/eslintPreset.js +36 -0
- package/eslint-config/index.d.ts +14 -0
- package/eslint-config/index.js +20 -0
- package/eslint-config/layers/configLayer.d.ts +2 -0
- package/eslint-config/layers/configLayer.js +16 -0
- package/eslint-config/layers/jsLayer.d.ts +2 -0
- package/eslint-config/layers/jsLayer.js +20 -0
- package/eslint-config/layers/prettierLayer.d.ts +5 -0
- package/eslint-config/layers/prettierLayer.js +5 -0
- package/eslint-config/layers/reactHookLayer.d.ts +2 -0
- package/eslint-config/layers/reactHookLayer.js +16 -0
- package/eslint-config/layers/testLayer.d.ts +2 -0
- package/eslint-config/layers/testLayer.js +46 -0
- package/eslint-config/layers/tsLayer.d.ts +2 -0
- package/eslint-config/layers/tsLayer.js +70 -0
- package/eslint-config/plugins/freewindSingleExportPlugin.d.ts +2 -0
- package/eslint-config/plugins/freewindSingleExportPlugin.js +47 -0
- package/eslint-config/utils/withRuleOverrides.d.ts +2 -0
- package/eslint-config/utils/withRuleOverrides.js +9 -0
- package/index.d.ts +1 -0
- package/index.js +49 -0
- package/node/index.d.ts +2 -0
- package/node/index.js +3 -0
- package/node/md5.d.ts +11 -0
- package/node/md5.js +7 -0
- package/node/uuid.d.ts +11 -0
- package/node/uuid.js +7 -0
- package/package.json +115 -0
- package/prettier-config/freewindPrettierPreset.d.ts +2 -0
- package/prettier-config/freewindPrettierPreset.js +4 -0
- package/prettier-config/index.d.ts +1 -0
- package/prettier-config/index.js +2 -0
- package/react/hooks/useCopyToClipboard.d.ts +10 -0
- package/react/hooks/useCopyToClipboard.js +28 -0
- package/react/hooks/useDeepCompareSelector.d.ts +23 -0
- package/react/hooks/useDeepCompareSelector.js +14 -0
- package/react/hooks/useInputEvent/_internal/ink-input/index.d.ts +2 -0
- package/react/hooks/useInputEvent/_internal/ink-input/index.js +3 -0
- package/react/hooks/useInputEvent/_internal/ink-input/input-parser.d.ts +6 -0
- package/react/hooks/useInputEvent/_internal/ink-input/input-parser.js +98 -0
- package/react/hooks/useInputEvent/_internal/ink-input/kitty-keyboard.d.ts +19 -0
- package/react/hooks/useInputEvent/_internal/ink-input/kitty-keyboard.js +13 -0
- package/react/hooks/useInputEvent/_internal/ink-input/parse-keypress.d.ts +33 -0
- package/react/hooks/useInputEvent/_internal/ink-input/parse-keypress.js +319 -0
- package/react/hooks/useInputEvent/formatInputEvent.d.ts +2 -0
- package/react/hooks/useInputEvent/formatInputEvent.js +25 -0
- package/react/hooks/useInputEvent/index.d.ts +4 -0
- package/react/hooks/useInputEvent/index.js +4 -0
- package/react/hooks/useInputEvent/inputEventTypes.d.ts +51 -0
- package/react/hooks/useInputEvent/inputEventTypes.js +0 -0
- package/react/hooks/useInputEvent/parseInputEvent.d.ts +4 -0
- package/react/hooks/useInputEvent/parseInputEvent.js +100 -0
- package/react/hooks/useInputEvent/useInputEvent.d.ts +7 -0
- package/react/hooks/useInputEvent/useInputEvent.js +57 -0
- package/react/hooks/useOverlayStack/_internal/overlayStackId.d.ts +2 -0
- package/react/hooks/useOverlayStack/_internal/overlayStackId.js +6 -0
- package/react/hooks/useOverlayStack/createOverlayStackItem.d.ts +2 -0
- package/react/hooks/useOverlayStack/createOverlayStackItem.js +10 -0
- package/react/hooks/useOverlayStack/index.d.ts +3 -0
- package/react/hooks/useOverlayStack/index.js +3 -0
- package/react/hooks/useOverlayStack/overlayStackTypes.d.ts +13 -0
- package/react/hooks/useOverlayStack/overlayStackTypes.js +0 -0
- package/react/hooks/useOverlayStack/useOverlayStack.d.ts +2 -0
- package/react/hooks/useOverlayStack/useOverlayStack.js +24 -0
- package/react/index.d.ts +4 -0
- package/react/index.js +10 -0
- package/react/ink-components/InkModal/InkModal.d.ts +3 -0
- package/react/ink-components/InkModal/InkModal.js +101 -0
- package/react/ink-components/InkModal/index.d.ts +4 -0
- package/react/ink-components/InkModal/index.js +4 -0
- package/react/ink-components/InkModal/types.d.ts +24 -0
- package/react/ink-components/InkModal/types.js +0 -0
- package/react/ink-components/InkModal/utils/computeInkModalBodyMaxHeight.d.ts +1 -0
- package/react/ink-components/InkModal/utils/computeInkModalBodyMaxHeight.js +4 -0
- package/react/ink-components/InkModal/utils/resolveInkModalSize.d.ts +6 -0
- package/react/ink-components/InkModal/utils/resolveInkModalSize.js +7 -0
- package/react/ink-components/InkMultiSelect/InkMultiSelect.d.ts +22 -0
- package/react/ink-components/InkMultiSelect/InkMultiSelect.js +94 -0
- package/react/ink-components/InkMultiSelect/InkMultiSelectRow.d.ts +10 -0
- package/react/ink-components/InkMultiSelect/InkMultiSelectRow.js +35 -0
- package/react/ink-components/InkMultiSelect/index.d.ts +8 -0
- package/react/ink-components/InkMultiSelect/index.js +9 -0
- package/react/ink-components/InkMultiSelect/inkMultiSelectKeyboard.d.ts +17 -0
- package/react/ink-components/InkMultiSelect/inkMultiSelectKeyboard.js +19 -0
- package/react/ink-components/InkMultiSelect/types.d.ts +20 -0
- package/react/ink-components/InkMultiSelect/types.js +18 -0
- package/react/ink-components/InkMultiSelect/useInkMultiSelectNavigation.d.ts +10 -0
- package/react/ink-components/InkMultiSelect/useInkMultiSelectNavigation.js +40 -0
- package/react/ink-components/InkMultiSelect/utils/clampListScrollOffset.d.ts +1 -0
- package/react/ink-components/InkMultiSelect/utils/clampListScrollOffset.js +6 -0
- package/react/ink-components/InkMultiSelect/utils/formatMoreLabel.d.ts +1 -0
- package/react/ink-components/InkMultiSelect/utils/formatMoreLabel.js +6 -0
- package/react/ink-components/InkMultiSelect/utils/inkMultiSelectVisibleCount.d.ts +2 -0
- package/react/ink-components/InkMultiSelect/utils/inkMultiSelectVisibleCount.js +7 -0
- package/react/ink-components/InkScrollView/InkScrollView.d.ts +19 -0
- package/react/ink-components/InkScrollView/InkScrollView.js +103 -0
- package/react/ink-components/InkScrollView/Scrollbar.d.ts +7 -0
- package/react/ink-components/InkScrollView/Scrollbar.js +16 -0
- package/react/ink-components/InkScrollView/index.d.ts +9 -0
- package/react/ink-components/InkScrollView/index.js +18 -0
- package/react/ink-components/InkScrollView/utils/applyInkScrollInput.d.ts +10 -0
- package/react/ink-components/InkScrollView/utils/applyInkScrollInput.js +57 -0
- package/react/ink-components/InkScrollView/utils/bounds/getAbsoluteBounds.d.ts +7 -0
- package/react/ink-components/InkScrollView/utils/bounds/getAbsoluteBounds.js +19 -0
- package/react/ink-components/InkScrollView/utils/bounds/index.d.ts +3 -0
- package/react/ink-components/InkScrollView/utils/bounds/index.js +4 -0
- package/react/ink-components/InkScrollView/utils/bounds/isInside.d.ts +2 -0
- package/react/ink-components/InkScrollView/utils/bounds/isInside.js +7 -0
- package/react/ink-components/InkScrollView/utils/bounds/rowInViewport.d.ts +2 -0
- package/react/ink-components/InkScrollView/utils/bounds/rowInViewport.js +4 -0
- package/react/ink-components/InkScrollView/utils/inkScrollInputTarget.d.ts +11 -0
- package/react/ink-components/InkScrollView/utils/inkScrollInputTarget.js +0 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/allocateHeights.d.ts +6 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/allocateHeights.js +29 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/clampOffset.d.ts +1 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/clampOffset.js +7 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/computeScrollbarThumb.d.ts +5 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/computeScrollbarThumb.js +14 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/index.d.ts +10 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/index.js +11 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/offsetFromScrollbarClick.d.ts +1 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/offsetFromScrollbarClick.js +12 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/offsetFromScrollbarDrag.d.ts +1 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/offsetFromScrollbarDrag.js +8 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/resolveNextStickToBottomOffset.d.ts +8 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/resolveNextStickToBottomOffset.js +10 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByInputEventKey.d.ts +1 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByInputEventKey.js +15 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByKey.d.ts +9 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByKey.js +7 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByWheel.d.ts +2 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByWheel.js +8 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/stickToBottomOffset.d.ts +1 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/stickToBottomOffset.js +4 -0
- package/react/ink-components/InkScrollView/utils/useInkScrollInput.d.ts +10 -0
- package/react/ink-components/InkScrollView/utils/useInkScrollInput.js +17 -0
- package/react/ink-components/InkTimer/InkTimer.d.ts +9 -0
- package/react/ink-components/InkTimer/InkTimer.js +26 -0
- package/react/ink-components/InkTimer/index.d.ts +1 -0
- package/react/ink-components/InkTimer/index.js +2 -0
- package/react/ink-components/index.d.ts +4 -0
- package/react/ink-components/index.js +34 -0
- package/vite-plugins/fileLinePlaceholderPlugin.d.ts +26 -0
- package/vite-plugins/fileLinePlaceholderPlugin.js +57 -0
- package/vite-plugins/index.d.ts +1 -0
- package/vite-plugins/index.js +2 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const nonAlphanumericKeys: string[];
|
|
2
|
+
export default parseKeypress;
|
|
3
|
+
declare function parseKeypress(s?: string): {
|
|
4
|
+
eventType: string;
|
|
5
|
+
sequence: any;
|
|
6
|
+
raw: any;
|
|
7
|
+
isKittyProtocol: boolean;
|
|
8
|
+
isPrintable: boolean;
|
|
9
|
+
ctrl: boolean;
|
|
10
|
+
shift: boolean;
|
|
11
|
+
meta: boolean;
|
|
12
|
+
super: boolean;
|
|
13
|
+
hyper: boolean;
|
|
14
|
+
capsLock: boolean;
|
|
15
|
+
numLock: boolean;
|
|
16
|
+
name: any;
|
|
17
|
+
} | {
|
|
18
|
+
name: string;
|
|
19
|
+
ctrl: boolean;
|
|
20
|
+
meta: boolean;
|
|
21
|
+
shift: boolean;
|
|
22
|
+
sequence: string;
|
|
23
|
+
raw: string;
|
|
24
|
+
} | {
|
|
25
|
+
name: string;
|
|
26
|
+
ctrl: boolean;
|
|
27
|
+
meta: boolean;
|
|
28
|
+
shift: boolean;
|
|
29
|
+
sequence: string;
|
|
30
|
+
raw: string;
|
|
31
|
+
isKittyProtocol: boolean;
|
|
32
|
+
isPrintable: boolean;
|
|
33
|
+
};
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { kittyModifiers as e } from "./kitty-keyboard.js";
|
|
2
|
+
//#region src/react/hooks/useInputEvent/_internal/ink-input/parse-keypress.js
|
|
3
|
+
var t = new TextDecoder(), n = /^(?:\x1b)([a-zA-Z0-9])$/, r = /^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/, i = {
|
|
4
|
+
OP: "f1",
|
|
5
|
+
OQ: "f2",
|
|
6
|
+
OR: "f3",
|
|
7
|
+
OS: "f4",
|
|
8
|
+
"[P": "f1",
|
|
9
|
+
"[Q": "f2",
|
|
10
|
+
"[R": "f3",
|
|
11
|
+
"[S": "f4",
|
|
12
|
+
"[11~": "f1",
|
|
13
|
+
"[12~": "f2",
|
|
14
|
+
"[13~": "f3",
|
|
15
|
+
"[14~": "f4",
|
|
16
|
+
"[[A": "f1",
|
|
17
|
+
"[[B": "f2",
|
|
18
|
+
"[[C": "f3",
|
|
19
|
+
"[[D": "f4",
|
|
20
|
+
"[[E": "f5",
|
|
21
|
+
"[15~": "f5",
|
|
22
|
+
"[17~": "f6",
|
|
23
|
+
"[18~": "f7",
|
|
24
|
+
"[19~": "f8",
|
|
25
|
+
"[20~": "f9",
|
|
26
|
+
"[21~": "f10",
|
|
27
|
+
"[23~": "f11",
|
|
28
|
+
"[24~": "f12",
|
|
29
|
+
"[A": "up",
|
|
30
|
+
"[B": "down",
|
|
31
|
+
"[C": "right",
|
|
32
|
+
"[D": "left",
|
|
33
|
+
"[E": "clear",
|
|
34
|
+
"[F": "end",
|
|
35
|
+
"[H": "home",
|
|
36
|
+
OA: "up",
|
|
37
|
+
OB: "down",
|
|
38
|
+
OC: "right",
|
|
39
|
+
OD: "left",
|
|
40
|
+
OE: "clear",
|
|
41
|
+
OF: "end",
|
|
42
|
+
OH: "home",
|
|
43
|
+
"[1~": "home",
|
|
44
|
+
"[2~": "insert",
|
|
45
|
+
"[3~": "delete",
|
|
46
|
+
"[4~": "end",
|
|
47
|
+
"[5~": "pageup",
|
|
48
|
+
"[6~": "pagedown",
|
|
49
|
+
"[[5~": "pageup",
|
|
50
|
+
"[[6~": "pagedown",
|
|
51
|
+
"[7~": "home",
|
|
52
|
+
"[8~": "end",
|
|
53
|
+
"[a": "up",
|
|
54
|
+
"[b": "down",
|
|
55
|
+
"[c": "right",
|
|
56
|
+
"[d": "left",
|
|
57
|
+
"[e": "clear",
|
|
58
|
+
"[2$": "insert",
|
|
59
|
+
"[3$": "delete",
|
|
60
|
+
"[5$": "pageup",
|
|
61
|
+
"[6$": "pagedown",
|
|
62
|
+
"[7$": "home",
|
|
63
|
+
"[8$": "end",
|
|
64
|
+
Oa: "up",
|
|
65
|
+
Ob: "down",
|
|
66
|
+
Oc: "right",
|
|
67
|
+
Od: "left",
|
|
68
|
+
Oe: "clear",
|
|
69
|
+
"[2^": "insert",
|
|
70
|
+
"[3^": "delete",
|
|
71
|
+
"[5^": "pageup",
|
|
72
|
+
"[6^": "pagedown",
|
|
73
|
+
"[7^": "home",
|
|
74
|
+
"[8^": "end",
|
|
75
|
+
"[Z": "tab"
|
|
76
|
+
}, a = [...Object.values(i), "backspace"], o = (e) => [
|
|
77
|
+
"[a",
|
|
78
|
+
"[b",
|
|
79
|
+
"[c",
|
|
80
|
+
"[d",
|
|
81
|
+
"[e",
|
|
82
|
+
"[2$",
|
|
83
|
+
"[3$",
|
|
84
|
+
"[5$",
|
|
85
|
+
"[6$",
|
|
86
|
+
"[7$",
|
|
87
|
+
"[8$",
|
|
88
|
+
"[Z"
|
|
89
|
+
].includes(e), s = (e) => [
|
|
90
|
+
"Oa",
|
|
91
|
+
"Ob",
|
|
92
|
+
"Oc",
|
|
93
|
+
"Od",
|
|
94
|
+
"Oe",
|
|
95
|
+
"[2^",
|
|
96
|
+
"[3^",
|
|
97
|
+
"[5^",
|
|
98
|
+
"[6^",
|
|
99
|
+
"[7^",
|
|
100
|
+
"[8^"
|
|
101
|
+
].includes(e), c = /^\x1b\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/, l = /^\x1b\[(\d+);(\d+):(\d+)([A-Za-z~])$/, u = {
|
|
102
|
+
A: "up",
|
|
103
|
+
B: "down",
|
|
104
|
+
C: "right",
|
|
105
|
+
D: "left",
|
|
106
|
+
E: "clear",
|
|
107
|
+
F: "end",
|
|
108
|
+
H: "home",
|
|
109
|
+
P: "f1",
|
|
110
|
+
Q: "f2",
|
|
111
|
+
R: "f3",
|
|
112
|
+
S: "f4"
|
|
113
|
+
}, d = {
|
|
114
|
+
2: "insert",
|
|
115
|
+
3: "delete",
|
|
116
|
+
5: "pageup",
|
|
117
|
+
6: "pagedown",
|
|
118
|
+
7: "home",
|
|
119
|
+
8: "end",
|
|
120
|
+
11: "f1",
|
|
121
|
+
12: "f2",
|
|
122
|
+
13: "f3",
|
|
123
|
+
14: "f4",
|
|
124
|
+
15: "f5",
|
|
125
|
+
17: "f6",
|
|
126
|
+
18: "f7",
|
|
127
|
+
19: "f8",
|
|
128
|
+
20: "f9",
|
|
129
|
+
21: "f10",
|
|
130
|
+
23: "f11",
|
|
131
|
+
24: "f12"
|
|
132
|
+
}, f = {
|
|
133
|
+
27: "escape",
|
|
134
|
+
9: "tab",
|
|
135
|
+
127: "backspace",
|
|
136
|
+
8: "backspace",
|
|
137
|
+
57358: "capslock",
|
|
138
|
+
57359: "scrolllock",
|
|
139
|
+
57360: "numlock",
|
|
140
|
+
57361: "printscreen",
|
|
141
|
+
57362: "pause",
|
|
142
|
+
57363: "menu",
|
|
143
|
+
57376: "f13",
|
|
144
|
+
57377: "f14",
|
|
145
|
+
57378: "f15",
|
|
146
|
+
57379: "f16",
|
|
147
|
+
57380: "f17",
|
|
148
|
+
57381: "f18",
|
|
149
|
+
57382: "f19",
|
|
150
|
+
57383: "f20",
|
|
151
|
+
57384: "f21",
|
|
152
|
+
57385: "f22",
|
|
153
|
+
57386: "f23",
|
|
154
|
+
57387: "f24",
|
|
155
|
+
57388: "f25",
|
|
156
|
+
57389: "f26",
|
|
157
|
+
57390: "f27",
|
|
158
|
+
57391: "f28",
|
|
159
|
+
57392: "f29",
|
|
160
|
+
57393: "f30",
|
|
161
|
+
57394: "f31",
|
|
162
|
+
57395: "f32",
|
|
163
|
+
57396: "f33",
|
|
164
|
+
57397: "f34",
|
|
165
|
+
57398: "f35",
|
|
166
|
+
57399: "kp0",
|
|
167
|
+
57400: "kp1",
|
|
168
|
+
57401: "kp2",
|
|
169
|
+
57402: "kp3",
|
|
170
|
+
57403: "kp4",
|
|
171
|
+
57404: "kp5",
|
|
172
|
+
57405: "kp6",
|
|
173
|
+
57406: "kp7",
|
|
174
|
+
57407: "kp8",
|
|
175
|
+
57408: "kp9",
|
|
176
|
+
57409: "kpdecimal",
|
|
177
|
+
57410: "kpdivide",
|
|
178
|
+
57411: "kpmultiply",
|
|
179
|
+
57412: "kpsubtract",
|
|
180
|
+
57413: "kpadd",
|
|
181
|
+
57414: "kpenter",
|
|
182
|
+
57415: "kpequal",
|
|
183
|
+
57416: "kpseparator",
|
|
184
|
+
57417: "kpleft",
|
|
185
|
+
57418: "kpright",
|
|
186
|
+
57419: "kpup",
|
|
187
|
+
57420: "kpdown",
|
|
188
|
+
57421: "kppageup",
|
|
189
|
+
57422: "kppagedown",
|
|
190
|
+
57423: "kphome",
|
|
191
|
+
57424: "kpend",
|
|
192
|
+
57425: "kpinsert",
|
|
193
|
+
57426: "kpdelete",
|
|
194
|
+
57427: "kpbegin",
|
|
195
|
+
57428: "mediaplay",
|
|
196
|
+
57429: "mediapause",
|
|
197
|
+
57430: "mediaplaypause",
|
|
198
|
+
57431: "mediareverse",
|
|
199
|
+
57432: "mediastop",
|
|
200
|
+
57433: "mediafastforward",
|
|
201
|
+
57434: "mediarewind",
|
|
202
|
+
57435: "mediatracknext",
|
|
203
|
+
57436: "mediatrackprevious",
|
|
204
|
+
57437: "mediarecord",
|
|
205
|
+
57438: "lowervolume",
|
|
206
|
+
57439: "raisevolume",
|
|
207
|
+
57440: "mutevolume",
|
|
208
|
+
57441: "leftshift",
|
|
209
|
+
57442: "leftcontrol",
|
|
210
|
+
57443: "leftalt",
|
|
211
|
+
57444: "leftsuper",
|
|
212
|
+
57445: "lefthyper",
|
|
213
|
+
57446: "leftmeta",
|
|
214
|
+
57447: "rightshift",
|
|
215
|
+
57448: "rightcontrol",
|
|
216
|
+
57449: "rightalt",
|
|
217
|
+
57450: "rightsuper",
|
|
218
|
+
57451: "righthyper",
|
|
219
|
+
57452: "rightmeta",
|
|
220
|
+
57453: "isoLevel3Shift",
|
|
221
|
+
57454: "isoLevel5Shift"
|
|
222
|
+
}, p = (e) => e >= 0 && e <= 1114111 && !(e >= 55296 && e <= 57343), m = (e) => p(e) ? String.fromCodePoint(e) : "?";
|
|
223
|
+
function h(e) {
|
|
224
|
+
return e === 3 ? "release" : e === 2 ? "repeat" : "press";
|
|
225
|
+
}
|
|
226
|
+
function g(t) {
|
|
227
|
+
return {
|
|
228
|
+
ctrl: !!(t & e.ctrl),
|
|
229
|
+
shift: !!(t & e.shift),
|
|
230
|
+
meta: !!(t & (e.meta | e.alt)),
|
|
231
|
+
super: !!(t & e.super),
|
|
232
|
+
hyper: !!(t & e.hyper),
|
|
233
|
+
capsLock: !!(t & e.capsLock),
|
|
234
|
+
numLock: !!(t & e.numLock)
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
var _ = (e) => {
|
|
238
|
+
let t = c.exec(e);
|
|
239
|
+
if (!t) return null;
|
|
240
|
+
let n = parseInt(t[1], 10), r = t[2] ? Math.max(0, parseInt(t[2], 10) - 1) : 0, i = t[3] ? parseInt(t[3], 10) : 1, a = t[4];
|
|
241
|
+
if (!p(n)) return null;
|
|
242
|
+
let o;
|
|
243
|
+
a && (o = a.split(":").map((e) => m(parseInt(e, 10))).join(""));
|
|
244
|
+
let s, l;
|
|
245
|
+
return n === 32 ? (s = "space", l = !0) : n === 13 ? (s = "return", l = !0) : f[n] ? (s = f[n], l = !1) : n >= 1 && n <= 26 ? (s = String.fromCodePoint(n + 96), l = !1) : (s = m(n).toLowerCase(), l = !0), l && !o && (o = m(n)), {
|
|
246
|
+
name: s,
|
|
247
|
+
...g(r),
|
|
248
|
+
eventType: h(i),
|
|
249
|
+
sequence: e,
|
|
250
|
+
raw: e,
|
|
251
|
+
isKittyProtocol: !0,
|
|
252
|
+
isPrintable: l,
|
|
253
|
+
text: o
|
|
254
|
+
};
|
|
255
|
+
}, v = (e) => {
|
|
256
|
+
let t = l.exec(e);
|
|
257
|
+
if (!t) return null;
|
|
258
|
+
let n = parseInt(t[1], 10), r = Math.max(0, parseInt(t[2], 10) - 1), i = parseInt(t[3], 10), a = t[4], o = a === "~" ? d[n] : u[a];
|
|
259
|
+
return o ? {
|
|
260
|
+
name: o,
|
|
261
|
+
...g(r),
|
|
262
|
+
eventType: h(i),
|
|
263
|
+
sequence: e,
|
|
264
|
+
raw: e,
|
|
265
|
+
isKittyProtocol: !0,
|
|
266
|
+
isPrintable: !1
|
|
267
|
+
} : null;
|
|
268
|
+
}, y = (e = "") => {
|
|
269
|
+
let a;
|
|
270
|
+
e instanceof Uint8Array ? e[0] > 127 && e[1] === void 0 ? (e[0] -= 128, e = "\x1B" + t.decode(e)) : e = t.decode(e) : e !== void 0 && typeof e != "string" ? e = String(e) : e ||= "";
|
|
271
|
+
let l = _(e);
|
|
272
|
+
if (l) return l;
|
|
273
|
+
let u = v(e);
|
|
274
|
+
if (u) return u;
|
|
275
|
+
if (c.test(e)) return {
|
|
276
|
+
name: "",
|
|
277
|
+
ctrl: !1,
|
|
278
|
+
meta: !1,
|
|
279
|
+
shift: !1,
|
|
280
|
+
sequence: e,
|
|
281
|
+
raw: e,
|
|
282
|
+
isKittyProtocol: !0,
|
|
283
|
+
isPrintable: !1
|
|
284
|
+
};
|
|
285
|
+
let d = {
|
|
286
|
+
name: "",
|
|
287
|
+
ctrl: !1,
|
|
288
|
+
meta: !1,
|
|
289
|
+
shift: !1,
|
|
290
|
+
sequence: e,
|
|
291
|
+
raw: e
|
|
292
|
+
};
|
|
293
|
+
if (d.sequence = d.sequence || e || d.name, e === "\r" || e === "\x1B\r") d.raw = void 0, d.name = "return", d.meta = e.length === 2;
|
|
294
|
+
else if (e === "\n") d.name = "enter";
|
|
295
|
+
else if (e === " ") d.name = "tab";
|
|
296
|
+
else if (e === "\b" || e === "\x1B\b") d.name = "backspace", d.meta = e.charAt(0) === "\x1B";
|
|
297
|
+
else if (e === "" || e === "\x1B") d.name = "backspace", d.meta = e.charAt(0) === "\x1B";
|
|
298
|
+
else if (e === "\x1B" || e === "\x1B\x1B") d.name = "escape", d.meta = e.length === 2;
|
|
299
|
+
else if (e === " " || e === "\x1B ") d.name = "space", d.meta = e.length === 2;
|
|
300
|
+
else if (e.length === 1 && e <= "") d.name = String.fromCharCode(e.charCodeAt(0) + 97 - 1), d.ctrl = !0;
|
|
301
|
+
else if (e.length === 1 && e >= "0" && e <= "9") d.name = "number";
|
|
302
|
+
else if (e.length === 1 && e >= "a" && e <= "z") d.name = e;
|
|
303
|
+
else if (e.length === 1 && e >= "A" && e <= "Z") d.name = e.toLowerCase(), d.shift = !0;
|
|
304
|
+
else if (a = n.exec(e)) d.name = a[1].toLowerCase(), d.meta = !0, d.shift = /^[A-Z]$/.test(a[1]);
|
|
305
|
+
else if (a = r.exec(e)) {
|
|
306
|
+
let t = [...e];
|
|
307
|
+
t[0] === "\x1B" && t[1] === "\x1B" && (d.meta = !0);
|
|
308
|
+
let n = [
|
|
309
|
+
a[1],
|
|
310
|
+
a[2],
|
|
311
|
+
a[4],
|
|
312
|
+
a[6]
|
|
313
|
+
].filter(Boolean).join(""), r = (a[3] || a[5] || 1) - 1;
|
|
314
|
+
d.ctrl = !!(r & 4), d.meta = d.meta || !!(r & 10), d.shift = !!(r & 1), d.code = n, d.name = i[n] ?? "", d.shift = o(n) || d.shift, d.ctrl = s(n) || d.ctrl;
|
|
315
|
+
}
|
|
316
|
+
return d;
|
|
317
|
+
};
|
|
318
|
+
//#endregion
|
|
319
|
+
export { y as default, a as nonAlphanumericKeys };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/react/hooks/useInputEvent/formatInputEvent.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
if (e.type === "text") return `text "${e.text}"`;
|
|
4
|
+
if (e.type === "paste") return `paste ${e.text.length} chars`;
|
|
5
|
+
if (e.type === "key") {
|
|
6
|
+
let t = [
|
|
7
|
+
e.modifiers.ctrl ? "ctrl" : "",
|
|
8
|
+
e.modifiers.shift ? "shift" : "",
|
|
9
|
+
e.modifiers.meta ? "meta" : "",
|
|
10
|
+
e.modifiers.super ? "super" : ""
|
|
11
|
+
].filter(Boolean).join("+"), n = t ? `${t}+` : "", r = e.text ? ` text=${JSON.stringify(e.text)}` : "";
|
|
12
|
+
return `key ${n}${e.name} (${e.action})${r}`;
|
|
13
|
+
}
|
|
14
|
+
if (e.type === "mouse") {
|
|
15
|
+
let t = [
|
|
16
|
+
e.modifiers.ctrl ? "ctrl" : "",
|
|
17
|
+
e.modifiers.shift ? "shift" : "",
|
|
18
|
+
e.modifiers.meta ? "meta" : ""
|
|
19
|
+
].filter(Boolean).join("+");
|
|
20
|
+
return `mouse ${t ? `${t}+` : ""}${e.button} ${e.action} @ ${e.column},${e.row}`;
|
|
21
|
+
}
|
|
22
|
+
return e.type === "focus" ? e.focused ? "focus in" : "focus out" : `unknown ${JSON.stringify(e.raw)}`;
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { e as formatInputEvent };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { formatInputEvent as e } from "./formatInputEvent.js";
|
|
2
|
+
import { parserItemToInputEvent as t } from "./parseInputEvent.js";
|
|
3
|
+
import { useInputEvent as n } from "./useInputEvent.js";
|
|
4
|
+
export { e as formatInputEvent, t as parserItemToInputEvent, n as useInputEvent };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type InputEventModifiers = {
|
|
2
|
+
ctrl: boolean;
|
|
3
|
+
shift: boolean;
|
|
4
|
+
meta: boolean;
|
|
5
|
+
super: boolean;
|
|
6
|
+
hyper: boolean;
|
|
7
|
+
capsLock: boolean;
|
|
8
|
+
numLock: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type KeyAction = "press" | "repeat" | "release";
|
|
11
|
+
export type MouseButton = "left" | "middle" | "right" | "wheel-up" | "wheel-down" | "wheel-left" | "wheel-right" | "move";
|
|
12
|
+
export type TextInputEvent = {
|
|
13
|
+
type: "text";
|
|
14
|
+
text: string;
|
|
15
|
+
};
|
|
16
|
+
export type KeyInputEvent = {
|
|
17
|
+
type: "key";
|
|
18
|
+
name: string;
|
|
19
|
+
text: string;
|
|
20
|
+
modifiers: InputEventModifiers;
|
|
21
|
+
action: KeyAction;
|
|
22
|
+
raw: string;
|
|
23
|
+
};
|
|
24
|
+
export type PasteInputEvent = {
|
|
25
|
+
type: "paste";
|
|
26
|
+
text: string;
|
|
27
|
+
};
|
|
28
|
+
export type MouseInputEvent = {
|
|
29
|
+
type: "mouse";
|
|
30
|
+
button: MouseButton;
|
|
31
|
+
column: number;
|
|
32
|
+
row: number;
|
|
33
|
+
action: "press" | "release" | "move";
|
|
34
|
+
modifiers: Pick<InputEventModifiers, "ctrl" | "shift" | "meta">;
|
|
35
|
+
raw: string;
|
|
36
|
+
};
|
|
37
|
+
export type FocusInputEvent = {
|
|
38
|
+
type: "focus";
|
|
39
|
+
focused: boolean;
|
|
40
|
+
raw: string;
|
|
41
|
+
};
|
|
42
|
+
export type UnknownInputEvent = {
|
|
43
|
+
type: "unknown";
|
|
44
|
+
raw: string;
|
|
45
|
+
};
|
|
46
|
+
export type InputEvent = TextInputEvent | KeyInputEvent | PasteInputEvent | MouseInputEvent | FocusInputEvent | UnknownInputEvent;
|
|
47
|
+
export type UseInputEventOptions = {
|
|
48
|
+
isActive?: boolean;
|
|
49
|
+
enableMouse?: boolean;
|
|
50
|
+
enableFocus?: boolean;
|
|
51
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import e, { nonAlphanumericKeys as t } from "./_internal/ink-input/parse-keypress.js";
|
|
2
|
+
import "./_internal/ink-input/index.js";
|
|
3
|
+
//#region src/react/hooks/useInputEvent/parseInputEvent.ts
|
|
4
|
+
var n = "\x1B[I", r = "\x1B[O", i = /^\u001B\[<(\d+);(\d+);(\d+)([mM])$/, a = [/^\u001B\[\?\d+u$/, /^\u001B\[>\d+;(?:\d+;)?\d+c$/], o = (e) => a.some((t) => t.test(e)), s = (e) => {
|
|
5
|
+
if (e.isKittyProtocol) return e.isPrintable ? e.text ?? e.name : e.ctrl && e.name.length === 1 ? e.name : "";
|
|
6
|
+
if (e.ctrl) return e.name ?? "";
|
|
7
|
+
let n = e.sequence;
|
|
8
|
+
return t.includes(e.name) && (n = ""), n.startsWith("\x1B") && (n = n.slice(1)), n;
|
|
9
|
+
}, c = (e, t) => {
|
|
10
|
+
if (e === 35) return {
|
|
11
|
+
button: "move",
|
|
12
|
+
action: "move"
|
|
13
|
+
};
|
|
14
|
+
if (e === 64) return {
|
|
15
|
+
button: "wheel-up",
|
|
16
|
+
action: "press"
|
|
17
|
+
};
|
|
18
|
+
if (e === 65) return {
|
|
19
|
+
button: "wheel-down",
|
|
20
|
+
action: "press"
|
|
21
|
+
};
|
|
22
|
+
if (e === 66) return {
|
|
23
|
+
button: "wheel-left",
|
|
24
|
+
action: "press"
|
|
25
|
+
};
|
|
26
|
+
if (e === 67) return {
|
|
27
|
+
button: "wheel-right",
|
|
28
|
+
action: "press"
|
|
29
|
+
};
|
|
30
|
+
let n = e & 3, r = [
|
|
31
|
+
"left",
|
|
32
|
+
"middle",
|
|
33
|
+
"right"
|
|
34
|
+
];
|
|
35
|
+
return e >= 32 && e <= 34 ? {
|
|
36
|
+
button: r[n] ?? "left",
|
|
37
|
+
action: "move"
|
|
38
|
+
} : {
|
|
39
|
+
button: r[n] ?? "left",
|
|
40
|
+
action: t
|
|
41
|
+
};
|
|
42
|
+
}, l = (e) => {
|
|
43
|
+
let t = i.exec(e);
|
|
44
|
+
if (!t) return;
|
|
45
|
+
let n = Number(t[1]), r = Number(t[2]), a = Number(t[3]), { button: o, action: s } = c(n, t[4] === "M" ? "press" : "release");
|
|
46
|
+
return {
|
|
47
|
+
type: "mouse",
|
|
48
|
+
button: o,
|
|
49
|
+
column: r,
|
|
50
|
+
row: a,
|
|
51
|
+
action: s,
|
|
52
|
+
modifiers: {
|
|
53
|
+
shift: !!(n & 4),
|
|
54
|
+
meta: !!(n & 8),
|
|
55
|
+
ctrl: !!(n & 16)
|
|
56
|
+
},
|
|
57
|
+
raw: e
|
|
58
|
+
};
|
|
59
|
+
}, u = (e) => {
|
|
60
|
+
if (e === n) return {
|
|
61
|
+
type: "focus",
|
|
62
|
+
focused: !0,
|
|
63
|
+
raw: e
|
|
64
|
+
};
|
|
65
|
+
if (e === r) return {
|
|
66
|
+
type: "focus",
|
|
67
|
+
focused: !1,
|
|
68
|
+
raw: e
|
|
69
|
+
};
|
|
70
|
+
}, d = (t) => {
|
|
71
|
+
if (t.length > 1 && !t.startsWith("\x1B")) return {
|
|
72
|
+
type: "text",
|
|
73
|
+
text: t
|
|
74
|
+
};
|
|
75
|
+
let n = e(t), r = n.eventType ?? "press";
|
|
76
|
+
return !n.name && n.isKittyProtocol || !n.name && t.startsWith("\x1B") ? {
|
|
77
|
+
type: "unknown",
|
|
78
|
+
raw: t
|
|
79
|
+
} : {
|
|
80
|
+
type: "key",
|
|
81
|
+
name: n.name || "unknown",
|
|
82
|
+
text: s(n),
|
|
83
|
+
modifiers: {
|
|
84
|
+
ctrl: n.ctrl,
|
|
85
|
+
shift: n.shift,
|
|
86
|
+
meta: n.meta,
|
|
87
|
+
super: n.super ?? !1,
|
|
88
|
+
hyper: n.hyper ?? !1,
|
|
89
|
+
capsLock: n.capsLock ?? !1,
|
|
90
|
+
numLock: n.numLock ?? !1
|
|
91
|
+
},
|
|
92
|
+
action: r,
|
|
93
|
+
raw: t
|
|
94
|
+
};
|
|
95
|
+
}, f = (e) => typeof e == "string" ? o(e) ? void 0 : l(e) || u(e) || d(e) : {
|
|
96
|
+
type: "paste",
|
|
97
|
+
text: e.paste
|
|
98
|
+
};
|
|
99
|
+
//#endregion
|
|
100
|
+
export { f as parserItemToInputEvent };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InputEvent, UseInputEventOptions } from './inputEventTypes.js';
|
|
2
|
+
type UseInputEventHandler = (event: InputEvent) => void;
|
|
3
|
+
type UseInputEventResult = {
|
|
4
|
+
lastEvent: InputEvent | undefined;
|
|
5
|
+
};
|
|
6
|
+
export declare function useInputEvent(handler: UseInputEventHandler, options?: UseInputEventOptions): UseInputEventResult;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createInputParser as e } from "./_internal/ink-input/input-parser.js";
|
|
2
|
+
import "./_internal/ink-input/index.js";
|
|
3
|
+
import { parserItemToInputEvent as t } from "./parseInputEvent.js";
|
|
4
|
+
import { useEffect as n, useRef as r, useState as i } from "react";
|
|
5
|
+
import { useStdin as a, useStdout as o } from "ink";
|
|
6
|
+
//#region src/react/hooks/useInputEvent/useInputEvent.ts
|
|
7
|
+
var s = 20, c = "\x1B[?1000h\x1B[?1002h\x1B[?1006h", l = "\x1B[?1000l\x1B[?1002l\x1B[?1006l", u = "\x1B[?1004h", d = "\x1B[?1004l", f = "\x1B[?2004h", p = "\x1B[?2004l";
|
|
8
|
+
function m(m, h = {}) {
|
|
9
|
+
let { isActive: g = !0, enableMouse: _ = !0, enableFocus: v = !0 } = h, { stdin: y, setRawMode: b, isRawModeSupported: x } = a(), { stdout: S } = o(), [C, w] = i(void 0), T = r(m);
|
|
10
|
+
return T.current = m, n(() => {
|
|
11
|
+
if (g) return _ && S.write(c), v && S.write(u), S.write(f), () => {
|
|
12
|
+
_ && S.write(l), v && S.write(d), S.write(p);
|
|
13
|
+
};
|
|
14
|
+
}, [
|
|
15
|
+
S,
|
|
16
|
+
g,
|
|
17
|
+
_,
|
|
18
|
+
v
|
|
19
|
+
]), n(() => {
|
|
20
|
+
if (!(!g || !x)) return b(!0), y.setEncoding("utf8"), () => {
|
|
21
|
+
b(!1);
|
|
22
|
+
};
|
|
23
|
+
}, [
|
|
24
|
+
g,
|
|
25
|
+
x,
|
|
26
|
+
b,
|
|
27
|
+
y
|
|
28
|
+
]), n(() => {
|
|
29
|
+
if (!g || !x) return;
|
|
30
|
+
let n = e(), r, i = (e) => {
|
|
31
|
+
let n = t(e);
|
|
32
|
+
n && (w(n), T.current(n));
|
|
33
|
+
}, a = () => {
|
|
34
|
+
r !== void 0 && (clearTimeout(r), r = void 0);
|
|
35
|
+
}, o = () => {
|
|
36
|
+
a(), r = setTimeout(() => {
|
|
37
|
+
r = void 0;
|
|
38
|
+
let e = n.flushPendingEscape();
|
|
39
|
+
e && i(e);
|
|
40
|
+
}, s);
|
|
41
|
+
}, c = (e) => {
|
|
42
|
+
a();
|
|
43
|
+
let t = Buffer.isBuffer(e) ? e.toString("utf8") : e;
|
|
44
|
+
for (let e of n.push(t)) i(e);
|
|
45
|
+
n.hasPendingEscape() && o();
|
|
46
|
+
};
|
|
47
|
+
return y.on("data", c), () => {
|
|
48
|
+
a(), y.off("data", c), n.reset();
|
|
49
|
+
};
|
|
50
|
+
}, [
|
|
51
|
+
y,
|
|
52
|
+
g,
|
|
53
|
+
x
|
|
54
|
+
]), { lastEvent: C };
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { m as useInputEvent };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { nextOverlayStackId as e } from "./_internal/overlayStackId.js";
|
|
2
|
+
//#region src/react/hooks/useOverlayStack/createOverlayStackItem.ts
|
|
3
|
+
var t = (t, n, r) => ({
|
|
4
|
+
id: e(),
|
|
5
|
+
label: t,
|
|
6
|
+
depth: n,
|
|
7
|
+
data: r
|
|
8
|
+
});
|
|
9
|
+
//#endregion
|
|
10
|
+
export { t as createOverlayStackItem };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type OverlayStackItem<TData = undefined> = {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
depth: number;
|
|
5
|
+
data: TData;
|
|
6
|
+
};
|
|
7
|
+
export type UseOverlayStackResult<TData = undefined> = {
|
|
8
|
+
stack: OverlayStackItem<TData>[];
|
|
9
|
+
top: OverlayStackItem<TData> | undefined;
|
|
10
|
+
push: (label: string, data?: TData) => void;
|
|
11
|
+
pop: () => void;
|
|
12
|
+
update: (id: string, patch: Partial<Pick<OverlayStackItem<TData>, "label" | "data">>) => void;
|
|
13
|
+
};
|
|
File without changes
|