tw5-typed 0.6.3 → 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,6 +1,6 @@
1
1
  {
2
2
  "name": "tw5-typed",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "scripts": {
5
5
  "check": "tsc --noEmit && eslint src/**/*.ts",
6
6
  "docs": "docs-ts",
@@ -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
  }