tw5-typed 0.3.2 → 0.3.4

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.2",
5
+ "version": "0.3.4",
6
6
  "url": "https://github.com/tiddly-gittly/tw5-typed",
7
7
  "homepage": "https://github.com/tiddly-gittly/tw5-typed",
8
8
  "bugs": {
package/src/core.d.ts CHANGED
@@ -27,6 +27,12 @@ declare module 'tiddlywiki' {
27
27
  Wiki: typeof Wiki;
28
28
  Story: typeof Story;
29
29
  Tiddler: typeof Tiddler;
30
+ syncadaptor?: SyncAdaptor;
31
+ /**
32
+ * Presents when we have $tw.syncadaptor
33
+ */
34
+ syncer?: Syncer;
35
+ Syncer: { new(): Syncer };
30
36
 
31
37
  wiki: Wiki;
32
38
  boot: IBoot;
@@ -43,7 +49,6 @@ declare module 'tiddlywiki' {
43
49
  fakeDocument: IFakeDocument;
44
50
  passwordPrompt: PasswordPrompt;
45
51
  packageInfo: Record<string, unknown>;
46
- syncadaptor: SyncAdaptor;
47
52
 
48
53
  /**
49
54
  * 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.
@@ -6,6 +6,7 @@
6
6
  /// <reference path="widgets/index.d.ts" />
7
7
  /// <reference path="parsers/index.d.ts" />
8
8
  /// <reference path="syncer/syncAdaptor.d.ts" />
9
+ /// <reference path="syncer/syncer.d.ts" />
9
10
 
10
11
  declare module 'tiddlywiki' {
11
12
  export interface ITWModuleExports {
@@ -1,5 +1,9 @@
1
1
  declare module 'tiddlywiki' {
2
- export abstract class SyncAdaptor {
2
+ /**
3
+ * SyncAdaptorModules
4
+ * @url https://tiddlywiki.com/dev/#SyncAdaptorModules
5
+ */
6
+ export interface SyncAdaptor {
3
7
  name: string;
4
8
  supportsLazyLoading: boolean;
5
9
  isReady(): boolean;
@@ -8,6 +12,29 @@ declare module 'tiddlywiki' {
8
12
  title: string,
9
13
  callback: (error: null, fileInfo: IFileInfo) => void,
10
14
  ): void;
15
+ /**
16
+ * Retrieves the titles of tiddlers that need to be updated from the server.
17
+
18
+ This method is optional. If an adaptor doesn't implement it then synchronisation will be unidirectional from the TiddlyWiki store to the adaptor, but not the other way.
19
+
20
+ The syncer will use the `getUpdatedTiddlers()` method in preference to the `getSkinnyTiddlers()` method.
21
+
22
+ |!Parameter |!Description |
23
+ |syncer |Reference to the syncer object making the call |
24
+ |callback |Callback function invoked with parameter `err,data` -- see below |
25
+
26
+ The data provided by the callback is as follows:
27
+
28
+ ```
29
+ {
30
+ modifications: [<array of title>],
31
+ deletions: [<array of title>],
32
+ }
33
+ ```
34
+ * @param syncer
35
+ * @param callback
36
+ */
37
+ getUpdatedTiddlers(syncer: Syncer,callback: (error: Error | null | undefined, changes: { modifications: string[]; deletions: string[] }) => void): void;
11
38
  wiki: Wiki;
12
39
  }
13
40
  }
@@ -0,0 +1,9 @@
1
+ declare module 'tiddlywiki' {
2
+ export class Syncer {
3
+ syncadaptor?: SyncAdaptor;
4
+ /**
5
+ Synchronise from the server by reading the skinny tiddler list and queuing up loads for any tiddlers that we don't already have up to date
6
+ */
7
+ syncFromServer(): void;
8
+ }
9
+ }
@@ -18,6 +18,6 @@ declare module 'tiddlywiki' {
18
18
  /**
19
19
  * A basic logging implementation
20
20
  */
21
- Logger: Logger;
21
+ Logger: { new(loggerName: string): Logger};
22
22
  }
23
23
  }
File without changes
@@ -67,7 +67,10 @@ declare module 'tiddlywiki' {
67
67
  */
68
68
  compileFilter(
69
69
  filterString: string,
70
- ): (source?: SourceIterator | string[] | Record<string, unknown>, widget?: Widget) => string[];
70
+ ): (
71
+ source?: SourceIterator | string[] | Record<string, unknown>,
72
+ widget?: Widget,
73
+ ) => string[];
71
74
  /**
72
75
  *
73
76
  * @param filterString
@@ -80,15 +83,15 @@ declare module 'tiddlywiki' {
80
83
  makeTiddlerIterator(titles: string[]): SourceIterator;
81
84
  /**
82
85
  * You can use this with `makeTiddlerIterator`:
83
- *
86
+ *
84
87
  * ```js
85
88
  * $tw.wiki.filterTiddlers(filter, undefined, $tw.wiki.makeTiddlerIterator(['title']))
86
89
  * ```
87
- *
90
+ *
88
91
  * This calls `compileFilter`
89
- * @param filterString
90
- * @param widget
91
- * @param source
92
+ * @param filterString
93
+ * @param widget
94
+ * @param source
92
95
  */
93
96
  filterTiddlers(
94
97
  filterString: string,
@@ -221,7 +224,7 @@ declare module 'tiddlywiki' {
221
224
  outputType: OutputMimeTypes,
222
225
  textType: TextMimeTypes,
223
226
  text: string,
224
- options?: Partial<IMakeWidgetOptions> & IParserOptions,
227
+ options?: Partial<IMakeWidgetOptions> & IParseOptions,
225
228
  ): string;
226
229
  /**
227
230
  Make a widget tree for a parse tree
@@ -271,11 +274,51 @@ declare module 'tiddlywiki' {
271
274
  isShadowTiddler(title: string): boolean;
272
275
  isBinaryTiddler(title: string): boolean;
273
276
  isImageTiddler(title: string): boolean;
277
+ isSystemTiddler(title: string): boolean;
278
+ isTemporaryTiddler(title: string): boolean;
279
+ isVolatileTiddler(title: string): boolean;
280
+ /**
281
+ * Like addTiddler() except it will silently reject any plugin tiddlers that are older than the currently loaded version. Returns true if the tiddler was imported
282
+ */
283
+ importTiddler(title: string): boolean;
274
284
  /** return shadowTiddlers[title].source; */
275
285
  getShadowSource(title: string): string | null;
276
286
  getTiddlerBacklinks(targetTitle: string): string[];
277
287
  getTiddlerLinks(title: string): string[];
278
288
  getPluginInfo(title: string): { tiddlers: Record<string, ITiddlerFields> };
279
289
  getChangeCount(title: string): number;
290
+ getCreationFields(): {
291
+ created: Date;
292
+ creator?: string;
293
+ [x: string]: unknown;
294
+ };
295
+ getModificationFields(): {
296
+ modified: Date;
297
+ modifier?: string;
298
+ [x: string]: unknown;
299
+ };
300
+ /**
301
+ Generate an unused title from the specified base
302
+ options.prefix must be a string
303
+ */
304
+ generateNewTitle(baseTitle: string, options: { prefix?: string }): string;
305
+
306
+ addEventListener(
307
+ type: string,
308
+ handler: (event: unknown) => void | Promise<void>,
309
+ ): void;
310
+ addEventListener(
311
+ type: "change",
312
+ handler: (change: IChangedTiddlers) => void | Promise<void>,
313
+ ): void;
314
+
315
+ dispatchEvent(
316
+ type: string,
317
+ dataOrEvent: unknown,
318
+ ): void;
319
+ dispatchEvent(
320
+ type: "change",
321
+ change: IChangedTiddlers,
322
+ ): void;
280
323
  }
281
324
  }