tw5-typed 0.0.7 → 0.0.8

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.0.7",
5
+ "version": "0.0.8",
6
6
  "url": "https://github.com/tiddly-gittly/tw5-typed",
7
7
  "homepage": "https://github.com/tiddly-gittly/tw5-typed",
8
8
  "bugs": {
@@ -22,19 +22,25 @@
22
22
  "devDependencies": {
23
23
  "@typescript-eslint/eslint-plugin": "5.10.2",
24
24
  "@typescript-eslint/parser": "5.10.2",
25
- "typescript": "4.5.5",
26
25
  "eslint": "8.8.0",
27
26
  "eslint-config-prettier": "8.3.0",
28
27
  "eslint-config-standard": "17.0.0-1",
29
28
  "eslint-config-standard-with-typescript": "21.0.1",
30
29
  "eslint-import-resolver-alias": "1.1.2",
31
30
  "eslint-import-resolver-typescript": "2.5.0",
31
+ "eslint-plugin-html": "6.2.0",
32
32
  "eslint-plugin-import": "2.25.4",
33
+ "eslint-plugin-n": "14.0.0",
33
34
  "eslint-plugin-node": "11.1.0",
34
35
  "eslint-plugin-prettier": "4.0.0",
36
+ "eslint-plugin-promise": "6.0.0",
37
+ "eslint-plugin-react": "7.28.0",
38
+ "eslint-plugin-react-hooks": "4.3.0",
39
+ "eslint-plugin-security": "1.4.0",
40
+ "eslint-plugin-security-node": "1.1.1",
35
41
  "eslint-plugin-typescript-sort-keys": "2.1.0",
36
42
  "eslint-plugin-unicorn": "40.1.0",
37
- "prettier": "2.5.1"
38
- },
39
- "dependencies": {}
43
+ "prettier": "2.5.1",
44
+ "typescript": "4.5.5"
45
+ }
40
46
  }
@@ -0,0 +1,9 @@
1
+ declare module 'tiddlywiki' {
2
+ export class Crypto {
3
+ setPassword(newPassword: string): void;
4
+ updateCryptoStateTiddler(): void;
5
+ hasPassword(): boolean;
6
+ encrypt(text: string, password: string): string | null;
7
+ decrypt(text: string, password: string): string | null;
8
+ }
9
+ }
@@ -0,0 +1,54 @@
1
+ declare module 'tiddlywiki' {
2
+ export interface PasswordPromptInfo {
3
+ callback: PasswordPromptInfoCallback;
4
+ form: TWDOMElement;
5
+ owner: PasswordPrompt;
6
+ serviceName: string;
7
+ }
8
+
9
+ export type PasswordPromptInfoCallback = (
10
+ data: {
11
+ password: string;
12
+ password2?: string;
13
+ username: string;
14
+ } | null,
15
+ ) => boolean;
16
+
17
+ export class PasswordPrompt {
18
+ /** Creates a PasswordPrompt object */
19
+ constructor();
20
+ /** Store of pending password prompts */
21
+ passwordPrompts: PasswordPromptInfo[];
22
+ promptWrapper: TWDOMElement;
23
+ /** Hides or shows the wrapper depending on whether there are any outstanding prompts */
24
+ setWrapperDisplay(): void;
25
+ /**
26
+ * Adds a new password prompt. Options are:
27
+ * @param {{
28
+ * submitText: string;
29
+ * serviceName: string;
30
+ * noUserName: boolean;
31
+ * canCancel: boolean;
32
+ * repeatPassword: boolean;
33
+ * callback: PasswordPromptInfoCallback;
34
+ * }} options Options are:
35
+ * * submitText: text to use for submit button (defaults to "Login")
36
+ * * serviceName: text of the human readable service name
37
+ * * noUserName: set true to disable username prompt
38
+ * * canCancel: set true to enable a cancel button (callback called with null)
39
+ * * repeatPassword: set true to prompt for the password twice
40
+ * * callback: function to be called on submission with parameter of object {username:,password:}. Callback must return `true` to remove the password prompt
41
+ * @returns {PasswordPromptInfo}
42
+ * @memberof PasswordPrompt
43
+ */
44
+ createPrompt(options: {
45
+ callback: PasswordPromptInfoCallback;
46
+ canCancel: boolean;
47
+ noUserName: boolean;
48
+ repeatPassword: boolean;
49
+ serviceName: string;
50
+ submitText: string;
51
+ }): PasswordPromptInfo;
52
+ removePrompt(promptInfo: PasswordPromptInfo): void;
53
+ }
54
+ }
@@ -0,0 +1,25 @@
1
+ declare module 'tiddlywiki' {
2
+ export class Tiddler {
3
+ constructor(...fields: Array<Record<string, unknown> | Tiddler>);
4
+ readonly cache: ITiddlerCache;
5
+ readonly fields: ITiddlerFields;
6
+ static fieldModules: IModule;
7
+ hasField(field: string): boolean;
8
+ isEqual(tiddler: Tiddler, excludeFields: string[]): boolean;
9
+ }
10
+
11
+ export interface ITiddlerFields {
12
+ readonly [anyKey: string]: unknown;
13
+ readonly color: string;
14
+ readonly created: Date;
15
+ readonly list: string[];
16
+ readonly modified: Date;
17
+ readonly tags: string[];
18
+ readonly text: string;
19
+ readonly title: string;
20
+ readonly type: string;
21
+ }
22
+
23
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
24
+ export interface ITiddlerCache {}
25
+ }
package/src/Wiki.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ declare module 'tiddlywiki' {
2
+ export class Wiki {
3
+ /**
4
+ * Wiki constructor. State is stored in private members that only a small number of privileged accessor methods have direct access. Methods added via the prototype have to use these accessors and cannot access the state data directly.
5
+ * @param {{ enableIndexers: unknown[] }} options options include:
6
+ * * enableIndexers - Array of indexer names to enable, or null to use all available indexers
7
+ * @memberof Wiki
8
+ */
9
+ constructor(options: { enableIndexers: unknown[] });
10
+ addIndexer(indexer, name): void;
11
+ getTiddler: (title: string) => Tiddler | undefined;
12
+ /**
13
+ * Get full list of tiddler titles in the wiki
14
+ */
15
+ getTiddlers: () => string[];
16
+ }
17
+ }
@@ -1,42 +1,42 @@
1
1
  declare module 'tiddlywiki' {
2
- export type SourceIterator = (tiddler: Object, title: string) => void;
2
+ export type SourceIterator = (tiddler: Tiddler, title: string) => void;
3
3
  export interface ISearchOptions {
4
- /** an iterator function for the source tiddlers, called source(iterator), where iterator is called as iterator(tiddler,title) */
5
- source?: (iter: SourceIterator) => void;
6
- /** An array of tiddler titles to exclude from the search */
7
- exclude?: string[];
8
- /** If true returns tiddlers that do not contain the specified string */
9
- invert?: boolean;
10
- /** If true forces a case sensitive search */
11
- caseSensitive?: boolean;
12
- /** If specified, restricts the search to the specified field, or an array of field names */
13
- field?: string | string[];
14
4
  /** If true, forces all but regexp searches to be anchored to the start of text */
15
5
  anchored?: boolean;
6
+ /** If true forces a case sensitive search */
7
+ caseSensitive?: boolean;
8
+ /** An array of tiddler titles to exclude from the search */
9
+ exclude?: string[];
16
10
  /** If true, the field options are inverted to specify the fields that are not to be searched */
17
11
  excludeField?: boolean;
12
+ /** If specified, restricts the search to the specified field, or an array of field names */
13
+ field?: string | string[];
14
+ /** If true returns tiddlers that do not contain the specified string */
15
+ invert?: boolean;
18
16
  /** searches for literal string */
19
17
  literal?: boolean;
18
+ /** an iterator function for the source tiddlers, called source(iterator), where iterator is called as iterator(tiddler,title) */
19
+ source?: (iter: SourceIterator) => void;
20
20
  /** same as literal except runs of whitespace are treated as a single space */
21
21
  whitespace?: boolean;
22
22
  /** (default) treats search string as a list of tokens, and matches if all tokens are found, regardless of adjacency or ordering */
23
23
  words?: boolean;
24
24
  }
25
25
 
26
- export interface IFilterOperatorParamOperator {
27
- /** the name of the filter operator specified in the WikiText; */
28
- operator: string;
26
+ export interface IFilterOperatorParameterOperator {
29
27
  /** the operand for the filter step (as a string; if the filter specified it in angle brackets or braces, the text reference or letiable name will have already been resolved); */
30
28
  operand: string;
29
+ /** the name of the filter operator specified in the WikiText; */
30
+ operator: string;
31
31
  /** (optional) a string containing a single exclamation mark if the filter operator is to be negated; */
32
32
  prefix?: string;
33
+ /** (optional, deprecated) used instead of `operand` if the filter operand is a regexp. */
34
+ regexp?: string;
33
35
  /** (optional) a string containing an additional filter argument (typically a tiddler field name) following the filter name (separated by a colon in the filter syntax); */
34
36
  suffix?: string;
35
37
  /** multiple suffix
36
38
  * for example, in `search:<field list>:<flag list>[<operand>]`, you will get `<field list>` as suffixes[0], and `<flag list>` as suffixes[1]
37
39
  */
38
40
  suffixes?: string[][];
39
- /** (optional, deprecated) used instead of `operand` if the filter operand is a regexp. */
40
- regexp?: string;
41
41
  }
42
42
  }
@@ -0,0 +1,80 @@
1
+ declare module 'tiddlywiki' {
2
+ export interface ITWModuleExports {
3
+ [exportName: unknown]: unknown;
4
+ name?: string;
5
+ type?: string;
6
+ }
7
+ export interface IModuleInfo {
8
+ definition: string | TWModuleDefinitionFucntion | ITWModuleExports;
9
+ exports: ITWModuleExports | null;
10
+ moduleType: string;
11
+ }
12
+ export interface ITWRequire {
13
+ (title: string): ITWModuleExports;
14
+ readonly main: NodeJS.Module | { TiddlyWiki: typeof TiddlyWiki };
15
+ }
16
+ export interface IModuleSandbox {
17
+ $tw: ITiddlyWiki;
18
+ Buffer?: Buffer;
19
+ clearInterval: typeof clearInterval;
20
+ clearTimeout: typeof clearTimeout;
21
+ console: Console;
22
+ exports: ITWModuleExports;
23
+ module: { exports: ITWModuleExports; readonly id: string };
24
+ process?: NodeJS.Process;
25
+ require: ITWRequire;
26
+ setInterval: typeof setInterval;
27
+ setTimeout: typeof setTimeout;
28
+ }
29
+ export type TWModuleDefinitionFucntion = (moduleInfo: IModuleInfo, exports: ITWModuleExports, requireFunction: ITWRequire) => void;
30
+ /**
31
+ * Information about each module is kept in an object with these members:
32
+ *
33
+ * * moduleType: type of module
34
+ * * definition: object, function or string defining the module; see below
35
+ * * exports: exports of the module, filled in after execution
36
+ *
37
+ * The `definition` can be of several types:
38
+ *
39
+ * * An object can be used to directly specify the exports of the module
40
+ * * A function with the arguments `module,require,exports` that returns `exports`
41
+ * * A string function body with the same arguments
42
+ *
43
+ * 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
44
+ */
45
+ interface ITWModules {
46
+ /** Apply the exports of the modules of a particular type to a target object */
47
+ applyMethods(moduleType: string, targetObject?: ITWModuleExports): ITWModuleExports;
48
+ /** Return a class created from a modules. The module should export the properties to be added to those of the optional base class */
49
+ createClassFromModule(moduleExports: ITWModuleExports, baseClass: new () => unknown): ITWModuleExports;
50
+ /** Return an array of classes created from the modules of a specified type. Each module should export the properties to be added to those of the optional base class */
51
+ createClassesFromModules(moduleType: string, subType: string | null | undefined, baseClass: new () => unknown): Record<string, ITWModuleExports>;
52
+ /**
53
+ * Define a JavaScript tiddler module for later execution
54
+ * @param {string} moduleName name of module being defined
55
+ * @param {string} moduleType type of module
56
+ * @param {(string | TWModuleDefinitionFucntion | ITWModuleExports)} definition module definition; see discussion above
57
+ * @memberof ITWModules
58
+ */
59
+ define(moduleName: string, moduleType: string, definition: string | TWModuleDefinitionFucntion | ITWModuleExports): void;
60
+ /**
61
+ * Execute the module named 'moduleName'. The name can optionally be relative to the module named 'moduleRoot'
62
+ * @memberof ITWModules
63
+ */
64
+ execute(moduleName: string, moduleRoot: string): ITWModuleExports;
65
+ /**
66
+ * Apply a callback to each module of a particular type
67
+ *
68
+ * @param {string} moduleType type of modules to enumerate
69
+ * @param {(title, moduleExports) => void} callback function called as callback(title,moduleExports) for each module
70
+ * @memberof ITWModules
71
+ */
72
+ forEachModuleOfType(moduleType: string, callback: (title, moduleExports) => void): void;
73
+ /** Get all the modules of a particular type in a hashmap by their `name` field */
74
+ getModulesByTypeAsHashmap(moduleType: string, nameField: string): Record<string, IModuleInfo>;
75
+ /** hashmap by module name of moduleInfo */
76
+ titles: Record<string, IModuleInfo>;
77
+ /** hashmap by module type and then name of moduleInfo */
78
+ types: Record<string, Record<string, IModuleInfo>>;
79
+ }
80
+ }
package/src/tw.d.ts CHANGED
@@ -1,34 +1,4 @@
1
1
  declare module 'tiddlywiki' {
2
- export interface ITiddler {
3
- constructor(...fields: (Record<string, unknown> | ITiddler)[]);
4
- readonly cache: ITiddlerCache;
5
- readonly fields: ITiddlerFields;
6
- // static fieldModules: IModule;
7
- hasField(field: string): boolean;
8
- isEqual(tiddler: ITiddler, excludeFields: string[]): boolean;
9
- }
10
-
11
- export interface ITiddlerFields {
12
- readonly created: Date;
13
- readonly list: string[];
14
- readonly modified: Date;
15
- readonly tags: string[];
16
- readonly text: string;
17
- readonly title: string;
18
- readonly type: string;
19
- readonly color: string;
20
- readonly [anyKey: string]: unknown;
21
- }
22
-
23
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
24
- export interface ITiddlerCache {}
25
-
26
- /**
27
- * filepath: '/Users/linonetwo/xxxx/wiki/Meme-of-LinOnetwo/tiddlers/tiddlerTitle.tid',
28
- * hasMetaFile: false
29
- * tiddlerTitle: string,
30
- * type: 'application/x-tiddler',
31
- */
32
2
  export interface IBootFilesIndexItem {
33
3
  filepath: string;
34
4
  hasMetaFile: boolean;
@@ -40,147 +10,69 @@ declare module 'tiddlywiki' {
40
10
  */
41
11
  export type IBootFilesIndex = Partial<Record<string, IBootFilesIndexItem>>;
42
12
 
43
- export interface IModule {
44
- moduleType: string;
45
- definition: unknown;
46
- exports: object | null;
13
+ export interface IPluginInfo {
14
+ tiddlers: ITiddlerFields[];
15
+ }
16
+
17
+ export interface IFileExtensionInfo {
18
+ type: string;
19
+ }
20
+
21
+ export interface IContentTypeInfo {
22
+ deserializerType: string;
23
+ encoding: string;
24
+ extension: string;
25
+ flags: string[];
47
26
  }
48
27
 
49
- export interface TiddlyWiki {
28
+ export interface ITiddlyWiki {
29
+ Tiddler: typeof Tiddler;
30
+ Wiki: typeof Wiki;
31
+
50
32
  boot: {
51
33
  argv: string[];
52
34
  files: IBootFilesIndex;
35
+ log(logString: string): void;
36
+ logMessages: string[];
53
37
  startup(options: { callback?: () => unknown }): void;
54
38
  /** Default boot tasks */
55
39
  tasks: {
56
- trapErrors: boolean;
57
40
  readBrowserTiddlers: boolean;
41
+ trapErrors: boolean;
58
42
  };
59
- logMessages: string[];
60
- log(str: string): void;
61
43
  };
62
44
 
63
- /** Broswer features, if tw isn't running on a browser environment, the value will be `null` */
64
45
  browser: null | object;
46
+
47
+ config: ITWConfig;
48
+
49
+ hooks: {
50
+ addHook: (hookName: string, callback: (...arguments_: unknown[]) => unknown) => void;
51
+ };
52
+
53
+ modules: ITWModules;
65
54
  /** NodeJS features, if tw isn't running on a NodeJS environment, the value will be `null` */
66
55
  node: null | object;
56
+ /** Broswer features, if tw isn't running on a browser environment, the value will be `null` */
67
57
  nodeWebKit: null | object;
68
58
 
69
- /**
70
- * Information about each module is kept in an object with these members:
71
- *
72
- * * moduleType: type of module
73
- * * definition: object, function or string defining the module; see below
74
- * * exports: exports of the module, filled in after execution
75
- *
76
- * The `definition` can be of several types:
77
- *
78
- * * An object can be used to directly specify the exports of the module
79
- * * A function with the arguments `module,require,exports` that returns `exports`
80
- * * A string function body with the same arguments
81
- *
82
- * 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
83
- */
84
- modules: {
85
- /** hashmap by module name of moduleInfo */
86
- titles: Record<string, IModule>;
87
- /** hashmap by module type and then name of moduleInfo */
88
- types: Record<string, Record<string, IModule>>;
89
- /**
90
- * Define a JavaScript tiddler module for later execution
91
- * @param {string} moduleName name of module being defined
92
- * @param {string} moduleType type of module
93
- * @param {unknown} definition module definition; see discussion above
94
- */
95
- define(moduleName: string, moduleType: string, definition: unknown): void;
96
- };
97
-
98
- /** External JavaScript can populate this array before calling boot.js in order to preload tiddlers */
99
- preloadTiddlers: Record<string, Record<string, unknown>>;
100
59
  /** Convenience function for pushing a tiddler onto the preloading array */
101
60
  preloadTiddler(fields: Record<string, unknown>): void;
102
61
  /** Convenience function for pushing an array of tiddlers onto the preloading array */
103
- preloadTiddlerArray(fieldsArray: Record<string, unknown>[]): void;
62
+ preloadTiddlerArray(fieldsArray: Array<Record<string, unknown>>): void;
63
+ /** External JavaScript can populate this array before calling boot.js in order to preload tiddlers */
64
+ preloadTiddlers: Record<string, Record<string, unknown>>;
104
65
 
105
- hooks: {
106
- addHook: (hookName: string, callback: (...arguments_: any[]) => unknown) => void;
107
- };
108
- wiki: {
109
- getTiddler: (title: string) => ITiddler | undefined;
110
- /**
111
- * Get full list of tiddler titles in the wiki
112
- */
113
- getTiddlers: () => string[];
114
- };
115
- utils: {
116
- /** Check if an object has a property. */
117
- hop(object: object, property: string): boolean;
118
- /** Determine if a value is an array. */
119
- isArray(value: unknown): boolean;
120
- /** Check if an array is equal by value and by reference. */
121
- isArrayEqual(array1: unknown[], array2: unknown[]): boolean;
122
- /**
123
- * Push entries onto an array, removing them first if they already exist in the array
124
- *
125
- * * array: array to modify (assumed to be free of duplicates)
126
- * * value: a single value to push or an array of values to push
127
- */
128
- pushTop(array: unknown[], value: unknown): void;
129
- /** Determine if a value is a date */
130
- isDate(value: unknown): void;
131
- /**
132
- * Iterate through all the own properties of an object or array.
133
- *
134
- * Callback is invoked with (element, index, object), if callback returns false, then the each loop will be terminated.
135
- * */
136
- each<T = object | unknown[]>(object: T, callback: (element?: unknown, index?: string | number, object?: T) => boolean | void);
137
- /**
138
- * Helper for making DOM elements
139
- * Options include:
140
- * * namespace:
141
- * * attributes: hashmap of attribute values
142
- * * style: hashmap of styles
143
- * * text: text to add as a child node
144
- * * children: array of further child nodes
145
- * * innerHTML: optional HTML for element
146
- * * class: class name(s)
147
- * * document: defaults to current document
148
- * * eventListeners: array of event listeners (this option won't work until `$tw.utils.addEventListeners()` has been loaded)
149
- *
150
- * @param {string} tag tag name
151
- * @param {{
152
- * namespace?: string;
153
- * attributes?: Record<string, unknown>;
154
- * style?: Record<string, string>;
155
- * text?: string;
156
- * children?: Element[];
157
- * innerHTML?: string;
158
- * class?: string;
159
- * document?: Document;
160
- * eventListeners?: EventListener[];
161
- * }} options
162
- * @returns {Element}
163
- */
164
- domMaker(
165
- tag: string,
166
- options: {
167
- namespace?: string;
168
- attributes?: Record<string, unknown>;
169
- style?: Record<string, string>;
170
- text?: string;
171
- children?: Element[];
172
- innerHTML?: string;
173
- class?: string;
174
- document?: Document;
175
- eventListeners?: EventListener[];
176
- },
177
- ): Element;
178
- };
66
+ utils: ITWUtils;
67
+
68
+ version: string;
69
+
70
+ wiki: Wiki;
179
71
  }
180
72
 
181
- export function TiddlyWiki(): TiddlyWiki;
73
+ export declare function TiddlyWiki($tw: object): ITiddlyWiki;
182
74
 
183
75
  global {
184
- const $tw: TiddlyWiki;
76
+ const $tw: ITiddlyWiki;
185
77
  }
186
78
  }
@@ -0,0 +1,40 @@
1
+ declare module 'tiddlywiki' {
2
+ declare interface ITWConfig {
3
+ [configName: string]: unknown;
4
+ /** Map type to file content type */
5
+ contentTypeInfo: Record<string, IContentTypeInfo>;
6
+ /** Default is `TIDDLYWIKI_EDITION_PATH` */
7
+ editionsEnvVar: string;
8
+ /** Default is `../editions/` */
9
+ editionsPath: string;
10
+ /** Map file extension */
11
+ fileExtensionInfo: Record<string, IFileExtensionInfo>;
12
+ /** Default is `^\\/\\*\\\\(?:\\r?\\n)((?:^[^\\r\\n]*(?:\\r?\\n))+?)(^\\\\\\*\\/$(?:\\r?\\n)?)` */
13
+ jsModuleHeaderRegExpString: string;
14
+ /** Default is `TIDDLYWIKI_LANGUAGE_PATH` */
15
+ languagesEnvVar: string;
16
+ /** Default is `../languages/` */
17
+ languagesPath: string;
18
+ //
19
+ /** Default is `TIDDLYWIKI_PLUGIN_PATH` */
20
+ pluginsEnvVar: string;
21
+ /** Default is `../plugins/` */
22
+ pluginsPath: string;
23
+ /** Default is `TIDDLYWIKI_THEME_PATH` */
24
+ themesEnvVar: string;
25
+ /** Default is `../themes/` */
26
+ themesPath: string;
27
+ /** Default is `./tiddlywiki.info` */
28
+ wikiInfo: string;
29
+ /** Default is `./languages` */
30
+ wikiLanguagesSubDir: string;
31
+ /** Default is `./output` */
32
+ wikiOutputSubDir: string;
33
+ /** Default is `./plugins` */
34
+ wikiPluginsSubDir: string;
35
+ /** Default is `./themes` */
36
+ wikiThemesSubDir: string;
37
+ /** Default is `./tiddlers` */
38
+ wikiTiddlersSubDir: string;
39
+ }
40
+ }
package/src/utils.d.ts ADDED
@@ -0,0 +1,144 @@
1
+ declare module 'tiddlywiki' {
2
+ export type TWDocument = Document;
3
+ export type TWDOMElement = Element;
4
+ export type TWEachCallback<T> = (element?: unknown, index?: string | number, object?: T) => boolean | undefined;
5
+ interface ITWUtils {
6
+ Crypto: typeof Crypto;
7
+ PasswordPrompt: typeof PasswordPrompt;
8
+ /** Returns true if the version string A is greater than the version string B. Returns true if the versions are the same */
9
+ checkVersions(versionStringA: string, versionStringB: string): boolean;
10
+ /**
11
+ * 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.
12
+ * Missing or malformed version strings are parsed as 0.0.0
13
+ */
14
+ compareVersions(versionStringA: string, versionStringB: string): -1 | 0 | 1;
15
+ /** Convert a URIComponent encoded string to a string safely */
16
+ decodeURIComponentSafe(uri: string): string;
17
+ /** Convert a URI encoded string to a string safely */
18
+ decodeURISafe(uri: string): string;
19
+ /** 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 */
20
+ deepDefaults(object: object, ...sourceObjectList: object[]): object;
21
+ /**
22
+ * Helper for making DOM elements
23
+ * @param {string} tag tag name
24
+ * @param {{
25
+ * namespace?: string;
26
+ * attributes?: Record<string, unknown>;
27
+ * style?: Record<string, string>;
28
+ * text?: string;
29
+ * children?: Element[];
30
+ * innerHTML?: string;
31
+ * class?: string;
32
+ * document?: Document;
33
+ * eventListeners?: EventListener[];
34
+ * }} options Options include:
35
+ * * namespace: defaults to http://www.w3.org/1999/xhtml
36
+ * * attributes: hashmap of attribute values
37
+ * * style: hashmap of styles
38
+ * * text: text to add as a child node
39
+ * * children: array of further child nodes
40
+ * * innerHTML: optional HTML for element
41
+ * * class: class name(s)
42
+ * * document: defaults to current document
43
+ * * eventListeners: array of event listeners (this option won't work until `$tw.utils.addEventListeners()` has been loaded)
44
+ * @returns {Element}
45
+ */
46
+ domMaker(
47
+ tag: string,
48
+ options: {
49
+ attributes?: Record<string, unknown>;
50
+ children?: TWDOMElement[];
51
+ class?: string;
52
+ document?: TWDocument;
53
+ eventListeners?: EventListener[];
54
+ innerHTML?: string;
55
+ namespace?: string;
56
+ style?: Record<string, string>;
57
+ text?: string;
58
+ },
59
+ ): TWDOMElement;
60
+ /**
61
+ * Iterate through all the own properties of an object or array.
62
+ * Callback is invoked with (element, index, object), if callback returns false, then the each loop will be terminated.
63
+ */
64
+ each<T = object | unknown[]>(object: T, callback: TWEachCallback<T>): void;
65
+ /** Display an error and exit */
66
+ error(error: Event | string): void;
67
+ /** Run code globally with specified context variables in scope */
68
+ evalGlobal(code: string, context: IModuleSandbox, filename: string): unknown;
69
+ /** Run code in a sandbox with only the specified context variables in scope */
70
+ evalSandboxed(code: string, context: IModuleSandbox, filename: string): unknown;
71
+ /** Extend an object with the properties from a list of source objects */
72
+ extend(object: object, ...sourceObjectList: object[]): object;
73
+ /** Given an extension, always access the $tw.config.fileExtensionInfo using a lowercase extension only. */
74
+ getFileExtensionInfo(extension: string): IFileExtensionInfo | null;
75
+ /** 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) */
76
+ getLocationHash(): string;
77
+ /** Given an extension, get the correct encoding for that file. defaults to utf8 */
78
+ getTypeEncoding(extension: string): string;
79
+ /** Check if an object has a property. */
80
+ hop(object: object, property: string): boolean;
81
+ /** Convert "&amp;" to &, "&nbsp;" to nbsp, "&lt;" to <, "&gt;" to > and "&quot;" to " */
82
+ htmlDecode(text: string): string;
83
+ /** Determine if a value is an array. */
84
+ isArray(value: unknown): boolean;
85
+ /** Check if an array is equal by value and by reference. */
86
+ isArrayEqual(array1: unknown[], array2: unknown[]): boolean;
87
+ /** Determine if a value is a date */
88
+ isDate(value: unknown): void;
89
+ /** Pad a string to a given length with "0"s. Length defaults to 2 */
90
+ pad(value: number, length?: number): string;
91
+ /** Parse a date from a UTC YYYYMMDDHHMMSSmmm format string */
92
+ parseDate(value: string | Date): Date;
93
+ /** Parse a block of name:value fields. The `fields` object is used as the basis for the return value */
94
+ parseFields(text: string, fields?: object): object;
95
+ /** Parse a string array from a bracketted list. For example "OneTiddler [[Another Tiddler]] LastOne" */
96
+ parseStringArray(value: string | string[], allowDuplicate?: boolean): string[];
97
+ /** Parse a semantic version string into its constituent parts -- see https://semver.org */
98
+ parseVersion(version: string): {
99
+ build?: string;
100
+ major: number;
101
+ minor: number;
102
+ patch: number;
103
+ prerelease?: string;
104
+ version: string;
105
+ } | null;
106
+ /**
107
+ * Push entries onto an array, removing them first if they already exist in the array
108
+ * * array: array to modify (assumed to be free of duplicates)
109
+ * * value: a single value to push or an array of values to push
110
+ */
111
+ pushTop(array: unknown[], value: unknown): void;
112
+ /**
113
+ * Register file type information
114
+ * @param {string} contentType
115
+ * @param {string} encoding
116
+ * @param {(string | string[])} extension
117
+ * @param {{
118
+ * flags: string[];
119
+ * deserializerType: string;
120
+ * }} [options] Options includes:
121
+ * * flags:"image" for image types
122
+ * * deserializerType: defaults to type if not specified
123
+ */
124
+ registerFileType(
125
+ contentType: string,
126
+ encoding: string,
127
+ extension: string | string[],
128
+ options?: {
129
+ deserializerType?: string;
130
+ flags?: string[];
131
+ },
132
+ ): void;
133
+ /**
134
+ * Resolves a source filepath delimited with `/` relative to a specified absolute root filepath.
135
+ * In relative paths, the special folder name `..` refers to immediate parent directory, and the
136
+ * name `.` refers to the current directory
137
+ */
138
+ resolvePath(sourcepath: string, rootpath: string): string;
139
+ /** Convert a date into UTC YYYYMMDDHHMMSSmmm format */
140
+ stringifyDate(value: Date): string;
141
+ /** Stringify an array of tiddler titles into a list string */
142
+ stringifyList(value: string[]): string;
143
+ }
144
+ }
package/src/widget.d.ts CHANGED
@@ -1,13 +1,12 @@
1
- declare class variablesConstructor {
2
-
3
- }
1
+ // eslint-disable-next-line @typescript-eslint/no-extraneous-class
2
+ declare class variablesConstructor {}
4
3
 
5
4
  export class Widget {
6
- constructor(parseTreeNode: any, options: any);
7
- initialize: (parseTreeNode: any, options: any) => void;
8
- parseTreeNode: any;
9
- wiki: any;
5
+ constructor(parseTreeNode: unknown, options: unknown);
6
+ initialize: (parseTreeNode: unknown, options: unknown) => void;
7
+ parseTreeNode: unknown;
8
+ wiki: unknown;
10
9
  parentWidget?: Widget;
11
10
  variablesConstructor: variablesConstructor;
12
- variables: any;
11
+ variables: unknown;
13
12
  }