tw5-typed 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Tiddly Gittly
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # TW5-Typed
2
+ TypeScript type definitions for TiddlyWiki5.
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "description": "Types for tiddlywiki",
3
+ "license": "MIT",
4
+ "name": "tw5-typed",
5
+ "version": "0.0.1",
6
+ "url": "https://github.com/tiddly-gittly/tw5-typed",
7
+ "types": "src/index.d.ts",
8
+ "author": "",
9
+ "scripts": {
10
+ },
11
+ "devDependencies": {
12
+ "typescript": "^4.5.5"
13
+ },
14
+ "dependencies": {
15
+ }
16
+ }
@@ -0,0 +1,40 @@
1
+ export type SourceIterator = (tiddler: Object, title: string) => void;
2
+ export interface ISearchOptions {
3
+ /** an iterator function for the source tiddlers, called source(iterator), where iterator is called as iterator(tiddler,title) */
4
+ source?: (iter: SourceIterator) => void;
5
+ /** An array of tiddler titles to exclude from the search */
6
+ exclude?: string[];
7
+ /** If true returns tiddlers that do not contain the specified string */
8
+ invert?: boolean;
9
+ /** If true forces a case sensitive search */
10
+ caseSensitive?: boolean;
11
+ /** If specified, restricts the search to the specified field, or an array of field names */
12
+ field?: string | string[];
13
+ /** If true, forces all but regexp searches to be anchored to the start of text */
14
+ anchored?: boolean;
15
+ /** If true, the field options are inverted to specify the fields that are not to be searched */
16
+ excludeField?: boolean;
17
+ /** searches for literal string */
18
+ literal?: boolean;
19
+ /** same as literal except runs of whitespace are treated as a single space */
20
+ whitespace?: boolean;
21
+ /** (default) treats search string as a list of tokens, and matches if all tokens are found, regardless of adjacency or ordering */
22
+ words?: boolean;
23
+ }
24
+
25
+ export interface IFilterOperatorParamOperator {
26
+ /** the name of the filter operator specified in the WikiText; */
27
+ operator: string;
28
+ /** the operand for the filter step (as a string; if the filter specified it in angle brackets or braces, the text reference or letiable name will have already been resolved); */
29
+ operand: string;
30
+ /** (optional) a string containing a single exclamation mark if the filter operator is to be negated; */
31
+ prefix?: string;
32
+ /** (optional) a string containing an additional filter argument (typically a tiddler field name) following the filter name (separated by a colon in the filter syntax); */
33
+ suffix?: string;
34
+ /** multiple suffix
35
+ * for example, in `search:<field list>:<flag list>[<operand>]`, you will get `<field list>` as suffixes[0], and `<flag list>` as suffixes[1]
36
+ */
37
+ suffixes?: string[][];
38
+ /** (optional, deprecated) used instead of `operand` if the filter operand is a regexp. */
39
+ regexp?: string;
40
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { I$TW } from './tw';
2
+ import './filter-operator';
3
+
4
+ declare module 'tiddlywiki' {
5
+ export * from './tw';
6
+ export * from './filter-operator';
7
+ }
8
+
9
+ // this only work when there is no import statement...
10
+ // declare module '@tiddlygit/tiddlywiki' {
11
+ // export * from 'tiddlywiki';
12
+ // }
13
+
14
+ declare global {
15
+ var $tw: I$TW;
16
+ }
package/src/tw.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ export interface ITiddler {
2
+ cache: ITiddlerCache;
3
+ fields: ITiddlerFields;
4
+ }
5
+
6
+ export interface ITiddlerFields {
7
+ created: string;
8
+ list: string[];
9
+ modified: string;
10
+ tags: string[];
11
+ text: string;
12
+ title: string;
13
+ type: string;
14
+ }
15
+
16
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
17
+ export interface ITiddlerCache {}
18
+
19
+ /**
20
+ * filepath: '/Users/linonetwo/xxxx/wiki/Meme-of-LinOnetwo/tiddlers/tiddlerTitle.tid',
21
+ * hasMetaFile: false
22
+ * tiddlerTitle: string,
23
+ * type: 'application/x-tiddler',
24
+ */
25
+ export interface IBootFilesIndexItem {
26
+ filepath: string;
27
+ hasMetaFile: boolean;
28
+ tiddlerTitle: string;
29
+ type: string;
30
+ }
31
+ /**
32
+ * Record<tiddlerTitle, IBootFilesIndexItem>
33
+ */
34
+ export type IBootFilesIndex = Partial<Record<string, IBootFilesIndexItem>>;
35
+
36
+ export interface I$TW {
37
+ boot: { argv: string[]; files: IBootFilesIndex; startup: (options: { callback?: () => unknown }) => void };
38
+ hooks: { addHook: (hookName: string, callback: (...arguments_: any[]) => unknown) => void };
39
+ wiki: {
40
+ getTiddler: (title: string) => ITiddler | undefined;
41
+ };
42
+ }
43
+ export function TiddlyWiki(): I$TW;