refactor: use tw5-typed

This commit is contained in:
tiddlygit-test 2022-02-07 00:14:52 +08:00
parent 55075edaa3
commit a1fe6d5072
5 changed files with 275 additions and 156 deletions

380
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -163,6 +163,7 @@
"ts-loader": "9.2.6",
"ts-migrate": "0.1.27",
"ts-node": "10.4.0",
"tw5-typed": "^0.0.6",
"typeface-roboto": "1.1.13",
"typescript": "4.5.5",
"typescript-plugin-styled-components": "2.0.0",

View file

@ -1,7 +1,8 @@
import 'source-map-support/register';
import { expose } from 'threads/worker';
import path from 'path';
import tiddlywiki, { I$TW } from '@tiddlygit/tiddlywiki';
import type { I$TW } from 'tiddlywiki';
import tiddlywiki from '@tiddlygit/tiddlywiki';
import { Observable } from 'rxjs';
import intercept from 'intercept-stdout';
import { Server } from 'http';

45
src/type.d.ts vendored
View file

@ -3,50 +3,9 @@ declare module 'errio' {
export function stringify(error: Error): string;
export function register(error: ErrorConstructor): void;
}
declare module '@tiddlygit/tiddlywiki' {
export interface ITiddler {
cache: ITiddlerCache;
fields: ITiddlerFields;
}
export interface ITiddlerFields {
created: string;
list: string[];
modified: string;
tags: string[];
text: string;
title: string;
type: string;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ITiddlerCache {}
/**
* filepath: '/Users/linonetwo/xxxx/wiki/Meme-of-LinOnetwo/tiddlers/tiddlerTitle.tid',
* hasMetaFile: false
* tiddlerTitle: string,
* type: 'application/x-tiddler',
*/
export interface IBootFilesIndexItem {
filepath: string;
hasMetaFile: boolean;
tiddlerTitle: string;
type: string;
}
/**
* Record<tiddlerTitle, IBootFilesIndexItem>
*/
export type IBootFilesIndex = Partial<Record<string, IBootFilesIndexItem>>;
export interface I$TW {
boot: { argv: string[]; files: IBootFilesIndex; startup: (options: { callback?: () => unknown }) => void };
hooks: { addHook: (hookName: string, callback: (...arguments_: any[]) => unknown) => void };
wiki: {
getTiddler: (title: string) => ITiddler | undefined;
};
}
export function TiddlyWiki(): I$TW;
export * from 'tiddlywiki';
}
declare module 'threads-plugin' {

View file

@ -55,7 +55,7 @@
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
"types": ["reflect-metadata"] /* Type declaration files to be included in compilation. */,
"types": ["reflect-metadata", "tw5-typed"] /* Type declaration files to be included in compilation. */,
"allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
"resolveJsonModule": true,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,