1
0
mirror of https://github.com/laurent22/joplin.git synced 2026-03-15 10:06:37 +02:00

Compare commits

...

1 Commits

Author SHA1 Message Date
Laurent Cozic
bfae770b19 Testing adding type to plugin framework 2020-10-06 19:08:33 +01:00
597 changed files with 8826 additions and 4 deletions

View File

@@ -1 +0,0 @@
declare var joplin:any;

View File

@@ -0,0 +1,5 @@
import Joplin from './types/lib/services/plugins/api/Joplin';
declare const joplin:Joplin;
export default joplin;

View File

@@ -1,3 +1,6 @@
import joplin from '../joplin';
import { ToolbarButtonLocation } from 'lib/services/plugins/ToolbarButtonController';
joplin.plugins.register({
onStart: async function() {
await joplin.settings.registerSection('myCustomSection', {
@@ -34,7 +37,7 @@ joplin.plugins.register({
},
});
await joplin.views.toolbarButtons.create('incValue', 'noteToolbar');
await joplin.views.toolbarButtons.create('checkValue', 'noteToolbar');
await joplin.views.toolbarButtons.create('incValue', ToolbarButtonLocation.NoteToolbar);
await joplin.views.toolbarButtons.create('checkValue', ToolbarButtonLocation.NoteToolbar);
},
});

View File

@@ -4,6 +4,10 @@
"module": "commonjs",
"target": "es2015",
"jsx": "react",
"allowJs": true
"allowJs": true,
"baseUrl": "./types",
"paths": {
"lib/*": ["./lib/*"],
},
}
}

View File

@@ -0,0 +1,8 @@
export default class PluginAssetsLoader {
static instance_: PluginAssetsLoader;
logger_: any;
static instance(): PluginAssetsLoader;
setLogger(logger: any): void;
logger(): any;
importAssets(): Promise<void>;
}

View File

@@ -0,0 +1,27 @@
export interface QueueItemAction {
(): void;
}
export interface QueueItem {
action: QueueItemAction;
context: any;
}
export declare enum IntervalType {
Debounce = 1,
Fixed = 2
}
export default class AsyncActionQueue {
queue_: QueueItem[];
interval_: number;
intervalType_: number;
scheduleProcessingIID_: any;
processing_: boolean;
needProcessing_: boolean;
constructor(interval?: number, intervalType?: IntervalType);
push(action: QueueItemAction, context?: any): void;
get queue(): QueueItem[];
private scheduleProcessing;
private processQueue;
reset(): Promise<unknown>;
processAllNow(): Promise<unknown>;
waitForAllDone(): Promise<unknown>;
}

View File

@@ -0,0 +1,41 @@
import Logger from 'lib/Logger';
export default class BaseApplication {
private logger_;
private dbLogger_;
private eventEmitter_;
private scheduleAutoAddResourcesIID_;
private database_;
protected showStackTraces_: boolean;
protected showPromptString_: boolean;
private currentFolder_;
protected store_: any;
constructor();
destroy(): Promise<void>;
logger(): Logger;
store(): any;
currentFolder(): any;
refreshCurrentFolder(): Promise<void>;
switchCurrentFolder(folder: any): void;
handleStartFlags_(argv: string[], setDefaults?: boolean): Promise<{
matched: any;
argv: string[];
}>;
on(eventName: string, callback: Function): any;
exit(code?: number): Promise<void>;
refreshNotes(state: any, useSelectedNoteId?: boolean, noteHash?: string): Promise<void>;
resourceFetcher_downloadComplete(event: any): void;
decryptionWorker_resourceMetadataButNotBlobDecrypted(): Promise<void>;
reducerActionToString(action: any): string;
hasGui(): boolean;
uiType(): "cli" | "gui";
generalMiddlewareFn(): (store: any) => (next: any) => (action: any) => Promise<any>;
applySettingsSideEffects(action?: any): Promise<void>;
generalMiddleware(store: any, next: any, action: any): Promise<any>;
dispatch(action: any): any;
reducer(state: any, action: any): any;
initRedux(): void;
deinitRedux(): void;
readFlagsFromFile(flagPath: string): Promise<any>;
determineProfileDir(initArgs: any): any;
start(argv: string[]): Promise<any>;
}

View File

@@ -0,0 +1,24 @@
interface JoplinServerApiOptions {
username: Function;
password: Function;
baseUrl: Function;
}
export default class JoplinServerApi {
logger_: any;
options_: JoplinServerApiOptions;
kvStore_: any;
constructor(options: JoplinServerApiOptions);
setLogger(l: any): void;
logger(): any;
setKvStore(v: any): void;
kvStore(): any;
authToken(): string;
baseUrl(): string;
static baseUrlFromNextcloudWebDavUrl(webDavUrl: string): string;
syncTargetId(settings: any): any;
static connectionErrorMessage(error: any): any;
setupSyncTarget(webDavUrl: string): Promise<any>;
requestToCurl_(url: string, options: any): string;
exec(method: string, path?: string, body?: any, headers?: any, options?: any): Promise<any>;
}
export {};

View File

@@ -0,0 +1,51 @@
export declare enum TargetType {
Database = "database",
File = "file",
Console = "console"
}
declare enum LogLevel {
None = 0,
Error = 10,
Warn = 20,
Info = 30,
Debug = 40
}
interface Target {
type: TargetType;
level?: LogLevel;
database?: any;
console?: any;
prefix?: string;
path?: string;
source?: string;
}
declare class Logger {
static LEVEL_NONE: LogLevel;
static LEVEL_ERROR: LogLevel;
static LEVEL_WARN: LogLevel;
static LEVEL_INFO: LogLevel;
static LEVEL_DEBUG: LogLevel;
static fsDriver_: any;
private targets_;
private level_;
private lastDbCleanup_;
static fsDriver(): any;
setLevel(level: LogLevel): void;
level(): LogLevel;
targets(): Target[];
addTarget(type: TargetType, options?: any): void;
objectToString(object: any): string;
objectsToString(...object: any[]): string;
static databaseCreateTableSql(): string;
lastEntries(limit?: number, options?: any): Promise<any>;
targetLevel(target: Target): LogLevel;
log(level: LogLevel, ...object: any[]): void;
error(...object: any[]): void;
warn(...object: any[]): void;
info(...object: any[]): void;
debug(...object: any[]): void;
static levelStringToId(s: string): LogLevel;
static levelIdToString(id: LogLevel): "error" | "warn" | "info" | "none" | "debug";
static levelIds(): LogLevel[];
}
export default Logger;

View File

@@ -0,0 +1,10 @@
export interface SharedData {
title?: string;
text?: string;
resources?: string[];
}
declare const ShareExtension: {
data: () => any;
close: () => any;
};
export default ShareExtension;

View File

@@ -0,0 +1,52 @@
import Logger from './Logger';
import LockHandler from 'lib/services/synchronizer/LockHandler';
import MigrationHandler from 'lib/services/synchronizer/MigrationHandler';
interface RemoteItem {
id: string;
path?: string;
type_?: number;
}
export default class Synchronizer {
private db_;
private api_;
private appType_;
private logger_;
private state_;
private cancelling_;
private maxResourceSize_;
private downloadQueue_;
private clientId_;
private lockHandler_;
private migrationHandler_;
private encryptionService_;
private syncTargetIsLocked_;
testingHooks_: string[];
private onProgress_;
private progressReport_;
dispatch: Function;
constructor(db: any, api: any, appType: string);
state(): string;
db(): any;
api(): any;
clientId(): string;
setLogger(l: Logger): void;
logger(): Logger;
lockHandler(): LockHandler;
migrationHandler(): MigrationHandler;
maxResourceSize(): number;
setEncryptionService(v: any): void;
encryptionService(): any;
waitForSyncToFinish(): Promise<void>;
static reportToLines(report: any): any[];
logSyncOperation(action: any, local?: any, remote?: RemoteItem, message?: string, actionCount?: number): void;
logSyncSummary(report: any): Promise<void>;
cancel(): Promise<unknown>;
cancelling(): boolean;
logLastRequests(): void;
static stateToLabel(state: string): any;
isFullSync(steps: string[]): boolean;
lockErrorStatus_(): Promise<"" | "hasExclusiveLock" | "syncLockGone">;
apiCall(fnName: string, ...args: any[]): Promise<any>;
start(options?: any): Promise<any>;
}
export {};

View File

@@ -0,0 +1,9 @@
declare type rationale = {
title: string;
message: string;
buttonPositive: string;
buttonNegative?: string;
buttonNeutral?: string;
};
declare const _default: (permissions: string, rationale?: rationale) => Promise<boolean>;
export default _default;

View File

@@ -0,0 +1,3 @@
import { CommandRuntime, CommandDeclaration } from '../services/CommandService';
export declare const declaration: CommandDeclaration;
export declare const runtime: () => CommandRuntime;

View File

@@ -0,0 +1,3 @@
import { CommandRuntime, CommandDeclaration } from '../services/CommandService';
export declare const declaration: CommandDeclaration;
export declare const runtime: () => CommandRuntime;

View File

@@ -0,0 +1,3 @@
import { CommandRuntime, CommandDeclaration } from '../services/CommandService';
export declare const declaration: CommandDeclaration;
export declare const runtime: () => CommandRuntime;

View File

@@ -0,0 +1,2 @@
declare const _default: any;
export default _default;

View File

@@ -0,0 +1,21 @@
declare class EventManager {
private emitter_;
private appStatePrevious_;
private appStateWatchedProps_;
private appStateListeners_;
constructor();
reset(): void;
on(eventName: string, callback: Function): any;
emit(eventName: string, object?: any): any;
removeListener(eventName: string, callback: Function): any;
off(eventName: string, callback: Function): any;
filterOn(filterName: string, callback: Function): any;
filterOff(filterName: string, callback: Function): any;
filterEmit(filterName: string, object: any): any;
appStateOn(propName: string, callback: Function): void;
appStateOff(propName: string, callback: Function): void;
stateValue_(state: any, propName: string): any;
appStateEmit(state: any): void;
}
declare const eventManager: EventManager;
export default eventManager;

View File

@@ -0,0 +1 @@
export default function useEffectDebugger(effectHook: any, dependencies: any, dependencyNames?: any[]): void;

View File

@@ -0,0 +1 @@
export default function useImperativeHandleDebugger(ref: any, effectHook: any, dependencies: any, dependencyNames?: any[]): void;

View File

@@ -0,0 +1 @@
export default function usePrevious(value: any, initialValue?: any): any;

View File

@@ -0,0 +1 @@
export default function usePropsDebugger(effectHook: any, props: any): void;

View File

@@ -0,0 +1,5 @@
declare const _default: {
install: (context: any, ruleOptions: any) => (md: any, mdOptions: any) => void;
style: Function;
};
export default _default;

View File

@@ -0,0 +1 @@
export default function (): (md: any) => void;

View File

@@ -0,0 +1,16 @@
declare function style(): ({
name: string;
inline?: undefined;
text?: undefined;
mime?: undefined;
} | {
inline: boolean;
text: string;
mime: string;
name?: undefined;
})[];
declare const _default: {
install: (context: any, ruleOptions: any) => (md: any, mdOptions: any) => void;
style: typeof style;
};
export default _default;

View File

@@ -0,0 +1 @@
export default function (context: any, ruleOptions: any): (md: any, mdOptions: any) => void;

View File

@@ -0,0 +1,18 @@
interface StringToStringMap {
[key: string]: string;
}
declare function defaultLocale(): string;
declare function supportedLocales(): string[];
interface SupportedLocalesToLanguagesOptions {
includeStats?: boolean;
}
declare function supportedLocalesToLanguages(options?: SupportedLocalesToLanguagesOptions): StringToStringMap;
declare function closestSupportedLocale(canonicalName: string, defaultToEnglish?: boolean, locales?: string[]): string;
declare function countryCodeOnly(canonicalName: string): string;
declare function countryDisplayName(canonicalName: string): string;
declare function localeStrings(canonicalName: string): any;
declare function setLocale(canonicalName: string): void;
declare function languageCode(): string;
declare function _(s: string, ...args: any[]): any;
declare function _n(singular: string, plural: string, n: number, ...args: any[]): any;
export { _, _n, supportedLocales, countryDisplayName, localeStrings, setLocale, supportedLocalesToLanguages, defaultLocale, closestSupportedLocale, languageCode, countryCodeOnly };

View File

@@ -0,0 +1,18 @@
declare const BaseModel: any;
export interface Notification {
id: string;
noteId: string;
date: Date;
title: string;
body?: string;
}
export default class Alarm extends BaseModel {
static tableName(): string;
static modelType(): any;
static byNoteId(noteId: string): any;
static deleteExpiredAlarms(): Promise<any>;
static alarmIdsWithoutNotes(): Promise<any>;
static makeNotification(alarm: any, note?: any): Promise<Notification>;
static allDue(): Promise<any>;
}
export {};

View File

@@ -0,0 +1,101 @@
declare const BaseModel: any;
export declare enum SettingItemType {
Int = 1,
String = 2,
Bool = 3,
Array = 4,
Object = 5,
Button = 6
}
interface KeysOptions {
secureOnly?: boolean;
}
export interface SettingItem {
value: any;
type: SettingItemType;
public: boolean;
subType?: string;
key?: string;
isEnum?: boolean;
section?: string;
label?(): string;
description?(appType: string): string;
options?(): any;
appTypes?: string[];
show?(settings: any): boolean;
filter?(value: any): any;
secure?: boolean;
advanced?: boolean;
minimum?: number;
maximum?: number;
step?: number;
onClick?(): void;
unitLabel?(value: any): string;
}
interface SettingItems {
[key: string]: SettingItem;
}
export interface SettingSection {
label: string;
iconName?: string;
description?: string;
name?: string;
}
declare class Setting extends BaseModel {
private static metadata_;
private static keychainService_;
private static keys_;
private static cache_;
private static saveTimeoutId_;
private static customMetadata_;
private static customSections_;
static tableName(): string;
static modelType(): any;
static reset(): Promise<void>;
static keychainService(): any;
static setKeychainService(s: any): void;
static metadata(): SettingItems;
private static validateKey;
static registerSetting(key: string, metadataItem: SettingItem): Promise<void>;
static registerSection(name: string, section: SettingSection): Promise<void>;
static settingMetadata(key: string): SettingItem;
static keyExists(key: string): boolean;
static keyDescription(key: string, appType?: string): string;
static isSecureKey(key: string): boolean;
static keys(publicOnly?: boolean, appType?: string, options?: KeysOptions): string[];
static isPublic(key: string): boolean;
static loadOne(key: string): any;
static load(): any;
static toPlainObject(): any;
static dispatchUpdateAll(): void;
static setConstant(key: string, value: any): void;
static setValue(key: string, value: any): void;
static incValue(key: string, inc: any): void;
static toggle(key: string): void;
static objectValue(settingKey: string, objectKey: string, defaultValue?: any): any;
static setObjectValue(settingKey: string, objectKey: string, value: any): void;
static deleteObjectValue(settingKey: string, objectKey: string): void;
static deleteKeychainPasswords(): Promise<void>;
static valueToString(key: string, value: any): any;
static filterValue(key: string, value: any): any;
static formatValue(key: string, value: any): any;
static value(key: string): any;
static isEnum(key: string): boolean;
static enumOptionValues(key: string): string[];
static enumOptionLabel(key: string, value: any): any;
static enumOptions(key: string): any;
static enumOptionsDoc(key: string, templateString?: string): string;
static isAllowedEnumOption(key: string, value: any): boolean;
static subValues(baseKey: string, settings: any, options?: any): any;
static saveAll(): Promise<void>;
static scheduleSave(): void;
static cancelScheduleSave(): void;
static publicSettings(appType: string): any;
static typeToString(typeId: number): "object" | "string" | "int" | "bool" | "array";
static groupMetadatasBySections(metadatas: SettingItem[]): any[];
static sectionNameToLabel(name: string): any;
static sectionDescription(name: string): any;
static sectionNameToIcon(name: string): string;
static appTypeToLabel(name: string): string;
}
export default Setting;

View File

@@ -0,0 +1,2 @@
export declare function setLogger(v: any): void;
export default function (): Promise<Date>;

View File

@@ -0,0 +1,143 @@
import { State as PluginServiceState } from 'lib/services/plugins/reducer';
interface StateLastSelectedNotesIds {
Folder: any;
Tag: any;
Search: any;
}
interface StateClipperServer {
startState: string;
port: number;
}
interface StateDecryptionWorker {
state: string;
itemIndex: number;
itemCount: number;
decryptedItemCounts: any;
decryptedItemCount: number;
skippedItemCount: number;
}
interface StateResourceFetcher {
toFetchCount: number;
}
export interface State {
notes: any[];
notesSource: string;
notesParentType: string;
folders: any[];
tags: any[];
masterKeys: any[];
notLoadedMasterKeys: any[];
searches: any[];
highlightedWords: string[];
selectedNoteIds: string[];
selectedNoteHash: string;
selectedFolderId: string;
selectedTagId: string;
selectedSearchId: string;
selectedItemType: string;
selectedSmartFilterId: string;
lastSelectedNotesIds: StateLastSelectedNotesIds;
showSideMenu: boolean;
screens: any;
historyCanGoBack: boolean;
syncStarted: boolean;
syncReport: any;
searchQuery: string;
settings: any;
sharedData: any;
appState: string;
hasDisabledSyncItems: boolean;
hasDisabledEncryptionItems: boolean;
customCss: string;
templates: any[];
collapsedFolderIds: string[];
clipperServer: StateClipperServer;
decryptionWorker: StateDecryptionWorker;
selectedNoteTags: any[];
resourceFetcher: StateResourceFetcher;
backwardHistoryNotes: any[];
forwardHistoryNotes: any[];
pluginsLegacy: any;
provisionalNoteIds: string[];
editorNoteStatuses: any;
isInsertingNotes: boolean;
hasEncryptedItems: boolean;
pluginService: PluginServiceState;
}
export declare const defaultState: State;
export declare const MAX_HISTORY = 200;
export declare const stateUtils: any;
declare const reducer: <Base extends {
readonly notes: readonly any[];
readonly notesSource: string;
readonly notesParentType: string;
readonly folders: readonly any[];
readonly tags: readonly any[];
readonly masterKeys: readonly any[];
readonly notLoadedMasterKeys: readonly any[];
readonly searches: readonly any[];
readonly highlightedWords: readonly string[];
readonly selectedNoteIds: readonly string[];
readonly selectedNoteHash: string;
readonly selectedFolderId: string;
readonly selectedTagId: string;
readonly selectedSearchId: string;
readonly selectedItemType: string;
readonly selectedSmartFilterId: string;
readonly lastSelectedNotesIds: {
readonly Folder: any;
readonly Tag: any;
readonly Search: any;
};
readonly showSideMenu: boolean;
readonly screens: any;
readonly historyCanGoBack: boolean;
readonly syncStarted: boolean;
readonly syncReport: any;
readonly searchQuery: string;
readonly settings: any;
readonly sharedData: any;
readonly appState: string;
readonly hasDisabledSyncItems: boolean;
readonly hasDisabledEncryptionItems: boolean;
readonly customCss: string;
readonly templates: readonly any[];
readonly collapsedFolderIds: readonly string[];
readonly clipperServer: {
readonly startState: string;
readonly port: number;
};
readonly decryptionWorker: {
readonly state: string;
readonly itemIndex: number;
readonly itemCount: number;
readonly decryptedItemCounts: any;
readonly decryptedItemCount: number;
readonly skippedItemCount: number;
};
readonly selectedNoteTags: readonly any[];
readonly resourceFetcher: {
readonly toFetchCount: number;
};
readonly backwardHistoryNotes: readonly any[];
readonly forwardHistoryNotes: readonly any[];
readonly pluginsLegacy: any;
readonly provisionalNoteIds: readonly string[];
readonly editorNoteStatuses: any;
readonly isInsertingNotes: boolean;
readonly hasEncryptedItems: boolean;
readonly pluginService: {
readonly plugins: {
readonly [x: string]: {
readonly id: string;
readonly views: {
readonly [x: string]: {
readonly id: string;
readonly type: string;
};
};
};
};
};
}>(base: Base, action: any) => Base;
export default reducer;

View File

@@ -0,0 +1,13 @@
import Logger from 'lib/Logger';
export default class AlarmService {
private static driver_;
private static logger_;
static setDriver(v: any): void;
static driver(): any;
static setLogger(v: Logger): void;
static logger(): Logger;
static setInAppNotificationHandler(v: any): void;
static garbageCollect(): Promise<void>;
static updateNoteNotification(noteOrId: any, isDeleted?: boolean): Promise<void>;
static updateAllNotifications(): Promise<void>;
}

View File

@@ -0,0 +1,9 @@
import { Notification } from 'lib/models/Alarm';
export default class AlarmServiceDriver {
private PushNotification_;
PushNotificationHandler_(): any;
hasPersistentNotifications(): boolean;
notificationIsSet(): void;
clearNotification(id: any): Promise<any>;
scheduleNotification(notification: Notification): Promise<void>;
}

View File

@@ -0,0 +1,13 @@
import { Notification } from 'lib/models/Alarm';
export default class AlarmServiceDriver {
private hasPermission_;
private inAppNotificationHandler_;
constructor();
hasPersistentNotifications(): boolean;
notificationIsSet(): void;
setInAppNotificationHandler(v: any): void;
hasPermissions(perm?: any): Promise<any>;
requestPermissions(): Promise<any>;
clearNotification(id: any): Promise<void>;
scheduleNotification(notification: Notification): Promise<void>;
}

View File

@@ -0,0 +1,17 @@
import { Notification } from 'lib/models/Alarm';
interface Options {
appName: string;
}
export default class AlarmServiceDriverNode {
private appName_;
private notifications_;
private service_;
constructor(options: Options);
setService(s: any): void;
logger(): any;
hasPersistentNotifications(): boolean;
notificationIsSet(id: string): boolean;
clearNotification(id: string): Promise<void>;
scheduleNotification(notification: Notification): Promise<void>;
}
export {};

View File

@@ -0,0 +1,7 @@
import Logger from 'lib/Logger';
export default class BaseService {
static logger_: Logger;
protected instanceLogger_: Logger;
logger(): Logger;
setLogger(v: Logger): void;
}

View File

@@ -0,0 +1,8 @@
export default class BooleanExpression {
private expression_;
private rules_;
constructor(expression: string);
private createContext;
private get rules();
evaluate(context: any): boolean;
}

View File

@@ -0,0 +1,56 @@
import BaseService from 'lib/services/BaseService';
declare type LabelFunction = () => string;
export interface CommandRuntime {
execute(props: any): Promise<any>;
isEnabled?(props: any): boolean;
mapStateToProps?(state: any): any;
title?(props: any): string;
}
export interface CommandDeclaration {
name: string;
label?: LabelFunction | string;
parentLabel?: LabelFunction | string;
iconName?: string;
tinymceIconName?: string;
role?: string;
}
export interface Command {
declaration: CommandDeclaration;
runtime?: CommandRuntime;
}
interface ReduxStore {
dispatch(action: any): void;
getState(): any;
}
interface Utils {
store: ReduxStore;
}
export declare const utils: Utils;
interface CommandByNameOptions {
mustExist?: boolean;
runtimeMustBeRegistered?: boolean;
}
export default class CommandService extends BaseService {
private static instance_;
static instance(): CommandService;
private commands_;
private commandPreviousStates_;
initialize(store: any): void;
on(eventName: string, callback: Function): void;
off(eventName: string, callback: Function): void;
commandByName(name: string, options?: CommandByNameOptions): Command;
registerDeclaration(declaration: CommandDeclaration): void;
registerRuntime(commandName: string, runtime: CommandRuntime): void;
componentRegisterCommands(component: any, commands: any[]): void;
componentUnregisterCommands(commands: any[]): void;
unregisterRuntime(commandName: string): void;
execute(commandName: string, props?: any): Promise<any>;
scheduleExecute(commandName: string, args: any): void;
isEnabled(commandName: string, props: any): boolean;
commandMapStateToProps(commandName: string, state: any): any;
title(commandName: string, props: any): string;
iconName(commandName: string, variant?: string): string;
label(commandName: string, fullLabel?: boolean): string;
exists(commandName: string): boolean;
}
export {};

View File

@@ -0,0 +1,39 @@
import { KeyboardEvent } from 'react';
declare const BaseService: any;
export interface KeymapItem {
accelerator: string;
command: string;
}
export default class KeymapService extends BaseService {
private keymap;
private platform;
private customKeymapPath;
private defaultKeymapItems;
private lastSaveTime_;
constructor();
get lastSaveTime(): number;
initialize(platform?: string): void;
loadCustomKeymap(customKeymapPath: string): Promise<void>;
saveCustomKeymap(customKeymapPath?: string): Promise<void>;
acceleratorExists(command: string): boolean;
private convertToPlatform;
registerCommandAccelerator(commandName: string, accelerator: string): void;
setAccelerator(command: string, accelerator: string): void;
getAccelerator(command: string): string;
getDefaultAccelerator(command: string): string;
getCommandNames(): string[];
getKeymapItems(): KeymapItem[];
getCustomKeymapItems(): KeymapItem[];
getDefaultKeymapItems(): KeymapItem[];
overrideKeymap(customKeymapItems: KeymapItem[]): void;
private validateKeymapItem;
validateKeymap(proposedKeymapItem?: KeymapItem): void;
validateAccelerator(accelerator: string): void;
domToElectronAccelerator(event: KeyboardEvent<HTMLDivElement>): string;
static domToElectronKey(domKey: string): string;
on(eventName: string, callback: Function): void;
off(eventName: string, callback: Function): void;
private static instance_;
static instance(): KeymapService;
}
export {};

View File

@@ -0,0 +1,23 @@
export default class ResourceEditWatcher {
private static instance_;
private logger_;
private dispatch;
private watcher_;
private chokidar_;
private watchedItems_;
private eventEmitter_;
private tempDir_;
constructor();
initialize(logger: any, dispatch: Function): void;
static instance(): ResourceEditWatcher;
private tempDir;
logger(): any;
on(eventName: string, callback: Function): any;
off(eventName: string, callback: Function): any;
private watch;
openAndWatch(resourceId: string): Promise<void>;
stopWatching(resourceId: string): Promise<void>;
stopWatchingAll(): Promise<void>;
private watchedItemByResourceId;
private watchedItemByPath;
}

View File

@@ -0,0 +1,5 @@
export declare const defaultState: {
watchedResources: {};
};
declare const reducer: <Base extends any>(base: Base, action: any) => Base;
export default reducer;

View File

@@ -0,0 +1 @@
export declare function loadKeychainServiceAndSettings(KeychainServiceDriver: any): Promise<void>;

View File

@@ -0,0 +1,17 @@
export default class UndoRedoService {
private pushAsyncQueue;
private undoStates;
private redoStates;
private eventEmitter;
private isUndoing;
constructor();
on(eventName: string, callback: Function): any;
off(eventName: string, callback: Function): any;
push(state: any): void;
schedulePush(state: any): void;
undo(redoState: any): Promise<any>;
redo(undoState: any): Promise<any>;
reset(): Promise<unknown>;
get canUndo(): boolean;
get canRedo(): boolean;
}

View File

@@ -0,0 +1,27 @@
import CommandService from '../CommandService';
interface MenuItem {
id: string;
label: string;
click: Function;
role?: any;
accelerator?: string;
}
interface MenuItems {
[key: string]: MenuItem;
}
interface MenuItemProps {
[key: string]: any;
}
export default class MenuUtils {
private service_;
private menuItemCache_;
private menuItemPropsCache_;
constructor(service: CommandService);
private get service();
private get keymapService();
private commandToMenuItem;
commandToStatefulMenuItem(commandName: string, props?: any): MenuItem;
commandsToMenuItems(commandNames: string[], onClick: Function): MenuItems;
commandsToMenuItemProps(state: any, commandNames: string[]): MenuItemProps;
}
export {};

View File

@@ -0,0 +1,17 @@
import CommandService from '../CommandService';
export interface ToolbarButtonInfo {
name: string;
tooltip: string;
iconName: string;
enabled: boolean;
onClick(): void;
title: string;
}
export default class ToolbarButtonUtils {
private service_;
private toolbarButtonCache_;
constructor(service: CommandService);
private get service();
private commandToToolbarButton;
commandsToToolbarButtons(state: any, commandNames: string[]): ToolbarButtonInfo[];
}

View File

@@ -0,0 +1 @@
export default function propsHaveChanged(previous: any, next: any): boolean;

View File

@@ -0,0 +1,252 @@
export declare const enum ContextKeyExprType {
False = 0,
True = 1,
Defined = 2,
Not = 3,
Equals = 4,
NotEquals = 5,
And = 6,
Regex = 7,
NotRegex = 8,
Or = 9,
In = 10,
NotIn = 11
}
export interface IContextKeyExprMapper {
mapDefined(key: string): ContextKeyExpression;
mapNot(key: string): ContextKeyExpression;
mapEquals(key: string, value: any): ContextKeyExpression;
mapNotEquals(key: string, value: any): ContextKeyExpression;
mapRegex(key: string, regexp: RegExp | null): ContextKeyRegexExpr;
mapIn(key: string, valueKey: string): ContextKeyInExpr;
}
export interface IContextKeyExpression {
cmp(other: ContextKeyExpression): number;
equals(other: ContextKeyExpression): boolean;
evaluate(context: IContext): boolean;
serialize(): string;
keys(): string[];
map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
negate(): ContextKeyExpression;
}
export declare type ContextKeyExpression = (ContextKeyFalseExpr | ContextKeyTrueExpr | ContextKeyDefinedExpr | ContextKeyNotExpr | ContextKeyEqualsExpr | ContextKeyNotEqualsExpr | ContextKeyRegexExpr | ContextKeyNotRegexExpr | ContextKeyAndExpr | ContextKeyOrExpr | ContextKeyInExpr | ContextKeyNotInExpr);
export declare abstract class ContextKeyExpr {
static false(): ContextKeyExpression;
static true(): ContextKeyExpression;
static has(key: string): ContextKeyExpression;
static equals(key: string, value: any): ContextKeyExpression;
static notEquals(key: string, value: any): ContextKeyExpression;
static regex(key: string, value: RegExp): ContextKeyExpression;
static in(key: string, value: string): ContextKeyExpression;
static not(key: string): ContextKeyExpression;
static and(...expr: Array<ContextKeyExpression | undefined | null>): ContextKeyExpression | undefined;
static or(...expr: Array<ContextKeyExpression | undefined | null>): ContextKeyExpression | undefined;
static deserialize(serialized: string | null | undefined, strict?: boolean): ContextKeyExpression | undefined;
private static _deserializeOrExpression;
private static _deserializeAndExpression;
private static _deserializeOne;
private static _deserializeValue;
private static _deserializeRegexValue;
}
export declare class ContextKeyFalseExpr implements IContextKeyExpression {
static INSTANCE: ContextKeyFalseExpr;
readonly type = ContextKeyExprType.False;
protected constructor();
cmp(other: ContextKeyExpression): number;
equals(other: ContextKeyExpression): boolean;
evaluate(_context: IContext): boolean;
serialize(): string;
keys(): string[];
map(_mapFnc: IContextKeyExprMapper): ContextKeyExpression;
negate(): ContextKeyExpression;
}
export declare class ContextKeyTrueExpr implements IContextKeyExpression {
static INSTANCE: ContextKeyTrueExpr;
readonly type = ContextKeyExprType.True;
protected constructor();
cmp(other: ContextKeyExpression): number;
equals(other: ContextKeyExpression): boolean;
evaluate(_context: IContext): boolean;
serialize(): string;
keys(): string[];
map(_mapFnc: IContextKeyExprMapper): ContextKeyExpression;
negate(): ContextKeyExpression;
}
export declare class ContextKeyDefinedExpr implements IContextKeyExpression {
protected readonly key: string;
static create(key: string): ContextKeyExpression;
readonly type = ContextKeyExprType.Defined;
protected constructor(key: string);
cmp(other: ContextKeyExpression): number;
equals(other: ContextKeyExpression): boolean;
evaluate(context: IContext): boolean;
serialize(): string;
keys(): string[];
map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
negate(): ContextKeyExpression;
}
export declare class ContextKeyEqualsExpr implements IContextKeyExpression {
private readonly key;
private readonly value;
static create(key: string, value: any): ContextKeyExpression;
readonly type = ContextKeyExprType.Equals;
private constructor();
cmp(other: ContextKeyExpression): number;
equals(other: ContextKeyExpression): boolean;
evaluate(context: IContext): boolean;
serialize(): string;
keys(): string[];
map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
negate(): ContextKeyExpression;
}
export declare class ContextKeyInExpr implements IContextKeyExpression {
private readonly key;
private readonly valueKey;
static create(key: string, valueKey: string): ContextKeyInExpr;
readonly type = ContextKeyExprType.In;
private constructor();
cmp(other: ContextKeyExpression): number;
equals(other: ContextKeyExpression): boolean;
evaluate(context: IContext): boolean;
serialize(): string;
keys(): string[];
map(mapFnc: IContextKeyExprMapper): ContextKeyInExpr;
negate(): ContextKeyExpression;
}
export declare class ContextKeyNotInExpr implements IContextKeyExpression {
private readonly _actual;
static create(actual: ContextKeyInExpr): ContextKeyNotInExpr;
readonly type = ContextKeyExprType.NotIn;
private constructor();
cmp(other: ContextKeyExpression): number;
equals(other: ContextKeyExpression): boolean;
evaluate(context: IContext): boolean;
serialize(): string;
keys(): string[];
map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
negate(): ContextKeyExpression;
}
export declare class ContextKeyNotEqualsExpr implements IContextKeyExpression {
private readonly key;
private readonly value;
static create(key: string, value: any): ContextKeyExpression;
readonly type = ContextKeyExprType.NotEquals;
private constructor();
cmp(other: ContextKeyExpression): number;
equals(other: ContextKeyExpression): boolean;
evaluate(context: IContext): boolean;
serialize(): string;
keys(): string[];
map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
negate(): ContextKeyExpression;
}
export declare class ContextKeyNotExpr implements IContextKeyExpression {
private readonly key;
static create(key: string): ContextKeyExpression;
readonly type = ContextKeyExprType.Not;
private constructor();
cmp(other: ContextKeyExpression): number;
equals(other: ContextKeyExpression): boolean;
evaluate(context: IContext): boolean;
serialize(): string;
keys(): string[];
map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
negate(): ContextKeyExpression;
}
export declare class ContextKeyRegexExpr implements IContextKeyExpression {
private readonly key;
private readonly regexp;
static create(key: string, regexp: RegExp | null): ContextKeyRegexExpr;
readonly type = ContextKeyExprType.Regex;
private constructor();
cmp(other: ContextKeyExpression): number;
equals(other: ContextKeyExpression): boolean;
evaluate(context: IContext): boolean;
serialize(): string;
keys(): string[];
map(mapFnc: IContextKeyExprMapper): ContextKeyRegexExpr;
negate(): ContextKeyExpression;
}
export declare class ContextKeyNotRegexExpr implements IContextKeyExpression {
private readonly _actual;
static create(actual: ContextKeyRegexExpr): ContextKeyExpression;
readonly type = ContextKeyExprType.NotRegex;
private constructor();
cmp(other: ContextKeyExpression): number;
equals(other: ContextKeyExpression): boolean;
evaluate(context: IContext): boolean;
serialize(): string;
keys(): string[];
map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
negate(): ContextKeyExpression;
}
export declare class ContextKeyAndExpr implements IContextKeyExpression {
readonly expr: ContextKeyExpression[];
static create(_expr: ReadonlyArray<ContextKeyExpression | null | undefined>): ContextKeyExpression | undefined;
readonly type = ContextKeyExprType.And;
private constructor();
cmp(other: ContextKeyExpression): number;
equals(other: ContextKeyExpression): boolean;
evaluate(context: IContext): boolean;
private static _normalizeArr;
serialize(): string;
keys(): string[];
map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
negate(): ContextKeyExpression;
}
export declare class ContextKeyOrExpr implements IContextKeyExpression {
readonly expr: ContextKeyExpression[];
static create(_expr: ReadonlyArray<ContextKeyExpression | null | undefined>): ContextKeyExpression | undefined;
readonly type = ContextKeyExprType.Or;
private constructor();
cmp(other: ContextKeyExpression): number;
equals(other: ContextKeyExpression): boolean;
evaluate(context: IContext): boolean;
private static _normalizeArr;
serialize(): string;
keys(): string[];
map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
negate(): ContextKeyExpression;
}
export declare class RawContextKey<T> extends ContextKeyDefinedExpr {
private readonly _defaultValue;
constructor(key: string, defaultValue: T | undefined);
bindTo(target: IContextKeyService): IContextKey<T>;
getValue(target: IContextKeyService): T | undefined;
toNegated(): ContextKeyExpression;
isEqualTo(value: string): ContextKeyExpression;
notEqualsTo(value: string): ContextKeyExpression;
}
export interface IContext {
getValue<T>(key: string): T | undefined;
}
export interface IContextKey<T> {
set(value: T): void;
reset(): void;
get(): T | undefined;
}
export interface IContextKeyServiceTarget {
parentElement: IContextKeyServiceTarget | null;
setAttribute(attr: string, value: string): void;
removeAttribute(attr: string): void;
hasAttribute(attr: string): boolean;
getAttribute(attr: string): string | null;
}
export interface IReadableSet<T> {
has(value: T): boolean;
}
export interface IContextKeyChangeEvent {
affectsSome(keys: IReadableSet<string>): boolean;
}
export interface IContextKeyService {
readonly _serviceBrand: undefined;
dispose(): void;
bufferChangeEvents(callback: Function): void;
createKey<T>(key: string, defaultValue: T | undefined): IContextKey<T>;
contextMatchesRules(rules: ContextKeyExpression | undefined): boolean;
getContextKeyValue<T>(key: string): T | undefined;
createScoped(target?: IContextKeyServiceTarget): IContextKeyService;
getContext(target: IContextKeyServiceTarget | null): IContext;
updateParent(parentContextKeyService?: IContextKeyService): void;
}
export declare const SET_CONTEXT_COMMAND_ID = "setContext";

View File

@@ -0,0 +1 @@
export default function populateDatabase(db: any): Promise<void>;

View File

@@ -0,0 +1,36 @@
import { ModuleType, FileSystemItem, ImportModuleOutputFormat, Module, ImportOptions, ExportOptions, ImportExportResult } from './types';
export default class InteropService {
private defaultModules_;
private userModules_;
private eventEmitter_;
private static instance_;
static instance(): InteropService;
constructor();
on(eventName: string, callback: Function): any;
off(eventName: string, callback: Function): any;
modules(): Module[];
registerModule(module: Module): void;
findModuleByFormat_(type: ModuleType, format: string, target?: FileSystemItem, outputFormat?: ImportModuleOutputFormat): Module;
private modulePath;
private newModuleFromCustomFactory;
/**
* NOTE TO FUTURE SELF: It might make sense to simply move all the existing
* formatters to the `newModuleFromPath_` approach, so that there's only one way
* to do this mapping. This isn't a priority right now (per the convo in:
* https://github.com/laurent22/joplin/pull/1795#discussion_r322379121) but
* we can do it if it ever becomes necessary.
*/
newModuleByFormat_(type: ModuleType, format: string, outputFormat?: ImportModuleOutputFormat): any;
/**
* The existing `newModuleByFormat_` fn would load by the input format. This
* was fine when there was a 1-1 mapping of input formats to output formats,
* but now that we have 2 possible outputs for an `enex` input, we need to be
* explicit with which importer we want to use.
*
* https://github.com/laurent22/joplin/pull/1795#pullrequestreview-281574417
*/
newModuleFromPath_(type: ModuleType, options: any): any;
moduleByFileExtension_(type: ModuleType, ext: string): Module;
import(options: ImportOptions): Promise<ImportExportResult>;
export(options: ExportOptions): Promise<ImportExportResult>;
}

View File

@@ -0,0 +1,14 @@
export default class InteropService_Exporter_Base {
private context_;
private metadata_;
init(destDir: string, options?: any): Promise<void>;
prepareForProcessingItemType(itemType: number, itemsToExport: any[]): Promise<void>;
processItem(itemType: number, item: any): Promise<void>;
processResource(resource: any, filePath: string): Promise<void>;
close(): Promise<void>;
setMetadata(md: any): void;
metadata(): any;
updateContext(context: any): void;
context(): any;
temporaryDirectory_(createIt: boolean): Promise<string>;
}

View File

@@ -0,0 +1,11 @@
import InteropService_Exporter_Base from './InteropService_Exporter_Base';
import { ExportOptions, Module } from './types';
export default class InteropService_Exporter_Custom extends InteropService_Exporter_Base {
private customContext_;
private module_;
constructor(module: Module);
init(destPath: string, options: ExportOptions): Promise<void>;
processItem(itemType: number, item: any): Promise<void>;
processResource(resource: any, filePath: string): Promise<void>;
close(): Promise<void>;
}

View File

@@ -0,0 +1,10 @@
declare const InteropService_Exporter_Base: any;
export default class InteropService_Exporter_Html extends InteropService_Exporter_Base {
init(path: string, options?: any): Promise<void>;
makeDirPath_(item: any, pathPart?: string): Promise<string>;
processNoteResources_(item: any): Promise<any>;
processItem(_itemType: number, item: any): Promise<void>;
processResource(resource: any, filePath: string): Promise<void>;
close(): Promise<void>;
}
export {};

View File

@@ -0,0 +1,8 @@
declare const InteropService_Exporter_Base: any;
export default class InteropService_Exporter_Jex extends InteropService_Exporter_Base {
init(destPath: string): Promise<void>;
processItem(itemType: number, item: any): Promise<any>;
processResource(resource: any, filePath: string): Promise<any>;
close(): Promise<void>;
}
export {};

View File

@@ -0,0 +1,14 @@
declare const InteropService_Exporter_Base: any;
export default class InteropService_Exporter_Md extends InteropService_Exporter_Base {
init(destDir: string): Promise<void>;
makeDirPath_(item: any, pathPart?: string, findUniqueFilename?: boolean): Promise<string>;
relaceLinkedItemIdsByRelativePaths_(item: any): Promise<string>;
replaceResourceIdsByRelativePaths_(noteBody: string, relativePathToRoot: string): Promise<string>;
replaceNoteIdsByRelativePaths_(noteBody: string, relativePathToRoot: string): Promise<string>;
replaceItemIdsByRelativePaths_(noteBody: string, linkedItemIds: string[], paths: any, fn_createRelativePath: Function): Promise<string>;
prepareForProcessingItemType(itemType: number, itemsToExport: any[]): Promise<void>;
processItem(_itemType: number, item: any): Promise<void>;
processResource(_resource: any, filePath: string): Promise<void>;
close(): Promise<void>;
}
export {};

View File

@@ -0,0 +1,8 @@
declare const InteropService_Exporter_Base: any;
export default class InteropService_Exporter_Raw extends InteropService_Exporter_Base {
init(destDir: string): Promise<void>;
processItem(itemType: number, item: any): Promise<void>;
processResource(_resource: any, filePath: string): Promise<void>;
close(): Promise<void>;
}
export {};

View File

@@ -0,0 +1,11 @@
import { ImportExportResult } from './types';
export default class InteropService_Importer_Base {
private metadata_;
protected sourcePath_: string;
protected options_: any;
setMetadata(md: any): void;
metadata(): any;
init(sourcePath: string, options: any): Promise<void>;
exec(result: ImportExportResult): Promise<void>;
temporaryDirectory_(createIt: boolean): Promise<string>;
}

View File

@@ -0,0 +1,7 @@
import InteropService_Importer_Base from './InteropService_Importer_Base';
import { ImportExportResult, Module } from './types';
export default class InteropService_Importer_Custom extends InteropService_Importer_Base {
private module_;
constructor(handler: Module);
exec(result: ImportExportResult): Promise<void>;
}

View File

@@ -0,0 +1,6 @@
import { ImportExportResult } from './types';
declare const InteropService_Importer_Base: any;
export default class InteropService_Importer_EnexToHtml extends InteropService_Importer_Base {
exec(result: ImportExportResult): Promise<ImportExportResult>;
}
export {};

View File

@@ -0,0 +1,6 @@
import { ImportExportResult } from './types';
declare const InteropService_Importer_Base: any;
export default class InteropService_Importer_EnexToMd extends InteropService_Importer_Base {
exec(result: ImportExportResult): Promise<ImportExportResult>;
}
export {};

View File

@@ -0,0 +1,6 @@
import { ImportExportResult } from './types';
declare const InteropService_Importer_Base: any;
export default class InteropService_Importer_Jex extends InteropService_Importer_Base {
exec(result: ImportExportResult): Promise<ImportExportResult>;
}
export {};

View File

@@ -0,0 +1,13 @@
import { ImportExportResult } from './types';
declare const InteropService_Importer_Base: any;
export default class InteropService_Importer_Md extends InteropService_Importer_Base {
exec(result: ImportExportResult): Promise<ImportExportResult>;
importDirectory(dirPath: string, parentFolderId: string): Promise<void>;
/**
* Parse text for links, attempt to find local file, if found create Joplin resource
* and update link accordingly.
*/
importLocalImages(filePath: string, md: string): Promise<string>;
importFile(filePath: string, parentFolderId: string): Promise<any>;
}
export {};

View File

@@ -0,0 +1,6 @@
import { ImportExportResult } from './types';
declare const InteropService_Importer_Base: any;
export default class InteropService_Importer_Raw extends InteropService_Importer_Base {
exec(result: ImportExportResult): Promise<ImportExportResult>;
}
export {};

View File

@@ -0,0 +1,61 @@
export interface CustomImportContext {
sourcePath: string;
options: ImportOptions;
warnings: string[];
}
export interface CustomExportContext {
destPath: string;
options: ExportOptions;
}
export declare enum ModuleType {
Importer = "importer",
Exporter = "exporter"
}
export declare enum FileSystemItem {
File = "file",
Directory = "directory"
}
export declare enum ImportModuleOutputFormat {
Markdown = "md",
Html = "html"
}
export interface Module {
type: ModuleType;
format: string;
fileExtensions: string[];
description: string;
path?: string;
isNoteArchive?: boolean;
isCustom?: boolean;
sources?: FileSystemItem[];
importerClass?: string;
outputFormat?: ImportModuleOutputFormat;
isDefault?: boolean;
fullLabel?: Function;
onExec?(context: any): Promise<void>;
target?: FileSystemItem;
onInit?(context: any): Promise<void>;
onProcessItem?(context: any, itemType: number, item: any): Promise<void>;
onProcessResource?(context: any, resource: any, filePath: string): Promise<void>;
onClose?(context: any): Promise<void>;
}
export interface ImportOptions {
path?: string;
format?: string;
modulePath?: string;
destinationFolderId?: string;
destinationFolder?: any;
outputFormat?: ImportModuleOutputFormat;
}
export interface ExportOptions {
format?: string;
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
modulePath?: string;
target?: FileSystemItem;
}
export interface ImportExportResult {
warnings: string[];
}
export declare function defaultImportExportModule(type: ModuleType): Module;

View File

@@ -0,0 +1,13 @@
import KeychainServiceDriverBase from './KeychainServiceDriverBase';
declare const BaseService: any;
export default class KeychainService extends BaseService {
private driver;
private static instance_;
static instance(): KeychainService;
initialize(driver: KeychainServiceDriverBase): void;
setPassword(name: string, password: string): Promise<boolean>;
password(name: string): Promise<string>;
deletePassword(name: string): Promise<void>;
detectIfKeychainSupported(): Promise<void>;
}
export {};

View File

@@ -0,0 +1,6 @@
import KeychainServiceDriverBase from './KeychainServiceDriverBase';
export default class KeychainServiceDriver extends KeychainServiceDriverBase {
setPassword(): Promise<boolean>;
password(): Promise<string>;
deletePassword(): Promise<void>;
}

View File

@@ -0,0 +1,6 @@
import KeychainServiceDriverBase from './KeychainServiceDriverBase';
export default class KeychainServiceDriver extends KeychainServiceDriverBase {
setPassword(): Promise<boolean>;
password(): Promise<string>;
deletePassword(): Promise<void>;
}

View File

@@ -0,0 +1,6 @@
import KeychainServiceDriverBase from './KeychainServiceDriverBase';
export default class KeychainServiceDriver extends KeychainServiceDriverBase {
setPassword(name: string, password: string): Promise<boolean>;
password(name: string): Promise<string>;
deletePassword(name: string): Promise<void>;
}

View File

@@ -0,0 +1,11 @@
declare abstract class KeychainServiceDriverBase {
private appId_;
private clientId_;
constructor(appId: string, clientId: string);
get appId(): string;
get clientId(): string;
abstract setPassword(name: string, password: string): Promise<boolean>;
abstract password(name: string): Promise<string>;
abstract deletePassword(name: string): Promise<void>;
}
export default KeychainServiceDriverBase;

View File

@@ -0,0 +1,6 @@
import Plugin from './Plugin';
import BaseService from '../BaseService';
import Global from './api/Global';
export default abstract class BasePluginRunner extends BaseService {
run(plugin: Plugin, sandbox: Global): Promise<void>;
}

View File

@@ -0,0 +1,14 @@
import ViewController from './ViewController';
export declare enum MenuItemLocation {
File = "file",
Edit = "edit",
View = "view",
Note = "note",
Tools = "tools",
Help = "help",
Context = "context"
}
export default class MenuItemController extends ViewController {
constructor(id: string, pluginId: string, store: any, commandName: string, location: MenuItemLocation);
get type(): string;
}

View File

@@ -0,0 +1,20 @@
import { PluginManifest } from './utils/types';
import ViewController from './ViewController';
import { ViewHandle } from './utils/createViewHandle';
export default class Plugin {
private id_;
private baseDir_;
private manifest_;
private scriptText_;
private enabled_;
private logger_;
private viewControllers_;
constructor(id: string, baseDir: string, manifest: PluginManifest, scriptText: string, logger: any);
get id(): string;
get enabled(): boolean;
get manifest(): PluginManifest;
get scriptText(): string;
get baseDir(): string;
addViewController(v: ViewController): void;
viewController(handle: ViewHandle): ViewController;
}

View File

@@ -0,0 +1,21 @@
import Plugin from 'lib/services/plugins/Plugin';
import BasePluginRunner from 'lib/services/plugins/BasePluginRunner';
import BaseService from '../BaseService';
interface Plugins {
[key: string]: Plugin;
}
export default class PluginService extends BaseService {
private static instance_;
static instance(): PluginService;
private store_;
private platformImplementation_;
private plugins_;
private runner_;
initialize(platformImplementation: any, runner: BasePluginRunner, store: any): void;
get plugins(): Plugins;
pluginById(id: string): Plugin;
loadPlugin(path: string): Promise<Plugin>;
loadAndRunPlugins(pluginDirOrPaths: string | string[]): Promise<void>;
runPlugin(plugin: Plugin): Promise<void>;
}
export {};

View File

@@ -0,0 +1,9 @@
import ViewController from './ViewController';
export declare enum ToolbarButtonLocation {
NoteToolbar = "noteToolbar",
EditorToolbar = "editorToolbar"
}
export default class ToolbarButtonController extends ViewController {
constructor(id: string, pluginId: string, store: any, commandName: string, location: ToolbarButtonLocation);
get type(): string;
}

View File

@@ -0,0 +1,14 @@
import { ViewHandle } from './utils/createViewHandle';
export default class ViewController {
private handle_;
private pluginId_;
private store_;
constructor(handle: ViewHandle, pluginId: string, store: any);
protected get storeView(): any;
protected get store(): any;
get pluginId(): string;
get key(): string;
get handle(): ViewHandle;
get type(): string;
emitMessage(event: any): void;
}

View File

@@ -0,0 +1,33 @@
import ViewController from './ViewController';
export interface ButtonSpec {
id: string;
title?: string;
onClick?(): void;
}
export declare enum ContainerType {
Panel = "panel",
Dialog = "dialog"
}
export interface Options {
containerType: ContainerType;
}
export default class WebviewController extends ViewController {
private baseDir_;
private messageListener_;
private closeResponse_;
constructor(id: string, pluginId: string, store: any, baseDir: string);
get type(): string;
private setStoreProp;
get html(): string;
set html(html: string);
get containerType(): ContainerType;
set containerType(containerType: ContainerType);
addScript(path: string): Promise<void>;
emitMessage(event: any): void;
onMessage(callback: any): void;
open(): Promise<unknown>;
close(): Promise<void>;
closeWithResponse(result: any): void;
get buttons(): ButtonSpec[];
set buttons(buttons: ButtonSpec[]);
}

View File

@@ -0,0 +1,10 @@
import Plugin from '../Plugin';
import Joplin from './Joplin';
import Logger from 'lib/Logger';
export default class Global {
private joplin_;
constructor(logger: Logger, implementation: any, plugin: Plugin, store: any);
get joplin(): Joplin;
require(filePath: string): any;
get process(): any;
}

View File

@@ -0,0 +1,32 @@
import Plugin from '../Plugin';
import JoplinData from './JoplinData';
import JoplinPlugins from './JoplinPlugins';
import JoplinWorkspace from './JoplinWorkspace';
import JoplinFilters from './JoplinFilters';
import JoplinCommands from './JoplinCommands';
import JoplinViews from './JoplinViews';
import JoplinUtils from './JoplinUtils';
import JoplinInterop from './JoplinInterop';
import JoplinSettings from './JoplinSettings';
import Logger from 'lib/Logger';
export default class Joplin {
private data_;
private plugins_;
private workspace_;
private filters_;
private commands_;
private views_;
private utils_;
private interop_;
private settings_;
constructor(logger: Logger, implementation: any, plugin: Plugin, store: any);
get data(): JoplinData;
get plugins(): JoplinPlugins;
get workspace(): JoplinWorkspace;
get filters(): JoplinFilters;
get commands(): JoplinCommands;
get views(): JoplinViews;
get utils(): JoplinUtils;
get interop(): JoplinInterop;
get settings(): JoplinSettings;
}

View File

@@ -0,0 +1,19 @@
interface Command {
name: string;
label: string;
iconName?: string;
execute(props: any): Promise<any>;
isEnabled?(props: any): boolean;
mapStateToProps?(state: any): any;
}
export default class JoplinCommands {
/**
* <span class="platform-desktop">desktop</span> Executes the given command.
*/
execute(commandName: string, args: any): Promise<void>;
/**
* <span class="platform-desktop">desktop</span> Registers the given command.
*/
register(command: Command): Promise<void>;
}
export {};

View File

@@ -0,0 +1,13 @@
/**
* This module provides access to the Joplin data API: https://joplinapp.org/api/
* This is the main way to retrieve data, such as notes, notebooks, tags, etc.
* or to update them or delete them.
*/
export default class JoplinData {
private api_;
private serializeApiBody;
get(path: string, query?: any): Promise<any>;
post(path: string, query?: any, body?: any, files?: any[]): Promise<any>;
put(path: string, query?: any, body?: any, files?: any[]): Promise<any>;
delete(path: string, query?: any): Promise<any>;
}

View File

@@ -0,0 +1,10 @@
/**
* @ignore
*
* Not sure if it's the best way to hook into the app
* so for now disable filters.
*/
export default class JoplinFilters {
on(name: string, callback: Function): Promise<void>;
off(name: string, callback: Function): Promise<void>;
}

View File

@@ -0,0 +1,26 @@
import { FileSystemItem, ImportModuleOutputFormat } from 'lib/services/interop/types';
interface ExportModule {
format: string;
description: string;
target: FileSystemItem;
isNoteArchive: boolean;
fileExtensions?: string[];
onInit(context: any): Promise<void>;
onProcessItem(context: any, itemType: number, item: any): Promise<void>;
onProcessResource(context: any, resource: any, filePath: string): Promise<void>;
onClose(context: any): Promise<void>;
}
interface ImportModule {
format: string;
description: string;
isNoteArchive: boolean;
sources: FileSystemItem[];
fileExtensions?: string[];
outputFormat?: ImportModuleOutputFormat;
onExec(context: any): Promise<void>;
}
export default class JoplinInterop {
registerExportModule(module: ExportModule): Promise<void>;
registerImportModule(module: ImportModule): Promise<void>;
}
export {};

View File

@@ -0,0 +1,8 @@
import Plugin from '../Plugin';
import Logger from 'lib/Logger';
export default class JoplinPlugins {
private logger;
private plugin;
constructor(logger: Logger, plugin: Plugin);
register(script: any): Promise<void>;
}

View File

@@ -0,0 +1,28 @@
import { SettingItemType, SettingSection } from 'lib/models/Setting';
import Plugin from '../Plugin';
interface SettingItem {
value: any;
type: SettingItemType;
public: boolean;
label: string;
description?: string;
isEnum?: boolean;
section?: string;
options?: any;
appTypes?: string[];
secure?: boolean;
advanced?: boolean;
minimum?: number;
maximum?: number;
step?: number;
}
export default class JoplinSettings {
private plugin_;
constructor(plugin: Plugin);
private namespacedKey;
registerSetting(key: string, settingItem: SettingItem): Promise<void>;
registerSection(name: string, section: SettingSection): Promise<void>;
value(key: string): Promise<any>;
setValue(key: string, value: any): Promise<void>;
}
export {};

View File

@@ -0,0 +1,3 @@
export default class JoplinUtils {
escapeHtml(text: string): string;
}

View File

@@ -0,0 +1,18 @@
import Plugin from '../Plugin';
import JoplinViewsDialogs from './JoplinViewsDialogs';
import JoplinViewsMenuItems from './JoplinViewsMenuItems';
import JoplinViewsToolbarButtons from './JoplinViewsToolbarButtons';
import JoplinViewsPanels from './JoplinViewsPanels';
export default class JoplinViews {
private store;
private plugin;
private dialogs_;
private panels_;
private menuItems_;
private toolbarButtons_;
constructor(plugin: Plugin, store: any);
get dialogs(): JoplinViewsDialogs;
get panels(): JoplinViewsPanels;
get menuItems(): JoplinViewsMenuItems;
get toolbarButtons(): JoplinViewsToolbarButtons;
}

View File

@@ -0,0 +1,13 @@
import Plugin from '../Plugin';
import { ViewHandle } from '../utils/createViewHandle';
import { ButtonSpec } from '../WebviewController';
export default class JoplinViewsDialogs {
private store;
private plugin;
constructor(plugin: Plugin, store: any);
private controller;
create(): Promise<string>;
setHtml(handle: ViewHandle, html: string): Promise<string>;
setButtons(handle: ViewHandle, buttons: ButtonSpec[]): Promise<ButtonSpec[]>;
open(handle: ViewHandle): Promise<unknown>;
}

View File

@@ -0,0 +1,12 @@
import MenuItemController, { MenuItemLocation } from '../MenuItemController';
import Plugin from '../Plugin';
interface CreateMenuItemOptions {
accelerator: string;
}
export default class JoplinViewsMenuItems {
private store;
private plugin;
constructor(plugin: Plugin, store: any);
create(commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<MenuItemController>;
}
export {};

View File

@@ -0,0 +1,12 @@
import Plugin from '../Plugin';
import { ViewHandle } from '../utils/createViewHandle';
export default class JoplinViewsPanels {
private store;
private plugin;
constructor(plugin: Plugin, store: any);
private controller;
create(): Promise<string>;
setHtml(handle: ViewHandle, html: string): Promise<string>;
addScript(handle: ViewHandle, scriptPath: string): Promise<void>;
onMessage(handle: ViewHandle, callback: Function): Promise<void>;
}

View File

@@ -0,0 +1,8 @@
import Plugin from '../Plugin';
import ToolbarButtonController, { ToolbarButtonLocation } from '../ToolbarButtonController';
export default class JoplinViewsToolbarButtons {
private store;
private plugin;
constructor(plugin: Plugin, store: any);
create(commandName: string, location: ToolbarButtonLocation): Promise<ToolbarButtonController>;
}

View File

@@ -0,0 +1,16 @@
export interface EditorCommand {
name: string;
value: any;
}
export default class JoplinWorkspace {
private store;
private implementation_;
constructor(implementation: any, store: any);
onNoteSelectionChange(callback: Function): Promise<void>;
onNoteContentChange(callback: Function): Promise<void>;
onNoteAlarmTrigger(callback: Function): Promise<void>;
onSyncComplete(callback: Function): Promise<void>;
selectedNote(): Promise<any>;
selectedNoteIds(): Promise<any>;
execEditorCommand(command: EditorCommand): Promise<any>;
}

View File

@@ -0,0 +1,30 @@
import { Draft } from 'immer';
export interface ViewInfo {
view: any;
plugin: any;
}
interface PluginViewState {
id: string;
type: string;
}
interface PluginViewStates {
[key: string]: PluginViewState;
}
interface PluginState {
id: string;
views: PluginViewStates;
}
export interface PluginStates {
[key: string]: PluginState;
}
export interface State {
plugins: PluginStates;
}
export declare const stateRootKey = "pluginService";
export declare const defaultState: State;
export declare const utils: {
viewInfosByType: (plugins: PluginStates, type: string) => ViewInfo[];
commandNamesFromViews: (plugins: PluginStates, toolbarType: string) => string[];
};
declare const reducer: (draft: Draft<any>, action: any) => void;
export default reducer;

View File

@@ -0,0 +1,2 @@
export declare type Target = (name: string, args: any[]) => any;
export default function sandboxProxy(target: Target): any;

View File

@@ -0,0 +1,3 @@
import Plugin from '../Plugin';
export declare type ViewHandle = string;
export default function createViewHandle(plugin: Plugin): ViewHandle;

View File

@@ -0,0 +1,4 @@
import Global from '../api/Global';
declare type EventHandler = (callbackId: string, args: any[]) => void;
export default function executeSandboxCall(pluginId: string, sandbox: Global, path: string, args: any[], eventHandler: EventHandler): Promise<any>;
export {};

View File

@@ -0,0 +1,2 @@
import { PluginManifest } from './types';
export default function manifestFromObject(o: any): PluginManifest;

View File

@@ -0,0 +1,4 @@
export interface EventHandlers {
[key: string]: Function;
}
export default function mapEventHandlersToIds(arg: any, eventHandlers: EventHandlers): any;

View File

@@ -0,0 +1,11 @@
export declare enum PluginPermission {
Model = "model"
}
export interface PluginManifest {
manifest_version: number;
name: string;
version: string;
description?: string;
homepage_url?: string;
permissions?: PluginPermission[];
}

View File

@@ -0,0 +1,4 @@
declare const _default: {
externalEditWatcher: () => any;
};
export default _default;

View File

@@ -0,0 +1,18 @@
declare class ApiError extends Error {
private httpCode_;
constructor(message: string, httpCode?: number);
get httpCode(): number;
}
export declare class ErrorMethodNotAllowed extends ApiError {
constructor(message?: string);
}
export declare class ErrorNotFound extends ApiError {
constructor(message?: string);
}
export declare class ErrorForbidden extends ApiError {
constructor(message?: string);
}
export declare class ErrorBadRequest extends ApiError {
constructor(message?: string);
}
export {};

View File

@@ -0,0 +1,9 @@
interface Term {
name: string;
value: string;
negated: boolean;
quoted?: boolean;
wildcard?: boolean;
}
export default function filterParser(searchString: string): Term[];
export {};

View File

@@ -0,0 +1,10 @@
interface Term {
name: string;
value: string;
negated: boolean;
}
export default function queryBuilder(terms: Term[], fuzzy: boolean): {
query: string;
params: string[];
};
export {};

Some files were not shown because too many files have changed in this diff Show More