tw5-typed 0.4.2 → 0.4.3

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.4.2",
5
+ "version": "0.4.3",
6
6
  "url": "https://github.com/tiddly-gittly/tw5-typed",
7
7
  "homepage": "https://github.com/tiddly-gittly/tw5-typed",
8
8
  "bugs": {
@@ -18,7 +18,7 @@
18
18
  ],
19
19
  "scripts": {
20
20
  "check": "tsc --noEmit && eslint src/**/*.ts",
21
- "prepublishOnly": "npm run check"
21
+ "prepublishOnly": "tsc --noEmit"
22
22
  },
23
23
  "husky": {
24
24
  "hooks": {
@@ -36,6 +36,8 @@
36
36
  "devDependencies": {
37
37
  "@modern-js/eslint-config": "latest",
38
38
  "@modern-js/tsconfig": "latest",
39
+ "dprint": "^0.45.0",
40
+ "eslint-config-tidgi": "^1.1.5",
39
41
  "husky": "^8.0.2",
40
42
  "lint-staged": "^13.1.0",
41
43
  "rimraf": "^3.0.2",
package/src/core.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  /// <reference path="tiddler/index.d.ts" />
6
6
  /// <reference path="modules/index.d.ts" />
7
7
  /// <reference path="plugins/index.d.ts" />
8
+ /// <reference path="modules/utils/dom/index.d.ts" />
8
9
 
9
10
  declare module 'tiddlywiki' {
10
11
  export interface IPluginInfo {
@@ -48,6 +49,7 @@ declare module 'tiddlywiki' {
48
49
  fakeDocument: IFakeDocument;
49
50
  passwordPrompt: PasswordPrompt;
50
51
  packageInfo: Record<string, unknown>;
52
+ modal: IModal;
51
53
 
52
54
  /**
53
55
  * 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.
@@ -115,7 +115,10 @@ declare module '$:/core/modules/utils/dom.js' {
115
115
  * @param srcWindow The source window to get the scroll position from, defaults to the current window if not specified.
116
116
  * @returns An object with 'x' and 'y' properties representing the horizontal and vertical scroll positions in pixels.
117
117
  */
118
- export function getScrollPosition(srcWindow?: Window): { x: number; y: number; };
118
+ export function getScrollPosition(srcWindow?: Window): {
119
+ x: number;
120
+ y: number;
121
+ };
119
122
 
120
123
  /**
121
124
  * Adjusts the height of a textarea to fit its content, preserving scroll position, and returns the new height.
@@ -123,14 +126,24 @@ declare module '$:/core/modules/utils/dom.js' {
123
126
  * @param minHeight The minimum height to use for the textarea.
124
127
  * @returns The new height of the textarea.
125
128
  */
126
- export function resizeTextAreaToFit(domNode: HTMLTextAreaElement, minHeight: string): number;
129
+ export function resizeTextAreaToFit(
130
+ domNode: HTMLTextAreaElement,
131
+ minHeight: string,
132
+ ): number;
127
133
 
128
134
  /**
129
135
  * Gets the bounding rectangle of an element in absolute page coordinates.
130
136
  * @param element The element to get the bounding rectangle for.
131
137
  * @returns An object representing the bounding rectangle with properties: left, width, right, top, height, bottom.
132
138
  */
133
- export function getBoundingPageRect(element: Element): { left: number; width: number; right: number; top: number; height: number; bottom: number; };
139
+ export function getBoundingPageRect(element: Element): {
140
+ left: number;
141
+ width: number;
142
+ right: number;
143
+ top: number;
144
+ height: number;
145
+ bottom: number;
146
+ };
134
147
 
135
148
  /**
136
149
  * Saves a named password in the browser.
@@ -185,7 +198,10 @@ declare module '$:/core/modules/utils/dom.js' {
185
198
  * @param options Options for copying, including 'doNotNotify' to suppress notifications.
186
199
  * @returns True if the operation succeeded, otherwise false.
187
200
  */
188
- export function copyToClipboard(text: string, options?: { doNotNotify?: boolean }): boolean;
201
+ export function copyToClipboard(
202
+ text: string,
203
+ options?: { doNotNotify?: boolean },
204
+ ): boolean;
189
205
 
190
206
  /**
191
207
  * Gets the path part of the current location.
@@ -200,7 +216,11 @@ declare module '$:/core/modules/utils/dom.js' {
200
216
  * @param event The event object.
201
217
  * @returns An object containing variables derived from the DOM and event.
202
218
  */
203
- export function collectDOMVariables(selectedNode: Element, domNode: Element, event: Event): Record<string, string>;
219
+ export function collectDOMVariables(
220
+ selectedNode: Element,
221
+ domNode: Element,
222
+ event: Event,
223
+ ): Record<string, string>;
204
224
 
205
225
  /**
206
226
  * Safely executes a querySelector, avoiding exceptions on invalid selectors.
@@ -208,7 +228,10 @@ declare module '$:/core/modules/utils/dom.js' {
208
228
  * @param baseElement The base element to start the query from, defaults to document.
209
229
  * @returns The first element matching the selector, or null if none are found or the selector is invalid.
210
230
  */
211
- export function querySelectorSafe(selector: string, baseElement?: Element): Element | null;
231
+ export function querySelectorSafe(
232
+ selector: string,
233
+ baseElement?: Element,
234
+ ): Element | null;
212
235
 
213
236
  /**
214
237
  * Safely executes a querySelectorAll, avoiding exceptions on invalid selectors.
@@ -216,18 +239,8 @@ declare module '$:/core/modules/utils/dom.js' {
216
239
  * @param baseElement The base element to start the query from, defaults to document.
217
240
  * @returns A NodeList of elements matching the selector, or an empty NodeList if none are found or the selector is invalid.
218
241
  */
219
- export function querySelectorAllSafe(selector: string, baseElement?: Element): NodeList;
220
-
221
- /**
222
- * Notifier mechanism
223
- */
224
- export class Notifier {
225
- /**
226
- * Display a notification
227
- * * title: Title of tiddler containing the notification text
228
- * * options: see below
229
- * Options include:
230
- */
231
- display(title: string, options?: Record<string, unknown>): void;
232
- }
242
+ export function querySelectorAllSafe(
243
+ selector: string,
244
+ baseElement?: Element,
245
+ ): NodeList;
233
246
  }
@@ -0,0 +1,3 @@
1
+ /// <reference path="notifier.d.ts" />
2
+ /// <reference path="dom.d.ts" />
3
+ /// <reference path="modal.d.ts" />
@@ -0,0 +1,24 @@
1
+ /// <reference path="../../widgets/index.d.ts" />
2
+
3
+ declare module 'tiddlywiki' {
4
+ export interface IModal {
5
+ adjustPageClass: () => void;
6
+ /**
7
+ *
8
+ * @param title
9
+ * @param options
10
+ * variables: optional hashmap of variables to wrap around the widget
11
+ * downloadLink: normally is used for "Right-click to save changes"
12
+ */
13
+ display: (
14
+ title: string,
15
+ options?: {
16
+ downloadLink?: string;
17
+ event?: IWidgetEvent;
18
+ variables?: unknown;
19
+ },
20
+ ) => void;
21
+
22
+ // new (wiki: Wiki): ModalWidget;
23
+ }
24
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Notifier mechanism
3
+ */
4
+ declare module 'tiddlywiki' {
5
+ export interface Notifier {
6
+ /**
7
+ * Display a notification
8
+ * * title: Title of tiddler containing the notification text
9
+ * * options: see below
10
+ * Options include:
11
+ */
12
+ display(title: string, options?: Record<string, unknown>): void;
13
+ }
14
+ }
@@ -1,4 +1,3 @@
1
- /// <reference path="dom.d.ts" />
2
1
  /// <reference path="utils.d.ts" />
3
2
  /// <reference path="fakedom.d.ts" />
4
3
  /// <reference path="filesystem.d.ts" />
@@ -123,7 +123,7 @@ declare module 'tiddlywiki' {
123
123
  * @en
124
124
  * Initialise widget properties. These steps are pulled out of the constructor so that we can reuse them in subclasses
125
125
  * @zh
126
- * 初始化widget属性。这些步骤被拉出构造函数,以便我们可以在子类中重复使用它们
126
+ * 初始化 widget 属性。这些步骤被拉出构造函数,以便我们可以在子类中重复使用它们
127
127
  */
128
128
  initialise(
129
129
  parseTreeNode: IParseTreeNode,
@@ -134,7 +134,7 @@ declare module 'tiddlywiki' {
134
134
  * @en
135
135
  * Lifecycle method: Render this widget into the DOM
136
136
  * @zh
137
- * 生命周期方法: 将这个微件渲染到DOM中;
137
+ * 生命周期方法:将这个微件渲染到 DOM 中;
138
138
  * 只会在首次渲染、销毁后重新渲染时自动调用,或者通过 refreshSelf 等方法主动调用
139
139
  */
140
140
  render(parent: Element, nextSibling: Element | null): void;
@@ -307,7 +307,7 @@ declare module 'tiddlywiki' {
307
307
  * options include:
308
308
  * * `excludeEventAttributes`: ignores attributes whose name begins with "on"
309
309
  * @zh
310
- * 将微件的计算属性分配给一个domNode, 选项包括:
310
+ * 将微件的计算属性分配给一个 domNode, 选项包括:
311
311
  * * `excludeEventAttributes`: 忽略名称以 "on "开头的属性
312
312
  * 一些特殊的属性:
313
313
  * * `xlink:<xlink-name>`
@@ -476,31 +476,10 @@ declare module 'tiddlywiki' {
476
476
  * If you widget don't have any child widget, you can just write your own tear down logic. If it may have some child widget, don't forget to call original destroy method in the Widget class to destroy children widgets.
477
477
  * @version >=5.3.0
478
478
  * @url https://tiddlywiki.com/dev/#Widget%20%60destroy%60%20method%20examples
479
- */
479
+ */
480
480
  destroy(): void;
481
481
  removeLocalDomNodes(): void;
482
482
  }
483
-
484
- export type ModalWidget = {
485
- adjustPageClass: () => void;
486
- /**
487
- *
488
- * @param title
489
- * @param options
490
- * variables: optional hashmap of variables to wrap around the widget
491
- * downloadLink: normally is used for "Right-click to save changes"
492
- */
493
- display: (
494
- title: string,
495
- options?: {
496
- downloadLink?: string;
497
- event?: IWidgetEvent;
498
- variables?: unknown;
499
- },
500
- ) => void;
501
-
502
- new (wiki: Wiki): ModalWidget;
503
- };
504
483
  }
505
484
 
506
485
  declare module '$:/core/modules/widgets/widget.js' {
@@ -1,6 +1,7 @@
1
1
  /// <reference path="Crypto.d.ts" />
2
2
  /// <reference path="PasswordPrompt.d.ts" />
3
3
 
4
+
4
5
  type OptionalPropertyNames<T> = {
5
6
  [K in keyof T]-?: {} extends { [P in K]: T[K] } ? K : never;
6
7
  }[keyof T];
@@ -253,7 +254,7 @@ declare module 'tiddlywiki' {
253
254
  * @en
254
255
  * Convert a URIComponent encoded string to a string safely
255
256
  * @zh
256
- * 将一个URIComponent编码的字符串安全地转换为一个字符串。
257
+ * 将一个 URIComponent 编码的字符串安全地转换为一个字符串。
257
258
  */
258
259
  decodeURIComponentSafe: (uri: string) => string;
259
260
 
@@ -261,7 +262,7 @@ declare module 'tiddlywiki' {
261
262
  * @en
262
263
  * Convert a URI encoded string to a string safely
263
264
  * @zh
264
- * 将一个URI编码的字符串安全地转换为一个字符串
265
+ * 将一个 URI 编码的字符串安全地转换为一个字符串
265
266
  */
266
267
  decodeURISafe: (uri: string) => string;
267
268
 
@@ -277,7 +278,7 @@ declare module 'tiddlywiki' {
277
278
  * @en
278
279
  * 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)
279
280
  * @zh
280
- * 获取浏览器的location.hash。我们不使用location.hash,因为Firefox的自动解码方式(见http://stackoverflow.com/questions/1703552/encoding-of-window-location-hash)。
281
+ * 获取浏览器的 location.hash。我们不使用 location.hash,因为 Firefox 的自动解码方式(见 http://stackoverflow.com/questions/1703552/encoding-of-window-location-hash)。
281
282
  */
282
283
  getLocationHash: () => string;
283
284
 
@@ -285,7 +286,7 @@ declare module 'tiddlywiki' {
285
286
  * @en
286
287
  * Pad a string to a given length with "0"s. Length defaults to 2
287
288
  * @zh
288
- * 用 "0 "将一个字符串填充到指定的长度。长度默认为2
289
+ * 用 "0 "将一个字符串填充到指定的长度。长度默认为 2
289
290
  */
290
291
  pad: (value: number, length?: number) => string;
291
292
 
@@ -293,7 +294,7 @@ declare module 'tiddlywiki' {
293
294
  * @en
294
295
  * Convert a date into UTC `YYYYMMDDHHMMSSmmm` format
295
296
  * @zh
296
- * 将日期转换成UTC `YYYYMMDDHMMSSmmm` 格式
297
+ * 将日期转换成 UTC `YYYYMMDDHMMSSmmm` 格式
297
298
  */
298
299
  stringifyDate: (value: Date) => string;
299
300
 
@@ -301,7 +302,7 @@ declare module 'tiddlywiki' {
301
302
  * @en
302
303
  * Parse a date from a UTC `YYYYMMDDHHMMSSmmm` format string
303
304
  * @zh
304
- * 从UTC `YYYYMMDDHHMMSSmmm` 格式字符串中解析一个日期
305
+ * 从 UTC `YYYYMMDDHHMMSSmmm` 格式字符串中解析一个日期
305
306
  */
306
307
  parseDate: (value: string | Date) => Date | null;
307
308
 
@@ -309,7 +310,7 @@ declare module 'tiddlywiki' {
309
310
  * @en
310
311
  * Stringify an array of tiddler titles into a list string
311
312
  * @zh
312
- * 将一个数组的tiddler标题字符串化为一个列表字符串
313
+ * 将一个数组的 tiddler 标题字符串化为一个列表字符串
313
314
  */
314
315
  stringifyList: (value: string[]) => string;
315
316
 
@@ -330,7 +331,7 @@ declare module 'tiddlywiki' {
330
331
  * @en
331
332
  * Parse a block of name:value fields. The `fields` object is used as the basis for the return value
332
333
  * @zh
333
- * 解析一个name:value字段的块。`fields`对象被用作返回值的基础。
334
+ * 解析一个 name:value 字段的块。`fields`对象被用作返回值的基础。
334
335
  */
335
336
  parseFields: (text: string, fields?: object) => Record<string, string>;
336
337
 
@@ -376,8 +377,8 @@ declare module 'tiddlywiki' {
376
377
  * 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.
377
378
  * Missing or malformed version strings are parsed as 0.0.0
378
379
  * @zh
379
- * 如果版本字符串A大于版本字符串B,则返回+1;如果它们相同,则返回0;如果B大于A,则返回+1;
380
- * 缺失或畸形的版本字符串被解析为0.0.0
380
+ * 如果版本字符串 A 大于版本字符串 B,则返回 +1;如果它们相同,则返回 0;如果 B 大于 A,则返回 +1;
381
+ * 缺失或畸形的版本字符串被解析为 0.0.0
381
382
  */
382
383
  compareVersions: (
383
384
  versionStringA: string,
@@ -388,7 +389,7 @@ declare module 'tiddlywiki' {
388
389
  * @en
389
390
  * Returns true if the version string A is greater than the version string B. Returns true if the versions are the same
390
391
  * @zh
391
- * 如果版本字符串A大于版本字符串B,返回true;如果版本相同,返回true。
392
+ * 如果版本字符串 A 大于版本字符串 B,返回 true;如果版本相同,返回 true。
392
393
  */
393
394
  checkVersions: (versionStringA: string, versionStringB: string) => boolean;
394
395
 
@@ -430,7 +431,7 @@ declare module 'tiddlywiki' {
430
431
  * @en
431
432
  * Given an extension, get the correct encoding for that file. defaults to utf8
432
433
  * @zh
433
- * 给定一个扩展名,获得该文件的正确编码。 默认为utf8
434
+ * 给定一个扩展名,获得该文件的正确编码。默认为 utf8
434
435
  */
435
436
  getTypeEncoding: (extension: string) => string;
436
437