@sunshj/vscode-ab5x-utils 0.0.6 → 0.0.8
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/dist/index.cjs +4 -1
- package/dist/index.d.mts +7 -4
- package/dist/index.mjs +4 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -21,7 +21,10 @@ function createRegexCollector(regex, setupContextOrTransform, transform) {
|
|
|
21
21
|
};
|
|
22
22
|
if (transformFn) {
|
|
23
23
|
const item = transformFn(match, Object.assign({ _item }, context));
|
|
24
|
-
if (item) items.push(
|
|
24
|
+
if (item) items.push({
|
|
25
|
+
..._item,
|
|
26
|
+
...item
|
|
27
|
+
});
|
|
25
28
|
} else items.push(_item);
|
|
26
29
|
}
|
|
27
30
|
return items;
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { CodeLens, CodeLensProvider, CompletionItem, CompletionItemProvider, Dec
|
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
5
|
/** 匹配结果项 */
|
|
6
|
-
interface MatchItem<TExtra = unknown> {
|
|
6
|
+
interface MatchItem<TExtra = unknown> extends Record<string, unknown> {
|
|
7
7
|
/** 匹配的文本 */
|
|
8
8
|
text: string;
|
|
9
9
|
/** 匹配开始索引 */
|
|
@@ -17,7 +17,10 @@ type MaybeTextDocument = TextDocument | {
|
|
|
17
17
|
getText: () => string;
|
|
18
18
|
};
|
|
19
19
|
/** 收集函数类型 */
|
|
20
|
-
|
|
20
|
+
interface CollectFn<TExtra = unknown> {
|
|
21
|
+
(document: MaybeTextDocument): Array<MatchItem<TExtra>>;
|
|
22
|
+
(document: MaybeTextDocument, skipCache?: boolean): Array<MatchItem<TExtra>>;
|
|
23
|
+
}
|
|
21
24
|
/** DocumentLink 配置 */
|
|
22
25
|
interface DocumentLinkConfig<TExtra = unknown> {
|
|
23
26
|
/** 是否启用 */
|
|
@@ -106,9 +109,9 @@ type ContextWithMatchItem<TContext> = TContext & {
|
|
|
106
109
|
_item: MatchItem;
|
|
107
110
|
};
|
|
108
111
|
/** 创建基于正则的收集函数 - 无 context */
|
|
109
|
-
declare function createRegexCollector<TExtra = unknown>(regex: RegExp, transform?: (match: RegExpExecArray, context: ContextWithMatchItem<unknown>) => MatchItem<TExtra
|
|
112
|
+
declare function createRegexCollector<TExtra = unknown>(regex: RegExp, transform?: (match: RegExpExecArray, context: ContextWithMatchItem<unknown>) => Partial<MatchItem<TExtra>> | undefined): CollectFn<TExtra>;
|
|
110
113
|
/** 创建基于正则的收集函数 - 带 context */
|
|
111
|
-
declare function createRegexCollector<TContext = object, TExtra = unknown>(regex: RegExp, setupContext: () => TContext, transform: (match: RegExpExecArray, context: ContextWithMatchItem<TContext>) => MatchItem<TExtra
|
|
114
|
+
declare function createRegexCollector<TContext = object, TExtra = unknown>(regex: RegExp, setupContext: () => TContext, transform: (match: RegExpExecArray, context: ContextWithMatchItem<TContext>) => Partial<MatchItem<TExtra>> | undefined): CollectFn<TExtra>;
|
|
112
115
|
/** 从匹配项创建 Range */
|
|
113
116
|
declare function createRange(document: TextDocument, item: MatchItem): Range;
|
|
114
117
|
/** 获取匹配项的 extra 数据 */
|
package/dist/index.mjs
CHANGED
|
@@ -21,7 +21,10 @@ function createRegexCollector(regex, setupContextOrTransform, transform) {
|
|
|
21
21
|
};
|
|
22
22
|
if (transformFn) {
|
|
23
23
|
const item = transformFn(match, Object.assign({ _item }, context));
|
|
24
|
-
if (item) items.push(
|
|
24
|
+
if (item) items.push({
|
|
25
|
+
..._item,
|
|
26
|
+
...item
|
|
27
|
+
});
|
|
25
28
|
} else items.push(_item);
|
|
26
29
|
}
|
|
27
30
|
return items;
|