1ls 0.1.11 → 0.1.13
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 +279 -11
- package/dist/browser/constants.d.ts +1 -1
- package/dist/browser/index.js +11 -11
- package/dist/cli/constants.d.ts +1 -1
- package/dist/{utils → cli}/stream.d.ts +1 -1
- package/dist/completions/1ls.bash +10 -18
- package/dist/completions/1ls.zsh +69 -7
- package/dist/{shared/constants.d.ts → constants.d.ts} +1 -1
- package/dist/expression/constants.d.ts +2 -0
- package/dist/expression/index.d.ts +3 -12
- package/dist/expression/utils.d.ts +14 -1
- package/dist/file/constants.d.ts +4 -0
- package/dist/file/filters.d.ts +7 -0
- package/dist/file/grep.d.ts +10 -0
- package/dist/file/index.d.ts +7 -0
- package/dist/file/info.d.ts +4 -0
- package/dist/file/io.d.ts +5 -0
- package/dist/{utils → file}/types.d.ts +0 -17
- package/dist/file/walk.d.ts +4 -0
- package/dist/formats/index.d.ts +1 -1
- package/dist/formats/types.d.ts +1 -0
- package/dist/formats/yaml/index.d.ts +2 -0
- package/dist/formats/yaml/types.d.ts +8 -0
- package/dist/formats/yaml/utils.d.ts +28 -0
- package/dist/index.js +83 -63
- package/dist/interactive/builder/constants.d.ts +14 -0
- package/dist/interactive/{builder.d.ts → builder/index.d.ts} +1 -1
- package/dist/interactive/builder/types.d.ts +4 -0
- package/dist/interactive/builder/utils.d.ts +7 -0
- package/dist/interactive/methods/constants.d.ts +10 -0
- package/dist/interactive/methods/index.d.ts +4 -0
- package/dist/interactive/methods/types.d.ts +8 -0
- package/dist/interactive/preview/constants.d.ts +4 -0
- package/dist/interactive/preview/index.d.ts +5 -0
- package/dist/interactive/preview/types.d.ts +6 -0
- package/dist/interactive/tooltip/constants.d.ts +3 -0
- package/dist/interactive/tooltip/index.d.ts +20 -0
- package/dist/interactive/tooltip/types.d.ts +13 -0
- package/dist/interactive/types.d.ts +5 -7
- package/dist/{utils/logger.d.ts → logger.d.ts} +10 -1
- package/dist/navigator/builtins/constants.d.ts +62 -0
- package/dist/navigator/builtins/index.d.ts +6 -0
- package/dist/navigator/builtins/types.d.ts +3 -0
- package/dist/navigator/builtins/utils.d.ts +12 -0
- package/dist/navigator/json/constants.d.ts +2 -0
- package/dist/navigator/json/index.d.ts +22 -0
- package/dist/navigator/json/types.d.ts +3 -0
- package/dist/navigator/json/utils.d.ts +14 -0
- package/dist/shortcuts/constants.d.ts +15 -0
- package/dist/shortcuts/index.d.ts +9 -0
- package/dist/shortcuts/types.d.ts +6 -0
- package/dist/types.d.ts +22 -2
- package/dist/version.d.ts +1 -0
- package/package.json +5 -3
- package/dist/formats/yaml.d.ts +0 -3
- package/dist/interactive/methods.d.ts +0 -12
- package/dist/navigator/json.d.ts +0 -26
- package/dist/utils/constants.d.ts +0 -12
- package/dist/utils/file.d.ts +0 -27
- package/dist/utils/index.d.ts +0 -7
- package/dist/utils/shortcuts.d.ts +0 -8
package/dist/completions/1ls.zsh
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
#compdef 1ls
|
|
2
|
-
# Zsh completion for 1ls
|
|
3
2
|
|
|
4
3
|
_1ls() {
|
|
5
4
|
local -a opts format_opts shortcuts json_paths
|
|
6
5
|
|
|
7
|
-
# Main options
|
|
8
6
|
opts=(
|
|
9
7
|
'--help[Show help]'
|
|
10
8
|
'--version[Show version]'
|
|
@@ -24,10 +22,11 @@ _1ls() {
|
|
|
24
22
|
'--shortcuts[Show all available shortcuts]'
|
|
25
23
|
'--shorten[Convert expression to shorthand]:expression:'
|
|
26
24
|
'--expand[Convert shorthand to full form]:expression:'
|
|
25
|
+
'--slurp[Read all inputs into array]'
|
|
26
|
+
'--null-input[Use null as input]'
|
|
27
27
|
'readFile[Read from file]:file:_files'
|
|
28
28
|
)
|
|
29
29
|
|
|
30
|
-
# Common shorthand methods
|
|
31
30
|
shortcuts=(
|
|
32
31
|
'.mp:map - Transform each element'
|
|
33
32
|
'.flt:filter - Filter elements'
|
|
@@ -46,16 +45,79 @@ _1ls() {
|
|
|
46
45
|
'.trm:trim - Remove whitespace'
|
|
47
46
|
)
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
builtins=(
|
|
49
|
+
'head:hd - First element'
|
|
50
|
+
'last:lst - Last element'
|
|
51
|
+
'tail:tl - All but first'
|
|
52
|
+
'take:tk - Take n elements'
|
|
53
|
+
'drop:drp - Drop n elements'
|
|
54
|
+
'uniq:unq - Unique values'
|
|
55
|
+
'flatten:fltn - Flatten nested'
|
|
56
|
+
'rev:Reverse array'
|
|
57
|
+
'groupBy:grpBy - Group by key'
|
|
58
|
+
'sortBy:srtBy - Sort by key'
|
|
59
|
+
'chunk:chnk - Split into chunks'
|
|
60
|
+
'compact:cmpct - Remove falsy'
|
|
61
|
+
'pick:pk - Pick keys'
|
|
62
|
+
'omit:omt - Omit keys'
|
|
63
|
+
'keys:ks - Object keys'
|
|
64
|
+
'vals:Object values'
|
|
65
|
+
'merge:mrg - Shallow merge'
|
|
66
|
+
'deepMerge:dMrg - Deep merge'
|
|
67
|
+
'fromPairs:frPrs - Pairs to object'
|
|
68
|
+
'toPairs:toPrs - Object to pairs'
|
|
69
|
+
'sum:Sum array'
|
|
70
|
+
'mean:avg - Average'
|
|
71
|
+
'min:Minimum'
|
|
72
|
+
'max:Maximum'
|
|
73
|
+
'len:Length'
|
|
74
|
+
'count:cnt - Count items'
|
|
75
|
+
'isEmpty:emp - Check if empty'
|
|
76
|
+
'isNil:nil - Check if null/undefined'
|
|
77
|
+
'pluck:plk - Extract property'
|
|
78
|
+
'pipe:Compose left-to-right'
|
|
79
|
+
'compose:Compose right-to-left'
|
|
80
|
+
'id:Identity function'
|
|
81
|
+
'type:typ - Get value type'
|
|
82
|
+
'range:rng - Generate range'
|
|
83
|
+
'has:hs - Check if key exists'
|
|
84
|
+
'nth:Get nth element'
|
|
85
|
+
'contains:ctns - Check if contains'
|
|
86
|
+
'add:Concat/sum values'
|
|
87
|
+
'path:pth - Get all paths'
|
|
88
|
+
'getpath:gpth - Get value at path'
|
|
89
|
+
'setpath:spth - Set value at path'
|
|
90
|
+
'recurse:rec - Recurse all values'
|
|
91
|
+
'split:spl - Split string'
|
|
92
|
+
'join:jn - Join array'
|
|
93
|
+
'startswith:stw - Check prefix'
|
|
94
|
+
'endswith:edw - Check suffix'
|
|
95
|
+
'ltrimstr:ltrm - Trim prefix'
|
|
96
|
+
'rtrimstr:rtrm - Trim suffix'
|
|
97
|
+
'tostring:tstr - Convert to string'
|
|
98
|
+
'tonumber:tnum - Convert to number'
|
|
99
|
+
'floor:flr - Floor number'
|
|
100
|
+
'ceil:cl - Ceil number'
|
|
101
|
+
'round:rnd - Round number'
|
|
102
|
+
'abs:Absolute value'
|
|
103
|
+
'not:Boolean negation'
|
|
104
|
+
'select:sel - Filter by predicate'
|
|
105
|
+
'empty:Return nothing'
|
|
106
|
+
'error:Throw error'
|
|
107
|
+
'debug:dbg - Debug output'
|
|
108
|
+
)
|
|
109
|
+
|
|
50
110
|
json_paths=(
|
|
51
111
|
'.:Root object'
|
|
52
112
|
'.[]:All array elements'
|
|
113
|
+
'..:Recursive descent'
|
|
53
114
|
'.{keys}:Object keys'
|
|
54
115
|
'.{values}:Object values'
|
|
55
116
|
'.{entries}:Object entries'
|
|
117
|
+
'.foo?:Optional access'
|
|
118
|
+
'.foo ?? default:Null coalescing'
|
|
56
119
|
)
|
|
57
120
|
|
|
58
|
-
# Check context and provide appropriate completions
|
|
59
121
|
local curcontext="$curcontext" state line
|
|
60
122
|
typeset -A opt_args
|
|
61
123
|
|
|
@@ -65,15 +127,15 @@ _1ls() {
|
|
|
65
127
|
|
|
66
128
|
case $state in
|
|
67
129
|
args)
|
|
68
|
-
# If typing starts with ., offer shortcuts and paths
|
|
69
130
|
if [[ $words[$CURRENT] == .* ]]; then
|
|
70
131
|
_describe -t shortcuts 'shortcuts' shortcuts
|
|
71
132
|
_describe -t paths 'json paths' json_paths
|
|
72
133
|
else
|
|
134
|
+
_describe -t builtins 'builtin functions' builtins
|
|
73
135
|
_arguments "${opts[@]}"
|
|
74
136
|
fi
|
|
75
137
|
;;
|
|
76
138
|
esac
|
|
77
139
|
}
|
|
78
140
|
|
|
79
|
-
_1ls "$@"
|
|
141
|
+
_1ls "$@"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ShortcutMapping } from "
|
|
1
|
+
import type { ShortcutMapping } from "./shortcuts";
|
|
2
2
|
export declare const VALID_OUTPUT_FORMATS: readonly ["json", "yaml", "csv", "table"];
|
|
3
3
|
export declare const VALID_INPUT_FORMATS: readonly ["json", "yaml", "toml", "csv", "tsv", "lines", "text"];
|
|
4
4
|
export declare const SHORTCUTS: ShortcutMapping[];
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import { Token,
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export declare function createIndexAccessNode(index: number, object?: ASTNode): IndexAccessNode;
|
|
5
|
-
export declare function createSliceAccessNode(start: number | undefined, end: number | undefined, object?: ASTNode): SliceAccessNode;
|
|
6
|
-
export declare function createMethodCallNode(method: string, args: ASTNode[], object?: ASTNode): MethodCallNode;
|
|
7
|
-
export declare function createObjectOperationNode(operation: ObjectOperationType, object?: ASTNode): ObjectOperationNode;
|
|
8
|
-
export declare function createArraySpreadNode(object?: ASTNode): ArraySpreadNode;
|
|
9
|
-
export declare function createArrowFunctionNode(params: string[], body: ASTNode): ArrowFunctionNode;
|
|
10
|
-
export declare function createRootNode(expression?: ASTNode): RootNode;
|
|
11
|
-
export declare const VALID_OBJECT_OPERATIONS: readonly ObjectOperationType[];
|
|
12
|
-
export declare function isValidObjectOperation(value: string): value is ObjectOperationType;
|
|
1
|
+
import type { Token, RootNode } from "../types";
|
|
2
|
+
export { createErrorMessage, createPropertyAccessNode, createIndexAccessNode, createSliceAccessNode, createMethodCallNode, createObjectOperationNode, createArraySpreadNode, createArrowFunctionNode, createRootNode, createRecursiveDescentNode, createOptionalAccessNode, createNullCoalescingNode, isValidObjectOperation, } from "./utils";
|
|
3
|
+
export { VALID_OBJECT_OPERATIONS } from "./constants";
|
|
13
4
|
export declare class ExpressionParser {
|
|
14
5
|
private tokens;
|
|
15
6
|
private position;
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import { LiteralNode } from "../types";
|
|
1
|
+
import type { Token, ASTNode, LiteralNode, PropertyAccessNode, IndexAccessNode, SliceAccessNode, MethodCallNode, ObjectOperationNode, ObjectOperationType, ArraySpreadNode, ArrowFunctionNode, RootNode, RecursiveDescentNode, OptionalAccessNode, NullCoalescingNode } from "../types";
|
|
2
2
|
import { BOOLEAN_LITERALS } from "./constants";
|
|
3
3
|
export declare const isBooleanLiteral: (value: string) => value is (typeof BOOLEAN_LITERALS)[number];
|
|
4
4
|
export declare const createLiteralNode: (value: string | number | boolean | null) => LiteralNode;
|
|
5
5
|
export declare const tryParseLiteralIdentifier: (identifier: string) => LiteralNode | undefined;
|
|
6
|
+
export declare const createErrorMessage: (token: Token, message: string) => string;
|
|
7
|
+
export declare const createPropertyAccessNode: (property: string, object?: ASTNode) => PropertyAccessNode;
|
|
8
|
+
export declare const createIndexAccessNode: (index: number, object?: ASTNode) => IndexAccessNode;
|
|
9
|
+
export declare const createSliceAccessNode: (start: number | undefined, end: number | undefined, object?: ASTNode) => SliceAccessNode;
|
|
10
|
+
export declare const createMethodCallNode: (method: string, args: ASTNode[], object?: ASTNode) => MethodCallNode;
|
|
11
|
+
export declare const createObjectOperationNode: (operation: ObjectOperationType, object?: ASTNode) => ObjectOperationNode;
|
|
12
|
+
export declare const createArraySpreadNode: (object?: ASTNode) => ArraySpreadNode;
|
|
13
|
+
export declare const createArrowFunctionNode: (params: string[], body: ASTNode) => ArrowFunctionNode;
|
|
14
|
+
export declare const createRootNode: (expression?: ASTNode) => RootNode;
|
|
15
|
+
export declare const createRecursiveDescentNode: (object?: ASTNode) => RecursiveDescentNode;
|
|
16
|
+
export declare const createOptionalAccessNode: (expression: ASTNode, object?: ASTNode) => OptionalAccessNode;
|
|
17
|
+
export declare const createNullCoalescingNode: (left: ASTNode, right: ASTNode) => NullCoalescingNode;
|
|
18
|
+
export declare const isValidObjectOperation: (value: string) => value is ObjectOperationType;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const SUPPORTED_CODE_EXTENSIONS: readonly [".ts", ".js", ".tsx", ".jsx"];
|
|
2
|
+
export declare const SUPPORTED_DATA_EXTENSIONS: readonly [".json", ".yml", ".yaml"];
|
|
3
|
+
export declare const SUPPORTED_TEXT_EXTENSIONS: readonly [".md", ".txt"];
|
|
4
|
+
export declare const DEFAULT_SEARCH_EXTENSIONS: readonly [".ts", ".js", ".tsx", ".jsx", ".json", ".yml", ".yaml", ".md", ".txt"];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FileInfo } from "./types";
|
|
2
|
+
export declare const isHiddenFile: (entry: string) => boolean;
|
|
3
|
+
export declare const shouldIncludeHiddenFile: (entry: string, includeHidden: boolean) => boolean;
|
|
4
|
+
export declare const matchesExtensionFilter: (ext: string, extensions: string[] | undefined) => boolean;
|
|
5
|
+
export declare const matchesPatternFilter: (name: string, pattern: RegExp | undefined) => boolean;
|
|
6
|
+
export declare const shouldIncludeFile: (info: FileInfo, extensions: string[] | undefined, pattern: RegExp | undefined) => boolean;
|
|
7
|
+
export declare const isWithinDepthLimit: (depth: number, maxDepth: number | undefined) => boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { GrepOptions, GrepResult } from "./types";
|
|
2
|
+
export declare const createRegexFromPattern: (pattern: string | RegExp, ignoreCase: boolean) => RegExp;
|
|
3
|
+
export declare const createGrepResult: (filePath: string, lineNumber: number, matchIndex: number, lineContent: string, lines: readonly string[], contextSize: number | undefined) => GrepResult;
|
|
4
|
+
export declare const logVerboseError: (filePath: string, error: unknown, verbose: boolean) => void;
|
|
5
|
+
export declare const extractMatchesFromLine: (line: string, lineIndex: number, regex: RegExp, filePath: string, allLines: readonly string[], contextSize: number | undefined) => GrepResult[];
|
|
6
|
+
export declare const shouldStopSearching: (currentCount: number, maxMatches: number | undefined) => boolean;
|
|
7
|
+
export declare const searchFileContent: (filePath: string, regex: RegExp, options: GrepOptions) => Promise<GrepResult[]>;
|
|
8
|
+
export declare const searchInDirectory: (path: string, regex: RegExp, options: GrepOptions) => Promise<GrepResult[]>;
|
|
9
|
+
export declare function grep(pattern: string, path: string, options?: GrepOptions): Promise<GrepResult[]>;
|
|
10
|
+
export declare function grep(pattern: RegExp, path: string, options?: GrepOptions): Promise<GrepResult[]>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { FileInfo, ListOptions, GrepOptions, GrepResult } from "./types";
|
|
2
|
+
export { SUPPORTED_CODE_EXTENSIONS, SUPPORTED_DATA_EXTENSIONS, SUPPORTED_TEXT_EXTENSIONS, DEFAULT_SEARCH_EXTENSIONS, } from "./constants";
|
|
3
|
+
export { readFile, serializeContent, writeFile } from "./io";
|
|
4
|
+
export { createFileInfo, getFileInfo } from "./info";
|
|
5
|
+
export { isHiddenFile, shouldIncludeHiddenFile, matchesExtensionFilter, matchesPatternFilter, shouldIncludeFile, isWithinDepthLimit, } from "./filters";
|
|
6
|
+
export { processDirectoryEntry, walkDirectory, listFiles } from "./walk";
|
|
7
|
+
export { createRegexFromPattern, createGrepResult, logVerboseError, extractMatchesFromLine, shouldStopSearching, searchFileContent, searchInDirectory, grep, } from "./grep";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function readFile(path: string): Promise<unknown>;
|
|
2
|
+
export declare function readFile(path: string, parseJson: true): Promise<unknown>;
|
|
3
|
+
export declare function readFile(path: string, parseJson: false): Promise<string>;
|
|
4
|
+
export declare const serializeContent: (content: unknown) => string;
|
|
5
|
+
export declare const writeFile: (path: string, content: unknown) => Promise<void>;
|
|
@@ -30,20 +30,3 @@ export interface GrepResult {
|
|
|
30
30
|
match: string;
|
|
31
31
|
context?: string[];
|
|
32
32
|
}
|
|
33
|
-
export type DataFormat = "json" | "json5" | "yaml" | "toml" | "xml" | "ini" | "csv" | "tsv" | "protobuf" | "javascript" | "typescript" | "env" | "ndjson" | "lines" | "text";
|
|
34
|
-
export interface ShortcutMapping {
|
|
35
|
-
short: string;
|
|
36
|
-
full: string;
|
|
37
|
-
description: string;
|
|
38
|
-
type: "array" | "object" | "string" | "any";
|
|
39
|
-
}
|
|
40
|
-
export declare const LogLevel: {
|
|
41
|
-
readonly ERROR: 0;
|
|
42
|
-
readonly WARN: 1;
|
|
43
|
-
readonly INFO: 2;
|
|
44
|
-
readonly DEBUG: 3;
|
|
45
|
-
};
|
|
46
|
-
export type LogLevelType = (typeof LogLevel)[keyof typeof LogLevel];
|
|
47
|
-
export interface LogData {
|
|
48
|
-
[key: string]: unknown;
|
|
49
|
-
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FileInfo, ListOptions } from "./types";
|
|
2
|
+
export declare const processDirectoryEntry: (currentDir: string, entry: string, depth: number, options: ListOptions) => Promise<FileInfo[]>;
|
|
3
|
+
export declare const walkDirectory: (currentDir: string, depth: number, options: ListOptions) => Promise<FileInfo[]>;
|
|
4
|
+
export declare const listFiles: (dir: string, options?: ListOptions) => Promise<FileInfo[]>;
|
package/dist/formats/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataFormat } from "
|
|
1
|
+
import type { DataFormat } from "./types";
|
|
2
2
|
export declare function parseLines(input: string): string[];
|
|
3
3
|
export declare function parseInput(input: string, format?: DataFormat): Promise<unknown>;
|
|
4
4
|
export declare function detectFormat(input: string): DataFormat;
|
package/dist/formats/types.d.ts
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const getIndent: (line: string) => number;
|
|
2
|
+
export declare const countQuotes: (text: string) => number;
|
|
3
|
+
export declare const isCommentOutsideQuotes: (line: string, commentIdx: number) => boolean;
|
|
4
|
+
export declare const stripComment: (line: string) => string;
|
|
5
|
+
export declare const isMultilineIndicator: (value: string) => boolean;
|
|
6
|
+
export declare const isDocumentMarker: (trimmed: string) => boolean;
|
|
7
|
+
export declare const isListItemLine: (trimmed: string) => boolean;
|
|
8
|
+
export declare const getListItemContent: (trimmed: string) => string;
|
|
9
|
+
export declare const hasValidColonKey: (value: string) => boolean;
|
|
10
|
+
export declare const parseKeyValue: (line: string) => {
|
|
11
|
+
key: string;
|
|
12
|
+
value: string;
|
|
13
|
+
} | null;
|
|
14
|
+
export declare const extractAnchorFromValue: (value: string) => {
|
|
15
|
+
anchorName: string | null;
|
|
16
|
+
cleanValue: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const extractAnchorFromKey: (key: string) => {
|
|
19
|
+
cleanKey: string;
|
|
20
|
+
anchorName: string | null;
|
|
21
|
+
};
|
|
22
|
+
export declare const parseYAMLValue: (value: string) => unknown;
|
|
23
|
+
export declare const findPreviousKey: (lines: string[], currentIndex: number) => string | null;
|
|
24
|
+
export declare const collectMultilineContent: (lines: string[], startIdx: number, baseIndent: number) => {
|
|
25
|
+
contentLines: string[];
|
|
26
|
+
endIdx: number;
|
|
27
|
+
};
|
|
28
|
+
export declare const formatMultilineValue: (contentLines: string[], style: "|" | ">") => string;
|