tw5-typed 0.2.9 → 0.2.11

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.9",
5
+ "version": "0.2.11",
6
6
  "url": "https://github.com/tiddly-gittly/tw5-typed",
7
7
  "homepage": "https://github.com/tiddly-gittly/tw5-typed",
8
8
  "bugs": {
@@ -20,28 +20,28 @@
20
20
  "prepublishOnly": "npx tsc --noEmit"
21
21
  },
22
22
  "devDependencies": {
23
- "@types/node": "^17.0.31",
24
- "@typescript-eslint/eslint-plugin": "5.22.0",
25
- "@typescript-eslint/parser": "5.22.0",
26
- "eslint": "8.15.0",
23
+ "@types/node": "^18.11.9",
24
+ "@typescript-eslint/eslint-plugin": "5.44.0",
25
+ "@typescript-eslint/parser": "5.44.0",
26
+ "eslint": "8.28.0",
27
27
  "eslint-config-prettier": "8.5.0",
28
28
  "eslint-config-standard": "17.0.0",
29
- "eslint-config-standard-with-typescript": "21.0.1",
29
+ "eslint-config-standard-with-typescript": "23.0.0",
30
30
  "eslint-import-resolver-alias": "1.1.2",
31
- "eslint-import-resolver-typescript": "2.7.1",
32
- "eslint-plugin-html": "6.2.0",
31
+ "eslint-import-resolver-typescript": "3.5.2",
32
+ "eslint-plugin-html": "7.1.0",
33
33
  "eslint-plugin-import": "2.26.0",
34
- "eslint-plugin-n": "15.2.0",
34
+ "eslint-plugin-n": "15.5.1",
35
35
  "eslint-plugin-node": "11.1.0",
36
- "eslint-plugin-prettier": "4.0.0",
37
- "eslint-plugin-promise": "6.0.0",
38
- "eslint-plugin-react": "7.29.4",
39
- "eslint-plugin-react-hooks": "4.5.0",
36
+ "eslint-plugin-prettier": "4.2.1",
37
+ "eslint-plugin-promise": "6.1.1",
38
+ "eslint-plugin-react": "7.31.11",
39
+ "eslint-plugin-react-hooks": "4.6.0",
40
40
  "eslint-plugin-security": "1.5.0",
41
41
  "eslint-plugin-security-node": "1.1.1",
42
42
  "eslint-plugin-typescript-sort-keys": "2.1.0",
43
- "eslint-plugin-unicorn": "42.0.0",
44
- "prettier": "2.6.2",
45
- "typescript": "4.6.4"
43
+ "eslint-plugin-unicorn": "45.0.0",
44
+ "prettier": "2.8.0",
45
+ "typescript": "4.9.3"
46
46
  }
47
47
  }
package/src/Wiki.d.ts CHANGED
@@ -95,10 +95,12 @@ declare module 'tiddlywiki' {
95
95
 
96
96
  Alternative, uncached version of getTiddlerDataCached(). The return value can be mutated freely and reused
97
97
  */
98
- getTiddlerData<D extends Record<string, unknown> | undefined>(titleOrTiddler: string, fallbackData?: D): D;
99
- getTiddlerData<D extends Record<string, unknown> | undefined>(titleOrTiddler: Tiddler, fallbackData?: D): D;
98
+ getTiddlerData<D extends Record<any, unknown> | any[] | undefined>(titleOrTiddler: string, fallbackData?: D): D;
99
+ getTiddlerData<D extends Record<any, unknown> | any[] | undefined>(titleOrTiddler: Tiddler, fallbackData?: D): D;
100
100
  /**
101
- Get the content of a tiddler as a JavaScript object. How this is done depends on the type of the tiddler:
101
+ * D is any JSON, like JSON object or JSON array
102
+ *
103
+ * Get the content of a tiddler as a JavaScript object. How this is done depends on the type of the tiddler:
102
104
 
103
105
  application/json: the tiddler JSON is parsed into an object
104
106
  application/x-tiddler-dictionary: the tiddler is parsed as sequence of name:value pairs
@@ -110,8 +112,8 @@ declare module 'tiddlywiki' {
110
112
 
111
113
  Note that the same value is returned for repeated calls for the same tiddler data. The value is frozen to prevent modification; otherwise modifications would be visible to all callers
112
114
  */
113
- getTiddlerDataCached<D extends Record<string, unknown> | undefined>(titleOrTiddler: string, fallbackData?: D): D;
114
- getTiddlerDataCached<D extends Record<string, unknown> | undefined>(titleOrTiddler: Tiddler, fallbackData?: D): D;
115
+ getTiddlerDataCached<D>(titleOrTiddler: string, fallbackData?: D): D;
116
+ getTiddlerDataCached<D>(titleOrTiddler: Tiddler, fallbackData?: D): D;
115
117
  /**
116
118
  * Set tiddler text of any field.
117
119
  *
@@ -196,5 +198,11 @@ declare module 'tiddlywiki' {
196
198
  recursionMarker?: 'yes' | 'no';
197
199
  } & IMakeWidgetOptions,
198
200
  ): Widget;
201
+ /** Test for the existence of a tiddler (excludes shadow tiddlers) */
202
+ tiddlerExists(title: string): boolean;
203
+ /** Determines if a tiddler is a shadow tiddler, regardless of whether it has been overridden by a real tiddler */
204
+ isShadowTiddler(title: string): boolean;
205
+ /** return shadowTiddlers[title].source; */
206
+ getShadowSource(title: string): string | null;
199
207
  }
200
208
  }
package/src/ast.d.ts CHANGED
@@ -12,6 +12,7 @@ declare module 'tiddlywiki' {
12
12
  children?: IParseTreeNode[];
13
13
  end?: number;
14
14
  isBlock?: boolean;
15
+ isMacroDefinition?: boolean;
15
16
  isSelfClosing?: boolean;
16
17
  orderedAttributes?: IParseTreeAttribute[];
17
18
  start?: number;
package/src/utils.d.ts CHANGED
@@ -39,6 +39,10 @@ declare module 'tiddlywiki' {
39
39
  * Missing or malformed version strings are parsed as 0.0.0
40
40
  */
41
41
  compareVersions(versionStringA: string, versionStringB: string): -1 | 0 | 1;
42
+ /*
43
+ Return the number of keys in an object
44
+ */
45
+ count(object: Record<string, any>): number;
42
46
  /** Convert a URIComponent encoded string to a string safely */
43
47
  decodeURIComponentSafe(uri: string): string;
44
48
  /** Convert a URI encoded string to a string safely */
package/src/widget.d.ts CHANGED
@@ -45,6 +45,7 @@ declare module 'tiddlywiki' {
45
45
  initialize(parseTreeNode: IParseTreeNode, options?: unknown): void;
46
46
  parseTreeNode: IParseTreeNode;
47
47
  wiki: ITiddlyWiki;
48
+ document: IFakeDocument;
48
49
  parentWidget?: Widget;
49
50
  /** we can use $tw.rootWidget.widgetClasses.widget to new a widget
50
51
  *
@@ -85,6 +86,8 @@ declare module 'tiddlywiki' {
85
86
  addEventListener(type: string, handler: (event: IWidgetEvent) => void | Promise<void>): void;
86
87
  /**
87
88
  Dispatch an event to a widget. If the widget doesn't handle the event then it is also dispatched to the parent widget
89
+
90
+ Events added via `addEventListener`, like `tm-notify`, can be invoked by this.
88
91
  */
89
92
  dispatchEvent(typeOrEvent: string | Omit<IWidgetEvent, 'widget'>): void;
90
93
  /**
@@ -117,7 +120,7 @@ declare module 'tiddlywiki' {
117
120
  * @param event
118
121
  * @returns handled
119
122
  */
120
- invokeAction: (triggeringWidget: Widget, event: IWidgetEvent) => boolean | undefined;
123
+ invokeAction(triggeringWidget: Widget, event: IWidgetEvent): boolean | undefined;
121
124
 
122
125
  /**
123
126
  * Lifecycle method: Render this widget into the DOM
@@ -185,16 +188,28 @@ declare module 'tiddlywiki' {
185
188
  isTiddlyWikiFakeDom: boolean;
186
189
  setSequenceNumber: (value: any) => void;
187
190
  }
188
- export class TW_Element {
189
- isTiddlyWikiFakeDom: boolean;
190
- tag: string;
191
- attributes: Record<string, unknown>;
192
- isRaw: boolean;
193
- children: Array<TW_Element | TW_TextNode>;
191
+ export interface TW_Element extends HTMLElement {
194
192
  _style: Record<string, unknown>;
193
+ appendChild: <T extends TW_Element | TW_TextNode | Node>(node: T) => T;
194
+ isRaw: boolean;
195
+ isTiddlyWikiFakeDom: boolean;
195
196
  namespaceURI: string;
197
+ tag: string;
196
198
  }
197
- export class TW_TextNode {
199
+ export interface TW_TextNode extends Node {
198
200
  textContent: string;
199
201
  }
202
+
203
+ export interface ModalWidget {
204
+ new (wiki: Wiki): ModalWidget;
205
+ adjustPageClass(): void;
206
+ /**
207
+ *
208
+ * @param title
209
+ * @param options
210
+ * variables: optional hashmap of variables to wrap around the widget
211
+ * downloadLink: normally is used for "Right-click to save changes"
212
+ */
213
+ display(title: string, options?: { downloadLink?: string; event?: IWidgetEvent; variables?: unknown }): void;
214
+ }
200
215
  }