tw5-typed 0.2.17 → 0.2.18
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/LICENSE +1 -1
- package/package.json +3 -1
- package/src/boot/config.d.ts +20 -16
- package/src/core.d.ts +11 -28
- package/src/hooks.d.ts +83 -0
- package/src/modules/index.d.ts +8 -2
- package/src/modules/story.d.ts +56 -0
- package/src/modules/utils/dom.d.ts +51 -0
- package/src/modules/utils/filesystem.d.ts +33 -0
- package/src/modules/utils/index.d.ts +3 -0
- package/src/modules/utils/utils.d.ts +25 -0
- package/src/modules/widgets/index.d.ts +55 -20
- package/src/modules/wiki.d.ts +20 -0
- package/src/plugins/Gk0Wk/echarts/index.d.ts +4 -0
- package/src/plugins/Gk0Wk/index.d.ts +1 -0
- package/src/plugins/index.d.ts +2 -0
- package/src/plugins/tiddlywiki/codemirror/index.d.ts +4 -0
- package/src/plugins/tiddlywiki/index.d.ts +1 -0
- package/src/utils/index.d.ts +402 -178
- package/src/wiki/index.d.ts +1 -0
package/LICENSE
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"description": "Types for tiddlywiki",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "tw5-typed",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.18",
|
|
6
6
|
"url": "https://github.com/tiddly-gittly/tw5-typed",
|
|
7
7
|
"homepage": "https://github.com/tiddly-gittly/tw5-typed",
|
|
8
8
|
"bugs": {
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@modern-js/eslint-config": "latest",
|
|
34
34
|
"@modern-js/tsconfig": "latest",
|
|
35
|
+
"@types/codemirror": "^5.60.6",
|
|
36
|
+
"@types/echarts": "^4.9.16",
|
|
35
37
|
"@types/node": "^18.11.9",
|
|
36
38
|
"husky": "^8.0.2",
|
|
37
39
|
"lint-staged": "^13.1.0",
|
package/src/boot/config.d.ts
CHANGED
|
@@ -10,42 +10,46 @@ declare module 'tiddlywiki' {
|
|
|
10
10
|
type: string;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
export type ITWConfig = IConfig;
|
|
14
|
+
|
|
15
|
+
interface IConfig {
|
|
14
16
|
[configName: string]: unknown;
|
|
15
17
|
/** Map type to file content type */
|
|
16
18
|
contentTypeInfo: Record<string, IContentTypeInfo>;
|
|
17
|
-
/**
|
|
19
|
+
/** @default 'TIDDLYWIKI_EDITION_PATH' */
|
|
18
20
|
editionsEnvVar: string;
|
|
19
|
-
/**
|
|
21
|
+
/** @default '../editions/' */
|
|
20
22
|
editionsPath: string;
|
|
21
23
|
/** Map file extension */
|
|
22
24
|
fileExtensionInfo: Record<string, IFileExtensionInfo>;
|
|
23
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* @default '^\\/\\*\\\\(?:\\r?\\n)((?:^[^\\r\\n]*(?:\\r?\\n))+?)(^\\\\\\*\\/$(?:\\r?\\n)?)
|
|
27
|
+
*/
|
|
24
28
|
jsModuleHeaderRegExpString: string;
|
|
25
|
-
/**
|
|
29
|
+
/** @default 'TIDDLYWIKI_LANGUAGE_PATH' */
|
|
26
30
|
languagesEnvVar: string;
|
|
27
|
-
/**
|
|
31
|
+
/** @default '../languages/' */
|
|
28
32
|
languagesPath: string;
|
|
29
33
|
//
|
|
30
|
-
/**
|
|
34
|
+
/** @default 'TIDDLYWIKI_PLUGIN_PATH' */
|
|
31
35
|
pluginsEnvVar: string;
|
|
32
|
-
/**
|
|
36
|
+
/** @default '../plugins/'' */
|
|
33
37
|
pluginsPath: string;
|
|
34
|
-
/**
|
|
38
|
+
/** @default 'TIDDLYWIKI_THEME_PATH' */
|
|
35
39
|
themesEnvVar: string;
|
|
36
|
-
/**
|
|
40
|
+
/** @default '../themes/' */
|
|
37
41
|
themesPath: string;
|
|
38
|
-
/**
|
|
42
|
+
/** @default './tiddlywiki.info' */
|
|
39
43
|
wikiInfo: string;
|
|
40
|
-
/**
|
|
44
|
+
/** @default './languages' */
|
|
41
45
|
wikiLanguagesSubDir: string;
|
|
42
|
-
/**
|
|
46
|
+
/** @default './output' */
|
|
43
47
|
wikiOutputSubDir: string;
|
|
44
|
-
/**
|
|
48
|
+
/** @default './plugins' */
|
|
45
49
|
wikiPluginsSubDir: string;
|
|
46
|
-
/**
|
|
50
|
+
/** @default './themes' */
|
|
47
51
|
wikiThemesSubDir: string;
|
|
48
|
-
/**
|
|
52
|
+
/** @default './tiddlers' */
|
|
49
53
|
wikiTiddlersSubDir: string;
|
|
50
54
|
}
|
|
51
55
|
}
|
package/src/core.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
/// <reference path="hooks.d.ts" />
|
|
1
2
|
/// <reference path="boot/index.d.ts" />
|
|
2
3
|
/// <reference path="wiki/index.d.ts" />
|
|
3
4
|
/// <reference path="utils/index.d.ts" />
|
|
4
5
|
/// <reference path="tiddler/index.d.ts" />
|
|
5
6
|
/// <reference path="modules/index.d.ts" />
|
|
7
|
+
/// <reference path="plugins/index.d.ts" />
|
|
6
8
|
|
|
7
9
|
declare module 'tiddlywiki' {
|
|
8
10
|
export interface IPluginInfo {
|
|
@@ -22,19 +24,20 @@ declare module 'tiddlywiki' {
|
|
|
22
24
|
|
|
23
25
|
export interface ITiddlyWiki {
|
|
24
26
|
Wiki: typeof Wiki;
|
|
27
|
+
Story: typeof Story;
|
|
25
28
|
Tiddler: typeof Tiddler;
|
|
26
29
|
|
|
27
30
|
wiki: Wiki;
|
|
28
31
|
boot: IBoot;
|
|
29
32
|
crypto: Crypto;
|
|
30
|
-
utils:
|
|
33
|
+
utils: IUtils;
|
|
31
34
|
version: string;
|
|
32
35
|
safeMode: boolean;
|
|
33
|
-
config:
|
|
36
|
+
config: IConfig;
|
|
34
37
|
rootWidget: Widget;
|
|
35
38
|
notifier: Notifier;
|
|
36
39
|
language: ILanguage;
|
|
37
|
-
modules:
|
|
40
|
+
modules: IModules;
|
|
38
41
|
locationHash: string;
|
|
39
42
|
passwordPrompt: PasswordPrompt;
|
|
40
43
|
packageInfo: Record<string, unknown>;
|
|
@@ -46,34 +49,14 @@ declare module 'tiddlywiki' {
|
|
|
46
49
|
dragInProgress?: boolean;
|
|
47
50
|
|
|
48
51
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
hooks:
|
|
52
|
-
names: Record<string, any>;
|
|
53
|
-
/**
|
|
54
|
-
Add hooks to the hashmap
|
|
55
|
-
*/
|
|
56
|
-
addHook(
|
|
57
|
-
hookName: 'th-server-command-post-start',
|
|
58
|
-
callback: (listenCommand: unknown, server: Server) => void,
|
|
59
|
-
): void;
|
|
60
|
-
addHook(
|
|
61
|
-
hookName: string,
|
|
62
|
-
callback: (...arguments_: unknown[]) => unknown,
|
|
63
|
-
): void;
|
|
64
|
-
/**
|
|
65
|
-
Invoke the hook by key
|
|
66
|
-
*/
|
|
67
|
-
invokeHook(
|
|
68
|
-
hookName: string,
|
|
69
|
-
event: IWidgetEvent,
|
|
70
|
-
): undefined | IWidgetEvent;
|
|
71
|
-
};
|
|
52
|
+
* Global Hooks mechanism which allows plugins to modify default functionality
|
|
53
|
+
*/
|
|
54
|
+
hooks: IHooks;
|
|
72
55
|
|
|
73
|
-
addUnloadTask(task: any)
|
|
56
|
+
addUnloadTask(task: any);
|
|
74
57
|
|
|
75
58
|
/** Convenience function for pushing a tiddler onto the preloading array */
|
|
76
|
-
preloadTiddler(fields: Record<string, unknown>)
|
|
59
|
+
preloadTiddler(fields: Record<string, unknown>);
|
|
77
60
|
/** Convenience function for pushing an array of tiddlers onto the preloading array */
|
|
78
61
|
preloadTiddlerArray(fieldsArray: Array<Record<string, unknown>>): void;
|
|
79
62
|
/** External JavaScript can populate this array before calling boot.js in order to preload tiddlers */
|
package/src/hooks.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
declare module 'tiddlywiki' {
|
|
2
|
+
interface IHooks {
|
|
3
|
+
names: Record<string, Function[]>;
|
|
4
|
+
/** Add hooks to the hashmap */
|
|
5
|
+
addHook(
|
|
6
|
+
hookName: 'th-server-command-post-start',
|
|
7
|
+
callback: (
|
|
8
|
+
server: unknown,
|
|
9
|
+
nodeServer: Server,
|
|
10
|
+
who: 'tiddlywiki',
|
|
11
|
+
) => void,
|
|
12
|
+
);
|
|
13
|
+
addHook(
|
|
14
|
+
hookName: 'th-saving-tiddler',
|
|
15
|
+
callback: (toTiddler: Tiddler, fromTiddler: Tiddler) => Tiddler | void,
|
|
16
|
+
);
|
|
17
|
+
addHook(
|
|
18
|
+
hookName: 'th-renaming-tiddler',
|
|
19
|
+
callback: (toTiddler: Tiddler, fromTiddler: Tiddler) => Tiddler | void,
|
|
20
|
+
);
|
|
21
|
+
addHook(
|
|
22
|
+
hookName: 'th-relinking-tiddler',
|
|
23
|
+
callback: (toTiddler: Tiddler, fromTiddler: Tiddler) => Tiddler | void,
|
|
24
|
+
);
|
|
25
|
+
addHook(
|
|
26
|
+
hookName: 'th-importing-tiddler',
|
|
27
|
+
callback: (tiddler: Tiddler) => Tiddler | void,
|
|
28
|
+
);
|
|
29
|
+
addHook(
|
|
30
|
+
hookName: 'th-before-importing',
|
|
31
|
+
callback: (tiddler: Tiddler) => Tiddler | void,
|
|
32
|
+
);
|
|
33
|
+
addHook(
|
|
34
|
+
hookName: 'th-opening-default-tiddlers-list',
|
|
35
|
+
callback: (storyList: string[]) => string[],
|
|
36
|
+
);
|
|
37
|
+
addHook(
|
|
38
|
+
hookName: 'th-make-tiddler-path',
|
|
39
|
+
callback: (fullPath: string, fullPath: string) => string,
|
|
40
|
+
);
|
|
41
|
+
addHook(
|
|
42
|
+
hookName: 'th-rendering-element',
|
|
43
|
+
callback: (
|
|
44
|
+
parseTreeNodes: IParseTreeNode | null,
|
|
45
|
+
widget: Widget,
|
|
46
|
+
) => parseTreeNodes,
|
|
47
|
+
);
|
|
48
|
+
addHook(hookName: 'th-navigating', callback: (event: unknown) => unknown);
|
|
49
|
+
addHook(
|
|
50
|
+
hookName: 'th-closing-tiddler',
|
|
51
|
+
callback: (event: unknown) => unknown,
|
|
52
|
+
);
|
|
53
|
+
addHook(
|
|
54
|
+
hookName: 'th-editing-tiddler',
|
|
55
|
+
callback: (event: unknown) => unknown,
|
|
56
|
+
);
|
|
57
|
+
addHook(
|
|
58
|
+
hookName: 'th-cancelling-tiddler',
|
|
59
|
+
callback: (event: unknown) => unknown,
|
|
60
|
+
);
|
|
61
|
+
addHook(hookName: 'th-new-tiddler', callback: (event: unknown) => unknown);
|
|
62
|
+
addHook(hookName: 'th-deleting-tiddler', callback: (title: string) => void);
|
|
63
|
+
addHook(hookName: 'th-page-refreshed', callback: () => void);
|
|
64
|
+
addHook(hookName: 'th-boot-tiddlers-loaded', callback: () => void);
|
|
65
|
+
addHook(hookName: 'th-page-refreshed', callback: () => void);
|
|
66
|
+
addHook(hookName: 'th-page-refreshing', callback: () => void);
|
|
67
|
+
addHook(hookName: 'th-page-refreshed', callback: () => void);
|
|
68
|
+
addHook(
|
|
69
|
+
hookName: 'th-importing-file',
|
|
70
|
+
callback: (props: {
|
|
71
|
+
file: unknown;
|
|
72
|
+
type: string;
|
|
73
|
+
isBinary: boolean;
|
|
74
|
+
callback: Function;
|
|
75
|
+
}) => boolean | void,
|
|
76
|
+
);
|
|
77
|
+
addHook(hookName: string, callback: (...arguments_: unknown[]) => unknown);
|
|
78
|
+
/**
|
|
79
|
+
* Invoke the hook by key
|
|
80
|
+
*/
|
|
81
|
+
invokeHook(hookName: string, event: IWidgetEvent): undefined | IWidgetEvent;
|
|
82
|
+
}
|
|
83
|
+
}
|
package/src/modules/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/// <reference path="wiki.d.ts" />
|
|
2
|
+
/// <reference path="story.d.ts" />
|
|
3
|
+
/// <reference path="utils/index.d.ts" />
|
|
1
4
|
/// <reference path="server/index.d.ts" />
|
|
2
5
|
/// <reference path="parsers/index.d.ts" />
|
|
3
6
|
/// <reference path="widgets/index.d.ts" />
|
|
@@ -18,7 +21,7 @@ declare module 'tiddlywiki' {
|
|
|
18
21
|
(title: string): ITWModuleExports;
|
|
19
22
|
readonly main: NodeJS.Module | { TiddlyWiki: TW5InitFunction };
|
|
20
23
|
}
|
|
21
|
-
export interface
|
|
24
|
+
export interface IEvalContent {
|
|
22
25
|
$tw: ITiddlyWiki;
|
|
23
26
|
// eslint-disable-next-line node/prefer-global/buffer
|
|
24
27
|
Buffer?: Buffer;
|
|
@@ -37,6 +40,9 @@ declare module 'tiddlywiki' {
|
|
|
37
40
|
exports: ITWModuleExports,
|
|
38
41
|
requireFunction: ITWRequire,
|
|
39
42
|
) => void;
|
|
43
|
+
|
|
44
|
+
export type ITWModules = IModules;
|
|
45
|
+
|
|
40
46
|
/**
|
|
41
47
|
* Information about each module is kept in an object with these members:
|
|
42
48
|
*
|
|
@@ -52,7 +58,7 @@ declare module 'tiddlywiki' {
|
|
|
52
58
|
*
|
|
53
59
|
* Each moduleInfo object is stored in two hashmaps: $tw.modules.titles and $tw.modules.types. The first is indexed by title and the second is indexed by type and then title
|
|
54
60
|
*/
|
|
55
|
-
interface
|
|
61
|
+
interface IModules {
|
|
56
62
|
/** Apply the exports of the modules of a particular type to a target object */
|
|
57
63
|
applyMethods: (
|
|
58
64
|
moduleType: string,
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
declare module 'tiddlywiki' {
|
|
2
|
+
declare class Story {
|
|
3
|
+
wiki: Wiki;
|
|
4
|
+
storyTitle: string;
|
|
5
|
+
historyTitle: string;
|
|
6
|
+
|
|
7
|
+
constructor(options: {
|
|
8
|
+
wiki?: Wiki;
|
|
9
|
+
storyTitle?: string;
|
|
10
|
+
historyTitle?: string;
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
getStoryList(): string[];
|
|
14
|
+
|
|
15
|
+
navigateTiddler(
|
|
16
|
+
navigateTo: string,
|
|
17
|
+
navigateFromTitle: string,
|
|
18
|
+
navigateFromClientRect: DOMRect,
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
addToStory(
|
|
22
|
+
navigateTo: string,
|
|
23
|
+
navigateFromTitle: string,
|
|
24
|
+
options?: {
|
|
25
|
+
openLinkFromInsideRiver?: 'top' | 'bottom' | 'above' | 'below';
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
addToHistory(
|
|
30
|
+
navigateTo: string | string[],
|
|
31
|
+
navigateFromClientRect: DOMRect,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
saveStoryList(storyList: string[] | string);
|
|
35
|
+
|
|
36
|
+
storyCloseTiddler(targetTitle: string);
|
|
37
|
+
|
|
38
|
+
storyCloseAllTiddlers();
|
|
39
|
+
|
|
40
|
+
storyCloseOtherTiddlers(targetTitle: string);
|
|
41
|
+
|
|
42
|
+
storyEditTiddler(targetTitle: string);
|
|
43
|
+
|
|
44
|
+
storyDeleteTiddler(targetTitle: string);
|
|
45
|
+
|
|
46
|
+
storySaveTiddler(targetTitle: string);
|
|
47
|
+
|
|
48
|
+
storyCancelTiddler(targetTitle: string);
|
|
49
|
+
|
|
50
|
+
storyNewTiddler(targetTitle: string);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
declare module '$:/core/modules/story.js' {
|
|
55
|
+
export { Story } from 'tiddlywiki';
|
|
56
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
declare const addClass: (element: Element, className: string) => void;
|
|
2
|
+
declare const addEventListeners: (
|
|
3
|
+
domNode: Node,
|
|
4
|
+
events: {
|
|
5
|
+
handlerFunction?: (event: MouseEvent) => void;
|
|
6
|
+
handlerMethod?: string;
|
|
7
|
+
handlerObject?: Widget;
|
|
8
|
+
name: string;
|
|
9
|
+
}[],
|
|
10
|
+
) => void;
|
|
11
|
+
|
|
12
|
+
declare class Notifier {
|
|
13
|
+
/**
|
|
14
|
+
* Display a notification
|
|
15
|
+
* * title: Title of tiddler containing the notification text
|
|
16
|
+
* * options: see below
|
|
17
|
+
* Options include:
|
|
18
|
+
*/
|
|
19
|
+
display(title: string, options?: Record<string, unknown>): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare module 'tiddlywiki' {
|
|
23
|
+
interface IUtils {
|
|
24
|
+
/**
|
|
25
|
+
* Alternative to `element.classList.add`, add a css class name to an element, see issue for detail.
|
|
26
|
+
* @link https://github.com/Jermolene/TiddlyWiki5/issues/6475
|
|
27
|
+
* @param element
|
|
28
|
+
* @param className
|
|
29
|
+
*/
|
|
30
|
+
addClass: typeof addClass;
|
|
31
|
+
/**
|
|
32
|
+
* Attach specified event handlers to a DOM node
|
|
33
|
+
* @param domNode: where to attach the event handlers
|
|
34
|
+
* @param events: array of event handlers to be added (see below)
|
|
35
|
+
* Each entry in the events array is an object with these properties:
|
|
36
|
+
* * name: event name of `addEventListener`
|
|
37
|
+
* * handlerFunction: optional event handler function
|
|
38
|
+
* * handlerObject: optional event handler object
|
|
39
|
+
* * handlerMethod: optionally specifies object handler method name (defaults to `handleEvent`)
|
|
40
|
+
*/
|
|
41
|
+
addEventListeners: typeof addEventListeners;
|
|
42
|
+
/**
|
|
43
|
+
* Notifier mechanism
|
|
44
|
+
*/
|
|
45
|
+
Notifier: typeof Notifier;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare module '$:/core/modules/utils/dom.js' {
|
|
50
|
+
export { addClass, addEventListeners, Notifier };
|
|
51
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare const generateTiddlerFilepath: (
|
|
2
|
+
title: string,
|
|
3
|
+
options?: {
|
|
4
|
+
directory?: string;
|
|
5
|
+
extension?: string;
|
|
6
|
+
fileInfo?: {
|
|
7
|
+
originalpath?: string;
|
|
8
|
+
filePath?: string;
|
|
9
|
+
writeError?: boolean;
|
|
10
|
+
};
|
|
11
|
+
pathFilters?: string[];
|
|
12
|
+
wiki?: Wiki;
|
|
13
|
+
},
|
|
14
|
+
) => string;
|
|
15
|
+
|
|
16
|
+
declare module 'tiddlywiki' {
|
|
17
|
+
interface IUtils {
|
|
18
|
+
/**
|
|
19
|
+
* Generate the filepath for saving a tiddler
|
|
20
|
+
* Options include:
|
|
21
|
+
* * extension: file extension to be added the finished filepath
|
|
22
|
+
* * directory: absolute path of root directory to which we are saving
|
|
23
|
+
* * pathFilters: optional array of filters to be used to generate the base path
|
|
24
|
+
* * wiki: optional wiki for evaluating the pathFilters
|
|
25
|
+
* * fileInfo: an existing fileInfo object to check against
|
|
26
|
+
*/
|
|
27
|
+
generateTiddlerFilepath: typeof generateTiddlerFilepath;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module '$:/core/modules/utils/utils.js' {
|
|
32
|
+
export { generateTiddlerFilepath };
|
|
33
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const count: (object: object) => number;
|
|
2
|
+
declare const hashString: (str: string) => number;
|
|
3
|
+
declare const formatDateString: (date: Date, format: string) => string;
|
|
4
|
+
|
|
5
|
+
declare module 'tiddlywiki' {
|
|
6
|
+
interface IUtils {
|
|
7
|
+
/**
|
|
8
|
+
* @en
|
|
9
|
+
* Return the number of keys in an object
|
|
10
|
+
* @zh
|
|
11
|
+
* 返回一个对象中的键的数量
|
|
12
|
+
*/
|
|
13
|
+
count: typeof count;
|
|
14
|
+
/** the function behind `<<now "format">> */
|
|
15
|
+
formatDateString: typeof formatDateString;
|
|
16
|
+
/** Hash a string to a number
|
|
17
|
+
* Derived from http://stackoverflow.com/a/15710692
|
|
18
|
+
*/
|
|
19
|
+
hashString: typeof hashString;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare module '$:/core/modules/utils/utils.js' {
|
|
24
|
+
export { count, formatDateString, hashString };
|
|
25
|
+
}
|
|
@@ -36,13 +36,24 @@ declare module 'tiddlywiki' {
|
|
|
36
36
|
widget: Widget;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
export interface IWidgetInitializeOptions {
|
|
40
|
+
wiki?: ITiddlyWiki;
|
|
41
|
+
parentWidget?: Widget;
|
|
42
|
+
}
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
45
|
* @link https://tiddlywiki.com/dev/#Widgets
|
|
46
|
+
*
|
|
47
|
+
* Create a widget object for a parse tree node
|
|
48
|
+
* * parseTreeNode: reference to the parse tree node to be rendered
|
|
49
|
+
* * options: see below
|
|
50
|
+
*
|
|
51
|
+
* Options include:
|
|
52
|
+
* * wiki: mandatory reference to wiki associated with this render tree
|
|
53
|
+
* * parentWidget: optional reference to a parent renderer node for the context chain
|
|
54
|
+
* * document: optional document object to use instead of global document
|
|
44
55
|
*/
|
|
45
|
-
export class Widget {
|
|
56
|
+
export declare class Widget {
|
|
46
57
|
parseTreeNode: IParseTreeNode;
|
|
47
58
|
|
|
48
59
|
wiki: ITiddlyWiki;
|
|
@@ -51,30 +62,48 @@ declare module 'tiddlywiki' {
|
|
|
51
62
|
|
|
52
63
|
parentWidget?: Widget;
|
|
53
64
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
attributes: Record<string, string>;
|
|
66
|
+
|
|
67
|
+
domNodes: Node[];
|
|
68
|
+
|
|
69
|
+
parentDomNode: Node;
|
|
59
70
|
|
|
60
|
-
|
|
71
|
+
eventListeners: Record<string, Function>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* we can use $tw.rootWidget.widgetClasses.xxx to new a widget
|
|
61
75
|
*
|
|
62
|
-
*
|
|
76
|
+
* This is a set of all widgets defined in tiddlywiki.
|
|
63
77
|
*/
|
|
64
|
-
|
|
78
|
+
widgetClasses: Record<string, typeof Widget>;
|
|
65
79
|
|
|
66
80
|
children: Widget[];
|
|
67
81
|
|
|
68
|
-
|
|
82
|
+
qualifiers?: Record<string, string>;
|
|
69
83
|
|
|
70
|
-
|
|
84
|
+
ancestorCount?: number;
|
|
71
85
|
|
|
72
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Set the value of a context variable
|
|
88
|
+
* * name: name of the variable
|
|
89
|
+
* * value: value of the variable
|
|
90
|
+
* * params: array of {name:, default:} for each parameter
|
|
91
|
+
* * isMacroDefinition: true if the variable is set via a \define macro pragma (and hence should have variable substitution performed)
|
|
92
|
+
*/
|
|
93
|
+
variables: Record<
|
|
94
|
+
string,
|
|
95
|
+
{
|
|
96
|
+
value: string;
|
|
97
|
+
params?: { name: string; default: string }[];
|
|
98
|
+
isMacroDefinition: boolean;
|
|
99
|
+
}
|
|
100
|
+
>;
|
|
73
101
|
|
|
74
|
-
|
|
102
|
+
constructor(
|
|
103
|
+
parseTreeNode: IParseTreeNode,
|
|
104
|
+
options?: IWidgetInitializeOptions,
|
|
105
|
+
);
|
|
75
106
|
|
|
76
|
-
constructor(parseTreeNode: IParseTreeNode, options?: unknown);
|
|
77
|
-
initialize(parseTreeNode: IParseTreeNode, options?: unknown): void;
|
|
78
107
|
/**
|
|
79
108
|
Make child widgets correspondng to specified parseTreeNodes
|
|
80
109
|
And push them to `this.children`
|
|
@@ -84,9 +113,10 @@ declare module 'tiddlywiki' {
|
|
|
84
113
|
parseTreeNodes?: IParseTreeNode[],
|
|
85
114
|
options?: { variables?: unknown },
|
|
86
115
|
): void;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Initialise widget properties. These steps are pulled out of the constructor so that we can reuse them in subclasses
|
|
119
|
+
*/
|
|
90
120
|
initialise(
|
|
91
121
|
parseTreeNode: IParseTreeNode,
|
|
92
122
|
options?: {
|
|
@@ -280,3 +310,8 @@ declare module 'tiddlywiki' {
|
|
|
280
310
|
new (wiki: Wiki): ModalWidget;
|
|
281
311
|
};
|
|
282
312
|
}
|
|
313
|
+
|
|
314
|
+
export module '$:/core/modules/widgets/widget.js' {
|
|
315
|
+
import { Widget } from 'tiddlywiki';
|
|
316
|
+
export { Widget as widget };
|
|
317
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const getCreationFields: () => { created?: Date; creator?: string };
|
|
2
|
+
declare const getModificationFields: () => {
|
|
3
|
+
modified?: Date;
|
|
4
|
+
modifier?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const getTiddlersWithTag: (tag: string) => string[];
|
|
7
|
+
|
|
8
|
+
declare module 'tiddlywiki' {
|
|
9
|
+
class Wiki {
|
|
10
|
+
getCreationFields: typeof getCreationFields;
|
|
11
|
+
|
|
12
|
+
getModificationFields: typeof getModificationFields;
|
|
13
|
+
|
|
14
|
+
getTiddlersWithTag: typeof getTiddlersWithTag;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare module '$:/core/modules/wiki.js' {
|
|
19
|
+
export { getModificationFields, getCreationFields, getTiddlersWithTag };
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference path="echarts/index.d.ts" />
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference path="codemirror/index.d.ts" />
|
package/src/utils/index.d.ts
CHANGED
|
@@ -1,164 +1,364 @@
|
|
|
1
1
|
/// <reference path="Crypto.d.ts" />
|
|
2
2
|
/// <reference path="PasswordPrompt.d.ts" />
|
|
3
3
|
|
|
4
|
+
type OptionalPropertyNames<T> = {
|
|
5
|
+
[K in keyof T]-?: {} extends { [P in K]: T[K] } ? K : never;
|
|
6
|
+
}[keyof T];
|
|
7
|
+
|
|
8
|
+
type SpreadProperties<L, R, K extends keyof L & keyof R> = {
|
|
9
|
+
[P in K]: L[P] | Exclude<R[P], undefined>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type Id<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;
|
|
13
|
+
|
|
14
|
+
type SpreadTwo<L, R> = Id<
|
|
15
|
+
Pick<L, Exclude<keyof L, keyof R>> &
|
|
16
|
+
Pick<R, Exclude<keyof R, OptionalPropertyNames<R>>> &
|
|
17
|
+
Pick<R, Exclude<OptionalPropertyNames<R>, keyof L>> &
|
|
18
|
+
SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
type Spread<A extends readonly [...any]> = A extends [infer L, ...infer R]
|
|
22
|
+
? SpreadTwo<L, Spread<R>>
|
|
23
|
+
: unknown;
|
|
24
|
+
|
|
4
25
|
declare module 'tiddlywiki' {
|
|
5
26
|
export type TWDocument = Document;
|
|
6
|
-
export type
|
|
7
|
-
|
|
8
|
-
export type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
27
|
+
export type TWElement = Element;
|
|
28
|
+
export type TWDOMElement = TWElement;
|
|
29
|
+
export type ITWUtils = IUtils;
|
|
30
|
+
|
|
31
|
+
export interface IDomMakerOptions {
|
|
32
|
+
/**
|
|
33
|
+
* @type {string}
|
|
34
|
+
* @default 'http://www.w3.org/1999/xhtml'
|
|
35
|
+
* @memberof IDomMakerOptions
|
|
36
|
+
*/
|
|
37
|
+
namespace?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @en
|
|
41
|
+
* hashmap of attribute values
|
|
42
|
+
* @zh
|
|
43
|
+
* 属性值的 map
|
|
44
|
+
*
|
|
45
|
+
* @type {Record<string, unknown>}
|
|
46
|
+
* @memberof IDomMakerOptions
|
|
47
|
+
*/
|
|
48
|
+
attributes?: Record<string, unknown>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @en
|
|
52
|
+
* Styles for Element
|
|
53
|
+
* @zh
|
|
54
|
+
* 元素的样式
|
|
55
|
+
*
|
|
56
|
+
* @type {CSSStyleDeclaration}
|
|
57
|
+
* @memberof IDomMakerOptions
|
|
58
|
+
*/
|
|
59
|
+
style?: CSSStyleDeclaration;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @en
|
|
63
|
+
* text to add as a child node
|
|
64
|
+
* @zh
|
|
65
|
+
* 添加为子节点的文本
|
|
66
|
+
*
|
|
67
|
+
* @type {string}
|
|
68
|
+
* @memberof IDomMakerOptions
|
|
69
|
+
*/
|
|
70
|
+
text?: string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @en
|
|
74
|
+
* array of further child nodes
|
|
75
|
+
* @zh
|
|
76
|
+
* 其他子节点的数组
|
|
77
|
+
*
|
|
78
|
+
* @type {TWElement[]}
|
|
79
|
+
* @memberof IDomMakerOptions
|
|
80
|
+
*/
|
|
81
|
+
children?: TWElement[];
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @en
|
|
85
|
+
* optional HTML for element
|
|
86
|
+
* @zh
|
|
87
|
+
* 元素的 HTML 内容
|
|
88
|
+
*
|
|
89
|
+
* @type {string}
|
|
90
|
+
* @memberof IDomMakerOptions
|
|
91
|
+
*/
|
|
92
|
+
innerHTML?: string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @en
|
|
96
|
+
* class name(s)
|
|
97
|
+
* @zh
|
|
98
|
+
* 元素的 class,多个则以空格分隔
|
|
99
|
+
*
|
|
100
|
+
* @type {string}
|
|
101
|
+
* @memberof IDomMakerOptions
|
|
102
|
+
*/
|
|
103
|
+
class?: string;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @en
|
|
107
|
+
* defaults to current document
|
|
108
|
+
* @zh
|
|
109
|
+
* 默认为当前 document
|
|
110
|
+
*
|
|
111
|
+
* @type {TWDocument}
|
|
112
|
+
* @memberof IDomMakerOptions
|
|
113
|
+
*/
|
|
114
|
+
document?: TWDocument;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @en
|
|
118
|
+
* array of event listeners (this option won't work until `$tw.utils.addEventListeners()` has been loaded)
|
|
119
|
+
* @zh
|
|
120
|
+
* 事件监听器的数组(这个选项在`$tw.utils.addEventListeners()`被加载之前不会起作用)。
|
|
121
|
+
*
|
|
122
|
+
* @type {EventListener[]}
|
|
123
|
+
* @memberof IDomMakerOptions
|
|
124
|
+
*/
|
|
125
|
+
eventListeners?: EventListener[];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface IUtils {
|
|
14
129
|
Crypto: typeof Crypto;
|
|
15
130
|
PasswordPrompt: typeof PasswordPrompt;
|
|
131
|
+
|
|
16
132
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Attach specified event handlers to a DOM node
|
|
25
|
-
@param domNode: where to attach the event handlers
|
|
26
|
-
@param events: array of event handlers to be added (see below)
|
|
27
|
-
Each entry in the events array is an object with these properties:
|
|
28
|
-
- name: event name of `addEventListener`
|
|
29
|
-
- handlerFunction: optional event handler function
|
|
30
|
-
- handlerObject: optional event handler object
|
|
31
|
-
- handlerMethod: optionally specifies object handler method name (defaults to `handleEvent`)
|
|
32
|
-
*/
|
|
33
|
-
addEventListeners: (
|
|
34
|
-
domNode: Node,
|
|
35
|
-
events: {
|
|
36
|
-
handlerFunction?: (event: MouseEvent) => void;
|
|
37
|
-
handlerMethod?: string;
|
|
38
|
-
handlerObject?: Widget;
|
|
39
|
-
name: string;
|
|
40
|
-
}[],
|
|
41
|
-
) => void;
|
|
42
|
-
/** Returns true if the version string A is greater than the version string B. Returns true if the versions are the same */
|
|
43
|
-
checkVersions: (versionStringA: string, versionStringB: string) => boolean;
|
|
133
|
+
* @en
|
|
134
|
+
* Check if an object has a property.
|
|
135
|
+
* @zh
|
|
136
|
+
* 检查一个对象是否有一个属性。
|
|
137
|
+
*/
|
|
138
|
+
hop: (object: Object, property: string | symbol) => boolean;
|
|
139
|
+
|
|
44
140
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
141
|
+
* @en
|
|
142
|
+
* Determine if a value is an array.
|
|
143
|
+
* @zh
|
|
144
|
+
* 判断对象是否是一个数组。
|
|
47
145
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
versionStringB: string,
|
|
51
|
-
) => -1 | 0 | 1;
|
|
52
|
-
/*
|
|
53
|
-
Return the number of keys in an object
|
|
54
|
-
*/
|
|
55
|
-
count: (object: Record<string, any>) => number;
|
|
56
|
-
/** Convert a URIComponent encoded string to a string safely */
|
|
57
|
-
decodeURIComponentSafe: (uri: string) => string;
|
|
58
|
-
/** Convert a URI encoded string to a string safely */
|
|
59
|
-
decodeURISafe: (uri: string) => string;
|
|
60
|
-
/** Fill in any null or undefined properties of an object with the properties from a list of source objects. Each property that is an object is called recursively */
|
|
61
|
-
deepDefaults: (
|
|
62
|
-
origin: Record<string | symbol, unknown>,
|
|
63
|
-
...defaults: Record<string | symbol, unknown>[]
|
|
64
|
-
) => Record<string | symbol, unknown>;
|
|
146
|
+
isArray: (value: unknown) => boolean;
|
|
147
|
+
|
|
65
148
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @
|
|
69
|
-
*
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
* * innerHTML: optional HTML for element
|
|
85
|
-
* * class: class name(s)
|
|
86
|
-
* * document: defaults to current document
|
|
87
|
-
* * eventListeners: array of event listeners (this option won't work until `$tw.utils.addEventListeners()` has been loaded)
|
|
88
|
-
* @returns {Element}
|
|
89
|
-
*/
|
|
90
|
-
domMaker: (
|
|
91
|
-
tag: string,
|
|
92
|
-
options: {
|
|
93
|
-
attributes?: Record<string, unknown>;
|
|
94
|
-
children?: TWDOMElement[];
|
|
95
|
-
class?: string;
|
|
96
|
-
document?: TWDocument;
|
|
97
|
-
eventListeners?: EventListener[];
|
|
98
|
-
innerHTML?: string;
|
|
99
|
-
namespace?: string;
|
|
100
|
-
style?: Record<string, string>;
|
|
101
|
-
text?: string;
|
|
102
|
-
},
|
|
103
|
-
) => TWDOMElement;
|
|
149
|
+
* @en
|
|
150
|
+
* Check if an array is equal by value and by reference.
|
|
151
|
+
* @zh
|
|
152
|
+
* 检查一个数组的值和引用是否相等。
|
|
153
|
+
*/
|
|
154
|
+
isArrayEqual: (array1: unknown[], array2: unknown[]) => boolean;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @en
|
|
158
|
+
* Add an entry to a sorted array if it doesn't already exist, while maintaining the sort order
|
|
159
|
+
* @zh
|
|
160
|
+
* 如果一个已排序的数组中不存在一个条目,则添加该条目,同时保持排序顺序
|
|
161
|
+
*/
|
|
162
|
+
insertSortedArray: <T extends Array<unknown>>(
|
|
163
|
+
array: T,
|
|
164
|
+
value: unknown,
|
|
165
|
+
) => T;
|
|
166
|
+
|
|
104
167
|
/**
|
|
168
|
+
* @en
|
|
169
|
+
* Push entries onto an array, removing them first if they already exist in the array
|
|
170
|
+
* @zh
|
|
171
|
+
* 将条目推送到一个数组中,如果它们已经存在于数组中,则先将其删除。
|
|
172
|
+
*
|
|
173
|
+
* @param {unknown[]} array array to modify (assumed to be free of duplicates)
|
|
174
|
+
* @param {unknown} value a single value to push or an array of values to push
|
|
175
|
+
* @returns {unknown[]}
|
|
176
|
+
*/
|
|
177
|
+
pushTop: <T extends Array<unknown>>(array: T, value: unknown) => T;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @en
|
|
181
|
+
* Determine if a value is a date
|
|
182
|
+
* @zh
|
|
183
|
+
* 确定一个值是否是一个日期
|
|
184
|
+
*/
|
|
185
|
+
isDate: (value: unknown) => void;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @en
|
|
105
189
|
* Iterate through all the own properties of an object or array.
|
|
106
190
|
* Callback is invoked with (element, index, object), if callback returns false, then the each loop will be terminated.
|
|
191
|
+
* @zh
|
|
192
|
+
* 遍历一个对象或数组的所有自身属性。
|
|
193
|
+
* callback 被遍历调用 (element, index, object),如果回调返回 false,那么每个循环将被终止。
|
|
194
|
+
* @param {T} object
|
|
195
|
+
* @param {(element: T[keyof T], index: keyof T, object: T) => void | false} callback
|
|
196
|
+
* @example
|
|
197
|
+
* $tw.utils.each([1, 2, 3], element => console.log(element));
|
|
198
|
+
* $tw.utils.each({ a: 1, b: 2 }, (value, key) => console.log(key, value));
|
|
107
199
|
*/
|
|
108
|
-
each: <
|
|
109
|
-
object:
|
|
110
|
-
callback:
|
|
200
|
+
each: <T>(
|
|
201
|
+
object: T,
|
|
202
|
+
callback: (
|
|
203
|
+
element: T[keyof T],
|
|
204
|
+
index: keyof T,
|
|
205
|
+
object: T,
|
|
206
|
+
) => void | false,
|
|
111
207
|
) => void;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @en
|
|
211
|
+
* Helper for making DOM elements
|
|
212
|
+
* @zh
|
|
213
|
+
* 产生一个 DOM 元素
|
|
214
|
+
*
|
|
215
|
+
* @param {string} tag tag name
|
|
216
|
+
* @param {IDomMakerOptions} options
|
|
217
|
+
* @returns {TWElement}
|
|
218
|
+
*/
|
|
219
|
+
domMaker: (tag: string, options: IDomMakerOptions) => TWElement;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @en
|
|
223
|
+
* Display an error and exit
|
|
224
|
+
* @zh
|
|
225
|
+
* 打印一个错误,如果在 Node 环境下,会退出进程
|
|
226
|
+
*/
|
|
227
|
+
error: (error: Event | Error | string) => null | never;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @en
|
|
231
|
+
* Extend an object with the properties from a list of source objects
|
|
232
|
+
* @zh
|
|
233
|
+
* 用源对象列表中的属性扩展一个对象
|
|
234
|
+
*/
|
|
235
|
+
extend: <O extends object, S extends object[]>(
|
|
236
|
+
origin: O,
|
|
237
|
+
...sources: [...S]
|
|
238
|
+
) => Spread<[O, ...S]>;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* @en
|
|
242
|
+
* Fill in any null or undefined properties of an object with the properties from a list of source objects. Each property that is an object is called recursively
|
|
243
|
+
* @zh
|
|
244
|
+
* 用源对象列表中的属性来填充对象的任何空或未定义的属性。每个属于对象的属性都被递归地调用
|
|
245
|
+
*/
|
|
246
|
+
deepDefaults: <O extends object, S extends object[]>(
|
|
247
|
+
origin: O,
|
|
248
|
+
...sources: [...S]
|
|
249
|
+
) => Spread<[O, ...S]>;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* @en
|
|
253
|
+
* Convert a URIComponent encoded string to a string safely
|
|
254
|
+
* @zh
|
|
255
|
+
* 将一个URIComponent编码的字符串安全地转换为一个字符串。
|
|
256
|
+
*/
|
|
257
|
+
decodeURIComponentSafe: (uri: string) => string;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* @en
|
|
261
|
+
* Convert a URI encoded string to a string safely
|
|
262
|
+
* @zh
|
|
263
|
+
* 将一个URI编码的字符串安全地转换为一个字符串
|
|
264
|
+
*/
|
|
265
|
+
decodeURISafe: (uri: string) => string;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @en
|
|
269
|
+
* Convert `&` to `&`, ` ` to ` `, `<` to `<`, `>` to `>` and `"` to `"`
|
|
270
|
+
* @zh
|
|
271
|
+
* 将`&`转换成`&`,` `转换成` `,`<`转换成`<`,`>`转换成`>`,`"`转换成`"`
|
|
272
|
+
*/
|
|
142
273
|
htmlDecode: (text: string) => string;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* @en
|
|
277
|
+
* Get the browser location.hash. We don't use location.hash because of the way that Firefox auto-urldecodes it (see http://stackoverflow.com/questions/1703552/encoding-of-window-location-hash)
|
|
278
|
+
* @zh
|
|
279
|
+
* 获取浏览器的location.hash。我们不使用location.hash,因为Firefox的自动解码方式(见http://stackoverflow.com/questions/1703552/encoding-of-window-location-hash)。
|
|
280
|
+
*/
|
|
281
|
+
getLocationHash: () => string;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @en
|
|
285
|
+
* Pad a string to a given length with "0"s. Length defaults to 2
|
|
286
|
+
* @zh
|
|
287
|
+
* 用 "0 "将一个字符串填充到指定的长度。长度默认为2
|
|
288
|
+
*/
|
|
150
289
|
pad: (value: number, length?: number) => string;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* @en
|
|
293
|
+
* Convert a date into UTC `YYYYMMDDHHMMSSmmm` format
|
|
294
|
+
* @zh
|
|
295
|
+
* 将日期转换成UTC `YYYYMMDDHMMSSmmm` 格式
|
|
296
|
+
*/
|
|
297
|
+
stringifyDate: (value: Date) => string;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* @en
|
|
301
|
+
* Parse a date from a UTC `YYYYMMDDHHMMSSmmm` format string
|
|
302
|
+
* @zh
|
|
303
|
+
* 从UTC `YYYYMMDDHHMMSSmmm` 格式字符串中解析一个日期
|
|
304
|
+
*/
|
|
305
|
+
parseDate: (value: string | Date) => Date | null;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* @en
|
|
309
|
+
* Stringify an array of tiddler titles into a list string
|
|
310
|
+
* @zh
|
|
311
|
+
* 将一个数组的tiddler标题字符串化为一个列表字符串
|
|
312
|
+
*/
|
|
313
|
+
stringifyList: (value: string[]) => string;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* @en
|
|
317
|
+
* Parse a string array from a bracketted list. For example `OneTiddler [[Another Tiddler]] LastOne`
|
|
318
|
+
* @zh
|
|
319
|
+
* 从一个带括号的列表中解析一个字符串数组。例如,`OneTiddler [[Another Tiddler]] LastOne`
|
|
320
|
+
*/
|
|
157
321
|
parseStringArray: (
|
|
158
322
|
value: string | string[],
|
|
159
323
|
allowDuplicate?: boolean,
|
|
160
|
-
) => string[];
|
|
161
|
-
|
|
324
|
+
) => string[] | null;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* @en
|
|
328
|
+
* Parse a block of name:value fields. The `fields` object is used as the basis for the return value
|
|
329
|
+
* @zh
|
|
330
|
+
* 解析一个name:value字段的块。`fields`对象被用作返回值的基础。
|
|
331
|
+
*/
|
|
332
|
+
parseFields: (text: string, fields?: object) => Record<string, string>;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* @en
|
|
336
|
+
* Safely parse a string as JSON
|
|
337
|
+
* @zh
|
|
338
|
+
* 安全地解析一个字符串为 JSON 对象
|
|
339
|
+
*/
|
|
340
|
+
parseJSONSafe: (
|
|
341
|
+
input: string,
|
|
342
|
+
defaultJSON?: (error: Error) => unknown,
|
|
343
|
+
) => unknown;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* @en
|
|
347
|
+
* Resolves a source filepath delimited with `/` relative to a specified absolute root filepath.
|
|
348
|
+
* In relative paths, the special folder name `..` refers to immediate parent directory, and the
|
|
349
|
+
* name `.` refers to the current directory
|
|
350
|
+
* @zh
|
|
351
|
+
* 将以`/`为界的源文件路径相对于指定的绝对根文件路径进行解析。
|
|
352
|
+
* 在相对路径中,特殊的文件夹名称`...`指的是直接的父目录,而名称`.`指的是当前目录。
|
|
353
|
+
*/
|
|
354
|
+
resolvePath: (sourcepath: string, rootpath: string) => string;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* @en
|
|
358
|
+
* Parse a semantic version string into its constituent parts -- see https://semver.org
|
|
359
|
+
* @zh
|
|
360
|
+
* 将一个语义版本字符串解析为其构成部分 -- 见 https://semver.org
|
|
361
|
+
*/
|
|
162
362
|
parseVersion: (version: string) => {
|
|
163
363
|
build?: string;
|
|
164
364
|
major: number;
|
|
@@ -167,14 +367,34 @@ declare module 'tiddlywiki' {
|
|
|
167
367
|
prerelease?: string;
|
|
168
368
|
version: string;
|
|
169
369
|
} | null;
|
|
370
|
+
|
|
170
371
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
372
|
+
* @en
|
|
373
|
+
* Returns +1 if the version string A is greater than the version string B, 0 if they are the same, and +1 if B is greater than A.
|
|
374
|
+
* Missing or malformed version strings are parsed as 0.0.0
|
|
375
|
+
* @zh
|
|
376
|
+
* 如果版本字符串A大于版本字符串B,则返回+1;如果它们相同,则返回0;如果B大于A,则返回+1;
|
|
377
|
+
* 缺失或畸形的版本字符串被解析为0.0.0
|
|
174
378
|
*/
|
|
175
|
-
|
|
379
|
+
compareVersions: (
|
|
380
|
+
versionStringA: string,
|
|
381
|
+
versionStringB: string,
|
|
382
|
+
) => -1 | 0 | 1;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* @en
|
|
386
|
+
* Returns true if the version string A is greater than the version string B. Returns true if the versions are the same
|
|
387
|
+
* @zh
|
|
388
|
+
* 如果版本字符串A大于版本字符串B,返回true;如果版本相同,返回true。
|
|
389
|
+
*/
|
|
390
|
+
checkVersions: (versionStringA: string, versionStringB: string) => boolean;
|
|
391
|
+
|
|
176
392
|
/**
|
|
393
|
+
* @en
|
|
177
394
|
* Register file type information
|
|
395
|
+
* @zh
|
|
396
|
+
* 注册文件类型信息
|
|
397
|
+
*
|
|
178
398
|
* @param {string} contentType
|
|
179
399
|
* @param {string} encoding
|
|
180
400
|
* @param {(string | string[])} extension
|
|
@@ -194,41 +414,45 @@ declare module 'tiddlywiki' {
|
|
|
194
414
|
flags?: string[];
|
|
195
415
|
},
|
|
196
416
|
) => void;
|
|
417
|
+
|
|
197
418
|
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
419
|
+
* @en
|
|
420
|
+
* Given an extension, always access the $tw.config.fileExtensionInfo using a lowercase extension only.
|
|
421
|
+
* @zh
|
|
422
|
+
* 给定一个扩展名,总是只使用小写的扩展名来访问$tw.config.fileExtensionInfo。
|
|
201
423
|
*/
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
424
|
+
getFileExtensionInfo: (extension: string) => IFileExtensionInfo | null;
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* @en
|
|
428
|
+
* Given an extension, get the correct encoding for that file. defaults to utf8
|
|
429
|
+
* @zh
|
|
430
|
+
* 给定一个扩展名,获得该文件的正确编码。 默认为utf8
|
|
431
|
+
*/
|
|
432
|
+
getTypeEncoding: (extension: string) => string;
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* @en
|
|
436
|
+
* Run code globally with specified context variables in scope
|
|
437
|
+
* @zh
|
|
438
|
+
* 在全局范围内运行代码,范围内有指定的上下文变量
|
|
439
|
+
*/
|
|
440
|
+
evalGlobal: (
|
|
441
|
+
code: string,
|
|
442
|
+
context: IEvalContent,
|
|
443
|
+
filename: string,
|
|
444
|
+
) => unknown;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* @en
|
|
448
|
+
* Run code in a sandbox with only the specified context variables in scope
|
|
449
|
+
* @zh
|
|
450
|
+
* 在沙盒中运行代码,范围内只有指定的上下文变量
|
|
451
|
+
*/
|
|
452
|
+
evalSandboxed: (
|
|
453
|
+
code: string,
|
|
454
|
+
context: IEvalContent,
|
|
455
|
+
filename: string,
|
|
456
|
+
) => unknown;
|
|
233
457
|
}
|
|
234
458
|
}
|
package/src/wiki/index.d.ts
CHANGED
|
@@ -257,5 +257,6 @@ declare module 'tiddlywiki' {
|
|
|
257
257
|
getShadowSource(title: string): string | null;
|
|
258
258
|
getTiddlerBacklinks(targetTitle: string): string[];
|
|
259
259
|
getTiddlerLinks(title: string): string[];
|
|
260
|
+
getPluginInfo(title: string): { tiddlers: ITiddlerFields[] };
|
|
260
261
|
}
|
|
261
262
|
}
|