tw5-typed 0.6.2 → 0.6.4
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/package.json
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
/// <reference path="../../wiki/index.d.ts" />
|
|
2
2
|
/// <reference path="../../tiddler/index.d.ts" />
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
declare module '$:/core/modules/utils/utils.js' {
|
|
5
|
+
import type { Tiddler, Wiki } from 'tiddlywiki';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* File information for saving a tiddler
|
|
9
|
+
*/
|
|
10
|
+
export interface FileInfo {
|
|
11
|
+
filepath: string;
|
|
12
|
+
type: string;
|
|
13
|
+
hasMetaFile: boolean;
|
|
14
|
+
isEditableFile?: boolean;
|
|
15
|
+
originalpath?: string;
|
|
16
|
+
overwrite?: boolean;
|
|
17
|
+
writeError?: boolean;
|
|
18
|
+
encoding?: string;
|
|
19
|
+
}
|
|
6
20
|
/**
|
|
7
21
|
* Return the subdirectories of a path
|
|
8
22
|
* @param directoryPath - The path to the directory
|
|
@@ -131,12 +145,65 @@ declare module '$:/core/modules/utils/utils.js' {
|
|
|
131
145
|
* * pathFilters: optional array of filters to be used to generate the base path
|
|
132
146
|
* * wiki: optional wiki for evaluating the pathFilters
|
|
133
147
|
* * fileInfo: an existing fileInfo object to check against
|
|
148
|
+
* * fileInfo.overwrite: if true, turns off filename clash numbers (defaults to false)
|
|
134
149
|
*/
|
|
135
150
|
export function generateTiddlerFilepath(
|
|
136
151
|
title: string,
|
|
137
152
|
options: {
|
|
153
|
+
directory?: string;
|
|
154
|
+
extension?: string;
|
|
138
155
|
extFilters?: string[];
|
|
156
|
+
fileInfo?: FileInfo;
|
|
157
|
+
pathFilters?: string[];
|
|
139
158
|
wiki?: Wiki;
|
|
140
159
|
},
|
|
141
160
|
): string;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Save a tiddler to a file described by the fileInfo
|
|
164
|
+
* @param tiddler - The tiddler to save
|
|
165
|
+
* @param fileInfo - File information including filepath, type, and hasMetaFile flag
|
|
166
|
+
* @param callback - Callback function called when save is complete
|
|
167
|
+
* @description 将 tiddler 保存到由 fileInfo 描述的文件
|
|
168
|
+
*/
|
|
169
|
+
export function saveTiddlerToFile(
|
|
170
|
+
tiddler: Tiddler,
|
|
171
|
+
fileInfo: FileInfo,
|
|
172
|
+
callback: (error: Error | null, fileInfo?: FileInfo) => void,
|
|
173
|
+
): void;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Save a tiddler to a file described by the fileInfo (synchronous)
|
|
177
|
+
* @param tiddler - The tiddler to save
|
|
178
|
+
* @param fileInfo - File information including filepath, type, and hasMetaFile flag
|
|
179
|
+
* @returns The fileInfo object
|
|
180
|
+
* @description 同步地将 tiddler 保存到由 fileInfo 描述的文件
|
|
181
|
+
*/
|
|
182
|
+
export function saveTiddlerToFileSync(tiddler: Tiddler, fileInfo: FileInfo): FileInfo;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Delete a file described by the fileInfo if it exists
|
|
186
|
+
* @param fileInfo - File information including filepath and hasMetaFile flag
|
|
187
|
+
* @param callback - Callback function called when delete is complete
|
|
188
|
+
* @description 删除由 fileInfo 描述的文件(如果存在)
|
|
189
|
+
*/
|
|
190
|
+
export function deleteTiddlerFile(
|
|
191
|
+
fileInfo: FileInfo,
|
|
192
|
+
callback: (error: Error | null, fileInfo?: FileInfo) => void,
|
|
193
|
+
): void;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Cleanup old files on disk by comparing adaptor info and boot info
|
|
197
|
+
* @param options - Options object containing adaptorInfo, bootInfo, and title
|
|
198
|
+
* @param callback - Callback function called when cleanup is complete
|
|
199
|
+
* @description 通过比较 adaptor 信息和启动信息来清理磁盘上的旧文件
|
|
200
|
+
*/
|
|
201
|
+
export function cleanupTiddlerFiles(
|
|
202
|
+
options: {
|
|
203
|
+
adaptorInfo?: FileInfo;
|
|
204
|
+
bootInfo?: FileInfo;
|
|
205
|
+
title?: string;
|
|
206
|
+
},
|
|
207
|
+
callback: (error: Error | null, fileInfo?: FileInfo) => void,
|
|
208
|
+
): void;
|
|
142
209
|
}
|
|
@@ -376,7 +376,7 @@ declare module 'tiddlywiki' {
|
|
|
376
376
|
*/
|
|
377
377
|
addEventListeners(
|
|
378
378
|
listeners: Array<{
|
|
379
|
-
handler: (event: IWidgetEvent) => undefined | Promise<void> | boolean
|
|
379
|
+
handler: (event: IWidgetEvent) => undefined | Promise<void> | boolean;
|
|
380
380
|
type: string;
|
|
381
381
|
}>,
|
|
382
382
|
): void;
|
|
@@ -389,7 +389,7 @@ declare module 'tiddlywiki' {
|
|
|
389
389
|
*/
|
|
390
390
|
addEventListener(
|
|
391
391
|
type: string,
|
|
392
|
-
handler: (event: IWidgetEvent) => undefined | Promise<void> | boolean
|
|
392
|
+
handler: (event: IWidgetEvent) => undefined | Promise<void> | boolean,
|
|
393
393
|
): void;
|
|
394
394
|
|
|
395
395
|
/**
|
|
@@ -462,7 +462,7 @@ declare module 'tiddlywiki' {
|
|
|
462
462
|
/**
|
|
463
463
|
* @en
|
|
464
464
|
* Invoke the action widgets defined in a string
|
|
465
|
-
*
|
|
465
|
+
*
|
|
466
466
|
* This calls `invokeActions` under the hood
|
|
467
467
|
*
|
|
468
468
|
* @param {string} actions
|
|
@@ -480,6 +480,11 @@ declare module 'tiddlywiki' {
|
|
|
480
480
|
): boolean;
|
|
481
481
|
|
|
482
482
|
removeLocalDomNodes(): void;
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Make a fake widget with specified variables, suitable for variable lookup in filters
|
|
486
|
+
*/
|
|
487
|
+
makeFakeWidgetWithVariables(variables: Record<string, string>): Widget;
|
|
483
488
|
}
|
|
484
489
|
}
|
|
485
490
|
|