tw5-typed 1.0.1 → 1.0.3
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 +1 -1
- package/src/hooks.d.ts +4 -2
- package/src/index.d.ts +28 -2
- package/src/modules/syncer/syncAdaptor.d.ts +10 -1
- package/src/modules/utils/filesystem.d.ts +13 -13
- package/src/utils/index.d.ts +36 -0
package/package.json
CHANGED
package/src/hooks.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
declare module 'tiddlywiki' {
|
|
2
|
+
import type { Server as HttpServer } from 'node:http';
|
|
3
|
+
|
|
2
4
|
interface ImportFileInfo {
|
|
3
5
|
callback: (tiddlerFieldsArray: unknown[]) => void;
|
|
4
6
|
file: { lastModified?: number; lastModifiedDate?: Date; name: string; path?: string; size: number; type: string; webkitRelativePath?: string };
|
|
@@ -12,10 +14,10 @@ declare module 'tiddlywiki' {
|
|
|
12
14
|
hookName: 'th-server-command-post-start',
|
|
13
15
|
callback: (
|
|
14
16
|
server: unknown,
|
|
15
|
-
nodeServer:
|
|
17
|
+
nodeServer: HttpServer,
|
|
16
18
|
who: 'tiddlywiki',
|
|
17
19
|
) => void,
|
|
18
|
-
);
|
|
20
|
+
): void;
|
|
19
21
|
addHook(
|
|
20
22
|
hookName: 'th-saving-tiddler' | 'th-renaming-tiddler' | 'th-relinking-tiddler',
|
|
21
23
|
callback: (toTiddler: Tiddler, fromTiddler: Tiddler) => Tiddler | undefined,
|
package/src/index.d.ts
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference path="./boot/config.d.ts" />
|
|
2
|
+
/// <reference path="./boot/index.d.ts" />
|
|
3
|
+
/// <reference path="./core.d.ts" />
|
|
4
|
+
/// <reference path="./hooks.d.ts" />
|
|
5
|
+
/// <reference path="./tiddler/index.d.ts" />
|
|
6
|
+
/// <reference path="./utils/Crypto.d.ts" />
|
|
7
|
+
/// <reference path="./utils/PasswordPrompt.d.ts" />
|
|
8
|
+
/// <reference path="./utils/index.d.ts" />
|
|
9
|
+
/// <reference path="./wiki/index.d.ts" />
|
|
10
|
+
/// <reference path="./modules/index.d.ts" />
|
|
11
|
+
/// <reference path="./modules/filters/index.d.ts" />
|
|
12
|
+
/// <reference path="./modules/indexers/index.d.ts" />
|
|
13
|
+
/// <reference path="./modules/keyboard.d.ts" />
|
|
14
|
+
/// <reference path="./modules/parsers/index.d.ts" />
|
|
15
|
+
/// <reference path="./modules/server/index.d.ts" />
|
|
16
|
+
/// <reference path="./modules/story.d.ts" />
|
|
17
|
+
/// <reference path="./modules/syncer/syncadaptor.d.ts" />
|
|
18
|
+
/// <reference path="./modules/syncer/syncer.d.ts" />
|
|
19
|
+
/// <reference path="./modules/utils/filesystem.d.ts" />
|
|
20
|
+
/// <reference path="./modules/utils/logger.d.ts" />
|
|
21
|
+
/// <reference path="./modules/utils/dom/index.d.ts" />
|
|
22
|
+
/// <reference path="./modules/utils/linked-list.d.ts" />
|
|
23
|
+
/// <reference path="./modules/widgets/index.d.ts" />
|
|
24
|
+
/// <reference path="./plugins/index.d.ts" />
|
|
25
|
+
|
|
26
|
+
// Export something to make this a module (required for global declarations to work)
|
|
27
|
+
export {};
|
|
2
28
|
|
|
3
29
|
declare module 'tiddlywiki' {
|
|
4
30
|
export type TW5InitFunction = (baseObject?: Record<string, unknown>) => ITiddlyWiki;
|
|
@@ -6,5 +32,5 @@ declare module 'tiddlywiki' {
|
|
|
6
32
|
}
|
|
7
33
|
|
|
8
34
|
declare global {
|
|
9
|
-
|
|
35
|
+
const $tw: import('tiddlywiki').ITiddlyWiki;
|
|
10
36
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
declare module 'tiddlywiki' {
|
|
2
|
+
/**
|
|
3
|
+
* File information for a tiddler stored in the filesystem
|
|
4
|
+
*/
|
|
5
|
+
export interface FileInfo {
|
|
6
|
+
filepath: string;
|
|
7
|
+
hasMetaFile?: boolean;
|
|
8
|
+
type: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
2
11
|
/**
|
|
3
12
|
* SyncAdaptorModules
|
|
4
13
|
* @url https://tiddlywiki.com/dev/#SyncAdaptorModules
|
|
@@ -6,7 +15,7 @@ declare module 'tiddlywiki' {
|
|
|
6
15
|
export interface SyncAdaptor {
|
|
7
16
|
getTiddlerFileInfo(
|
|
8
17
|
title: string,
|
|
9
|
-
callback: (error: null, fileInfo:
|
|
18
|
+
callback: (error: Error | null | string, fileInfo: FileInfo) => void,
|
|
10
19
|
): void;
|
|
11
20
|
getTiddlerInfo(title: string): IBootFilesIndexItem;
|
|
12
21
|
/**
|
|
@@ -2,7 +2,7 @@ declare module 'tiddlywiki' {
|
|
|
2
2
|
/**
|
|
3
3
|
* File information for saving a tiddler
|
|
4
4
|
*/
|
|
5
|
-
export interface
|
|
5
|
+
export interface IFileInfo {
|
|
6
6
|
filepath: string;
|
|
7
7
|
type: string;
|
|
8
8
|
hasMetaFile: boolean;
|
|
@@ -15,7 +15,7 @@ declare module 'tiddlywiki' {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
declare module '$:/core/modules/utils/filesystem.js' {
|
|
18
|
-
import type {
|
|
18
|
+
import type { IFileInfo, Tiddler, Wiki } from 'tiddlywiki';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Return the subdirectories of a path
|
|
@@ -114,11 +114,11 @@ declare module '$:/core/modules/utils/filesystem.js' {
|
|
|
114
114
|
options: {
|
|
115
115
|
directory: string;
|
|
116
116
|
extFilters?: string[];
|
|
117
|
-
fileInfo?:
|
|
117
|
+
fileInfo?: IFileInfo;
|
|
118
118
|
pathFilters?: string[];
|
|
119
119
|
wiki?: Wiki;
|
|
120
120
|
},
|
|
121
|
-
):
|
|
121
|
+
): IFileInfo;
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
124
|
* Generate the file extension for saving a tiddler
|
|
@@ -153,7 +153,7 @@ declare module '$:/core/modules/utils/filesystem.js' {
|
|
|
153
153
|
directory?: string;
|
|
154
154
|
extension?: string;
|
|
155
155
|
extFilters?: string[];
|
|
156
|
-
fileInfo?:
|
|
156
|
+
fileInfo?: IFileInfo;
|
|
157
157
|
pathFilters?: string[];
|
|
158
158
|
wiki?: Wiki;
|
|
159
159
|
},
|
|
@@ -168,8 +168,8 @@ declare module '$:/core/modules/utils/filesystem.js' {
|
|
|
168
168
|
*/
|
|
169
169
|
export function saveTiddlerToFile(
|
|
170
170
|
tiddler: Tiddler,
|
|
171
|
-
fileInfo:
|
|
172
|
-
callback: (error: Error | null, fileInfo?:
|
|
171
|
+
fileInfo: IFileInfo,
|
|
172
|
+
callback: (error: Error | null, fileInfo?: IFileInfo) => void,
|
|
173
173
|
): void;
|
|
174
174
|
|
|
175
175
|
/**
|
|
@@ -179,7 +179,7 @@ declare module '$:/core/modules/utils/filesystem.js' {
|
|
|
179
179
|
* @returns The fileInfo object
|
|
180
180
|
* @description 同步地将 tiddler 保存到由 fileInfo 描述的文件
|
|
181
181
|
*/
|
|
182
|
-
export function saveTiddlerToFileSync(tiddler: Tiddler, fileInfo:
|
|
182
|
+
export function saveTiddlerToFileSync(tiddler: Tiddler, fileInfo: IFileInfo): IFileInfo;
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
185
|
* Delete a file described by the fileInfo if it exists
|
|
@@ -188,8 +188,8 @@ declare module '$:/core/modules/utils/filesystem.js' {
|
|
|
188
188
|
* @description 删除由 fileInfo 描述的文件(如果存在)
|
|
189
189
|
*/
|
|
190
190
|
export function deleteTiddlerFile(
|
|
191
|
-
fileInfo:
|
|
192
|
-
callback: (error: Error | null, fileInfo?:
|
|
191
|
+
fileInfo: IFileInfo,
|
|
192
|
+
callback: (error: Error | null, fileInfo?: IFileInfo) => void,
|
|
193
193
|
): void;
|
|
194
194
|
|
|
195
195
|
/**
|
|
@@ -200,10 +200,10 @@ declare module '$:/core/modules/utils/filesystem.js' {
|
|
|
200
200
|
*/
|
|
201
201
|
export function cleanupTiddlerFiles(
|
|
202
202
|
options: {
|
|
203
|
-
adaptorInfo?:
|
|
204
|
-
bootInfo?:
|
|
203
|
+
adaptorInfo?: IFileInfo;
|
|
204
|
+
bootInfo?: IFileInfo;
|
|
205
205
|
title?: string;
|
|
206
206
|
},
|
|
207
|
-
callback: (error: Error | null, fileInfo?:
|
|
207
|
+
callback: (error: Error | null, fileInfo?: IFileInfo) => void,
|
|
208
208
|
): void;
|
|
209
209
|
}
|
package/src/utils/index.d.ts
CHANGED
|
@@ -462,6 +462,42 @@ declare module 'tiddlywiki' {
|
|
|
462
462
|
* Parse a filter variable
|
|
463
463
|
*/
|
|
464
464
|
parseFilterVariable: (source: string) => unknown;
|
|
465
|
+
/**
|
|
466
|
+
* Create directory recursively
|
|
467
|
+
*/
|
|
468
|
+
createDirectory: (directoryPath: string) => void;
|
|
469
|
+
/**
|
|
470
|
+
* Generate tiddler file info for saving
|
|
471
|
+
*/
|
|
472
|
+
generateTiddlerFileInfo: (
|
|
473
|
+
tiddler: Tiddler,
|
|
474
|
+
options: {
|
|
475
|
+
directory: string;
|
|
476
|
+
pathFilters?: string[];
|
|
477
|
+
extFilters?: string[];
|
|
478
|
+
wiki: Wiki;
|
|
479
|
+
fileInfo?: Partial<IFileInfo>;
|
|
480
|
+
},
|
|
481
|
+
) => IFileInfo;
|
|
482
|
+
/**
|
|
483
|
+
* Save tiddler to file
|
|
484
|
+
*/
|
|
485
|
+
saveTiddlerToFile: (tiddler: Tiddler, fileInfo: IFileInfo, callback?: (error: Error | null) => void) => void;
|
|
486
|
+
/**
|
|
487
|
+
* Cleanup tiddler files (delete old files when tiddler is moved)
|
|
488
|
+
*/
|
|
489
|
+
cleanupTiddlerFiles: (
|
|
490
|
+
fileInfo: IFileInfo | Record<string, unknown>,
|
|
491
|
+
callback?: (error: Error | null, cleanedFileInfo?: IFileInfo) => void,
|
|
492
|
+
) => void;
|
|
493
|
+
/**
|
|
494
|
+
* Delete tiddler file
|
|
495
|
+
*/
|
|
496
|
+
deleteTiddlerFile: (fileInfo: IFileInfo, callback?: (error: Error | null, deletedFileInfo?: IFileInfo) => void) => void;
|
|
497
|
+
/**
|
|
498
|
+
* Format date string
|
|
499
|
+
*/
|
|
500
|
+
formatDateString: (date: Date, template: string) => string;
|
|
465
501
|
}
|
|
466
502
|
|
|
467
503
|
export type IUtilities = IUtilitiesBoot;
|