Skip to content

Commit 93d260b

Browse files
committed
refactor: export things in tw plugin
1 parent fd35187 commit 93d260b

9 files changed

Lines changed: 24 additions & 15 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"tiddlywiki": "5.3.0",
5454
"tslib": "2.6.1",
5555
"tw5-plugin-packer": "0.0.10",
56-
"tw5-typed": "0.3.9",
56+
"tw5-typed": "0.3.10",
5757
"typescript": "5.1.6",
5858
"typesync": "0.11.1",
5959
"zx": "7.2.3"

pnpm-lock.yaml

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hooks/context.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ import { Widget } from 'tiddlywiki';
77
* > it will read the current context value from the closest matching Provider above it in the tree
88
* > https://reactjs.org/docs/context.html#reactcreatecontext
99
* so even multiple context is created in different react widget, the value may not collide, I think...
10-
*
11-
* */
10+
*/
1211
export const ParentWidgetContext = createContext<Widget | undefined>(undefined);

src/hooks/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
export * from './context';
12
export * from './useFilter';
23
export * from './useRenderTiddler';
34
export * from './useWidget';
4-
export * from './context';

src/hooks/useFilter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useState, useMemo } from 'react';
1+
import { useEffect, useMemo, useState } from 'react';
22
import { Widget } from 'tiddlywiki';
33

44
/** Filter result is basically a list of title. You can get tiddler detail using tw API like `$tw.wiki.getTiddler` */

src/hooks/useRenderTiddler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable unicorn/no-null */
12
import { RefObject, useContext, useEffect } from 'react';
23
import { ParentWidgetContext } from './context';
34

@@ -40,5 +41,5 @@ export function useRenderTiddler(tiddlerTitle: string, containerReference: RefOb
4041
}
4142
domNode.textContent = '';
4243
};
43-
}, [tiddlerTitle, containerReference]);
44+
}, [tiddlerTitle, containerReference, parentWidget, options?.skip]);
4445
}

src/index.js.meta

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
creator: LinOnetwo
2+
title: $:/plugins/linonetwo/tw-react/index.js
3+
type: application/javascript
4+
module-type: library

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
2-
* This file exports things that can be imported from npm
3-
* And won't be packaged into the plugin bundle.
2+
* This file exports things that can be imported from $:/plugins/linonetwo/tw-react/index.js
43
*/
54
export * from './hooks';
65
export * from './widget-type';

src/type.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
declare module '$:/plugins/linonetwo/tw-react/widget.js' {
22
import type { widget as Widget } from '$:/core/modules/widgets/widget.js';
33
import type * as ReactType from 'react';
4-
import type * as ReactDomType from 'react-dom';
4+
// import type * as ReactDomType from 'react-dom';
55
import type * as ReactDomClientType from 'react-dom/client';
66

77
export abstract class widget<
88
IProps extends ITWReactProps = ITWReactPropsDefault,
99
> extends Widget implements IReactWidget<IProps> {
10-
root?: ReturnType<ReactDomType['createRoot']> | undefined;
10+
root?: ReturnType<ReactDomClientType['createRoot']> | undefined;
1111
containerElement?: HTMLDivElement | undefined;
1212
getProps?: () => IProps;
1313
/**
@@ -20,3 +20,7 @@ declare module '$:/plugins/linonetwo/tw-react/widget.js' {
2020
| null;
2121
}
2222
}
23+
24+
declare module '$:/plugins/linonetwo/tw-react/index.js' {
25+
export * from 'tw-react';
26+
}

0 commit comments

Comments
 (0)