tw5-typed 0.3.0 → 0.3.2

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.3.0",
5
+ "version": "0.3.2",
6
6
  "url": "https://github.com/tiddly-gittly/tw5-typed",
7
7
  "homepage": "https://github.com/tiddly-gittly/tw5-typed",
8
8
  "bugs": {
@@ -4,10 +4,13 @@ declare module 'tiddlywiki' {
4
4
  export interface IBootFilesIndexItem {
5
5
  filepath: string;
6
6
  hasMetaFile: boolean;
7
- tiddlerTitle: string;
7
+ isEditableFile: boolean;
8
8
  type: string;
9
9
  }
10
10
 
11
+ /**
12
+ * Key is `tiddlerTitle: string;`
13
+ */
11
14
  export type IBootFilesIndex = Record<string, IBootFilesIndexItem>;
12
15
 
13
16
  export interface IStartUpOption {
package/src/core.d.ts CHANGED
@@ -82,12 +82,7 @@ declare module 'tiddlywiki' {
82
82
  loadTiddlersFromFile(
83
83
  filepath: string,
84
84
  defaultFields?: Record<string, unknown>,
85
- ): {
86
- filepath: string;
87
- type: string;
88
- tiddlers: ITiddlerFields[];
89
- hasMetaFile: boolean;
90
- };
85
+ ): ITiddlersInFile;
91
86
  loadMetadataForFile(filepath: string): ITiddlerFields | null;
92
87
  loadTiddlersFromPath(
93
88
  filepath: string,
@@ -37,6 +37,12 @@ declare module 'tiddlywiki' {
37
37
  encoding: string;
38
38
  filepath: string;
39
39
  }
40
+ export interface ITiddlersInFile {
41
+ filepath: string;
42
+ type: string;
43
+ tiddlers: ITiddlerFields[];
44
+ hasMetaFile: boolean;
45
+ }
40
46
  interface IUtils {
41
47
  /**
42
48
  * Generate the filepath for saving a tiddler
@@ -2,3 +2,4 @@
2
2
  /// <reference path="utils.d.ts" />
3
3
  /// <reference path="fakedom.d.ts" />
4
4
  /// <reference path="filesystem.d.ts" />
5
+ /// <reference path="logger.d.ts" />
@@ -0,0 +1,23 @@
1
+ declare module 'tiddlywiki' {
2
+ export class Logger {
3
+ new (): Logger;
4
+ setSaveBuffer(logger: Logger): void;
5
+ /**
6
+ Log a message
7
+ */
8
+ log: typeof console.log;
9
+ clearAlerts(): void;
10
+ getBuffer(): string;
11
+ table: typeof console.table;
12
+ /**
13
+ Alert a message
14
+ */
15
+ alert(...args: any[]): void;
16
+ }
17
+ interface IUtils {
18
+ /**
19
+ * A basic logging implementation
20
+ */
21
+ Logger: Logger;
22
+ }
23
+ }
@@ -30,12 +30,20 @@ declare module 'tiddlywiki' {
30
30
  hasField(): boolean;
31
31
  isPlugin(): boolean;
32
32
  isDraft(): boolean;
33
- getFieldStrings(field: string, defaultValue: string): string;
33
+ /**
34
+ * Stringify the field with the associated tiddler field module (if any)
35
+ */
36
+ getFieldString(field: string, defaultValue?: string): string;
37
+ /**
38
+ Get all the fields as a hashmap of strings. Options:
39
+ exclude: an array of field names to exclude
40
+ */
41
+ getFieldStrings(field: string, defaultValue?: string): string;
34
42
  getFieldDay(field: string): string;
35
43
  /**
36
44
  Get the value of a field as a list
37
45
  */
38
- getFieldList(field: string, defaultValue: string): string[];
46
+ getFieldList(field: string, defaultValue?: string): string[];
39
47
  /**
40
48
  Get all the fields as a name:value block.
41
49
  @param options:
@@ -43,6 +51,6 @@ declare module 'tiddlywiki' {
43
51
  */
44
52
  getFieldStringBlock(options: { exclude?: string[] }): string;
45
53
 
46
- isEqual(tiddler: Tiddler, excludeFields: string[]): boolean;
54
+ isEqual(tiddler: Tiddler, excludeFields?: string[]): boolean;
47
55
  }
48
56
  }
@@ -318,7 +318,7 @@ declare module 'tiddlywiki' {
318
318
  * Parse a string array from a bracketted list. For example `OneTiddler [[Another Tiddler]] LastOne`
319
319
  * @zh
320
320
  * 从一个带括号的列表中解析一个字符串数组。例如,`OneTiddler [[Another Tiddler]] LastOne`
321
- *
321
+ *
322
322
  * @returns {string[]} An array of tiddler titles. null if input is not string or string array. This won't happened in TS.
323
323
  */
324
324
  parseStringArray: (
@@ -457,5 +457,20 @@ declare module 'tiddlywiki' {
457
457
  context: IEvalContent,
458
458
  filename: string,
459
459
  ) => unknown;
460
+ /**
461
+ * Transliterate string to ASCII
462
+ * (Some pairs taken from http://semplicewebsites.com/ removing-accents-javascript)
463
+ */
464
+ transliterationPairs: Record<string, string>;
465
+ /**
466
+ * Remove any of the characters that are illegal in Windows filenames
467
+ * See `$tw.utils.transliterationPairs` for the list of replacements
468
+ */
469
+ transliterate: (str: string) => string;
470
+ /**
471
+ * Remove any of the characters that are illegal in Windows filenames
472
+ * See `$tw.utils.transliterationPairs` for the list of replacements
473
+ */
474
+ transliterateToSafeASCII: (str: string) => string;
460
475
  }
461
476
  }
@@ -276,5 +276,6 @@ declare module 'tiddlywiki' {
276
276
  getTiddlerBacklinks(targetTitle: string): string[];
277
277
  getTiddlerLinks(title: string): string[];
278
278
  getPluginInfo(title: string): { tiddlers: Record<string, ITiddlerFields> };
279
+ getChangeCount(title: string): number;
279
280
  }
280
281
  }