tw5-typed 0.2.22 → 0.2.24

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.22",
5
+ "version": "0.2.24",
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
@@ -31,14 +31,15 @@ declare module 'tiddlywiki' {
31
31
  boot: IBoot;
32
32
  crypto: Crypto;
33
33
  utils: IUtils;
34
+ config: IConfig;
34
35
  version: string;
35
36
  safeMode: boolean;
36
- config: IConfig;
37
+ modules: IModules;
37
38
  rootWidget: Widget;
38
39
  notifier: Notifier;
39
40
  language: ILanguage;
40
- modules: IModules;
41
41
  locationHash: string;
42
+ fakeDocument: IFakeDocument;
42
43
  passwordPrompt: PasswordPrompt;
43
44
  packageInfo: Record<string, unknown>;
44
45
 
@@ -1,6 +1,6 @@
1
1
  declare const addClass: (element: Element, className: string) => void;
2
2
  declare const addEventListeners: (
3
- domNode: Node,
3
+ domNode: Element,
4
4
  events: {
5
5
  handlerFunction?: (event: MouseEvent) => void;
6
6
  handlerMethod?: string;
@@ -0,0 +1,27 @@
1
+ declare module 'tiddlywiki' {
2
+ export class TW_Element extends HTMLElement {
3
+ _style: Record<string, unknown>;
4
+ appendChild: <T extends TW_Element | TW_TextNode | Node>(node: T) => T;
5
+ isRaw: boolean;
6
+ isTiddlyWikiFakeDom: boolean;
7
+ namespaceURI: string;
8
+ tag: string;
9
+ }
10
+
11
+ export class TW_TextNode extends Node {
12
+ textContent: string;
13
+ }
14
+
15
+ export interface IFakeDocument {
16
+ compatMode: string;
17
+ createElement: (tag: string) => TW_Element;
18
+ createElementNS: (namespace: string, tag: string) => TW_Element;
19
+ createTextNode: (text: string) => TW_TextNode;
20
+ isTiddlyWikiFakeDom: boolean;
21
+ setSequenceNumber: (value: any) => void;
22
+ }
23
+ }
24
+
25
+ declare module '$:/core/modules/utils/fakedom.js' {
26
+ export type { TW_Element, TW_TextNode, IFakeDocument } from 'tiddlywiki';
27
+ }
@@ -1,3 +1,4 @@
1
1
  /// <reference path="dom.d.ts" />
2
2
  /// <reference path="utils.d.ts" />
3
- /// <reference path="filesystem.d.ts" />
3
+ /// <reference path="fakedom.d.ts" />
4
+ /// <reference path="filesystem.d.ts" />
@@ -77,9 +77,9 @@ declare module 'tiddlywiki' {
77
77
 
78
78
  attributes: Record<string, string>;
79
79
 
80
- domNodes: Node[];
80
+ domNodes: Element[];
81
81
 
82
- parentDomNode: Node;
82
+ parentDomNode: Element;
83
83
 
84
84
  eventListeners: Record<string, Function>;
85
85
 
@@ -128,7 +128,7 @@ declare module 'tiddlywiki' {
128
128
  * 生命周期方法: 将这个微件渲染到DOM中;
129
129
  * 只会在首次渲染、销毁后重新渲染时自动调用,或者通过 refreshSelf 等方法主动调用
130
130
  */
131
- render(parent: Node, nextSibling: Node | null): void;
131
+ render(parent: Element, nextSibling: Element | null): void;
132
132
 
133
133
  /**
134
134
  * @en
@@ -304,7 +304,8 @@ declare module 'tiddlywiki' {
304
304
  * @return {*} {string}
305
305
  * @memberof Widget
306
306
  */
307
- getAttribute(name: string, fallbackText?: string): string;
307
+ getAttribute(name: string): string | undefined;
308
+ getAttribute(name: string, fallbackText: string): string;
308
309
 
309
310
  /**
310
311
  * @en
@@ -323,7 +324,7 @@ declare module 'tiddlywiki' {
323
324
  * @memberof Widget
324
325
  */
325
326
  assignAttributes(
326
- domNode: Node,
327
+ domNode: Element,
327
328
  options?: { excludeEventAttributes?: boolean },
328
329
  );
329
330
 
@@ -379,7 +380,7 @@ declare module 'tiddlywiki' {
379
380
  /**
380
381
  * Render the children of this widget into the DOM
381
382
  */
382
- renderChildren(parent: Node, nextSibling: Node | null): void;
383
+ renderChildren(parent: Element, nextSibling: Element | null): void;
383
384
 
384
385
  /**
385
386
  * Add a list of event listeners from an array [{type:,handler:},...]
@@ -420,12 +421,12 @@ declare module 'tiddlywiki' {
420
421
  * Find the next sibling in the DOM to this widget. This is done by scanning the widget tree through all next siblings and their descendents that share the same parent DOM node
421
422
  * @param startIndex Refer to this widget by its index within its parents children
422
423
  */
423
- findNextSiblingDomNode(startIndex?: number): Node | null;
424
+ findNextSiblingDomNode(startIndex?: number): Element | null;
424
425
 
425
426
  /**
426
427
  * Find the first DOM node generated by a widget or its children
427
428
  */
428
- findFirstDomNode(): Node | null;
429
+ findFirstDomNode(): Element | null;
429
430
 
430
431
  /**
431
432
  * Remove any DOM nodes created by this widget or its children
@@ -477,28 +478,6 @@ declare module 'tiddlywiki' {
477
478
  ): boolean;
478
479
  }
479
480
 
480
- export interface IFakeDocument {
481
- compatMode: string;
482
- createElement: (tag: string) => TW_Element;
483
- createElementNS: (namespace: string, tag: string) => TW_Element;
484
- createTextNode: (text: string) => TW_TextNode;
485
- isTiddlyWikiFakeDom: boolean;
486
- setSequenceNumber: (value: any) => void;
487
- }
488
- // eslint-disable-next-line @typescript-eslint/naming-convention
489
- export interface TW_Element extends HTMLElement {
490
- _style: Record<string, unknown>;
491
- appendChild: <T extends TW_Element | TW_TextNode | Node>(node: T) => T;
492
- isRaw: boolean;
493
- isTiddlyWikiFakeDom: boolean;
494
- namespaceURI: string;
495
- tag: string;
496
- }
497
- // eslint-disable-next-line @typescript-eslint/naming-convention
498
- export interface TW_TextNode extends Node {
499
- textContent: string;
500
- }
501
-
502
481
  export type ModalWidget = {
503
482
  adjustPageClass: () => void;
504
483
  /**
@@ -56,7 +56,7 @@ declare module 'tiddlywiki' {
56
56
  * @type {CSSStyleDeclaration}
57
57
  * @memberof IDomMakerOptions
58
58
  */
59
- style?: CSSStyleDeclaration;
59
+ style?: Partial<CSSStyleDeclaration>;
60
60
 
61
61
  /**
62
62
  * @en