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 { getEnumerableOwnDescriptors as e } from "./getEnumerableOwnDescriptors.js";
|
|
2
|
+
//#region src/common/deepEqual.ts
|
|
3
|
+
function t(t) {
|
|
4
|
+
return e(t).map(([e]) => e);
|
|
5
|
+
}
|
|
6
|
+
function n(e) {
|
|
7
|
+
return typeof e == "object" && !!e;
|
|
8
|
+
}
|
|
9
|
+
function r(e, t) {
|
|
10
|
+
if (e.constructor !== t.constructor || e.byteLength !== t.byteLength) return !1;
|
|
11
|
+
let n = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), r = new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
|
|
12
|
+
return n.every((e, t) => e === r[t]);
|
|
13
|
+
}
|
|
14
|
+
function i(e, t, n) {
|
|
15
|
+
let r = e.get(t);
|
|
16
|
+
return r?.has(n) ? !0 : r ? (r.add(n), !1) : (e.set(t, new WeakSet([n])), !1);
|
|
17
|
+
}
|
|
18
|
+
function a(e, o, s) {
|
|
19
|
+
if (Object.is(e, o)) return !0;
|
|
20
|
+
if (!n(e) || !n(o) || Object.getPrototypeOf(e) !== Object.getPrototypeOf(o)) return !1;
|
|
21
|
+
if (e instanceof Date && o instanceof Date) return Object.is(e.getTime(), o.getTime());
|
|
22
|
+
if (e instanceof RegExp && o instanceof RegExp) return e.source === o.source && e.flags === o.flags && e.lastIndex === o.lastIndex;
|
|
23
|
+
if (e instanceof Map && o instanceof Map) {
|
|
24
|
+
if (e.size !== o.size || i(s, e, o)) return e.size === o.size;
|
|
25
|
+
let t = Array.from(e.entries()), n = Array.from(o.entries());
|
|
26
|
+
return t.every(([e, t], r) => {
|
|
27
|
+
let i = n[r];
|
|
28
|
+
return i !== void 0 && a(e, i[0], s) && a(t, i[1], s);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (e instanceof Set && o instanceof Set) {
|
|
32
|
+
if (e.size !== o.size || i(s, e, o)) return e.size === o.size;
|
|
33
|
+
let t = Array.from(e.values()), n = Array.from(o.values());
|
|
34
|
+
return t.every((e, t) => a(e, n[t], s));
|
|
35
|
+
}
|
|
36
|
+
if (e instanceof ArrayBuffer && o instanceof ArrayBuffer) return r(new Uint8Array(e), new Uint8Array(o));
|
|
37
|
+
if (ArrayBuffer.isView(e) && ArrayBuffer.isView(o)) return r(e, o);
|
|
38
|
+
if (Array.isArray(e) && Array.isArray(o)) return e.length !== o.length || i(s, e, o) ? e.length === o.length : e.every((e, t) => a(e, o[t], s));
|
|
39
|
+
let c = t(e), l = t(o);
|
|
40
|
+
return c.length !== l.length || i(s, e, o) ? c.length === l.length : c.every((t) => l.includes(t) && a(Reflect.get(e, t), Reflect.get(o, t), s));
|
|
41
|
+
}
|
|
42
|
+
function o(e, t) {
|
|
43
|
+
return a(e, t, /* @__PURE__ */ new WeakMap());
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { o as deepEqual };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deepParseJsonStrings(value: unknown): unknown;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/common/deepParseJsonStrings.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let t = e.trim();
|
|
4
|
+
if (!t || t[0] !== "{" && t[0] !== "[") return e;
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(t);
|
|
7
|
+
} catch {
|
|
8
|
+
return e;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function t(e) {
|
|
12
|
+
return !!(e && typeof e == "object" && !Array.isArray(e));
|
|
13
|
+
}
|
|
14
|
+
function n(r) {
|
|
15
|
+
if (typeof r == "string") {
|
|
16
|
+
let t = e(r);
|
|
17
|
+
return t === r ? r : n(t);
|
|
18
|
+
}
|
|
19
|
+
return Array.isArray(r) ? r.map((e) => n(e)) : t(r) ? Object.fromEntries(Object.entries(r).map(([e, t]) => [e, n(t)])) : r;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { n as deepParseJsonStrings };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declares a compile-time dependency between values without changing runtime behavior.
|
|
3
|
+
*
|
|
4
|
+
* Useful when you want TypeScript to keep certain inferred relationships alive.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const config = { mode: 'prod' as const }
|
|
9
|
+
* dependsOn(config)
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function dependsOn(...values: unknown[]): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluates a callback immediately and returns its result.
|
|
3
|
+
*
|
|
4
|
+
* Useful when you want a small local scope inside an expression.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const message = doExpr(() => {
|
|
9
|
+
* const name = 'Ada'
|
|
10
|
+
* return `Hello, ${name}`
|
|
11
|
+
* })
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function doExpr<T>(fn: () => T): T;
|
package/common/doExpr.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function flatChildren<T>(items: T[], childrenFn: (item: T) => T[] | undefined): T[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a number with rounding to `fractionDigits`, then trims trailing zeros.
|
|
3
|
+
*
|
|
4
|
+
* Returns `NaN`, `Infinity`, or `-Infinity` unchanged as strings.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* formatDecimal(12.3, 2) // '12.3'
|
|
9
|
+
* formatDecimal(12.345, 2) // '12.35'
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatDecimal(value: number, fractionDigits: number): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/common/formatDecimal.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (!Number.isInteger(t) || t < 0) throw Error("fractionDigits must be a non-negative integer.");
|
|
4
|
+
return Number.isFinite(e) ? new Intl.NumberFormat("en-US", {
|
|
5
|
+
maximumFractionDigits: t,
|
|
6
|
+
minimumFractionDigits: 0,
|
|
7
|
+
useGrouping: !1
|
|
8
|
+
}).format(e) : String(e);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { e as formatDecimal };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatFriendlyTime(input: string | number | Date, nowInput?: string | number | Date): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/common/formatFriendlyTime.ts
|
|
2
|
+
var e = 1e3, t = 60 * e, n = 60 * t, r = 24 * n, i = 7 * r, a = 30 * r, o = 365 * r;
|
|
3
|
+
function s(s, c = Date.now()) {
|
|
4
|
+
let l = new Date(s).getTime(), u = new Date(c).getTime();
|
|
5
|
+
if (!Number.isFinite(l) || !Number.isFinite(u)) return "";
|
|
6
|
+
let d = u - l, f = Math.abs(d);
|
|
7
|
+
return f < 5 * e ? "刚刚" : f < t ? `${Math.max(1, Math.floor(f / e))}秒${d >= 0 ? "前" : "后"}` : f < n ? `${Math.floor(f / t)}分钟${d >= 0 ? "前" : "后"}` : f < r ? `${Math.floor(f / n)}小时${d >= 0 ? "前" : "后"}` : f < i ? `${Math.floor(f / r)}天${d >= 0 ? "前" : "后"}` : f < a ? `${Math.floor(f / i)}周${d >= 0 ? "前" : "后"}` : f < o ? `${Math.floor(f / a)}个月${d >= 0 ? "前" : "后"}` : `${Math.floor(f / o)}年${d >= 0 ? "前" : "后"}`;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { s as formatFriendlyTime };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a byte count into a compact size string based on UTF-8 byte totals.
|
|
3
|
+
*
|
|
4
|
+
* The returned value does not include `B` and has no trailing space, so it can
|
|
5
|
+
* be reused in broader count displays.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const bytes = new TextEncoder().encode('你好').length
|
|
10
|
+
* formatSize(bytes) // '6'
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function formatSize(bytes: number): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/common/formatSize.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"",
|
|
4
|
+
"K",
|
|
5
|
+
"M",
|
|
6
|
+
"G",
|
|
7
|
+
"T",
|
|
8
|
+
"P",
|
|
9
|
+
"E"
|
|
10
|
+
], t = 102.4;
|
|
11
|
+
function n(n) {
|
|
12
|
+
if (!Number.isFinite(n)) return "0";
|
|
13
|
+
let r = n < 0 ? "-" : "", i = Math.abs(n), a = i < t ? 0 : 1;
|
|
14
|
+
for (a === 1 && (i /= 1024); i >= 1024 && a < e.length - 1;) i /= 1024, a += 1;
|
|
15
|
+
let o = i >= 100 || a === 0 ? 0 : 1;
|
|
16
|
+
return `${r}${i.toFixed(o).replace(/\.0$/, "")}${e[a]}`;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { n as formatSize };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface FuzzyMatchPart {
|
|
2
|
+
text: string;
|
|
3
|
+
matched: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface FuzzyMatchHit {
|
|
6
|
+
value: string;
|
|
7
|
+
score: number;
|
|
8
|
+
ranges: Array<[number, number]>;
|
|
9
|
+
parts: FuzzyMatchPart[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Fuzzy-matches a query against candidate strings, sorts best hits first, and can
|
|
13
|
+
* optionally return highlight-ready metadata.
|
|
14
|
+
*
|
|
15
|
+
* Matching is case-insensitive and rewards exact, prefix, word-boundary, camel-case,
|
|
16
|
+
* and contiguous matches.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* fuzzyMatch('fm', ['fuzzyMatch', 'formatDecimal'])
|
|
21
|
+
* // ['fuzzyMatch', 'formatDecimal']
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function fuzzyMatch(query: string, candidates: string[], highlight?: false): string[];
|
|
25
|
+
export declare function fuzzyMatch(query: string, candidates: string[], highlight: true): FuzzyMatchHit[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { buildHighlightRanges as e } from "./utils/buildHighlightRanges.js";
|
|
2
|
+
import { buildHighlightParts as t } from "./utils/buildHighlightParts.js";
|
|
3
|
+
import { rankFuzzyCandidates as n } from "./utils/rankFuzzyCandidates.js";
|
|
4
|
+
import { scoreLooseFuzzyMatch as r } from "./utils/scoreLooseFuzzyMatch.js";
|
|
5
|
+
//#region src/common/fuzzy/fuzzyMatch.ts
|
|
6
|
+
function i(i, a, o = !1) {
|
|
7
|
+
let s = n(i, a, r);
|
|
8
|
+
return o ? s.map(({ value: n, score: r, indexes: i }) => {
|
|
9
|
+
let a = e(i);
|
|
10
|
+
return {
|
|
11
|
+
value: n,
|
|
12
|
+
score: r,
|
|
13
|
+
ranges: a,
|
|
14
|
+
parts: t(n, a)
|
|
15
|
+
};
|
|
16
|
+
}) : s.map(({ value: e }) => e);
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { i as fuzzyMatch };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FuzzyMatchHit } from './fuzzyMatch.js';
|
|
2
|
+
/**
|
|
3
|
+
* Fuzzy-matches a query against path-like candidates, sorts best hits first, and can
|
|
4
|
+
* optionally return highlight-ready metadata for file-picker style search.
|
|
5
|
+
*
|
|
6
|
+
* Query separators `/`, `\`, and whitespace split the query into ordered parts that
|
|
7
|
+
* match different path segments in order. A continuous query matches within one path
|
|
8
|
+
* segment only and never spans `/`.
|
|
9
|
+
*
|
|
10
|
+
* Basename matches are preferred over directory-only matches. Both `/` and `\` in
|
|
11
|
+
* candidates and queries are normalized before matching.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* fuzzyMatchPath('common/fm', ['src/common/fuzzy/fuzzyMatch.ts'])
|
|
16
|
+
* // ['src/common/fuzzy/fuzzyMatch.ts']
|
|
17
|
+
*
|
|
18
|
+
* fuzzyMatchPath('abc', ['aaa/bbbc.ts', 'src/abc.ts'])
|
|
19
|
+
* // ['src/abc.ts']
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function fuzzyMatchPath(query: string, candidates: string[], highlight?: false): string[];
|
|
23
|
+
export declare function fuzzyMatchPath(query: string, candidates: string[], highlight: true): FuzzyMatchHit[];
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { buildHighlightRanges as e } from "./utils/buildHighlightRanges.js";
|
|
2
|
+
import { buildHighlightParts as t } from "./utils/buildHighlightParts.js";
|
|
3
|
+
import { normalizePathSeparators as n } from "./utils/normalizePathSeparators.js";
|
|
4
|
+
import { rankFuzzyCandidates as r } from "./utils/rankFuzzyCandidates.js";
|
|
5
|
+
import { scoreLooseFuzzyMatch as i } from "./utils/scoreLooseFuzzyMatch.js";
|
|
6
|
+
//#region src/common/fuzzy/fuzzyMatchPath.ts
|
|
7
|
+
function a(n, i, a = !1) {
|
|
8
|
+
let s = r(n, i, o);
|
|
9
|
+
return a ? s.map(({ value: n, score: r, indexes: i }) => {
|
|
10
|
+
let a = e(i);
|
|
11
|
+
return {
|
|
12
|
+
value: n,
|
|
13
|
+
score: r,
|
|
14
|
+
ranges: a,
|
|
15
|
+
parts: t(n, a)
|
|
16
|
+
};
|
|
17
|
+
}) : s.map(({ value: e }) => e);
|
|
18
|
+
}
|
|
19
|
+
function o(e, t) {
|
|
20
|
+
let r = n(e), i = n(t);
|
|
21
|
+
return s(i) ? u(r, i) : l(r, i);
|
|
22
|
+
}
|
|
23
|
+
function s(e) {
|
|
24
|
+
return /[\s/]/.test(e);
|
|
25
|
+
}
|
|
26
|
+
function c(e) {
|
|
27
|
+
return n(e).split(/[\s/]+/).filter(Boolean);
|
|
28
|
+
}
|
|
29
|
+
function l(e, t) {
|
|
30
|
+
let n = d(e), r = [];
|
|
31
|
+
for (let e = 0; e < n.length; e += 1) {
|
|
32
|
+
let a = n[e];
|
|
33
|
+
if (!a) continue;
|
|
34
|
+
let o = i(a.value, t);
|
|
35
|
+
if (!o) continue;
|
|
36
|
+
let s = e === n.length - 1;
|
|
37
|
+
r.push({
|
|
38
|
+
score: o.score + e * 12 + (s ? 900 : -1200),
|
|
39
|
+
indexes: o.indexes.map((e) => e + a.start),
|
|
40
|
+
spread: o.spread
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return p(r);
|
|
44
|
+
}
|
|
45
|
+
function u(e, t) {
|
|
46
|
+
let n = d(e), r = c(t);
|
|
47
|
+
if (r.length <= 1 || r.length > n.length) return;
|
|
48
|
+
let a = [], o = n.length - 1;
|
|
49
|
+
for (let e = r.length - 1; e >= 0; --e) {
|
|
50
|
+
let t = r[e];
|
|
51
|
+
if (!t) return;
|
|
52
|
+
let s;
|
|
53
|
+
for (let r = o; r >= e; --r) {
|
|
54
|
+
let e = n[r];
|
|
55
|
+
if (!e) continue;
|
|
56
|
+
let a = i(e.value, t);
|
|
57
|
+
if (!a) continue;
|
|
58
|
+
let o = {
|
|
59
|
+
score: a.score + r * 12,
|
|
60
|
+
indexes: a.indexes.map((t) => t + e.start),
|
|
61
|
+
spread: a.spread
|
|
62
|
+
};
|
|
63
|
+
(!s || o.score > s.score || o.score === s.score && (o.indexes[0] ?? -1) > (s.indexes[0] ?? -1)) && (s = o);
|
|
64
|
+
}
|
|
65
|
+
if (!s) return;
|
|
66
|
+
a.unshift(s);
|
|
67
|
+
let c = s.indexes[0];
|
|
68
|
+
if (c === void 0 || (o = f(n, c), o < e - 1)) return;
|
|
69
|
+
}
|
|
70
|
+
let s = Array.from(new Set(a.flatMap((e) => e.indexes))).sort((e, t) => e - t), l = s[0], u = s[s.length - 1];
|
|
71
|
+
if (!(l === void 0 || u === void 0)) return {
|
|
72
|
+
score: a.reduce((e, t, n) => e + t.score + (n === a.length - 1 ? 500 : 0), 0),
|
|
73
|
+
indexes: s,
|
|
74
|
+
spread: u - l
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function d(e) {
|
|
78
|
+
let t = [], n = 0;
|
|
79
|
+
for (let r = 0; r <= e.length; r += 1) {
|
|
80
|
+
if (r < e.length && e[r] !== "/") continue;
|
|
81
|
+
let i = e.slice(n, r);
|
|
82
|
+
i && t.push({
|
|
83
|
+
value: i,
|
|
84
|
+
start: n
|
|
85
|
+
}), n = r + 1;
|
|
86
|
+
}
|
|
87
|
+
return t;
|
|
88
|
+
}
|
|
89
|
+
function f(e, t) {
|
|
90
|
+
for (let n = e.length - 1; n >= 0; --n) {
|
|
91
|
+
let r = e[n];
|
|
92
|
+
if (r && r.start < t) return n;
|
|
93
|
+
}
|
|
94
|
+
return -1;
|
|
95
|
+
}
|
|
96
|
+
function p(e) {
|
|
97
|
+
let t;
|
|
98
|
+
for (let n of e) (!t || n.score > t.score || n.score === t.score && n.spread < t.spread) && (t = n);
|
|
99
|
+
return t;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { a as fuzzyMatchPath };
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/common/fuzzy/utils/buildHighlightParts.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (t.length === 0) return e ? [{
|
|
4
|
+
text: e,
|
|
5
|
+
matched: !1
|
|
6
|
+
}] : [];
|
|
7
|
+
let n = [], r = 0;
|
|
8
|
+
for (let [i, a] of t) r < i && n.push({
|
|
9
|
+
text: e.slice(r, i),
|
|
10
|
+
matched: !1
|
|
11
|
+
}), n.push({
|
|
12
|
+
text: e.slice(i, a),
|
|
13
|
+
matched: !0
|
|
14
|
+
}), r = a;
|
|
15
|
+
return r < e.length && n.push({
|
|
16
|
+
text: e.slice(r),
|
|
17
|
+
matched: !1
|
|
18
|
+
}), n;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { e as buildHighlightParts };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildHighlightRanges(indexes: number[]): Array<[number, number]>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/common/fuzzy/utils/buildHighlightRanges.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
if (e.length === 0) return [];
|
|
4
|
+
let t = [], n = e[0];
|
|
5
|
+
if (n === void 0) return [];
|
|
6
|
+
let r = n, i = n + 1;
|
|
7
|
+
for (let n = 1; n < e.length; n += 1) {
|
|
8
|
+
let a = e[n];
|
|
9
|
+
if (a !== void 0) {
|
|
10
|
+
if (a === i) {
|
|
11
|
+
i += 1;
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
t.push([r, i]), r = a, i = a + 1;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return t.push([r, i]), t;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { e as buildHighlightRanges };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { buildHighlightRanges as e } from "./buildHighlightRanges.js";
|
|
2
|
+
import { buildHighlightParts as t } from "./buildHighlightParts.js";
|
|
3
|
+
import { normalizePathSeparators as n } from "./normalizePathSeparators.js";
|
|
4
|
+
import { rankFuzzyCandidates as r } from "./rankFuzzyCandidates.js";
|
|
5
|
+
import { scoreLooseFuzzyMatch as i } from "./scoreLooseFuzzyMatch.js";
|
|
6
|
+
export { t as buildHighlightParts, e as buildHighlightRanges, n as normalizePathSeparators, r as rankFuzzyCandidates, i as scoreLooseFuzzyMatch };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function normalizePathSeparators(value: string): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/common/fuzzy/utils/rankFuzzyCandidates.ts
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
let r = e.trim();
|
|
4
|
+
if (!r) return t.map((e) => ({
|
|
5
|
+
value: e,
|
|
6
|
+
score: 0,
|
|
7
|
+
indexes: []
|
|
8
|
+
}));
|
|
9
|
+
let i = t.map((e, t) => {
|
|
10
|
+
let i = n(e, r);
|
|
11
|
+
if (i) return {
|
|
12
|
+
index: t,
|
|
13
|
+
value: e,
|
|
14
|
+
score: i.score,
|
|
15
|
+
indexes: i.indexes,
|
|
16
|
+
spread: i.spread
|
|
17
|
+
};
|
|
18
|
+
}).filter((e) => e !== void 0);
|
|
19
|
+
return i.sort((e, t) => t.score - e.score || e.spread - t.spread || e.value.length - t.value.length || e.index - t.index), i.map(({ value: e, score: t, indexes: n }) => ({
|
|
20
|
+
value: e,
|
|
21
|
+
score: t,
|
|
22
|
+
indexes: n
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { e as rankFuzzyCandidates };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
//#region src/common/fuzzy/utils/scoreLooseFuzzyMatch.ts
|
|
2
|
+
var e = new Set([
|
|
3
|
+
"/",
|
|
4
|
+
"\\",
|
|
5
|
+
"-",
|
|
6
|
+
"_",
|
|
7
|
+
".",
|
|
8
|
+
" "
|
|
9
|
+
]);
|
|
10
|
+
function t(e) {
|
|
11
|
+
return e.trim().split(/\s+/).filter(Boolean);
|
|
12
|
+
}
|
|
13
|
+
function n(e, t) {
|
|
14
|
+
if (!t) return {
|
|
15
|
+
score: 0,
|
|
16
|
+
indexes: [],
|
|
17
|
+
spread: 0
|
|
18
|
+
};
|
|
19
|
+
if (t.length > e.length) return;
|
|
20
|
+
let n = e.toLowerCase(), r = t.toLowerCase(), i = Array.from({ length: t.length }, () => Array.from({ length: e.length }, () => void 0)), s = r[0];
|
|
21
|
+
if (s === void 0) return;
|
|
22
|
+
for (let r = 0; r < e.length; r += 1) {
|
|
23
|
+
let o = n[r];
|
|
24
|
+
if (o === void 0 || o !== s) continue;
|
|
25
|
+
let c = i[0];
|
|
26
|
+
if (!c) return;
|
|
27
|
+
c[r] = {
|
|
28
|
+
score: a(e, t, r, 0, !0),
|
|
29
|
+
previousIndex: -1
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
for (let s = 1; s < t.length; s += 1) for (let c = s; c < e.length; c += 1) {
|
|
33
|
+
let l = n[c], u = r[s];
|
|
34
|
+
if (l === void 0 || u === void 0 || l !== u) continue;
|
|
35
|
+
let d;
|
|
36
|
+
for (let n = s - 1; n < c; n += 1) {
|
|
37
|
+
let r = i[s - 1]?.[n];
|
|
38
|
+
if (!r) continue;
|
|
39
|
+
let l = r.score + a(e, t, c, s, !1) + o(c - n);
|
|
40
|
+
(!d || l > d.score) && (d = {
|
|
41
|
+
score: l,
|
|
42
|
+
previousIndex: n
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
let f = i[s];
|
|
46
|
+
if (!f) return;
|
|
47
|
+
f[c] = d;
|
|
48
|
+
}
|
|
49
|
+
let c, l = -1;
|
|
50
|
+
for (let n = t.length - 1; n < e.length; n += 1) {
|
|
51
|
+
let e = i[t.length - 1]?.[n];
|
|
52
|
+
e && (!c || e.score > c.score || e.score === c.score && n < l) && (c = e, l = n);
|
|
53
|
+
}
|
|
54
|
+
if (!c) return;
|
|
55
|
+
let u = Array(t.length), d = t.length - 1, f = l;
|
|
56
|
+
for (; d >= 0;) {
|
|
57
|
+
u[d] = f;
|
|
58
|
+
let e = i[d]?.[f];
|
|
59
|
+
if (!e) return;
|
|
60
|
+
f = e.previousIndex, --d;
|
|
61
|
+
}
|
|
62
|
+
let p = u[0], m = u[u.length - 1];
|
|
63
|
+
if (p === void 0 || m === void 0) return;
|
|
64
|
+
let h = m - p, g = c.score;
|
|
65
|
+
if (n === r) g += 2e3;
|
|
66
|
+
else if (n.startsWith(r)) g += 600 + Math.round(t.length / e.length * 120);
|
|
67
|
+
else {
|
|
68
|
+
let e = n.indexOf(r);
|
|
69
|
+
e >= 0 && (g += 320 - Math.min(160, e * 8));
|
|
70
|
+
}
|
|
71
|
+
return g += Math.round(t.length / e.length * 100), g -= h * 4, g -= Math.max(0, e.length - t.length), {
|
|
72
|
+
score: g,
|
|
73
|
+
indexes: u,
|
|
74
|
+
spread: h
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function r(e) {
|
|
78
|
+
return Array.from(new Set(e)).sort((e, t) => e - t);
|
|
79
|
+
}
|
|
80
|
+
function i(e, i) {
|
|
81
|
+
let a = t(i);
|
|
82
|
+
if (a.length === 0) return {
|
|
83
|
+
score: 0,
|
|
84
|
+
indexes: [],
|
|
85
|
+
spread: 0
|
|
86
|
+
};
|
|
87
|
+
let o = 0, s = [];
|
|
88
|
+
for (let t of a) {
|
|
89
|
+
let r = n(e, t);
|
|
90
|
+
if (!r) return;
|
|
91
|
+
o += r.score, s.push(...r.indexes);
|
|
92
|
+
}
|
|
93
|
+
let c = r(s), l = c[0], u = c[c.length - 1];
|
|
94
|
+
return l === void 0 || u === void 0 ? {
|
|
95
|
+
score: o,
|
|
96
|
+
indexes: [],
|
|
97
|
+
spread: 0
|
|
98
|
+
} : {
|
|
99
|
+
score: o,
|
|
100
|
+
indexes: c,
|
|
101
|
+
spread: u - l
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function a(e, t, n, r, i) {
|
|
105
|
+
let a = e[n], o = t[r], c = 10;
|
|
106
|
+
return a !== void 0 && o !== void 0 && a === o && (c += 2), s(e, n) && (c += 28), i && n === 0 && (c += 16), c;
|
|
107
|
+
}
|
|
108
|
+
function o(e) {
|
|
109
|
+
return e === 1 ? 30 : Math.max(-20, 12 - (e - 1) * 5);
|
|
110
|
+
}
|
|
111
|
+
function s(t, n) {
|
|
112
|
+
if (n === 0) return !0;
|
|
113
|
+
let r = t[n], i = t[n - 1];
|
|
114
|
+
return r === void 0 || i === void 0 ? !1 : !!(e.has(i) || c(i) && l(r) || u(i) !== u(r));
|
|
115
|
+
}
|
|
116
|
+
function c(e) {
|
|
117
|
+
return e >= "a" && e <= "z";
|
|
118
|
+
}
|
|
119
|
+
function l(e) {
|
|
120
|
+
return e >= "A" && e <= "Z";
|
|
121
|
+
}
|
|
122
|
+
function u(e) {
|
|
123
|
+
return e >= "0" && e <= "9";
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
export { i as scoreLooseFuzzyMatch };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getEnumerableOwnDescriptors(value: object): Array<[key: string | symbol, descriptor: PropertyDescriptor]>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/common/getEnumerableOwnDescriptors.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let t = [];
|
|
4
|
+
for (let n of Reflect.ownKeys(e)) {
|
|
5
|
+
let r = Object.getOwnPropertyDescriptor(e, n);
|
|
6
|
+
r?.enumerable && t.push([n, r]);
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { e as getEnumerableOwnDescriptors };
|