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,46 @@
|
|
|
1
|
+
import { doExpr as e } from "../../common/doExpr.js";
|
|
2
|
+
import "../../common/index.js";
|
|
3
|
+
import { tsLayer as t } from "./tsLayer.js";
|
|
4
|
+
import { withRuleOverrides as n } from "../utils/withRuleOverrides.js";
|
|
5
|
+
import r from "@factory/eslint-plugin";
|
|
6
|
+
import i from "@vitest/eslint-plugin";
|
|
7
|
+
//#region src/eslint-config/layers/testLayer.ts
|
|
8
|
+
var a = {
|
|
9
|
+
...t,
|
|
10
|
+
plugins: {
|
|
11
|
+
...t.plugins,
|
|
12
|
+
"@factory": r,
|
|
13
|
+
vitest: i
|
|
14
|
+
},
|
|
15
|
+
rules: n(t.rules, {
|
|
16
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
17
|
+
"@typescript-eslint/no-empty-object-type": "off",
|
|
18
|
+
"@typescript-eslint/no-unsafe-function-type": "off",
|
|
19
|
+
"@typescript-eslint/no-wrapper-object-types": "off",
|
|
20
|
+
"@typescript-eslint/no-restricted-types": "off",
|
|
21
|
+
"@typescript-eslint/require-await": "off",
|
|
22
|
+
"@factory/test-file-location": "error",
|
|
23
|
+
"vitest/no-restricted-matchers": ["error", e(() => {
|
|
24
|
+
let e = "Use toMatchInlineSnapshot() or toThrowErrorMatchingInlineSnapshot() instead if possible";
|
|
25
|
+
return {
|
|
26
|
+
toMatchSnapshot: "Use toMatchInlineSnapshot() instead if possible",
|
|
27
|
+
toThrowErrorMatchingSnapshot: "Use toThrowErrorMatchingInlineSnapshot() instead if possible",
|
|
28
|
+
toBe: e,
|
|
29
|
+
toEqual: e,
|
|
30
|
+
toStrictEqual: e,
|
|
31
|
+
toMatchObject: e,
|
|
32
|
+
toContain: e,
|
|
33
|
+
toContainEqual: e,
|
|
34
|
+
toBeNull: e,
|
|
35
|
+
toBeUndefined: e,
|
|
36
|
+
toBeTruthy: e,
|
|
37
|
+
toBeFalsy: e,
|
|
38
|
+
toHaveProperty: e,
|
|
39
|
+
toThrow: e,
|
|
40
|
+
toThrowError: e
|
|
41
|
+
};
|
|
42
|
+
})]
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { a as testLayer };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { freewindSingleExportPlugin as e } from "../plugins/freewindSingleExportPlugin.js";
|
|
2
|
+
import t from "typescript-eslint";
|
|
3
|
+
import n from "eslint-plugin-filename-match-export";
|
|
4
|
+
import r from "eslint-plugin-no-default-export";
|
|
5
|
+
import i from "eslint-plugin-react";
|
|
6
|
+
import a from "eslint-plugin-require-react-fc";
|
|
7
|
+
//#region src/eslint-config/layers/tsLayer.ts
|
|
8
|
+
var o = (e) => `应尽力收窄类型:${e};确属必要/合理 → 向用户确认后方可使用eslint-disable-next-line`, s = o("Record value 写具体类型,别用 unknown"), c = {
|
|
9
|
+
...t.configs.base,
|
|
10
|
+
languageOptions: {
|
|
11
|
+
parser: t.parser,
|
|
12
|
+
parserOptions: { projectService: !0 }
|
|
13
|
+
},
|
|
14
|
+
settings: { react: { version: "detect" } },
|
|
15
|
+
plugins: {
|
|
16
|
+
"@typescript-eslint": t.plugin,
|
|
17
|
+
react: i,
|
|
18
|
+
"single-export": e,
|
|
19
|
+
"filename-match-export": n,
|
|
20
|
+
"no-default-export": r,
|
|
21
|
+
"require-react-fc": a
|
|
22
|
+
},
|
|
23
|
+
rules: {
|
|
24
|
+
"single-export/single-export": "error",
|
|
25
|
+
"no-default-export/no-default-export": "error",
|
|
26
|
+
"@typescript-eslint/prefer-destructuring": [
|
|
27
|
+
"error",
|
|
28
|
+
{
|
|
29
|
+
array: !1,
|
|
30
|
+
object: !1
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
enforceForRenamedProperties: !0,
|
|
34
|
+
enforceForDeclarationWithTypeAnnotation: !1
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"@typescript-eslint/no-empty-function": ["error", { allow: ["arrowFunctions"] }],
|
|
38
|
+
eqeqeq: [
|
|
39
|
+
"error",
|
|
40
|
+
"always",
|
|
41
|
+
{ null: "ignore" }
|
|
42
|
+
],
|
|
43
|
+
"@typescript-eslint/require-await": "error",
|
|
44
|
+
"@typescript-eslint/no-explicit-any": "error",
|
|
45
|
+
"@typescript-eslint/no-empty-object-type": "error",
|
|
46
|
+
"@typescript-eslint/no-unsafe-function-type": "error",
|
|
47
|
+
"@typescript-eslint/no-wrapper-object-types": "error",
|
|
48
|
+
"@typescript-eslint/no-restricted-types": ["error", { types: {
|
|
49
|
+
object: o("object → interface 或具体 shape"),
|
|
50
|
+
"Record<string,unknown>": s,
|
|
51
|
+
"Record<number,unknown>": s,
|
|
52
|
+
unknown: o("unknown → 具体类型")
|
|
53
|
+
} }],
|
|
54
|
+
"@typescript-eslint/explicit-module-boundary-types": ["error", {
|
|
55
|
+
allowArgumentsExplicitlyTypedAsAny: !1,
|
|
56
|
+
allowDirectConstAssertionInArrowFunctions: !0,
|
|
57
|
+
allowHigherOrderFunctions: !0,
|
|
58
|
+
allowTypedFunctionExpressions: !0,
|
|
59
|
+
allowOverloadFunctions: !0
|
|
60
|
+
}],
|
|
61
|
+
"react/function-component-definition": ["error", {
|
|
62
|
+
namedComponents: "arrow-function",
|
|
63
|
+
unnamedComponents: "arrow-function"
|
|
64
|
+
}],
|
|
65
|
+
"react/no-deprecated": "error",
|
|
66
|
+
"require-react-fc/require-react-fc": "error"
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
//#endregion
|
|
70
|
+
export { c as tsLayer };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/eslint-config/plugins/freewindSingleExportPlugin.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
if (e.type === "FunctionDeclaration") return !0;
|
|
4
|
+
if (e.type !== "VariableDeclarator") return !1;
|
|
5
|
+
let t = e.init?.type;
|
|
6
|
+
return t === "FunctionExpression" || t === "ArrowFunctionExpression";
|
|
7
|
+
}
|
|
8
|
+
function t(t, n, r) {
|
|
9
|
+
let i = n.sourceCode.getScope(r);
|
|
10
|
+
for (; i !== null;) {
|
|
11
|
+
let n = i.variables.find((e) => e.name === t);
|
|
12
|
+
if (n) return n.defs.some((t) => e(t.node));
|
|
13
|
+
i = i.upper;
|
|
14
|
+
}
|
|
15
|
+
return !1;
|
|
16
|
+
}
|
|
17
|
+
function n(n, r) {
|
|
18
|
+
if (n.type !== "ExportNamedDeclaration") return !1;
|
|
19
|
+
let i = n;
|
|
20
|
+
return i.declaration?.type === "FunctionDeclaration" ? !0 : i.declaration?.type === "VariableDeclaration" ? i.declaration.declarations?.some((t) => e(t)) ?? !1 : !i.specifiers?.length || i.declaration ? !1 : i.specifiers.some((e) => e.exportKind !== "type" && e.local?.type === "Identifier" && e.local.name !== void 0 && t(e.local.name, r, i));
|
|
21
|
+
}
|
|
22
|
+
var r = { rules: { "single-export": {
|
|
23
|
+
meta: {
|
|
24
|
+
type: "problem",
|
|
25
|
+
docs: { description: "Enforce a single function export per file" },
|
|
26
|
+
schema: [],
|
|
27
|
+
messages: { multipleExports: "Only one export is allowed per file. Found {{count}} exports. Split functionality across multiple files following domain boundaries." }
|
|
28
|
+
},
|
|
29
|
+
create(e) {
|
|
30
|
+
let t = [];
|
|
31
|
+
return {
|
|
32
|
+
ExportNamedDeclaration(e) {
|
|
33
|
+
(e.declaration || e.specifiers?.length) && !e.source && t.push(e);
|
|
34
|
+
},
|
|
35
|
+
"Program:exit"() {
|
|
36
|
+
let r = t.filter((t) => n(t, e)), i = r.length;
|
|
37
|
+
if (!(i <= 1)) for (let [t, n] of r.entries()) t > 0 && e.report({
|
|
38
|
+
node: n,
|
|
39
|
+
messageId: "multipleExports",
|
|
40
|
+
data: { count: String(i) }
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
} } };
|
|
46
|
+
//#endregion
|
|
47
|
+
export { r as freewindSingleExportPlugin };
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './common/index.js';
|
package/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { fuzzyMatchPath as e } from "./common/fuzzy/fuzzyMatchPath.js";
|
|
2
|
+
import { fuzzyMatch as t } from "./common/fuzzy/fuzzyMatch.js";
|
|
3
|
+
import { formatSize as n } from "./common/formatSize.js";
|
|
4
|
+
import { truncateString as r } from "./common/truncateString.js";
|
|
5
|
+
import { anyToString as i } from "./common/anyToString/anyToString.js";
|
|
6
|
+
import { assertsType as a } from "./common/assertsType.js";
|
|
7
|
+
import { buildSequence as o } from "./common/buildSequence.js";
|
|
8
|
+
import { deepClone as s } from "./common/deepClone.js";
|
|
9
|
+
import { deepEqual as c } from "./common/deepEqual.js";
|
|
10
|
+
import { deepParseJsonStrings as l } from "./common/deepParseJsonStrings.js";
|
|
11
|
+
import { dependsOn as u } from "./common/dependsOn.js";
|
|
12
|
+
import { doExpr as d } from "./common/doExpr.js";
|
|
13
|
+
import { flatChildren as f } from "./common/flatChildren.js";
|
|
14
|
+
import { formatDecimal as p } from "./common/formatDecimal.js";
|
|
15
|
+
import { formatFriendlyTime as m } from "./common/formatFriendlyTime.js";
|
|
16
|
+
import { isNonNil as h } from "./common/isNonNil.js";
|
|
17
|
+
import { buildTree as g } from "./common/tree/buildTree.js";
|
|
18
|
+
import { isRecord as _ } from "./common/isRecord.js";
|
|
19
|
+
import { isJsonRecord as v } from "./common/jsonRecord/isJsonRecord.js";
|
|
20
|
+
import { filterJsonRecord as y } from "./common/jsonRecord/filterJsonRecord.js";
|
|
21
|
+
import { flatTree as b } from "./common/tree/flatTree.js";
|
|
22
|
+
import { isEmptyRecord as x } from "./common/isEmptyRecord.js";
|
|
23
|
+
import { isNil as S } from "./common/isNil.js";
|
|
24
|
+
import { isSimpleInt as C } from "./common/simpleInt/isSimpleInt.js";
|
|
25
|
+
import { isSimpleIntInputing as w } from "./common/simpleInt/isSimpleIntInputing.js";
|
|
26
|
+
import { isSimpleNumber as T } from "./common/simpleInt/isSimpleNumber.js";
|
|
27
|
+
import { isSimpleNumberInputing as E } from "./common/simpleInt/isSimpleNumberInputing.js";
|
|
28
|
+
import { mapJsonRecord as D } from "./common/jsonRecord/mapJsonRecord.js";
|
|
29
|
+
import { mapTree as O } from "./common/tree/mapTree.js";
|
|
30
|
+
import { modifyJsonRecord as k } from "./common/jsonRecord/modifyJsonRecord.js";
|
|
31
|
+
import { onlyUnique as A } from "./common/onlyUnique.js";
|
|
32
|
+
import { parseSimpleIntOrNil as j } from "./common/simpleInt/parseSimpleIntOrNil.js";
|
|
33
|
+
import { parseSimpleInt as M } from "./common/simpleInt/parseSimpleInt.js";
|
|
34
|
+
import { parseSimpleNumberOrNil as N } from "./common/simpleInt/parseSimpleNumberOrNil.js";
|
|
35
|
+
import { parseSimpleNumber as P } from "./common/simpleInt/parseSimpleNumber.js";
|
|
36
|
+
import { pipe as F } from "./common/pipe.js";
|
|
37
|
+
import { pipeNonNil as I } from "./common/pipeNonNil.js";
|
|
38
|
+
import { jsonRecordDiff as L } from "./common/jsonRecord/jsonRecordDiff.js";
|
|
39
|
+
import { pruneTree as R } from "./common/tree/pruneTree.js";
|
|
40
|
+
import { sortTree as z } from "./common/tree/sortTree.js";
|
|
41
|
+
import { tap as B } from "./common/tap.js";
|
|
42
|
+
import { treeToArray as V } from "./common/tree/treeToArray.js";
|
|
43
|
+
import { treeToRows as H } from "./common/tree/treeToRows.js";
|
|
44
|
+
import { truncateJsonStrings as U } from "./common/truncateJsonStrings.js";
|
|
45
|
+
import { tryParsePartialJson as W } from "./common/tryParsePartialJson.js";
|
|
46
|
+
import { walkJsonRecord as G } from "./common/jsonRecord/walkJsonRecord.js";
|
|
47
|
+
import { walkTree as K } from "./common/tree/walkTree.js";
|
|
48
|
+
import "./common/index.js";
|
|
49
|
+
export { i as anyToString, a as assertsType, o as buildSequence, g as buildTree, s as deepClone, c as deepEqual, l as deepParseJsonStrings, u as dependsOn, d as doExpr, y as filterJsonRecord, f as flatChildren, b as flatTree, p as formatDecimal, m as formatFriendlyTime, n as formatSize, t as fuzzyMatch, e as fuzzyMatchPath, x as isEmptyRecord, v as isJsonRecord, S as isNil, h as isNonNil, _ as isRecord, C as isSimpleInt, w as isSimpleIntInputing, T as isSimpleNumber, E as isSimpleNumberInputing, L as jsonRecordDiff, D as mapJsonRecord, O as mapTree, k as modifyJsonRecord, A as onlyUnique, M as parseSimpleInt, j as parseSimpleIntOrNil, P as parseSimpleNumber, N as parseSimpleNumberOrNil, F as pipe, I as pipeNonNil, R as pruneTree, z as sortTree, B as tap, V as treeToArray, H as treeToRows, U as truncateJsonStrings, r as truncateString, W as tryParsePartialJson, G as walkJsonRecord, K as walkTree };
|
package/node/index.d.ts
ADDED
package/node/index.js
ADDED
package/node/md5.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the MD5 hex digest of a UTF-8 string.
|
|
3
|
+
*
|
|
4
|
+
* Node.js only. MD5 is unsuitable for passwords, signatures, or other security-sensitive use.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* md5('hello') // '5d41402abc4b2a76b9719d911017c592'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function md5(value: string): string;
|
package/node/md5.js
ADDED
package/node/uuid.d.ts
ADDED
package/node/uuid.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "freewind-ts-utils",
|
|
3
|
+
"version": "0.18.2",
|
|
4
|
+
"description": "TypeScript utils for common, node, and browser usage",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./index.js",
|
|
8
|
+
"module": "./index.js",
|
|
9
|
+
"types": "./index.d.ts",
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public",
|
|
12
|
+
"registry": "https://registry.npmjs.org/"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./index.d.ts",
|
|
17
|
+
"default": "./index.js"
|
|
18
|
+
},
|
|
19
|
+
"./common": {
|
|
20
|
+
"types": "./common/index.d.ts",
|
|
21
|
+
"default": "./common/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./common/*": {
|
|
24
|
+
"types": "./common/*.d.ts",
|
|
25
|
+
"default": "./common/*.js"
|
|
26
|
+
},
|
|
27
|
+
"./node": {
|
|
28
|
+
"types": "./node/index.d.ts",
|
|
29
|
+
"default": "./node/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./node/*": {
|
|
32
|
+
"types": "./node/*.d.ts",
|
|
33
|
+
"default": "./node/*.js"
|
|
34
|
+
},
|
|
35
|
+
"./react": {
|
|
36
|
+
"types": "./react/index.d.ts",
|
|
37
|
+
"default": "./react/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./react/*": {
|
|
40
|
+
"types": "./react/hooks/*.d.ts",
|
|
41
|
+
"default": "./react/hooks/*.js"
|
|
42
|
+
},
|
|
43
|
+
"./react/useInputEvent": {
|
|
44
|
+
"types": "./react/hooks/useInputEvent/index.d.ts",
|
|
45
|
+
"default": "./react/hooks/useInputEvent/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./react/useOverlayStack": {
|
|
48
|
+
"types": "./react/hooks/useOverlayStack/index.d.ts",
|
|
49
|
+
"default": "./react/hooks/useOverlayStack/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./react/ink-components": {
|
|
52
|
+
"types": "./react/ink-components/index.d.ts",
|
|
53
|
+
"default": "./react/ink-components/index.js"
|
|
54
|
+
},
|
|
55
|
+
"./react/ink-components/*": {
|
|
56
|
+
"types": "./react/ink-components/*/index.d.ts",
|
|
57
|
+
"default": "./react/ink-components/*/index.js"
|
|
58
|
+
},
|
|
59
|
+
"./antd": {
|
|
60
|
+
"types": "./antd/index.d.ts",
|
|
61
|
+
"default": "./antd/index.js"
|
|
62
|
+
},
|
|
63
|
+
"./antd/*": {
|
|
64
|
+
"types": "./antd/*/index.d.ts",
|
|
65
|
+
"default": "./antd/*/index.js"
|
|
66
|
+
},
|
|
67
|
+
"./vite-plugins": {
|
|
68
|
+
"types": "./vite-plugins/index.d.ts",
|
|
69
|
+
"default": "./vite-plugins/index.js"
|
|
70
|
+
},
|
|
71
|
+
"./vite-plugins/*": {
|
|
72
|
+
"types": "./vite-plugins/*.d.ts",
|
|
73
|
+
"default": "./vite-plugins/*.js"
|
|
74
|
+
},
|
|
75
|
+
"./eslint-config": {
|
|
76
|
+
"types": "./eslint-config/index.d.ts",
|
|
77
|
+
"default": "./eslint-config/index.js"
|
|
78
|
+
},
|
|
79
|
+
"./prettier-config": {
|
|
80
|
+
"types": "./prettier-config/index.d.ts",
|
|
81
|
+
"default": "./prettier-config/index.js"
|
|
82
|
+
},
|
|
83
|
+
"./package.json": "./package.json"
|
|
84
|
+
},
|
|
85
|
+
"lint-staged": {
|
|
86
|
+
"*.{ts,tsx}": [
|
|
87
|
+
"prettier --write",
|
|
88
|
+
"eslint --fix"
|
|
89
|
+
],
|
|
90
|
+
"*.{json,css,md}": "prettier --write"
|
|
91
|
+
},
|
|
92
|
+
"dependencies": {
|
|
93
|
+
"@babel/parser": "^7.28.5",
|
|
94
|
+
"@babel/traverse": "^7.28.5",
|
|
95
|
+
"@factory/eslint-plugin": "0.1.0",
|
|
96
|
+
"@vitest/eslint-plugin": "1.6.19",
|
|
97
|
+
"eslint-config-prettier": "^10.1.8",
|
|
98
|
+
"eslint-plugin-filename-match-export": "1.4.0",
|
|
99
|
+
"eslint-plugin-no-default-export": "1.0.0",
|
|
100
|
+
"eslint-plugin-react": "7.37.5",
|
|
101
|
+
"eslint-plugin-require-react-fc": "1.0.1",
|
|
102
|
+
"globals": "^17.6.0",
|
|
103
|
+
"magic-string": "^0.30.21",
|
|
104
|
+
"typescript-eslint": "^8.60.1"
|
|
105
|
+
},
|
|
106
|
+
"peerDependencies": {
|
|
107
|
+
"ahooks": "^3",
|
|
108
|
+
"antd": "^6",
|
|
109
|
+
"ink": "^7",
|
|
110
|
+
"react": ">=19.2.0",
|
|
111
|
+
"react-dom": ">=19.2.0",
|
|
112
|
+
"react-json-view-lite": "^2.5.0",
|
|
113
|
+
"vite": "^6 || ^8"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { freewindPrettierPreset } from './freewindPrettierPreset.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type Options = {
|
|
2
|
+
onError?: (error: unknown) => void;
|
|
3
|
+
};
|
|
4
|
+
export declare function useCopyToClipboard(options?: Options): {
|
|
5
|
+
copied: boolean;
|
|
6
|
+
copying: boolean;
|
|
7
|
+
copy: (this: unknown, value: string) => Promise<boolean>;
|
|
8
|
+
reset: (this: unknown) => void;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useState as e } from "react";
|
|
2
|
+
import { useMemoizedFn as t } from "ahooks";
|
|
3
|
+
//#region src/react/hooks/useCopyToClipboard.ts
|
|
4
|
+
var n = () => void 0;
|
|
5
|
+
function r(r = {}) {
|
|
6
|
+
let i = r.onError ?? n, [a, o] = e(!1), [s, c] = e(!1);
|
|
7
|
+
return {
|
|
8
|
+
copied: a,
|
|
9
|
+
copying: s,
|
|
10
|
+
copy: t(async (e) => {
|
|
11
|
+
if (s) return !1;
|
|
12
|
+
if (!navigator.clipboard?.writeText) throw Error("Clipboard API is unavailable");
|
|
13
|
+
c(!0), o(!1);
|
|
14
|
+
try {
|
|
15
|
+
return await navigator.clipboard.writeText(e), o(!0), !0;
|
|
16
|
+
} catch (e) {
|
|
17
|
+
throw i(e), e;
|
|
18
|
+
} finally {
|
|
19
|
+
c(!1);
|
|
20
|
+
}
|
|
21
|
+
}),
|
|
22
|
+
reset: t(() => {
|
|
23
|
+
o(!1);
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { r as useCopyToClipboard };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a stable selector that reuses the previous result when `deepEqual` says
|
|
3
|
+
* the next selected value is unchanged. Pair it with `useContextSelector` to
|
|
4
|
+
* avoid rerenders from freshly created object or array slices.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* export const useStore = <T,>(selector: (store: CliStore) => T) => {
|
|
9
|
+
* const deepSelector = useDeepCompareSelector(selector)
|
|
10
|
+
*
|
|
11
|
+
* return useContextSelector(CliStoreContext, (store) => {
|
|
12
|
+
* if (!store) throw new Error('CliStoreProvider is missing')
|
|
13
|
+
* return deepSelector(store)
|
|
14
|
+
* })
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* const { name1, name2 } = useStore((store) => ({
|
|
18
|
+
* name1: store.name1,
|
|
19
|
+
* name2: store.name2,
|
|
20
|
+
* }))
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function useDeepCompareSelector<T, S>(selector: (value: T) => S): (value: T) => S;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { deepEqual as e } from "../../common/deepEqual.js";
|
|
2
|
+
import { useCallback as t, useRef as n } from "react";
|
|
3
|
+
//#region src/react/hooks/useDeepCompareSelector.ts
|
|
4
|
+
function r(r) {
|
|
5
|
+
let i = n(r);
|
|
6
|
+
i.current = r;
|
|
7
|
+
let a = n(void 0);
|
|
8
|
+
return t((t) => {
|
|
9
|
+
let n = i.current(t);
|
|
10
|
+
return a.current !== void 0 && e(a.current, n) ? a.current : (a.current = n, n);
|
|
11
|
+
}, []);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { r as useDeepCompareSelector };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//#region src/react/hooks/useInputEvent/_internal/ink-input/input-parser.js
|
|
2
|
+
var e = "\x1B", t = "\x1B[200~", n = "\x1B[201~", r = (e) => e >= 48 && e <= 63, i = (e) => e >= 32 && e <= 47, a = (e) => e >= 64 && e <= 126, o = (e, t, n) => {
|
|
3
|
+
let o = t + n + 1, s = o;
|
|
4
|
+
for (; s < e.length; s++) {
|
|
5
|
+
let n = e.codePointAt(s);
|
|
6
|
+
if (n === void 0) return "pending";
|
|
7
|
+
if (!(r(n) || i(n)) && !(n === 91 && s === o)) return a(n) ? {
|
|
8
|
+
sequence: e.slice(t, s + 1),
|
|
9
|
+
nextIndex: s + 1
|
|
10
|
+
} : void 0;
|
|
11
|
+
}
|
|
12
|
+
return "pending";
|
|
13
|
+
}, s = (e, t, n) => {
|
|
14
|
+
let r = t + n + 2;
|
|
15
|
+
if (r > e.length) return "pending";
|
|
16
|
+
let i = e.codePointAt(r - 1);
|
|
17
|
+
if (!(i === void 0 || !a(i))) return {
|
|
18
|
+
sequence: e.slice(t, r),
|
|
19
|
+
nextIndex: r
|
|
20
|
+
};
|
|
21
|
+
}, c = (e, t, n) => {
|
|
22
|
+
let r = e[t + n];
|
|
23
|
+
if (r === void 0) return "pending";
|
|
24
|
+
if (r === "[") return o(e, t, n);
|
|
25
|
+
if (r === "O") return s(e, t, n);
|
|
26
|
+
}, l = (e, t) => {
|
|
27
|
+
let n = e.codePointAt(t + 1), r = n !== void 0 && n > 65535 ? 2 : 1, i = t + 1 + r;
|
|
28
|
+
return {
|
|
29
|
+
sequence: e.slice(t, i),
|
|
30
|
+
nextIndex: i
|
|
31
|
+
};
|
|
32
|
+
}, u = (t, n) => {
|
|
33
|
+
if (n === t.length - 1) return "pending";
|
|
34
|
+
if (t[n + 1] === e) {
|
|
35
|
+
if (n + 2 >= t.length) return "pending";
|
|
36
|
+
let e = c(t, n, 2);
|
|
37
|
+
return e === "pending" ? "pending" : e || {
|
|
38
|
+
sequence: t.slice(n, n + 2),
|
|
39
|
+
nextIndex: n + 2
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
let r = c(t, n, 1);
|
|
43
|
+
return r === "pending" ? "pending" : r || l(t, n);
|
|
44
|
+
}, d = (e, t) => {
|
|
45
|
+
let n = 0;
|
|
46
|
+
for (let r = 0; r < e.length; r++) {
|
|
47
|
+
let i = e[r];
|
|
48
|
+
(i === "" || i === "\b") && (r > n && t.push(e.slice(n, r)), t.push(i), n = r + 1);
|
|
49
|
+
}
|
|
50
|
+
n < e.length && t.push(e.slice(n));
|
|
51
|
+
}, f = (r) => {
|
|
52
|
+
let i = [], a = 0, o = (e) => ({
|
|
53
|
+
events: i,
|
|
54
|
+
pending: r.slice(e)
|
|
55
|
+
});
|
|
56
|
+
for (; a < r.length;) {
|
|
57
|
+
let s = r.indexOf(e, a);
|
|
58
|
+
if (s === -1) return d(r.slice(a), i), {
|
|
59
|
+
events: i,
|
|
60
|
+
pending: ""
|
|
61
|
+
};
|
|
62
|
+
s > a && d(r.slice(a, s), i);
|
|
63
|
+
let c = u(r, s);
|
|
64
|
+
if (c === "pending") return o(s);
|
|
65
|
+
if (c.sequence === t) {
|
|
66
|
+
let e = c.nextIndex, t = r.indexOf(n, e);
|
|
67
|
+
if (t === -1) return o(s);
|
|
68
|
+
i.push({ paste: r.slice(e, t) }), a = t + 6;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
i.push(c.sequence), a = c.nextIndex;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
events: i,
|
|
75
|
+
pending: ""
|
|
76
|
+
};
|
|
77
|
+
}, p = () => {
|
|
78
|
+
let n = "";
|
|
79
|
+
return {
|
|
80
|
+
push(e) {
|
|
81
|
+
let t = f(n + e);
|
|
82
|
+
return n = t.pending, t.events;
|
|
83
|
+
},
|
|
84
|
+
hasPendingEscape() {
|
|
85
|
+
return n.startsWith(e) && !n.startsWith(t) && n !== "\x1B[200";
|
|
86
|
+
},
|
|
87
|
+
flushPendingEscape() {
|
|
88
|
+
if (!n.startsWith(e)) return;
|
|
89
|
+
let t = n;
|
|
90
|
+
return n = "", t;
|
|
91
|
+
},
|
|
92
|
+
reset() {
|
|
93
|
+
n = "";
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
//#endregion
|
|
98
|
+
export { p as createInputParser };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function resolveFlags(flags: any): number;
|
|
2
|
+
export namespace kittyFlags {
|
|
3
|
+
let disambiguateEscapeCodes: number;
|
|
4
|
+
let reportEventTypes: number;
|
|
5
|
+
let reportAlternateKeys: number;
|
|
6
|
+
let reportAllKeysAsEscapeCodes: number;
|
|
7
|
+
let reportAssociatedText: number;
|
|
8
|
+
}
|
|
9
|
+
export namespace kittyModifiers {
|
|
10
|
+
export let shift: number;
|
|
11
|
+
export let alt: number;
|
|
12
|
+
export let ctrl: number;
|
|
13
|
+
let _super: number;
|
|
14
|
+
export { _super as super };
|
|
15
|
+
export let hyper: number;
|
|
16
|
+
export let meta: number;
|
|
17
|
+
export let capsLock: number;
|
|
18
|
+
export let numLock: number;
|
|
19
|
+
}
|