tw5-typed 0.2.16 → 0.2.17

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
@@ -2,7 +2,7 @@
2
2
  "description": "Types for tiddlywiki",
3
3
  "license": "MIT",
4
4
  "name": "tw5-typed",
5
- "version": "0.2.16",
5
+ "version": "0.2.17",
6
6
  "url": "https://github.com/tiddly-gittly/tw5-typed",
7
7
  "homepage": "https://github.com/tiddly-gittly/tw5-typed",
8
8
  "bugs": {
@@ -16,9 +16,6 @@
16
16
  "files": [
17
17
  "src/"
18
18
  ],
19
- "scripts": {
20
- "check": "tsc --noEmit && eslint src/**/*.ts"
21
- },
22
19
  "husky": {
23
20
  "hooks": {
24
21
  "pre-commit": "lint-staged"
@@ -39,6 +36,10 @@
39
36
  "husky": "^8.0.2",
40
37
  "lint-staged": "^13.1.0",
41
38
  "rimraf": "^3.0.2",
39
+ "tiddlywiki": "^5.2.5",
42
40
  "typescript": "^4.9.4"
41
+ },
42
+ "scripts": {
43
+ "check": "tsc --noEmit && eslint src/**/*.ts"
43
44
  }
44
- }
45
+ }
@@ -1,4 +1,15 @@
1
1
  declare module 'tiddlywiki' {
2
+ export interface IContentTypeInfo {
3
+ deserializerType: string;
4
+ encoding: string;
5
+ extension: string;
6
+ flags: string[];
7
+ }
8
+
9
+ export interface IFileExtensionInfo {
10
+ type: string;
11
+ }
12
+
2
13
  interface ITWConfig {
3
14
  [configName: string]: unknown;
4
15
  /** Map type to file content type */
@@ -0,0 +1,32 @@
1
+ /// <reference path="config.d.ts" />
2
+
3
+ declare module 'tiddlywiki' {
4
+ export interface IBootFilesIndexItem {
5
+ filepath: string;
6
+ hasMetaFile: boolean;
7
+ tiddlerTitle: string;
8
+ type: string;
9
+ }
10
+
11
+ export type IBootFilesIndex = Record<string, IBootFilesIndexItem>;
12
+
13
+ export interface IStartUpOption {
14
+ bootPath?: string;
15
+ callback?: () => unknown;
16
+ }
17
+
18
+ export interface IBoot {
19
+ argv: string[];
20
+ boot: (callback?: () => void) => void;
21
+ files: IBootFilesIndex;
22
+ log: (logString: string) => void;
23
+ logMessages: string[];
24
+ startup: (options: IStartUpOption) => void;
25
+ /** Default boot tasks */
26
+ tasks: {
27
+ readBrowserTiddlers: boolean;
28
+ trapErrors: boolean;
29
+ };
30
+ excludeRegExp: RegExp;
31
+ }
32
+ }
@@ -1,73 +1,117 @@
1
- /// <reference path="filter-operator.d.ts" />
2
- /// <reference path="modules.d.ts" />
3
- /// <reference path="Tiddler.d.ts" />
4
- /// <reference path="twconfig.d.ts" />
5
- /// <reference path="utils.d.ts" />
6
- /// <reference path="Widget.d.ts" />
7
- /// <reference path="Wiki.d.ts" />
8
- /// <reference path="parser.d.ts" />
9
- /// <reference path="ast.d.ts" />
10
-
11
- import { Server } from 'http';
1
+ /// <reference path="boot/index.d.ts" />
2
+ /// <reference path="wiki/index.d.ts" />
3
+ /// <reference path="utils/index.d.ts" />
4
+ /// <reference path="tiddler/index.d.ts" />
5
+ /// <reference path="modules/index.d.ts" />
12
6
 
13
7
  declare module 'tiddlywiki' {
14
- export interface IBootFilesIndexItem {
15
- filepath: string;
16
- hasMetaFile: boolean;
17
- tiddlerTitle: string;
18
- type: string;
19
- }
20
- /**
21
- * Record<tiddlerTitle, IBootFilesIndexItem>
22
- */
23
- export type IBootFilesIndex = Partial<Record<string, IBootFilesIndexItem>>;
24
-
25
8
  export interface IPluginInfo {
26
- tiddlers: ITiddlerFields[];
27
- }
28
-
29
- export interface IFileExtensionInfo {
30
- type: string;
9
+ version: string;
10
+ 'plugin-type': string;
11
+ dependents: string;
12
+ type: 'application/json';
13
+ text: string;
14
+ [pluginProperty: string]: string;
31
15
  }
32
16
 
33
17
  export interface ILanguage {
34
- getString: (
35
- key: string,
36
- options: { variables: { title: string } },
37
- ) => string;
38
- }
39
-
40
- export interface IContentTypeInfo {
41
- deserializerType: string;
42
- encoding: string;
43
- extension: string;
44
- flags: string[];
18
+ getString(key: string, options: { variables: { title: string } }): string;
45
19
  }
46
20
 
47
- export interface IStartUpOption {
48
- bootPath?: string;
49
- callback?: () => unknown;
50
- }
21
+ export type IWikiInfo = Record<string, unknown>;
51
22
 
52
23
  export interface ITiddlyWiki {
53
- Tiddler: typeof Tiddler;
54
24
  Wiki: typeof Wiki;
25
+ Tiddler: typeof Tiddler;
55
26
 
56
- boot: {
57
- argv: string[];
58
- boot: (callback?: () => void) => void;
59
- files: IBootFilesIndex;
60
- log: (logString: string) => void;
61
- logMessages: string[];
62
- startup: (options: IStartUpOption) => void;
63
- /** Default boot tasks */
64
- tasks: {
65
- readBrowserTiddlers: boolean;
66
- trapErrors: boolean;
67
- };
68
- excludeRegExp: RegExp;
27
+ wiki: Wiki;
28
+ boot: IBoot;
29
+ crypto: Crypto;
30
+ utils: ITWUtils;
31
+ version: string;
32
+ safeMode: boolean;
33
+ config: ITWConfig;
34
+ rootWidget: Widget;
35
+ notifier: Notifier;
36
+ language: ILanguage;
37
+ modules: ITWModules;
38
+ locationHash: string;
39
+ passwordPrompt: PasswordPrompt;
40
+ packageInfo: Record<string, unknown>;
41
+
42
+ /**
43
+ * Check for this window being the source of the drag. If true, some drop target widget will stop responding to the drop event, so you can handle drop event in your own widget.
44
+ * Used by `DropZoneWidget.prototype.handleDropEvent`
45
+ */
46
+ dragInProgress?: boolean;
47
+
48
+ /**
49
+ Global Hooks mechanism which allows plugins to modify default functionality
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;
69
71
  };
70
72
 
73
+ addUnloadTask(task: any): void;
74
+
75
+ /** Convenience function for pushing a tiddler onto the preloading array */
76
+ preloadTiddler(fields: Record<string, unknown>): void;
77
+ /** Convenience function for pushing an array of tiddlers onto the preloading array */
78
+ preloadTiddlerArray(fieldsArray: Array<Record<string, unknown>>): void;
79
+ /** External JavaScript can populate this array before calling boot.js in order to preload tiddlers */
80
+ preloadTiddlers: Record<string, Record<string, unknown>>;
81
+
82
+ getLibraryItemSearchPaths(libraryPath: string, envVar?: string): string;
83
+ findLibraryItem(name: string, paths: string[]): string | null;
84
+ loadPluginFolder(
85
+ filepath: string,
86
+ excludeRegExp?: RegExp,
87
+ ): IPluginInfo | null;
88
+ loadPlugin(name: string, paths: string[]): void;
89
+ loadPlugins(plugins: string[], libraryPath: string, envVar?: string): void;
90
+ loadWikiTiddlers(
91
+ wikiPath: string,
92
+ options?: { parentPaths?: string; readOnly?: boolean },
93
+ ): IWikiInfo;
94
+ loadTiddlersNode(): void;
95
+ loadTiddlersBrowser(): void;
96
+ loadTiddlersFromFile(
97
+ filepath: string,
98
+ defaultFields?: Record<string, unknown>,
99
+ ): {
100
+ filepath: string;
101
+ type: string;
102
+ tiddlers: ITiddlerFields[];
103
+ hasMetaFile: boolean;
104
+ };
105
+ loadMetadataForFile(filepath: string): ITiddlerFields | null;
106
+ loadTiddlersFromPath(
107
+ filepath: string,
108
+ excludeRegExp?: RegExp,
109
+ ): ITiddlerFields[];
110
+ loadTiddlersFromSpecification(
111
+ filepath: string,
112
+ excludeRegExp?: RegExp,
113
+ ): ITiddlerFields[];
114
+
71
115
  browser: null | {
72
116
  is?: {
73
117
  android?: boolean;
@@ -105,77 +149,9 @@ declare module 'tiddlywiki' {
105
149
  */
106
150
  isIE: boolean;
107
151
  };
108
-
109
- config: ITWConfig;
110
-
111
- /**
112
- * Check for this window being the source of the drag. If true, some drop target widget will stop responding to the drop event, so you can handle drop event in your own widget.
113
- * Used by `DropZoneWidget.prototype.handleDropEvent`
114
- */
115
- dragInProgress?: boolean;
116
-
117
- /**
118
- Global Hooks mechanism which allows plugins to modify default functionality
119
- */
120
- hooks: {
121
- /**
122
- Add hooks to the hashmap
123
- */
124
- addHook: (
125
- hookName: 'th-server-command-post-start',
126
- callback: (listenCommand: unknown, server: Server) => void,
127
- ) => void;
128
- addHook: (
129
- hookName: string,
130
- callback: (...arguments_: unknown[]) => unknown,
131
- ) => void;
132
- /**
133
- Invoke the hook by key
134
- */
135
- invokeHook: (
136
- hookName: string,
137
- event: IWidgetEvent,
138
- ) => undefined | IWidgetEvent;
139
- };
140
- /** Determines if a tiddler is a shadow tiddler, regardless of whether it has been overridden by a real tiddler */
141
- isShadowTiddler: (title: string) => boolean;
142
- language: ILanguage;
143
- modules: ITWModules;
144
-
145
152
  /** NodeJS features, if tw isn't running on a NodeJS environment, the value will be `null` */
146
- node: null | object;
153
+ node: null | Record<string, any>;
147
154
  /** Broswer features, if tw isn't running on a browser environment, the value will be `null` */
148
- nodeWebKit: null | object;
149
-
150
- notifier: Notifier;
151
- /** Convenience function for pushing a tiddler onto the preloading array */
152
- preloadTiddler: (fields: Record<string, unknown>) => void;
153
- /** Convenience function for pushing an array of tiddlers onto the preloading array */
154
- preloadTiddlerArray: (fieldsArray: Array<Record<string, unknown>>) => void;
155
-
156
- /** External JavaScript can populate this array before calling boot.js in order to preload tiddlers */
157
- preloadTiddlers: Record<string, Record<string, unknown>>;
158
-
159
- getLibraryItemSearchPaths: (libraryPath: string, envVar?: string) => string;
160
-
161
- findLibraryItem: (name: string, paths: string[]) => string | null;
162
-
163
- loadMetadataForFile: (filepath: string) => ITiddlerFields | null;
164
-
165
- loadPluginFolder: (
166
- filepath: string,
167
- excludeRegExp?: RegExp,
168
- ) => ITiddlerFields | null;
169
-
170
- rootWidget: Widget;
171
-
172
- /** Test for the existence of a tiddler (excludes shadow tiddlers) */
173
- tiddlerExists: (title: string) => boolean;
174
- utils: ITWUtils;
175
- version: string;
176
- wiki: Wiki;
155
+ nodeWebKit: null | Record<string, any>;
177
156
  }
178
-
179
- export type TW5InitFunction = ($tw?: ITiddlyWiki) => ITiddlyWiki;
180
- export const TiddlyWiki: TW5InitFunction;
181
157
  }
package/src/index.d.ts CHANGED
@@ -1,19 +1,14 @@
1
- /// <reference path="tw.d.ts" />
2
- /// <reference path="server.d.ts" />
1
+ /// <reference path="core.d.ts" />
3
2
 
4
- import * as TW from 'tiddlywiki';
3
+ import { ITiddlyWiki } from 'tiddlywiki';
5
4
 
6
5
  export * from 'tiddlywiki';
6
+
7
+ declare module 'tiddlywiki' {
8
+ export type TW5InitFunction = (baseObject?: Record<string, unknown>) => ITiddlyWiki
9
+ export const TiddlyWiki: TW5InitFunction;
10
+ }
11
+
7
12
  declare global {
8
- const $tw: TW.ITiddlyWiki;
9
- // const Buffer: ?Buffer;
10
- // const clearInterval: typeof global.clearInterval;
11
- // const clearTimeout: typeof global.clearTimeout;
12
- // const console: Console;
13
- // const exports: TW.ITWModuleExports;
14
- // const module: { exports: TW.ITWModuleExports; readonly id: string };
15
- // const process: ?NodeJS.Process;
16
- // const require: ITWRequire;
17
- // const setInterval: typeof global.setInterval;
18
- // const setTimeout: typeof global.setTimeout;
13
+ export let $tw: ITiddlyWiki;
19
14
  }
@@ -1,3 +1,8 @@
1
+ /// <reference path="server/index.d.ts" />
2
+ /// <reference path="parsers/index.d.ts" />
3
+ /// <reference path="widgets/index.d.ts" />
4
+ /// <reference path="parsers/index.d.ts" />
5
+
1
6
  declare module 'tiddlywiki' {
2
7
  export interface ITWModuleExports {
3
8
  [exportName: string]: unknown;
@@ -1,4 +1,58 @@
1
1
  declare module 'tiddlywiki' {
2
+ export interface IParserOptions {
3
+ /**
4
+ * Optional source uri, used in parseText
5
+ */
6
+ _canonical_uri?: string;
7
+ /**
8
+ * While calling `getCacheForTiddler`, use inlineParseTree or blockParseTree
9
+ */
10
+ parseAsInline?: boolean;
11
+ }
12
+
13
+ export class WikiParseRule {
14
+ is: { block?: boolean; inline?: boolean };
15
+
16
+ match?: unknown;
17
+
18
+ matchRegExp?: RegExp;
19
+
20
+ parser?: WikiParser;
21
+
22
+ nextTag?: unknown;
23
+
24
+ /** `{type: 'macrocall', start: 261, params: Array(1), name: 'reuse-tiddler', end: 290}` */
25
+ nextCall?: {
26
+ end: number;
27
+ name: string;
28
+ /** `{ type: 'macro-parameter'; start: 276; value: '快速创建新笔记按钮'; end: 288 }` */
29
+ params: { end: number; start: number; type: string; value: string };
30
+ start: number;
31
+ type: string;
32
+ };
33
+ }
34
+ export class WikiParser {
35
+ blockRules: { matchIndex?: number; rule: WikiParseRule }[];
36
+
37
+ inlineRules: { matchIndex?: number; rule: WikiParseRule }[];
38
+
39
+ pragmaRules: { matchIndex?: number; rule: WikiParseRule }[];
40
+
41
+ configTrimWhiteSpace: boolean;
42
+
43
+ pos: number;
44
+
45
+ source: string;
46
+
47
+ sourceLength: number;
48
+
49
+ type: string;
50
+
51
+ wiki: Wiki;
52
+
53
+ tree: IParseTreeNode[];
54
+ }
55
+
2
56
  export interface IParseTreeAttribute {
3
57
  end?: number;
4
58
  name?: string;
@@ -1,5 +1,3 @@
1
- /// <reference path="Wiki.d.ts" />
2
-
3
1
  import type Http from 'http';
4
2
 
5
3
  declare module 'tiddlywiki' {
File without changes
@@ -1,31 +1,33 @@
1
1
  declare module 'tiddlywiki' {
2
+ export type ITiddlerCache = Record<string, unknown>;
3
+
4
+ export interface ITiddlerFields {
5
+ readonly [anyKey: string]: unknown;
6
+ readonly color?: string;
7
+ readonly created: Date;
8
+ readonly list?: string[];
9
+ readonly modified: Date;
10
+ readonly tags: string[];
11
+ readonly text: string;
12
+ readonly title: string;
13
+ readonly type: string;
14
+ }
15
+
2
16
  export class Tiddler {
3
17
  static fieldModules: Record<string, IModuleInfo>;
4
18
 
5
19
  readonly cache: ITiddlerCache;
6
20
 
7
21
  readonly fields: ITiddlerFields;
22
+
8
23
  /**
9
24
  *
10
25
  * @param tiddlers multiple tiddler fields or instances, will merge them to create a new one
11
26
  */
12
27
  constructor(...tiddlers: Array<Record<string, unknown> | Tiddler>);
28
+
13
29
  hasField(field: string): boolean;
14
- isEqual(tiddler: Tiddler, excludeFields: string[]): boolean;
15
- }
16
30
 
17
- export interface ITiddlerFields {
18
- readonly [anyKey: string]: unknown;
19
- readonly color?: string;
20
- readonly created: Date;
21
- readonly list?: string[];
22
- readonly modified: Date;
23
- readonly tags: string[];
24
- readonly text: string;
25
- readonly title: string;
26
- readonly type: string;
31
+ isEqual(tiddler: Tiddler, excludeFields: string[]): boolean;
27
32
  }
28
-
29
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
30
- export interface ITiddlerCache {}
31
33
  }
File without changes
File without changes
@@ -1,4 +1,4 @@
1
- /// <reference path="parser.d.ts" />
1
+ /// <reference path="../modules/filters/index.d.ts" />>
2
2
 
3
3
  declare module 'tiddlywiki' {
4
4
  export interface IMakeWidgetOptions extends IRenderOptions {
package/src/parser.d.ts DELETED
@@ -1,57 +0,0 @@
1
- /// <reference path="ast.d.ts" />
2
-
3
- declare module 'tiddlywiki' {
4
- export interface IParserOptions {
5
- /**
6
- * Optional source uri, used in parseText
7
- */
8
- _canonical_uri?: string;
9
- /**
10
- * While calling `getCacheForTiddler`, use inlineParseTree or blockParseTree
11
- */
12
- parseAsInline?: boolean;
13
- }
14
-
15
- export class WikiParseRule {
16
- is: { block?: boolean; inline?: boolean };
17
-
18
- match?: unknown;
19
-
20
- matchRegExp?: RegExp;
21
-
22
- parser?: WikiParser;
23
-
24
- nextTag?: unknown;
25
-
26
- /** `{type: 'macrocall', start: 261, params: Array(1), name: 'reuse-tiddler', end: 290}` */
27
- nextCall?: {
28
- end: number;
29
- name: string;
30
- /** `{ type: 'macro-parameter'; start: 276; value: '快速创建新笔记按钮'; end: 288 }` */
31
- params: { end: number; start: number; type: string; value: string };
32
- start: number;
33
- type: string;
34
- };
35
- }
36
- export class WikiParser {
37
- blockRules: { matchIndex?: number; rule: WikiParseRule }[];
38
-
39
- inlineRules: { matchIndex?: number; rule: WikiParseRule }[];
40
-
41
- pragmaRules: { matchIndex?: number; rule: WikiParseRule }[];
42
-
43
- configTrimWhiteSpace: boolean;
44
-
45
- pos: number;
46
-
47
- source: string;
48
-
49
- sourceLength: number;
50
-
51
- type: string;
52
-
53
- wiki: Wiki;
54
-
55
- tree: IParseTreeNode[];
56
- }
57
- }