More TypeScript

This commit is contained in:
Mo Bitar
2020-04-10 08:42:35 -05:00
parent e7651fe92b
commit b5b53fdc43
87 changed files with 256 additions and 2085 deletions

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1,53 +0,0 @@
import { PasswordWizardType } from './types';
import { SNApplication, Challenge, ChallengeOrchestrator, ProtectedAction } from 'snjs';
import { AppState, DesktopManager, LockManager, ArchiveManager, NativeExtManager, StatusManager, ThemeManager, PreferencesManager, KeyboardManager } from './services';
declare type WebServices = {
appState: AppState;
desktopService: DesktopManager;
lockService: LockManager;
archiveService: ArchiveManager;
nativeExtService: NativeExtManager;
statusService: StatusManager;
themeService: ThemeManager;
prefsService: PreferencesManager;
keyboardService: KeyboardManager;
};
export declare class WebApplication extends SNApplication {
private $compile?;
private scope?;
private onDeinit?;
private webServices;
private currentAuthenticationElement?;
constructor($compile: ng.ICompileService, $timeout: ng.ITimeoutService, scope: ng.IScope, onDeinit: () => void);
/** @override */
deinit(): void;
setWebServices(services: WebServices): void;
/** @access public */
getAppState(): AppState;
/** @access public */
getDesktopService(): DesktopManager;
/** @access public */
getLockService(): LockManager;
/** @access public */
getArchiveService(): ArchiveManager;
/** @access public */
getNativeExtService(): NativeExtManager;
/** @access public */
getStatusService(): StatusManager;
/** @access public */
getThemeService(): ThemeManager;
/** @access public */
getPrefsService(): PreferencesManager;
/** @access public */
getKeyboardService(): KeyboardManager;
checkForSecurityUpdate(): Promise<boolean>;
presentPasswordWizard(type: PasswordWizardType): void;
promptForChallenge(challenge: Challenge, orchestrator: ChallengeOrchestrator): void;
performProtocolUpgrade(): Promise<void>;
presentPrivilegesModal(action: ProtectedAction, onSuccess: any, onCancel: any): Promise<void>;
presentPrivilegesManagementModal(): void;
authenticationInProgress(): boolean;
presentPasswordModal(callback: () => void): void;
presentRevisionPreviewModal(uuid: string, content: any): void;
}
export {};

View File

@@ -1,28 +0,0 @@
export class ApplicationManager {
constructor($compile: any, $rootScope: any, $timeout: any);
$compile: any;
$timeout: any;
$rootScope: any;
applications: any[];
changeObservers: any[];
/** @callback */
onApplicationDeinit(application: any): void;
/** @access private */
createDefaultApplication(): void;
activeApplication: WebApplication | null | undefined;
/** @access private */
createNewApplication(): WebApplication;
get application(): WebApplication | null | undefined;
/** @access public */
getApplications(): any[];
/**
* Notifies observer when the active application has changed.
* Any application which is no longer active is destroyed, and
* must be removed from the interface.
* @access public
* @param {function} callback
*/
addApplicationChangeObserver(callback: Function): void;
notifyObserversOfAppChange(): void;
}
import { WebApplication } from "./application";

View File

@@ -1,28 +0,0 @@
export class PureCtrl {
constructor($timeout: any);
$timeout: any;
props: any;
state: any;
$onInit(): void;
deinit(): void;
unsubApp: any;
unsubState: any;
application: any;
$onDestroy(): void;
/** @private */
private resetState;
/** @override */
getInitialState(): {};
setState(state: any): Promise<any>;
stateTimeout: any;
initProps(props: any): void;
addAppStateObserver(): void;
onAppStateEvent(eventName: any, data: any): void;
addAppEventObserver(): void;
onAppEvent(eventName: any): void;
/** @override */
onAppStart(): Promise<void>;
onAppLaunch(): Promise<void>;
onAppKeyChange(): Promise<void>;
onAppSync(): void;
}

View File

@@ -1,47 +0,0 @@
export class ApplicationView {
template: any;
controller: typeof ApplicationViewCtrl;
replace: boolean;
controllerAs: string;
bindToController: {
application: string;
};
}
declare class ApplicationViewCtrl extends PureCtrl {
constructor($compile: any, $location: any, $rootScope: any, $timeout: any);
$location: any;
$rootScope: any;
$compile: any;
platformString: string;
state: {
appClass: string;
};
onDragDrop(event: any): void;
onDragOver(event: any): void;
openModalComponent(component: any): void;
presentPermissionsDialog(dialog: any): void;
lockScreenPuppet: any;
loadApplication(): Promise<void>;
onAppStart(): void;
onAppLaunch(): void;
onUpdateAvailable(): void;
/** @override */
onAppEvent(eventName: any): Promise<void>;
syncStatus: any;
completedInitialSync: boolean | undefined;
/** @override */
onAppStateEvent(eventName: any, data: any): Promise<void>;
notesCollapsed: any;
tagsCollapsed: any;
updateLocalDataStatus(): void;
updateSyncStatus(): void;
showingDownloadStatus: boolean | undefined;
uploadSyncStatus: any;
overrideComponentManagerFunctions(): void;
showInvalidSessionAlert(): void;
lastShownDate: Date | undefined;
addDragDropHandlers(): void;
handleAutoSignInFromParams(): Promise<void>;
}
import { PureCtrl } from "./abstract/pure_ctrl";
export {};

View File

@@ -1,2 +0,0 @@
export const PANEL_NAME_NOTES: "notes";
export const PANEL_NAME_TAGS: "tags";

View File

@@ -1,122 +0,0 @@
export class EditorPanel {
restrict: string;
scope: {
application: string;
};
template: any;
replace: boolean;
controller: typeof EditorCtrl;
controllerAs: string;
bindToController: boolean;
}
declare class EditorCtrl {
constructor($timeout: any);
leftPanelPuppet: {
onReady: () => void;
};
rightPanelPuppet: {
onReady: () => void;
};
/** Used by .pug template */
prefKeyMonospace: string;
prefKeySpellcheck: string;
prefKeyMarginResizers: string;
deinit(): void;
/** @components */
onEditorLoad: (editor: any) => void;
unregisterComponent: any;
$onInit(): void;
/** @override */
getInitialState(): {
componentStack: never[];
editorDebounce: number;
isDesktop: any;
spellcheck: boolean;
mutable: {
tagsString: string;
};
};
onAppLaunch(): void;
/** @override */
onAppStateEvent(eventName: any, data: any): void;
/** @override */
onAppEvent(eventName: any): void;
/**
* Because note.locked accesses note.content.appData,
* we do not want to expose the template to direct access to note.locked,
* otherwise an exception will occur when trying to access note.locked if the note
* is deleted. There is potential for race conditions to occur with setState, where a
* previous setState call may have queued a digest cycle, and the digest cycle triggers
* on a deleted note.
*/
get noteLocked(): any;
streamItems(): void;
handleNoteSelectionChange(note: any, previousNote: any): Promise<void>;
editorForNote(note: any): any;
setMenuState(menu: any, state: any): void;
toggleMenu(menu: any): void;
closeAllMenus({ exclude }?: {
exclude: any;
}): void;
editorMenuOnSelect: (component: any) => void;
hasAvailableExtensions(): boolean;
performFirefoxPinnedTabFix(): void;
saveNote({ bypassDebouncer, updateClientModified, dontUpdatePreviews }: {
bypassDebouncer: any;
updateClientModified: any;
dontUpdatePreviews: any;
}): void;
saveTimeout: any;
showSavingStatus(): void;
showAllChangesSavedStatus(): void;
showErrorStatus(error: any): void;
setStatus(status: any, wait?: boolean): void;
statusTimeout: any;
contentChanged(): void;
onTitleEnter($event: any): void;
onTitleChange(): void;
focusEditor(): void;
lastEditorFocusEventSource: number | null | undefined;
focusTitle(): void;
clickedTextArea(): void;
onNameFocus(): void;
editingName: boolean | undefined;
onContentFocus(): void;
onNameBlur(): void;
selectedMenuItem(hide: any): void;
deleteNote(permanently: any): Promise<void>;
performNoteDeletion(note: any): void;
restoreTrashedNote(): void;
deleteNotePermanantely(): void;
getTrashCount(): any;
emptyTrash(): void;
togglePin(): void;
toggleLockNote(): void;
toggleProtectNote(): void;
toggleNotePreview(): void;
toggleArchiveNote(): void;
reloadTagsString(): void;
addTag(tag: any): void;
removeTag(tag: any): void;
saveTags({ strings }?: {
strings: any;
}): Promise<void>;
onPanelResizeFinish: (width: any, left: any, isMaxWidth: any) => void;
reloadPreferences(): void;
reloadFont(): void;
toggleKey(key: any): Promise<void>;
registerComponentHandler(): void;
reloadComponentStackArray(): void;
reloadComponentContext(): void;
toggleStackComponentForCurrentItem(component: any): void;
disassociateComponentWithCurrentNote(component: any): void;
associateComponentWithCurrentNote(component: any): void;
registerKeyboardShortcuts(): void;
altKeyObserver: any;
trashKeyObserver: any;
deleteKeyObserver: any;
onSystemEditorLoad(): void;
tabObserver: any;
removeTabObserver(): void;
}
export {};

View File

@@ -1,69 +0,0 @@
export class Footer {
restrict: string;
template: any;
controller: typeof FooterCtrl;
replace: boolean;
controllerAs: string;
bindToController: {
application: string;
};
}
declare class FooterCtrl {
constructor($rootScope: any, $timeout: any);
$rootScope: any;
rooms: any[];
themesWithIcons: any[];
showSyncResolution: any;
deinit(): void;
unregisterComponent: any;
rootScopeListener1: any;
rootScopeListener2: any;
closeAccountMenu: () => void;
toggleSyncResolutionMenu: () => void;
$onInit(): void;
arbitraryStatusMessage: any;
getInitialState(): {
hasPasscode: boolean;
};
reloadUpgradeStatus(): void;
onAppLaunch(): void;
user: any;
reloadPasscodeStatus(): Promise<void>;
addRootScopeListeners(): void;
/** @override */
onAppStateEvent(eventName: any, data: any): void;
backupStatus: any;
/** @override */
onAppKeyChange(): Promise<void>;
/** @override */
onAppEvent(eventName: any): void;
showAccountMenu: any;
streamItems(): void;
queueExtReload: boolean | undefined;
registerComponentHandler(): void;
reloadExtendedData(): void;
reloadInProgress: boolean | undefined;
updateOfflineStatus(): void;
offline: any;
openSecurityUpdate(): void;
findErrors(): void;
error: any;
accountMenuPressed(): void;
lockApp(): void;
refreshData(): void;
isRefreshing: boolean | undefined;
syncUpdated(): void;
lastSyncDate: any;
onNewUpdateAvailable(): void;
newUpdateAvailable: boolean | undefined;
clickedNewUpdateAnnouncement(): void;
reloadDockShortcuts(): void;
dockShortcuts: any;
initSvgForShortcut(shortcut: any): void;
selectShortcut(shortcut: any): void;
onRoomDismiss(room: any): void;
closeAllRooms(): void;
selectRoom(room: any): Promise<void>;
clickOutsideAccountMenu(): void;
}
export {};

View File

@@ -1,7 +0,0 @@
export { PureCtrl } from "./abstract/pure_ctrl";
export { EditorPanel } from "./editor";
export { Footer } from "./footer";
export { NotesPanel } from "./notes/notes";
export { TagsPanel } from "./tags";
export { Root } from "./root";
export { ApplicationView } from "./applicationView";

View File

@@ -1,23 +0,0 @@
export class LockScreen {
restrict: string;
template: any;
controller: typeof LockScreenCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
onValue: string;
puppet: string;
};
}
declare class LockScreenCtrl extends PureCtrl {
constructor($timeout: any);
formData: {};
get passcodeInput(): HTMLElement | null;
/** @override */
onAppStateEvent(eventName: any, data: any): Promise<void>;
submitPasscodeForm(): Promise<void>;
forgotPasscode(): void;
beginDeleteData(): void;
}
import { PureCtrl } from "./abstract/pure_ctrl";
export {};

View File

@@ -1,25 +0,0 @@
export function filterAndSortNotes({ notes, selectedTag, showArchived, hidePinned, filterText, sortBy, reverse }: {
notes: any;
selectedTag: any;
showArchived: any;
hidePinned: any;
filterText: any;
sortBy: any;
reverse: any;
}): any[];
export function filterNotes({ notes, selectedTag, showArchived, hidePinned, filterText }: {
notes: any;
selectedTag: any;
showArchived: any;
hidePinned: any;
filterText: any;
}): any;
export function sortNotes({ notes, sortBy, reverse }: {
notes?: any[] | undefined;
sortBy: any;
reverse: any;
}): any[];
export const SORT_KEY_CREATED_AT: "created_at";
export const SORT_KEY_UPDATED_AT: "updated_at";
export const SORT_KEY_CLIENT_UPDATED_AT: "client_updated_at";
export const SORT_KEY_TITLE: "title";

View File

@@ -1,118 +0,0 @@
export class NotesPanel {
template: any;
replace: boolean;
controller: typeof NotesCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
application: string;
};
}
declare class NotesCtrl {
constructor($timeout: any);
$onInit(): void;
panelPuppet: {
onReady: () => void;
} | null | undefined;
onWindowResize(): void;
deinit(): void;
onPanelResize: (newWidth: any, lastLeft: any, isAtMaxWidth: any, isCollapsed: any) => void;
getInitialState(): {
notes: never[];
renderedNotes: never[];
selectedNote: null;
tag: null;
sortBy: null;
showArchived: null;
hidePinned: null;
sortReverse: null;
panelTitle: null;
mutable: {
showMenu: boolean;
};
noteFilter: {
text: string;
};
};
onAppLaunch(): void;
/** @override */
onAppStateEvent(eventName: any, data: any): void;
/** @override */
onAppEvent(eventName: any): Promise<void>;
/**
* @access private
* Access the current state notes without awaiting any potential reloads
* that may be in progress. This is the sync alternative to `async getMostValidNotes`
*/
getPossiblyStaleNotes(): any;
/**
* @access private
* Access the current state notes after waiting for any pending reloads.
* This returns the most up to date notes, but is the asyncronous counterpart
* to `getPossiblyStaleNotes`
*/
getMostValidNotes(): Promise<any>;
/**
* Triggered programatically to create a new placeholder note
* when conditions allow for it. This is as opposed to creating a new note
* as part of user interaction (pressing the + button).
* @access private
*/
createPlaceholderNote(): Promise<void>;
streamNotesAndTags(): void;
selectNote(note: any): Promise<any>;
createNewNote(): Promise<void>;
handleTagChange(tag: any, previousTag: any): Promise<void>;
resetScrollPosition(): void;
removeNoteFromList(note: any): Promise<void>;
reloadNotes(): Promise<void>;
reloadNotesPromise: Promise<void> | undefined;
performPeloadNotes(): Promise<void>;
setShowMenuFalse(): void;
handleNoteSelection(note: any): Promise<void>;
selectedIndex: number | undefined;
reloadPreferences(): void;
paginate(): void;
resetPagination({ keepCurrentIfLarger }?: {
keepCurrentIfLarger: any;
}): void;
pageSize: number | undefined;
notesToDisplay: number | undefined;
reloadPanelTitle(): void;
optionsSubtitle(): string;
loadFlagsForNote(note: any): {
text: string;
class: string;
}[];
displayableNotes(): any;
getFirstNonProtectedNote(): any;
selectFirstNote(): void;
selectNextNote(): void;
selectNextOrCreateNew(): void;
selectPreviousNote(): boolean;
isFiltering(): boolean;
setNoteFilterText(text: any): Promise<void>;
clearFilterText(): Promise<void>;
filterTextChanged(): Promise<void>;
searchSubmitted: boolean | undefined;
onFilterEnter(): void;
selectedMenuItem(): void;
togglePrefKey(key: any): void;
selectedSortByCreated(): void;
selectedSortByUpdated(): void;
selectedSortByTitle(): void;
toggleReverseSort(): void;
setSortBy(type: any): void;
shouldShowTagsForNote(note: any): boolean;
getSearchBar(): HTMLElement | null;
registerKeyboardShortcuts(): void;
/**
* In the browser we're not allowed to override cmd/ctrl + n, so we have to
* use Control modifier as well. These rules don't apply to desktop, but
* probably better to be consistent.
*/
newNoteKeyObserver: any;
nextNoteKeyObserver: any;
searchKeyObserver: any;
}
export {};

View File

@@ -1,15 +0,0 @@
export class Root {
template: any;
controller: typeof RootCtrl;
replace: boolean;
controllerAs: string;
bindToController: boolean;
}
declare class RootCtrl {
constructor($timeout: any, applicationManager: any);
$timeout: any;
applicationManager: any;
reload(): void;
applications: any;
}
export {};

View File

@@ -1,52 +0,0 @@
export class TagsPanel {
restrict: string;
scope: {
application: string;
};
template: any;
replace: boolean;
controller: typeof TagsPanelCtrl;
controllerAs: string;
bindToController: boolean;
}
declare class TagsPanelCtrl {
constructor($timeout: any);
panelPuppet: {
onReady: () => void;
};
deinit(): void;
unregisterComponent: any;
getInitialState(): {
tags: never[];
smartTags: never[];
noteCounts: {};
};
onAppStart(): void;
onAppLaunch(): void;
/** @override */
onAppSync(): void;
/**
* Returns all officially saved tags as reported by the model manager.
* @access private
*/
getMappedTags(): any;
beginStreamingItems(): void;
/** @override */
onAppStateEvent(eventName: any, data: any): void;
/** @override */
onAppEvent(eventName: any): Promise<void>;
reloadNoteCounts(): void;
loadPreferences(): void;
onPanelResize: (newWidth: any, lastLeft: any, isAtMaxWidth: any, isCollapsed: any) => void;
registerComponentHandler(): void;
component: any;
selectTag(tag: any): Promise<void>;
clickedAddNewTag(): Promise<void>;
tagTitleDidChange(tag: any): void;
saveTag($event: any, tag: any): Promise<void>;
editingOriginalName: any;
selectedRenameTag($event: any, tag: any): Promise<void>;
selectedDeleteTag(tag: any): void;
removeTag(tag: any): void;
}
export {};

View File

@@ -1,43 +0,0 @@
export class Database {
locked: boolean;
/** @access public */
deinit(): void;
alertService: any;
db: any;
/** @access public */
setApplication(application: any): void;
/**
* Relinquishes the lock and allows db operations to proceed
* @access public
*/
unlock(): void;
/**
* Opens the database natively, or returns the existing database object if already opened.
* @access public
* @param {function} onNewDatabase - Callback to invoke when a database has been created
* as part of the open process. This can happen on new application sessions, or if the
* browser deleted the database without the user being aware.
*/
openDatabase(onNewDatabase: Function): Promise<any>;
/** @access public */
getAllPayloads(): Promise<any>;
/** @access public */
savePayload(payload: any): Promise<any>;
/** @access public */
savePayloads(payloads: any): Promise<any>;
/** @access private */
putItems(objectStore: any, items: any): Promise<[any, any, any, any, any, any, any, any, any, any]>;
/** @access public */
deletePayload(uuid: any): Promise<any>;
/** @access public */
clearAllPayloads(): Promise<any>;
/** @access private */
showAlert(message: any): void;
/**
* @access private
* @param {object} error - {code, name}
*/
showGenericError(error: object): void;
/** @access private */
displayOfflineAlert(): void;
}

View File

@@ -1,7 +0,0 @@
export function autofocus($timeout: any): {
restrict: string;
scope: {
shouldFocus: string;
};
link: ($scope: any, $element: any) => void;
};

View File

@@ -1,5 +0,0 @@
export function clickOutside($document: any): {
restrict: string;
replace: boolean;
link: ($scope: any, $element: any, attrs: any) => void;
};

View File

@@ -1,8 +0,0 @@
export function delayHide($timeout: any): {
restrict: string;
scope: {
show: string;
delay: string;
};
link: (scope: any, elem: any, attrs: any) => void;
};

View File

@@ -1,4 +0,0 @@
export function elemReady($parse: any): {
restrict: string;
link: ($scope: any, elem: any, attrs: any) => void;
};

View File

@@ -1,7 +0,0 @@
export function fileChange(): {
restrict: string;
scope: {
handler: string;
};
link: (scope: any, element: any) => void;
};

View File

@@ -1,9 +0,0 @@
export { autofocus } from "./autofocus";
export { clickOutside } from "./click-outside";
export { delayHide } from "./delay-hide";
export { elemReady } from "./elemReady";
export { fileChange } from "./file-change";
export { infiniteScroll } from "./infiniteScroll";
export { lowercase } from "./lowercase";
export { selectOnClick } from "./selectOnClick";
export { snEnter } from "./snEnter";

View File

@@ -1,3 +0,0 @@
export function infiniteScroll(): {
link: (scope: any, elem: any, attrs: any) => void;
};

View File

@@ -1,4 +0,0 @@
export function lowercase(): {
require: string;
link: (scope: any, element: any, attrs: any, modelCtrl: any) => void;
};

View File

@@ -1,4 +0,0 @@
export function selectOnClick($window: any): {
restrict: string;
link: (scope: any, element: any, attrs: any) => void;
};

View File

@@ -1 +0,0 @@
export function snEnter(): (scope: any, element: any, attrs: any) => void;

View File

@@ -1,71 +0,0 @@
export class AccountMenu {
restrict: string;
template: any;
controller: typeof AccountMenuCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
closeFunction: string;
application: string;
};
}
declare class AccountMenuCtrl {
constructor($timeout: any, appVersion: any);
appVersion: any;
/** @override */
getInitialState(): {
appVersion: string;
passcodeAutoLockOptions: any;
user: any;
formData: {
mergeLocal: boolean;
ephemeral: boolean;
};
mutable: {};
};
onAppKeyChange(): Promise<void>;
onAppLaunch(): Promise<void>;
refreshedCredentialState(): {
user: any;
canAddPasscode: boolean;
hasPasscode: any;
showPasscodeForm: boolean;
};
$onInit(): void;
syncStatus: any;
close(): void;
loadHost(): Promise<void>;
onHostInputChange(): void;
loadBackupsAvailability(): Promise<void>;
submitMfaForm(): void;
blurAuthFields(): void;
submitAuthForm(): void;
setFormDataState(formData: any): Promise<any>;
login(): Promise<void>;
register(): Promise<void>;
mergeLocalChanged(): void;
openPasswordWizard(): void;
openPrivilegesModal(): Promise<void>;
destroyLocalData(): void;
submitImportPassword(): Promise<void>;
readFile(file: any): Promise<any>;
/**
* @template
*/
importFileSelected<(Missing)>(files: any): Promise<void>;
performImport(data: any, password: any): Promise<void>;
importJSONData(data: any, password: any): Promise<any>;
downloadDataArchive(): Promise<void>;
notesAndTagsCount(): any;
encryptionStatusForNotes(): string;
reloadAutoLockInterval(): Promise<void>;
selectAutoLockInterval(interval: any): Promise<void>;
hidePasswordForm(): void;
hasPasscode(): any;
addPasscodeClicked(): void;
submitPasscodeForm(): void;
changePasscodePressed(): Promise<void>;
removePasscodePressed(): Promise<void>;
isDesktopApplication(): any;
}
export {};

View File

@@ -1,24 +0,0 @@
export class ActionsMenu {
restrict: string;
template: any;
replace: boolean;
controller: typeof ActionsMenuCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
item: string;
application: string;
};
}
declare class ActionsMenuCtrl {
constructor($timeout: any);
state: {
extensions: never[];
};
$onInit(): void;
loadExtensions(): Promise<void>;
executeAction(action: any, extension: any): Promise<void>;
handleActionResult(action: any, result: any): void;
subRowsForAction(parentAction: any, extension: any): any;
}
export {};

View File

@@ -1,29 +0,0 @@
export class ChallengeModal {
restrict: string;
template: any;
controller: typeof ChallengeModalCtrl;
controllerAs: string;
bindToController: {
challenge: string;
orchestrator: string;
application: string;
};
}
declare class ChallengeModalCtrl {
constructor($element: any, $timeout: any);
$element: any;
processingTypes: any[];
$onInit(): void;
deinit(): void;
application: any;
orchestrator: any;
challenge: any;
reloadProcessingStatus(): void;
promptForChallenge(challenge: any): "Enter your application passcode" | "Enter your account password";
cancel(): void;
onTextValueChange(challenge: any): void;
validate(): boolean;
submit(): Promise<void>;
dismiss(): void;
}
export {};

View File

@@ -1,19 +0,0 @@
export class ComponentModalCtrl {
constructor($element: any);
$element: any;
dismiss(): void;
}
export class ComponentModal {
restrict: string;
template: any;
controller: typeof ComponentModalCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
show: string;
component: string;
callback: string;
onDismiss: string;
application: string;
};
}

View File

@@ -1,47 +0,0 @@
export class ComponentView {
restrict: string;
template: any;
scope: {
component: string;
onLoad: string;
manualDealloc: string;
application: string;
};
controller: typeof ComponentViewCtrl;
controllerAs: string;
bindToController: boolean;
}
declare class ComponentViewCtrl {
constructor($scope: any, $rootScope: any, $timeout: any);
$rootScope: any;
$timeout: any;
componentValid: boolean;
cleanUpOn: any;
onVisibilityChange(): void;
$onDestroy(): void;
unregisterComponentHandler: any;
unregisterDesktopObserver: any;
component: any;
onLoad: any;
application: any;
$onChanges(): void;
didRegisterObservers: boolean | undefined;
lastComponentValue: any;
registerPackageUpdateObserver(): void;
registerComponentHandlers(): void;
reloadComponent(): Promise<void>;
reloadStatus(doManualReload?: boolean): void;
reloading: boolean | undefined;
expired: boolean | undefined;
loading: boolean | undefined;
error: string | null | undefined;
handleActivation(): void;
loadTimeout: any;
handleIframeLoadTimeout(): Promise<void>;
issueLoading: boolean | undefined;
didAttemptReload: boolean | undefined;
handleIframeLoad(iframe: any): Promise<void>;
disableActiveTheme(): void;
getUrl(): any;
}
export {};

View File

@@ -1,29 +0,0 @@
export class ConflictResolutionModal {
restrict: string;
template: any;
controller: typeof ConflictResolutionCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
item1: string;
item2: string;
callback: string;
application: string;
};
}
declare class ConflictResolutionCtrl {
constructor($element: any);
$element: any;
$onInit(): void;
contentType: any;
item1Content: string | undefined;
item2Content: string | undefined;
createContentString(item: any): string;
keepItem1(): void;
keepItem2(): void;
keepBoth(): void;
export(): void;
triggerCallback(): void;
dismiss(): void;
}
export {};

View File

@@ -1,27 +0,0 @@
export class EditorMenu {
restrict: string;
template: any;
controller: typeof EditorMenuCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
callback: string;
selectedEditor: string;
currentItem: string;
application: string;
};
}
declare class EditorMenuCtrl {
constructor($timeout: any);
state: {
isDesktop: any;
};
$onInit(): void;
selectComponent(component: any): void;
toggleDefaultForEditor(editor: any): void;
offlineAvailableForComponent(component: any): any;
makeEditorDefault(component: any): void;
removeEditorDefault(component: any): void;
shouldDisplayRunningLocallyLabel(component: any): boolean;
}
export {};

View File

@@ -1,17 +0,0 @@
export { AccountMenu } from "./accountMenu";
export { ActionsMenu } from "./actionsMenu";
export { ChallengeModal } from "./challengeModal";
export { ComponentModal } from "./componentModal";
export { ComponentView } from "./componentView";
export { ConflictResolutionModal } from "./conflictResolutionModal";
export { EditorMenu } from "./editorMenu";
export { InputModal } from "./inputModal";
export { MenuRow } from "./menuRow";
export { PanelResizer } from "./panelResizer";
export { PasswordWizard } from "./passwordWizard";
export { PermissionsModal } from "./permissionsModal";
export { PrivilegesAuthModal } from "./privilegesAuthModal";
export { PrivilegesManagementModal } from "./privilegesManagementModal";
export { RevisionPreviewModal } from "./revisionPreviewModal";
export { SessionHistoryMenu } from "./sessionHistoryMenu";
export { SyncResolutionMenu } from "./syncResolutionMenu";

View File

@@ -1,22 +0,0 @@
export class InputModal {
restrict: string;
template: any;
controller: typeof InputModalCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
type: string;
title: string;
message: string;
placeholder: string;
callback: string;
};
}
declare class InputModalCtrl {
constructor($element: any);
$element: any;
formData: {};
dismiss(): void;
submit(): void;
}
export {};

View File

@@ -1,30 +0,0 @@
export class MenuRow {
restrict: string;
transclude: boolean;
template: any;
controller: typeof MenuRowCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
action: string;
buttonAction: string;
buttonClass: string;
buttonText: string;
desc: string;
disabled: string;
circle: string;
circleAlign: string;
faded: string;
hasButton: string;
label: string;
spinnerClass: string;
stylekitClass: string;
subRows: string;
subtitle: string;
};
}
declare class MenuRowCtrl {
onClick($event: any): void;
clickAccessoryButton($event: any): void;
}
export {};

View File

@@ -1,72 +0,0 @@
export class PanelResizer {
restrict: string;
template: any;
controller: typeof PanelResizerCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
alwaysVisible: string;
collapsable: string;
control: string;
defaultWidth: string;
hoverable: string;
index: string;
minWidth: string;
onResizeFinish: string;
panelId: string;
property: string;
};
}
declare class PanelResizerCtrl {
constructor($compile: any, $element: any, $timeout: any);
$compile: any;
$element: any;
$timeout: any;
handleResize(): void;
onMouseMove(event: any): void;
onMouseUp(): void;
onMouseDown(event: any): void;
$onInit(): void;
$onDestroy(): void;
onResizeFinish: any;
control: any;
configureControl(): void;
configureDefaults(): void;
panel: HTMLElement | null | undefined;
resizerColumn: any;
currentMinWidth: any;
pressed: boolean | undefined;
startWidth: any;
lastDownX: any;
collapsed: boolean | undefined;
lastWidth: any;
startLeft: number | undefined;
lastLeft: any;
appFrame: DOMRect | null | undefined;
widthBeforeLastDblClick: any;
configureRightPanel(): void;
getParentRect(): any;
reloadDefaultValues(): void;
addDoubleClickHandler(): void;
addMouseDownListener(): void;
addMouseMoveListener(): void;
handleWidthEvent(event: any): void;
handleLeftEvent(event: any): void;
addMouseUpListener(): void;
isAtMaxWidth(): any;
isCollapsed(): boolean;
setWidth(width: any, finish: any): void;
setLeft(left: any): void;
finishSettingWidth(): void;
/**
* If an iframe is displayed adjacent to our panel, and the mouse exits over the iframe,
* document[onmouseup] is not triggered because the document is no longer the same over
* the iframe. We add an invisible overlay while resizing so that the mouse context
* remains in our main document.
*/
addInvisibleOverlay(): void;
overlay: any;
removeInvisibleOverlay(): void;
flash(): void;
}
export {};

View File

@@ -1,28 +0,0 @@
export class PasswordWizard {
restrict: string;
template: any;
controller: typeof PasswordWizardCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
type: string;
application: string;
};
}
declare class PasswordWizardCtrl {
constructor($element: any, $timeout: any);
$element: any;
$timeout: any;
$onInit(): void;
$onDestroy(): void;
/** Confirms with user before closing tab */
registerWindowUnloadStopper(): void;
resetContinueState(): void;
isContinuing: boolean | undefined;
nextStep(): Promise<void>;
setFormDataState(formData: any): Promise<any>;
validateCurrentPassword(): Promise<any>;
processPasswordChange(): Promise<boolean>;
dismiss(): void;
}
export {};

View File

@@ -1,21 +0,0 @@
export class PermissionsModal {
restrict: string;
template: any;
controller: typeof PermissionsModalCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
show: string;
component: string;
permissionsString: string;
callback: string;
};
}
declare class PermissionsModalCtrl {
constructor($element: any);
$element: any;
dismiss(): void;
accept(): void;
deny(): void;
}
export {};

View File

@@ -1,32 +0,0 @@
export class PrivilegesAuthModal {
restrict: string;
template: any;
controller: typeof PrivilegesAuthModalCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
action: string;
onSuccess: string;
onCancel: string;
application: string;
};
}
declare class PrivilegesAuthModalCtrl {
constructor($element: any, $timeout: any);
$element: any;
$timeout: any;
$onInit(): void;
authParameters: {} | undefined;
sessionLengthOptions: any;
selectedSessionLength: any;
requiredCredentials: any;
selectSessionLength(length: any): void;
promptForCredential(credential: any): any;
cancel(): void;
isCredentialInFailureState(credential: any): boolean;
validate(): boolean;
failedCredentials: any;
submit(): Promise<void>;
dismiss(): void;
}
export {};

View File

@@ -1,32 +0,0 @@
export class PrivilegesManagementModal {
restrict: string;
template: any;
controller: typeof PrivilegesManagementModalCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
application: string;
};
}
declare class PrivilegesManagementModalCtrl {
constructor($timeout: any, $element: any);
$element: any;
onAppLaunch(): void;
hasPasscode: any;
hasAccount: boolean | undefined;
displayInfoForCredential(credential: any): any;
displayInfoForAction(action: any): any;
isCredentialRequiredForAction(action: any, credential: any): any;
clearSession(): Promise<void>;
reloadPrivileges(): Promise<void>;
availableActions: any;
availableCredentials: any;
sessionExpirey: any;
sessionExpired: boolean | undefined;
credentialDisplayInfo: {} | undefined;
privileges: any;
checkboxValueChanged(action: any, credential: any): void;
cancel(): void;
dismiss(): void;
}
export {};

View File

@@ -1,26 +0,0 @@
export class RevisionPreviewModal {
restrict: string;
template: any;
controller: typeof RevisionPreviewModalCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
uuid: string;
content: string;
application: string;
};
}
declare class RevisionPreviewModalCtrl {
constructor($element: any, $timeout: any);
$element: any;
$timeout: any;
$onInit(): void;
$onDestroy(): void;
unregisterComponent: any;
configure(): Promise<void>;
note: any;
editor: any;
restore(asCopy: any): void;
dismiss(): void;
}
export {};

View File

@@ -1,28 +0,0 @@
export class SessionHistoryMenu {
restrict: string;
template: any;
controller: typeof SessionHistoryMenuCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
item: string;
application: string;
};
}
declare class SessionHistoryMenuCtrl {
constructor($timeout: any);
$timeout: any;
$onInit(): void;
diskEnabled: any;
autoOptimize: any;
reloadHistory(): void;
entries: any;
history: any;
openRevision(revision: any): void;
classForRevision(revision: any): "default" | "success" | "danger" | undefined;
clearItemHistory(): void;
clearAllHistory(): void;
toggleDiskSaving(): void;
toggleAutoOptimize(): void;
}
export {};

View File

@@ -1,21 +0,0 @@
export class SyncResolutionMenu {
restrict: string;
template: any;
controller: typeof SyncResolutionMenuCtrl;
controllerAs: string;
bindToController: boolean;
scope: {
closeFunction: string;
application: string;
};
}
declare class SyncResolutionMenuCtrl {
constructor($timeout: any);
$timeout: any;
status: {};
downloadBackup(encrypted: any): void;
skipBackup(): void;
performSyncResolution(): Promise<void>;
close(): void;
}
export {};

View File

@@ -1 +0,0 @@
export { trusted } from "./trusted";

View File

@@ -1 +0,0 @@
export function trusted($sce: any): (url: any) => any;

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export declare function configRoutes($locationProvider: ng.ILocationProvider): void;

View File

@@ -1,6 +0,0 @@
export class AlertService extends SNAlertService {
constructor(deviceInterface: import("../../../../../snjs/dist/@types").DeviceInterface);
alert(title: any, text: any, closeButtonText?: string, onClose: any): Promise<any>;
confirm(title: any, text: any, confirmButtonText?: string, cancelButtonText?: string, onConfirm: any, onCancel: any, destructive?: boolean): Promise<any>;
}
import { SNAlertService } from "../../../../../snjs/dist/@types";

View File

@@ -1,21 +0,0 @@
export class ArchiveManager {
constructor(application: any);
application: any;
/** @public */
public downloadBackup(encrypted: any): Promise<void>;
/** @public */
public downloadBackupOfItems(items: any, encrypted: any): Promise<void>;
/** @private */
private formattedDate;
/** @private */
private itemsData;
/** @private */
private loadZip;
/** @private */
private downloadZippedItems;
/** @private */
private hrefForData;
textFile: string | undefined;
/** @private */
private downloadData;
}

View File

@@ -1,49 +0,0 @@
export class DesktopManager extends ApplicationService {
constructor($rootScope: any, $timeout: any, application: any);
$rootScope: any;
$timeout: any;
componentActivationObservers: any[];
updateObservers: any[];
isDesktop: any;
/** @override */
onAppEvent(eventName: any): void;
dataLoaded: boolean | undefined;
saveBackup(): void;
getExtServerHost(): any;
/**
* Sending a component in its raw state is really slow for the desktop app
* Keys are not passed into ItemParams, so the result is not encrypted
*/
convertComponentForTransmission(component: any): Promise<any>;
syncComponentsInstallation(components: any): void;
installComponent(component: any): Promise<void>;
registerUpdateObserver(callback: any): () => void;
searchText(text: any): void;
lastSearchedText: any;
redoSearch(): void;
desktop_setSearchHandler(handler: any): void;
searchHandler: any;
desktop_windowGainedFocus(): void;
desktop_windowLostFocus(): void;
desktop_onComponentInstallationComplete(componentData: any, error: any): Promise<void>;
desktop_registerComponentActivationObserver(callback: any): {
id: () => number;
callback: any;
};
desktop_deregisterComponentActivationObserver(observer: any): void;
notifyComponentActivation(component: any): Promise<void>;
desktop_setExtServerHost(host: any): void;
extServerHost: any;
desktop_setComponentInstallationSyncHandler(handler: any): void;
installationSyncHandler: any;
desktop_setInstallComponentHandler(handler: any): void;
installComponentHandler: any;
desktop_setInitialDataLoadHandler(handler: any): void;
dataLoadHandler: any;
desktop_requestBackupFile(callback: any): Promise<void>;
desktop_setMajorDataChangeHandler(handler: any): void;
majorDataChangeHandler: any;
desktop_didBeginBackup(): void;
desktop_didFinishBackup(success: any): void;
}
import { ApplicationService } from "../../../../../../../../../../Users/mo/Desktop/sn/dev/snjs/dist/@types";

View File

@@ -1,10 +0,0 @@
export { AlertService } from "./alertService";
export { ArchiveManager } from "./archiveManager";
export { DesktopManager } from "./desktopManager";
export { KeyboardManager } from "./keyboardManager";
export { LockManager } from "./lockManager";
export { NativeExtManager } from "./nativeExtManager";
export { PreferencesManager } from "./preferencesManager";
export { StatusManager } from "./statusManager";
export { ThemeManager } from "./themeManager";
export { AppState } from "./state";

View File

@@ -1,42 +0,0 @@
export namespace KeyboardKeys {
export const Tab: string;
export const Backspace: string;
export const Up: string;
export const Down: string;
}
export namespace KeyboardModifiers {
export const Shift: string;
export const Ctrl: string;
export const Meta: string;
export const Alt: string;
}
export class KeyboardManager {
observers: any[];
handleKeyDown(event: any): void;
handleKeyUp(event: any): void;
/** @access public */
deinit(): void;
modifiersForEvent(event: any): any[];
eventMatchesKeyAndModifiers(event: any, key: any, modifiers?: any[]): boolean;
notifyObserver(event: any, keyEventType: any): void;
addKeyObserver({ key, modifiers, onKeyDown, onKeyUp, element, elements, notElement, notElementIds }: {
key: any;
modifiers: any;
onKeyDown: any;
onKeyUp: any;
element: any;
elements: any;
notElement: any;
notElementIds: any;
}): {
key: any;
modifiers: any;
onKeyDown: any;
onKeyUp: any;
element: any;
elements: any;
notElement: any;
notElementIds: any;
};
removeKeyObserver(observer: any): void;
}

View File

@@ -1,25 +0,0 @@
export class LockManager {
constructor(application: any);
application: any;
observeVisibility(): void;
unsubState: any;
deinit(): void;
setAutoLockInterval(interval: any): Promise<any>;
getAutoLockInterval(): Promise<any>;
/**
* Verify document is in focus every so often as visibilitychange event is
* not triggered on a typical window blur event but rather on tab changes.
*/
beginWebFocusPolling(): void;
pollFocusInterval: NodeJS.Timeout | undefined;
lastFocusState: string | undefined;
getAutoLockIntervalOptions(): {
value: number;
label: string;
}[];
documentVisibilityChanged(visible: any): Promise<void>;
beginAutoLockTimer(): Promise<void>;
lockAfterDate: Date | null | undefined;
lockTimeout: NodeJS.Timeout | undefined;
cancelAutoLockTimer(): void;
}

View File

@@ -1,17 +0,0 @@
/** A class for handling installation of system extensions */
export class NativeExtManager extends ApplicationService {
constructor(application: any);
extManagerId: string;
batchManagerId: string;
/** @override */
onAppLaunch(): void;
get extManagerPred(): SNPredicate;
get batchManagerPred(): SNPredicate;
reload(): void;
resolveExtensionsManager(): Promise<void>;
extensionsManagerTemplatePayload(): import("../../../../../snjs/dist/@types/protocol/payloads/pure_payload").PurePayload | undefined;
batchManagerTemplatePayload(): import("../../../../../snjs/dist/@types/protocol/payloads/pure_payload").PurePayload | undefined;
resolveBatchManager(): Promise<void>;
}
import { ApplicationService } from "../../../../../../../../../../Users/mo/Desktop/sn/dev/snjs/dist/@types";
import { SNPredicate } from "../../../../../../../../../../Users/mo/Desktop/sn/dev/snjs/dist/@types";

View File

@@ -1,29 +0,0 @@
export namespace PrefKeys {
export const TagsPanelWidth: string;
export const NotesPanelWidth: string;
export const EditorWidth: string;
export const EditorLeft: string;
export const EditorMonospaceEnabled: string;
export const EditorSpellcheck: string;
export const EditorResizersEnabled: string;
export const SortNotesBy: string;
export const SortNotesReverse: string;
export const NotesShowArchived: string;
export const NotesHidePinned: string;
export const NotesHideNotePreview: string;
export const NotesHideDate: string;
export const NotesHideTags: string;
}
export class PreferencesManager extends ApplicationService {
constructor(application: import("../../../../../snjs/dist/@types/application").SNApplication);
/** @override */
onAppLaunch(): void;
streamPreferences(): void;
loadSingleton(): Promise<void>;
userPreferences: any;
preferencesDidChange(): void;
syncUserPreferences(): void;
getValue(key: any, defaultValue: any): any;
setUserPrefValue(key: any, value: any, sync: any): void;
}
import { ApplicationService } from "../../../../../../../../../../Users/mo/Desktop/sn/dev/snjs/dist/@types";

View File

@@ -1,56 +0,0 @@
export namespace AppStateEvents {
export const TagChanged: number;
export const NoteChanged: number;
export const PreferencesChanged: number;
export const PanelResized: number;
export const EditorFocused: number;
export const BeganBackupDownload: number;
export const EndedBackupDownload: number;
export const DesktopExtsReady: number;
export const WindowDidFocus: number;
export const WindowDidBlur: number;
}
export namespace EventSources {
export const UserInteraction: number;
export const Script: number;
}
export class AppState {
constructor($rootScope: any, $timeout: any, application: any);
$timeout: any;
$rootScope: any;
application: any;
observers: any[];
locked: boolean;
deinit(): void;
unsubApp: any;
rootScopeCleanup1: any;
rootScopeCleanup2: any;
onVisibilityChange(): void;
addAppEventObserver(): void;
isLocked(): boolean;
registerVisibilityObservers(): void;
/** @returns A function that unregisters this observer */
addObserver(callback: any): () => void;
notifyEvent(eventName: any, data: any): Promise<any>;
setSelectedTag(tag: any): void;
selectedTag: any;
setSelectedNote(note: any): Promise<any>;
selectedNote: any;
getSelectedTag(): any;
getSelectedNote(): any;
setUserPreferences(preferences: any): void;
userPreferences: any;
panelDidResize({ name, collapsed }: {
name: any;
collapsed: any;
}): void;
editorDidFocus(eventSource: any): void;
beganBackupDownload(): void;
endedBackupDownload({ success }: {
success: any;
}): void;
/**
* When the desktop appplication extension server is ready.
*/
desktopExtensionsReady(): void;
}

View File

@@ -1,15 +0,0 @@
export class StatusManager {
statuses: any[];
observers: any[];
statusFromString(string: any): {
string: any;
};
replaceStatusWithString(status: any, string: any): any;
addStatusFromString(string: any): any;
addStatus(status: any): any;
removeStatus(status: any): null;
getStatusString(): string;
notifyObservers(): void;
addStatusObserver(callback: any): void;
removeStatusObserver(callback: any): void;
}

View File

@@ -1,26 +0,0 @@
export class ThemeManager extends ApplicationService {
constructor(application: any);
activeThemes: any[];
unsubState: any;
unregisterDesktop: any;
unregisterComponent: any;
/** @override */
onAppStart(): void;
/** @access private */
activateCachedThemes(): Promise<void>;
/** @access private */
registerObservers(): void;
/** @access public */
deactivateAllThemes(): void;
/** @access private */
activateTheme(theme: any, writeToCache?: boolean): void;
/** @access private */
deactivateTheme(theme: any): void;
/** @access private */
cacheThemes(): Promise<void>;
/** @access private */
decacheThemes(): Promise<void>;
/** @access private */
getCachedThemes(): Promise<import("../../../../../snjs/dist/@types/models/core/item").SNItem[]>;
}
import { ApplicationService } from "../../../../../../../../../../Users/mo/Desktop/sn/dev/snjs/dist/@types";

View File

@@ -1,43 +0,0 @@
export function StringSyncException(data: any): string;
export function StringDeleteNote({ title, permanently }: {
title: any;
permanently: any;
}): string;
export function StringEmptyTrash({ count }: {
count: any;
}): string;
export function StringImportError({ errorCount }: {
errorCount: any;
}): string;
/** @generic */
export const STRING_SESSION_EXPIRED: "Your session has expired. New changes will not be pulled in. Please sign out and sign back in to refresh your session.";
export const STRING_DEFAULT_FILE_ERROR: "Please use FileSafe or the Bold Editor to attach images and files. Learn more at standardnotes.org/filesafe.";
export const STRING_GENERIC_SYNC_ERROR: "There was an error syncing. Please try again. If all else fails, try signing out and signing back in.";
/** @footer */
export const STRING_NEW_UPDATE_READY: "A new update is ready to install. Please use the top-level 'Updates' menu to manage installation.";
/** @tags */
export const STRING_DELETE_TAG: "Are you sure you want to delete this tag? Note: deleting a tag will not delete its notes.";
/** @editor */
export const STRING_DELETED_NOTE: "The note you are attempting to edit has been deleted, and is awaiting sync. Changes you make will be disregarded.";
export const STRING_INVALID_NOTE: "The note you are attempting to save can not be found or has been deleted. Changes you make will not be synced. Please copy this note's text and start a new note.";
export const STRING_ELLIPSES: "...";
export const STRING_GENERIC_SAVE_ERROR: "There was an error saving your note. Please try again.";
export const STRING_DELETE_PLACEHOLDER_ATTEMPT: "This note is a placeholder and cannot be deleted. To remove from your list, simply navigate to a different note.";
export const STRING_DELETE_LOCKED_ATTEMPT: "This note is locked. If you'd like to delete it, unlock it, and try again.";
/** @account */
export const STRING_ACCOUNT_MENU_UNCHECK_MERGE: "Unchecking this option means any of the notes you have written while you were signed out will be deleted. Are you sure you want to discard these notes?";
export const STRING_SIGN_OUT_CONFIRMATION: "Are you sure you want to end your session? This will delete all local items and extensions.";
export const STRING_ERROR_DECRYPTING_IMPORT: "There was an error decrypting your items. Make sure the password you entered is correct and try again.";
export const STRING_E2E_ENABLED: "End-to-end encryption is enabled. Your data is encrypted on your device first, then synced to your private cloud.";
export const STRING_LOCAL_ENC_ENABLED: "Encryption is enabled. Your data is encrypted using your passcode before it is saved to your device storage.";
export const STRING_ENC_NOT_ENABLED: "Encryption is not enabled. Sign in, register, or add a passcode lock to enable encryption.";
export const STRING_IMPORT_SUCCESS: "Your data has been successfully imported.";
export const STRING_REMOVE_PASSCODE_CONFIRMATION: "Are you sure you want to remove your application passcode?";
export const STRING_REMOVE_PASSCODE_OFFLINE_ADDENDUM: " This will remove encryption from your local data.";
export const STRING_NON_MATCHING_PASSCODES: "The two passcodes you entered do not match. Please try again.";
export const STRING_NON_MATCHING_PASSWORDS: "The two passwords you entered do not match. Please try again.";
export const STRING_GENERATING_LOGIN_KEYS: "Generating Login Keys...";
export const STRING_GENERATING_REGISTER_KEYS: "Generating Account Keys...";
export const STRING_INVALID_IMPORT_FILE: "Unable to open file. Ensure it is a proper JSON file and try again.";
/** @password_change */
export const STRING_FAILED_PASSWORD_CHANGE: "There was an error re-encrypting your items. Your password was changed, but not all your items were properly re-encrypted and synced. You should try syncing again. If all else fails, you should restore your notes from backup.";

View File

@@ -1,4 +0,0 @@
export declare enum PasswordWizardType {
ChangePassword = 1,
AccountUpgrade = 2
}

View File

@@ -1,10 +0,0 @@
export function getParameterByName(name: any, url: any): string | null;
export function parametersFromURL(url: any): {};
export function isNullOrUndefined(value: any): boolean;
export function dictToArray(dict: any): any[];
export function humanReadableList(array: any): string;
export function getPlatformString(): string;
export function dateToLocalizedString(date: any): any;
/** Via https://davidwalsh.name/javascript-debounce-function */
export function debounce(func: any, wait: any, immediate: any): (...args: any[]) => void;
export function isDesktopApplication(): any;

View File

@@ -1,29 +0,0 @@
import { DeviceInterface, SNApplication } from 'snjs';
export declare class WebDeviceInterface extends DeviceInterface {
private database;
constructor(namespace: string, timeout: any);
setApplication(application: SNApplication): void;
deinit(): void;
getRawStorageValue(key: string): Promise<string | null>;
getAllRawStorageKeyValues(): Promise<{
key: string;
value: any;
}[]>;
setRawStorageValue(key: string, value: any): Promise<void>;
removeRawStorageValue(key: string): Promise<void>;
removeAllRawStorageValues(): Promise<void>;
openDatabase(): Promise<{
isNewDatabase?: boolean | undefined;
} | undefined>;
private getDatabaseKeyPrefix;
private keyForPayloadId;
getAllRawDatabasePayloads(): Promise<any>;
saveRawDatabasePayload(payload: any): Promise<any>;
saveRawDatabasePayloads(payloads: any[]): Promise<any>;
removeRawDatabasePayloadWithId(id: string): Promise<any>;
removeAllRawDatabasePayloads(): Promise<any>;
getKeychainValue(): Promise<any>;
setKeychainValue(value: any): Promise<void>;
clearKeychainValue(): Promise<void>;
openUrl(url: string): void;
}

View File

@@ -1,242 +0,0 @@
/**
* @ngdoc module
* @name ngSanitize
* @description
*
* The `ngSanitize` module provides functionality to sanitize HTML.
*
* See {@link ngSanitize.$sanitize `$sanitize`} for usage.
*/
/**
* @ngdoc service
* @name $sanitize
* @kind function
*
* @description
* Sanitizes an html string by stripping all potentially dangerous tokens.
*
* The input is sanitized by parsing the HTML into tokens. All safe tokens (from a whitelist) are
* then serialized back to a properly escaped HTML string. This means that no unsafe input can make
* it into the returned string.
*
* The whitelist for URL sanitization of attribute values is configured using the functions
* `aHrefSanitizationWhitelist` and `imgSrcSanitizationWhitelist` of {@link $compileProvider}.
*
* The input may also contain SVG markup if this is enabled via {@link $sanitizeProvider}.
*
* @param {string} html HTML input.
* @returns {string} Sanitized HTML.
*
* @example
<example module="sanitizeExample" deps="angular-sanitize.js" name="sanitize-service">
<file name="index.html">
<script>
angular.module('sanitizeExample', ['ngSanitize'])
.controller('ExampleController', ['$scope', '$sce', function($scope, $sce) {
$scope.snippet =
'<p style="color:blue">an html\n' +
'<em onmouseover="this.textContent=\'PWN3D!\'">click here</em>\n' +
'snippet</p>';
$scope.deliberatelyTrustDangerousSnippet = function() {
return $sce.trustAsHtml($scope.snippet);
};
}]);
</script>
<div ng-controller="ExampleController">
Snippet: <textarea ng-model="snippet" cols="60" rows="3"></textarea>
<table>
<tr>
<td>Directive</td>
<td>How</td>
<td>Source</td>
<td>Rendered</td>
</tr>
<tr id="bind-html-with-sanitize">
<td>ng-bind-html</td>
<td>Automatically uses $sanitize</td>
<td><pre>&lt;div ng-bind-html="snippet"&gt;<br/>&lt;/div&gt;</pre></td>
<td><div ng-bind-html="snippet"></div></td>
</tr>
<tr id="bind-html-with-trust">
<td>ng-bind-html</td>
<td>Bypass $sanitize by explicitly trusting the dangerous value</td>
<td>
<pre>&lt;div ng-bind-html="deliberatelyTrustDangerousSnippet()"&gt;
&lt;/div&gt;</pre>
</td>
<td><div ng-bind-html="deliberatelyTrustDangerousSnippet()"></div></td>
</tr>
<tr id="bind-default">
<td>ng-bind</td>
<td>Automatically escapes</td>
<td><pre>&lt;div ng-bind="snippet"&gt;<br/>&lt;/div&gt;</pre></td>
<td><div ng-bind="snippet"></div></td>
</tr>
</table>
</div>
</file>
<file name="protractor.js" type="protractor">
it('should sanitize the html snippet by default', function() {
expect(element(by.css('#bind-html-with-sanitize div')).getAttribute('innerHTML')).
toBe('<p>an html\n<em>click here</em>\nsnippet</p>');
});
it('should inline raw snippet if bound to a trusted value', function() {
expect(element(by.css('#bind-html-with-trust div')).getAttribute('innerHTML')).
toBe("<p style=\"color:blue\">an html\n" +
"<em onmouseover=\"this.textContent='PWN3D!'\">click here</em>\n" +
"snippet</p>");
});
it('should escape snippet without any filter', function() {
expect(element(by.css('#bind-default div')).getAttribute('innerHTML')).
toBe("&lt;p style=\"color:blue\"&gt;an html\n" +
"&lt;em onmouseover=\"this.textContent='PWN3D!'\"&gt;click here&lt;/em&gt;\n" +
"snippet&lt;/p&gt;");
});
it('should update', function() {
element(by.model('snippet')).clear();
element(by.model('snippet')).sendKeys('new <b onclick="alert(1)">text</b>');
expect(element(by.css('#bind-html-with-sanitize div')).getAttribute('innerHTML')).
toBe('new <b>text</b>');
expect(element(by.css('#bind-html-with-trust div')).getAttribute('innerHTML')).toBe(
'new <b onclick="alert(1)">text</b>');
expect(element(by.css('#bind-default div')).getAttribute('innerHTML')).toBe(
"new &lt;b onclick=\"alert(1)\"&gt;text&lt;/b&gt;");
});
</file>
</example>
*/
/**
* @ngdoc provider
* @name $sanitizeProvider
* @this
*
* @description
* Creates and configures {@link $sanitize} instance.
*/
declare function $SanitizeProvider(): void;
declare class $SanitizeProvider {
$get: (string | (($$sanitizeUri: any) => (html: any) => string))[];
/**
* @ngdoc method
* @name $sanitizeProvider#enableSvg
* @kind function
*
* @description
* Enables a subset of svg to be supported by the sanitizer.
*
* <div class="alert alert-warning">
* <p>By enabling this setting without taking other precautions, you might expose your
* application to click-hijacking attacks. In these attacks, sanitized svg elements could be positioned
* outside of the containing element and be rendered over other elements on the page (e.g. a login
* link). Such behavior can then result in phishing incidents.</p>
*
* <p>To protect against these, explicitly setup `overflow: hidden` css rule for all potential svg
* tags within the sanitized content:</p>
*
* <br>
*
* <pre><code>
* .rootOfTheIncludedContent svg {
* overflow: hidden !important;
* }
* </code></pre>
* </div>
*
* @param {boolean=} flag Enable or disable SVG support in the sanitizer.
* @returns {boolean|$sanitizeProvider} Returns the currently configured value if called
* without an argument or self for chaining otherwise.
*/
enableSvg: (enableSvg: any) => any;
/**
* @ngdoc method
* @name $sanitizeProvider#addValidElements
* @kind function
*
* @description
* Extends the built-in lists of valid HTML/SVG elements, i.e. elements that are considered safe
* and are not stripped off during sanitization. You can extend the following lists of elements:
*
* - `htmlElements`: A list of elements (tag names) to extend the current list of safe HTML
* elements. HTML elements considered safe will not be removed during sanitization. All other
* elements will be stripped off.
*
* - `htmlVoidElements`: This is similar to `htmlElements`, but marks the elements as
* "void elements" (similar to HTML
* [void elements](https://rawgit.com/w3c/html/html5.1-2/single-page.html#void-elements)). These
* elements have no end tag and cannot have content.
*
* - `svgElements`: This is similar to `htmlElements`, but for SVG elements. This list is only
* taken into account if SVG is {@link ngSanitize.$sanitizeProvider#enableSvg enabled} for
* `$sanitize`.
*
* <div class="alert alert-info">
* This method must be called during the {@link angular.Module#config config} phase. Once the
* `$sanitize` service has been instantiated, this method has no effect.
* </div>
*
* <div class="alert alert-warning">
* Keep in mind that extending the built-in lists of elements may expose your app to XSS or
* other vulnerabilities. Be very mindful of the elements you add.
* </div>
*
* @param {Array<String>|Object} elements - A list of valid HTML elements or an object with one or
* more of the following properties:
* - **htmlElements** - `{Array<String>}` - A list of elements to extend the current list of
* HTML elements.
* - **htmlVoidElements** - `{Array<String>}` - A list of elements to extend the current list of
* void HTML elements; i.e. elements that do not have an end tag.
* - **svgElements** - `{Array<String>}` - A list of elements to extend the current list of SVG
* elements. The list of SVG elements is only taken into account if SVG is
* {@link ngSanitize.$sanitizeProvider#enableSvg enabled} for `$sanitize`.
*
* Passing an array (`[...]`) is equivalent to passing `{htmlElements: [...]}`.
*
* @return {$sanitizeProvider} Returns self for chaining.
*/
addValidElements: (elements: Object | string[]) => any;
/**
* @ngdoc method
* @name $sanitizeProvider#addValidAttrs
* @kind function
*
* @description
* Extends the built-in list of valid attributes, i.e. attributes that are considered safe and are
* not stripped off during sanitization.
*
* **Note**:
* The new attributes will not be treated as URI attributes, which means their values will not be
* sanitized as URIs using `$compileProvider`'s
* {@link ng.$compileProvider#aHrefSanitizationWhitelist aHrefSanitizationWhitelist} and
* {@link ng.$compileProvider#imgSrcSanitizationWhitelist imgSrcSanitizationWhitelist}.
*
* <div class="alert alert-info">
* This method must be called during the {@link angular.Module#config config} phase. Once the
* `$sanitize` service has been instantiated, this method has no effect.
* </div>
*
* <div class="alert alert-warning">
* Keep in mind that extending the built-in list of attributes may expose your app to XSS or
* other vulnerabilities. Be very mindful of the attributes you add.
* </div>
*
* @param {Array<String>} attrs - A list of valid attributes.
*
* @returns {$sanitizeProvider} Returns self for chaining.
*/
addValidAttrs: (attrs: string[]) => any;
}
declare function sanitizeText(chars: any): string;
declare var $sanitizeMinErr: any;
declare var bind: any;
declare var extend: any;
declare var forEach: any;
declare var isArray: any;
declare var isDefined: any;
declare var lowercase: any;
declare var noop: any;
declare var nodeContains: any;
declare var htmlParser: any;
declare var htmlSanitizeWriter: any;

View File

@@ -1,4 +1,4 @@
import { PasswordWizardType } from './types'; import { PasswordWizardType, PasswordWizardScope } from './types';
import { import {
Environment, Environment,
SNApplication, SNApplication,
@@ -12,7 +12,17 @@ import angular from 'angular';
import { getPlatformString } from '@/utils'; import { getPlatformString } from '@/utils';
import { AlertService } from '@/services/alertService'; import { AlertService } from '@/services/alertService';
import { WebDeviceInterface } from '@/web_device_interface'; import { WebDeviceInterface } from '@/web_device_interface';
import { AppState, DesktopManager, LockManager, ArchiveManager, NativeExtManager, StatusManager, ThemeManager, PreferencesManager, KeyboardManager } from './services'; import {
AppState,
DesktopManager,
LockManager,
ArchiveManager,
NativeExtManager,
StatusManager,
ThemeManager,
PreferencesManager,
KeyboardManager
} from './services';
type WebServices = { type WebServices = {
appState: AppState appState: AppState
@@ -135,7 +145,7 @@ export class WebApplication extends SNApplication {
} }
presentPasswordWizard(type: PasswordWizardType) { presentPasswordWizard(type: PasswordWizardType) {
const scope: any = this.scope!.$new(true); const scope = this.scope!.$new(true) as PasswordWizardScope;
scope.type = type; scope.type = type;
scope.application = this; scope.application = this;
const el = this.$compile!("<password-wizard application='application' type='type'></password-wizard>")(scope); const el = this.$compile!("<password-wizard application='application' type='type'></password-wizard>")(scope);
@@ -171,8 +181,8 @@ export class WebApplication extends SNApplication {
async presentPrivilegesModal( async presentPrivilegesModal(
action: ProtectedAction, action: ProtectedAction,
onSuccess: any, onSuccess?: any,
onCancel: any onCancel?: any
) { ) {
if (this.authenticationInProgress()) { if (this.authenticationInProgress()) {
onCancel && onCancel(); onCancel && onCancel();

View File

@@ -1,20 +1,28 @@
import { WebApplication } from './../../application';
import { ApplicationEvent } from 'snjs'; import { ApplicationEvent } from 'snjs';
export type CtrlState = Partial<Record<string, any>>
export type CtrlProps = Partial<Record<string, any>>
export class PureCtrl { export class PureCtrl {
$timeout: ng.ITimeoutService
/** Passed through templates */
application?: WebApplication
props: CtrlProps = {}
state: CtrlState = {}
private unsubApp: any
private unsubState: any
private stateTimeout: any
/* @ngInject */ /* @ngInject */
constructor($timeout) { constructor($timeout: ng.ITimeoutService) {
if(!$timeout) {
throw Error('$timeout must not be null');
}
this.$timeout = $timeout; this.$timeout = $timeout;
this.props = {};
this.state = {};
/* Allow caller constructor to finish setting instance variables */ /* Allow caller constructor to finish setting instance variables */
setImmediate(() => { setImmediate(() => {
this.state = this.getInitialState(); this.state = this.getInitialState();
}); });
} }
$onInit() { $onInit() {
this.addAppEventObserver(); this.addAppEventObserver();
this.addAppStateObserver(); this.addAppStateObserver();
@@ -23,9 +31,9 @@ export class PureCtrl {
deinit() { deinit() {
this.unsubApp(); this.unsubApp();
this.unsubState(); this.unsubState();
this.unsubApp = null; this.unsubApp = undefined;
this.unsubState = null; this.unsubState = undefined;
this.application = null; this.application = undefined;
if (this.stateTimeout) { if (this.stateTimeout) {
this.$timeout.cancel(this.stateTimeout); this.$timeout.cancel(this.stateTimeout);
} }
@@ -46,8 +54,8 @@ export class PureCtrl {
return {}; return {};
} }
async setState(state) { async setState(state: CtrlState) {
if(!this.$timeout) { if (!this.$timeout) {
return; return;
} }
return new Promise((resolve) => { return new Promise((resolve) => {
@@ -58,7 +66,7 @@ export class PureCtrl {
}); });
} }
initProps(props) { initProps(props: CtrlProps) {
if (Object.keys(this.props).length > 0) { if (Object.keys(this.props).length > 0) {
throw 'Already init-ed props.'; throw 'Already init-ed props.';
} }
@@ -66,23 +74,24 @@ export class PureCtrl {
} }
addAppStateObserver() { addAppStateObserver() {
this.unsubState = this.application.getAppState().addObserver((eventName, data) => { this.unsubState = this.application!.getAppState()
this.onAppStateEvent(eventName, data); .addObserver((eventName: any, data: any) => {
}); this.onAppStateEvent(eventName, data);
});
} }
onAppStateEvent(eventName, data) { onAppStateEvent(eventName: any, data: any) {
/** Optional override */ /** Optional override */
} }
addAppEventObserver() { addAppEventObserver() {
if (this.application.isStarted()) { if (this.application!.isStarted()) {
this.onAppStart(); this.onAppStart();
} }
if (this.application.isLaunched()) { if (this.application!.isLaunched()) {
this.onAppLaunch(); this.onAppLaunch();
} }
this.unsubApp = this.application.addEventObserver(async (eventName) => { this.unsubApp = this.application!.addEventObserver(async (eventName) => {
this.onAppEvent(eventName); this.onAppEvent(eventName);
if (eventName === ApplicationEvent.Started) { if (eventName === ApplicationEvent.Started) {
await this.onAppStart(); await this.onAppStart();
@@ -96,7 +105,7 @@ export class PureCtrl {
}); });
} }
onAppEvent(eventName) { onAppEvent(eventName: ApplicationEvent) {
/** Optional override */ /** Optional override */
} }

View File

@@ -1,6 +1,6 @@
import { getPlatformString } from '@/utils'; import { getPlatformString } from '@/utils';
import template from '%/application-view.pug'; import template from '%/application-view.pug';
import { AppStateEvents } from '@/services/state'; import { AppStateEvent } from '@/services/state';
import { ApplicationEvent } from 'snjs'; import { ApplicationEvent } from 'snjs';
import angular from 'angular'; import angular from 'angular';
import { import {
@@ -127,7 +127,7 @@ class ApplicationViewCtrl extends PureCtrl {
/** @override */ /** @override */
async onAppStateEvent(eventName, data) { async onAppStateEvent(eventName, data) {
if (eventName === AppStateEvents.PanelResized) { if (eventName === AppStateEvent.PanelResized) {
if (data.panel === PANEL_NAME_NOTES) { if (data.panel === PANEL_NAME_NOTES) {
this.notesCollapsed = data.collapsed; this.notesCollapsed = data.collapsed;
} }
@@ -138,7 +138,7 @@ class ApplicationViewCtrl extends PureCtrl {
if (this.notesCollapsed) { appClass += "collapsed-notes"; } if (this.notesCollapsed) { appClass += "collapsed-notes"; }
if (this.tagsCollapsed) { appClass += " collapsed-tags"; } if (this.tagsCollapsed) { appClass += " collapsed-tags"; }
this.setState({ appClass }); this.setState({ appClass });
} else if (eventName === AppStateEvents.WindowDidFocus) { } else if (eventName === AppStateEvent.WindowDidFocus) {
if (!(await this.application.isLocked())) { if (!(await this.application.isLocked())) {
this.application.sync(); this.application.sync();
} }

View File

@@ -3,14 +3,14 @@ import {
ApplicationEvent, ApplicationEvent,
isPayloadSourceRetrieved, isPayloadSourceRetrieved,
ContentTypes, ContentTypes,
ProtectedActions ProtectedAction
} from 'snjs'; } from 'snjs';
import find from 'lodash/find'; import find from 'lodash/find';
import { isDesktopApplication } from '@/utils'; import { isDesktopApplication } from '@/utils';
import { KeyboardModifiers, KeyboardKeys } from '@/services/keyboardManager'; import { KeyboardModifiers, KeyboardKeys } from '@/services/keyboardManager';
import template from '%/editor.pug'; import template from '%/editor.pug';
import { PureCtrl } from '@Controllers'; import { PureCtrl } from '@Controllers';
import { AppStateEvents, EventSources } from '@/services/state'; import { AppStateEvent, EventSource } from '@/services/state';
import { import {
STRING_DELETED_NOTE, STRING_DELETED_NOTE,
STRING_INVALID_NOTE, STRING_INVALID_NOTE,
@@ -98,12 +98,12 @@ class EditorCtrl extends PureCtrl {
/** @override */ /** @override */
onAppStateEvent(eventName, data) { onAppStateEvent(eventName, data) {
if (eventName === AppStateEvents.NoteChanged) { if (eventName === AppStateEvent.NoteChanged) {
this.handleNoteSelectionChange( this.handleNoteSelectionChange(
this.application.getAppState().getSelectedNote(), this.application.getAppState().getSelectedNote(),
data.previousNote data.previousNote
); );
} else if (eventName === AppStateEvents.PreferencesChanged) { } else if (eventName === AppStateEvent.PreferencesChanged) {
this.reloadPreferences(); this.reloadPreferences();
} }
} }
@@ -496,7 +496,7 @@ class EditorCtrl extends PureCtrl {
focusEditor() { focusEditor() {
const element = document.getElementById(ElementIds.NoteTextEditor); const element = document.getElementById(ElementIds.NoteTextEditor);
if (element) { if (element) {
this.lastEditorFocusEventSource = EventSources.Script; this.lastEditorFocusEventSource = EventSource.Script;
element.focus(); element.focus();
} }
} }
@@ -568,11 +568,11 @@ class EditorCtrl extends PureCtrl {
}); });
}; };
const requiresPrivilege = await this.application.privilegesService.actionRequiresPrivilege( const requiresPrivilege = await this.application.privilegesService.actionRequiresPrivilege(
ProtectedActions.DeleteNote ProtectedAction.DeleteNote
); );
if (requiresPrivilege) { if (requiresPrivilege) {
this.application.presentPrivilegesModal( this.application.presentPrivilegesModal(
ProtectedActions.DeleteNote, ProtectedAction.DeleteNote,
() => { () => {
run(); run();
} }
@@ -656,7 +656,7 @@ class EditorCtrl extends PureCtrl {
/** Show privileges manager if protection is not yet set up */ /** Show privileges manager if protection is not yet set up */
this.application.privilegesService.actionHasPrivilegesConfigured( this.application.privilegesService.actionHasPrivilegesConfigured(
ProtectedActions.ViewProtectedNotes ProtectedAction.ViewProtectedNotes
).then((configured) => { ).then((configured) => {
if (!configured) { if (!configured) {
this.application.presentPrivilegesManagementModal(); this.application.presentPrivilegesManagementModal();

View File

@@ -2,11 +2,11 @@ import { dateToLocalizedString } from '@/utils';
import { import {
ApplicationEvent, ApplicationEvent,
TIMING_STRATEGY_FORCE_SPAWN_NEW, TIMING_STRATEGY_FORCE_SPAWN_NEW,
ProtectedActions, ProtectedAction,
ContentTypes ContentTypes
} from 'snjs'; } from 'snjs';
import template from '%/footer.pug'; import template from '%/footer.pug';
import { AppStateEvents, EventSources } from '@/services/state'; import { AppStateEvent, EventSource } from '@/services/state';
import { import {
STRING_GENERIC_SYNC_ERROR, STRING_GENERIC_SYNC_ERROR,
STRING_NEW_UPDATE_READY STRING_NEW_UPDATE_READY
@@ -96,16 +96,16 @@ class FooterCtrl extends PureCtrl {
/** @override */ /** @override */
onAppStateEvent(eventName, data) { onAppStateEvent(eventName, data) {
if (eventName === AppStateEvents.EditorFocused) { if (eventName === AppStateEvent.EditorFocused) {
if (data.eventSource === EventSources.UserInteraction) { if (data.eventSource === EventSource.UserInteraction) {
this.closeAllRooms(); this.closeAllRooms();
this.closeAccountMenu(); this.closeAccountMenu();
} }
} else if (eventName === AppStateEvents.BeganBackupDownload) { } else if (eventName === AppStateEvent.BeganBackupDownload) {
this.backupStatus = this.application.getStatusService().addStatusFromString( this.backupStatus = this.application.getStatusService().addStatusFromString(
"Saving local backup..." "Saving local backup..."
); );
} else if (eventName === AppStateEvents.EndedBackupDownload) { } else if (eventName === AppStateEvent.EndedBackupDownload) {
if (data.success) { if (data.success) {
this.backupStatus = this.application.getStatusService().replaceStatusWithString( this.backupStatus = this.application.getStatusService().replaceStatusWithString(
this.backupStatus, this.backupStatus,
@@ -363,11 +363,11 @@ class FooterCtrl extends PureCtrl {
if (!room.showRoom) { if (!room.showRoom) {
const requiresPrivilege = await this.application.privilegesService.actionRequiresPrivilege( const requiresPrivilege = await this.application.privilegesService.actionRequiresPrivilege(
ProtectedActions.ManageExtensions ProtectedAction.ManageExtensions
); );
if (requiresPrivilege) { if (requiresPrivilege) {
this.application.presentPrivilegesModal( this.application.presentPrivilegesModal(
ProtectedActions.ManageExtensions, ProtectedAction.ManageExtensions,
run run
); );
} else { } else {

View File

@@ -1,5 +1,5 @@
import template from '%/lock-screen.pug'; import template from '%/lock-screen.pug';
import { AppStateEvents } from '@/services/state'; import { AppStateEvent } from '@/services/state';
import { PureCtrl } from './abstract/pure_ctrl'; import { PureCtrl } from './abstract/pure_ctrl';
const ELEMENT_ID_PASSCODE_INPUT = 'passcode-input'; const ELEMENT_ID_PASSCODE_INPUT = 'passcode-input';
@@ -28,7 +28,7 @@ class LockScreenCtrl extends PureCtrl {
/** @override */ /** @override */
async onAppStateEvent(eventName, data) { async onAppStateEvent(eventName, data) {
if (eventName === AppStateEvents.WindowDidFocus) { if (eventName === AppStateEvent.WindowDidFocus) {
const input = this.passcodeInput; const input = this.passcodeInput;
if (input) { if (input) {
input.focus(); input.focus();

View File

@@ -2,7 +2,7 @@ import angular from 'angular';
import template from '%/notes.pug'; import template from '%/notes.pug';
import { ApplicationEvent, ContentTypes, removeFromArray } from 'snjs'; import { ApplicationEvent, ContentTypes, removeFromArray } from 'snjs';
import { PureCtrl } from '@Controllers'; import { PureCtrl } from '@Controllers';
import { AppStateEvents } from '@/services/state'; import { AppStateEvent } from '@/services/state';
import { KeyboardModifiers, KeyboardKeys } from '@/services/keyboardManager'; import { KeyboardModifiers, KeyboardKeys } from '@/services/keyboardManager';
import { import {
PrefKeys PrefKeys
@@ -89,14 +89,14 @@ class NotesCtrl extends PureCtrl {
/** @override */ /** @override */
onAppStateEvent(eventName, data) { onAppStateEvent(eventName, data) {
if (eventName === AppStateEvents.TagChanged) { if (eventName === AppStateEvent.TagChanged) {
this.handleTagChange(this.application.getAppState().getSelectedTag(), data.previousTag); this.handleTagChange(this.application.getAppState().getSelectedTag(), data.previousTag);
} else if (eventName === AppStateEvents.NoteChanged) { } else if (eventName === AppStateEvent.NoteChanged) {
this.handleNoteSelection(this.application.getAppState().getSelectedNote()); this.handleNoteSelection(this.application.getAppState().getSelectedNote());
} else if (eventName === AppStateEvents.PreferencesChanged) { } else if (eventName === AppStateEvent.PreferencesChanged) {
this.reloadPreferences(); this.reloadPreferences();
this.reloadNotes(); this.reloadNotes();
} else if (eventName === AppStateEvents.EditorFocused) { } else if (eventName === AppStateEvent.EditorFocused) {
this.setShowMenuFalse(); this.setShowMenuFalse();
} }
} }
@@ -384,10 +384,10 @@ class NotesCtrl extends PureCtrl {
if (width && this.panelPuppet.ready) { if (width && this.panelPuppet.ready) {
this.panelPuppet.setWidth(width); this.panelPuppet.setWidth(width);
if (this.panelPuppet.isCollapsed()) { if (this.panelPuppet.isCollapsed()) {
this.application.getAppState().panelDidResize({ this.application.getAppState().panelDidResize(
name: PANEL_NAME_NOTES, PANEL_NAME_NOTES,
collapsed: this.panelPuppet.isCollapsed() this.panelPuppet.isCollapsed()
}); );
} }
} }
} }
@@ -398,10 +398,10 @@ class NotesCtrl extends PureCtrl {
newWidth newWidth
); );
this.application.getPrefsService().syncUserPreferences(); this.application.getPrefsService().syncUserPreferences();
this.application.getAppState().panelDidResize({ this.application.getAppState().panelDidResize(
name: PANEL_NAME_NOTES, PANEL_NAME_NOTES,
collapsed: isCollapsed isCollapsed
}); );
} }
paginate() { paginate() {

View File

@@ -6,7 +6,7 @@ import {
ComponentActions ComponentActions
} from 'snjs'; } from 'snjs';
import template from '%/tags.pug'; import template from '%/tags.pug';
import { AppStateEvents } from '@/services/state'; import { AppStateEvent } from '@/services/state';
import { PANEL_NAME_TAGS } from '@/controllers/constants'; import { PANEL_NAME_TAGS } from '@/controllers/constants';
import { PrefKeys } from '@/services/preferencesManager'; import { PrefKeys } from '@/services/preferencesManager';
import { STRING_DELETE_TAG } from '@/strings'; import { STRING_DELETE_TAG } from '@/strings';
@@ -94,9 +94,9 @@ class TagsPanelCtrl extends PureCtrl {
/** @override */ /** @override */
onAppStateEvent(eventName, data) { onAppStateEvent(eventName, data) {
if (eventName === AppStateEvents.PreferencesChanged) { if (eventName === AppStateEvent.PreferencesChanged) {
this.loadPreferences(); this.loadPreferences();
} else if (eventName === AppStateEvents.TagChanged) { } else if (eventName === AppStateEvent.TagChanged) {
this.setState({ this.setState({
selectedTag: this.application.getAppState().getSelectedTag() selectedTag: this.application.getAppState().getSelectedTag()
}); });
@@ -146,10 +146,10 @@ class TagsPanelCtrl extends PureCtrl {
if (width) { if (width) {
this.panelPuppet.setWidth(width); this.panelPuppet.setWidth(width);
if (this.panelPuppet.isCollapsed()) { if (this.panelPuppet.isCollapsed()) {
this.application.getAppState().panelDidResize({ this.application.getAppState().panelDidResize(
name: PANEL_NAME_TAGS, PANEL_NAME_TAGS,
collapsed: this.panelPuppet.isCollapsed() this.panelPuppet.isCollapsed()
}); );
} }
} }
} }
@@ -160,10 +160,10 @@ class TagsPanelCtrl extends PureCtrl {
newWidth, newWidth,
true true
); );
this.application.getAppState().panelDidResize({ this.application.getAppState().panelDidResize(
name: PANEL_NAME_TAGS, PANEL_NAME_TAGS,
collapsed: isCollapsed isCollapsed
}); );
} }
registerComponentHandler() { registerComponentHandler() {

View File

@@ -1,6 +1,6 @@
import { isDesktopApplication, isNullOrUndefined } from '@/utils'; import { isDesktopApplication, isNullOrUndefined } from '@/utils';
import template from '%/directives/account-menu.pug'; import template from '%/directives/account-menu.pug';
import { ProtectedActions } from 'snjs'; import { ProtectedAction } from 'snjs';
import { PureCtrl } from '@Controllers'; import { PureCtrl } from '@Controllers';
import { import {
STRING_ACCOUNT_MENU_UNCHECK_MERGE, STRING_ACCOUNT_MENU_UNCHECK_MERGE,
@@ -278,11 +278,11 @@ class AccountMenuCtrl extends PureCtrl {
this.application.presentPrivilegesManagementModal(); this.application.presentPrivilegesManagementModal();
}; };
const needsPrivilege = await this.application.privilegesService.actionRequiresPrivilege( const needsPrivilege = await this.application.privilegesService.actionRequiresPrivilege(
ProtectedActions.ManagePrivileges ProtectedAction.ManagePrivileges
); );
if (needsPrivilege) { if (needsPrivilege) {
this.application.presentPrivilegesModal( this.application.presentPrivilegesModal(
ProtectedActions.ManagePrivileges, ProtectedAction.ManagePrivileges,
() => { () => {
run(); run();
} }
@@ -355,11 +355,11 @@ class AccountMenuCtrl extends PureCtrl {
} }
}; };
const needsPrivilege = await this.application.privilegesService.actionRequiresPrivilege( const needsPrivilege = await this.application.privilegesService.actionRequiresPrivilege(
ProtectedActions.ManageBackups ProtectedAction.ManageBackups
); );
if (needsPrivilege) { if (needsPrivilege) {
this.application.presentPrivilegesModal( this.application.presentPrivilegesModal(
ProtectedActions.ManageBackups, ProtectedAction.ManageBackups,
run run
); );
} else { } else {
@@ -438,11 +438,11 @@ class AccountMenuCtrl extends PureCtrl {
this.reloadAutoLockInterval(); this.reloadAutoLockInterval();
}; };
const needsPrivilege = await this.application.privilegesService.actionRequiresPrivilege( const needsPrivilege = await this.application.privilegesService.actionRequiresPrivilege(
ProtectedActions.ManagePasscode ProtectedAction.ManagePasscode
); );
if (needsPrivilege) { if (needsPrivilege) {
this.application.presentPrivilegesModal( this.application.presentPrivilegesModal(
ProtectedActions.ManagePasscode, ProtectedAction.ManagePasscode,
() => { () => {
run(); run();
} }
@@ -497,11 +497,11 @@ class AccountMenuCtrl extends PureCtrl {
this.addPasscodeClicked(); this.addPasscodeClicked();
}; };
const needsPrivilege = await this.application.privilegesService.actionRequiresPrivilege( const needsPrivilege = await this.application.privilegesService.actionRequiresPrivilege(
ProtectedActions.ManagePasscode ProtectedAction.ManagePasscode
); );
if (needsPrivilege) { if (needsPrivilege) {
this.application.presentPrivilegesModal( this.application.presentPrivilegesModal(
ProtectedActions.ManagePasscode, ProtectedAction.ManagePasscode,
run run
); );
} else { } else {
@@ -525,11 +525,11 @@ class AccountMenuCtrl extends PureCtrl {
}); });
}; };
const needsPrivilege = await this.application.privilegesService.actionRequiresPrivilege( const needsPrivilege = await this.application.privilegesService.actionRequiresPrivilege(
ProtectedActions.ManagePasscode ProtectedAction.ManagePasscode
); );
if (needsPrivilege) { if (needsPrivilege) {
this.application.presentPrivilegesModal( this.application.presentPrivilegesModal(
ProtectedActions.ManagePasscode, ProtectedAction.ManagePasscode,
run run
); );
} else { } else {

View File

@@ -1,5 +1,7 @@
import { WebApplication } from './../../application';
import { PasswordWizardScope, PasswordWizardType, WebDirective } from './../../types';
import template from '%/directives/password-wizard.pug'; import template from '%/directives/password-wizard.pug';
import { PureCtrl } from '@Controllers'; import { PureCtrl } from '@Controllers/abstract/pure_ctrl';
const DEFAULT_CONTINUE_TITLE = "Continue"; const DEFAULT_CONTINUE_TITLE = "Continue";
const Steps = { const Steps = {
@@ -7,15 +9,19 @@ const Steps = {
FinishStep: 2 FinishStep: 2
}; };
class PasswordWizardCtrl extends PureCtrl { class PasswordWizardCtrl extends PureCtrl implements PasswordWizardScope {
$element: JQLite
application!: WebApplication
type!: PasswordWizardType
isContinuing = false
/* @ngInject */ /* @ngInject */
constructor( constructor(
$element, $element: JQLite,
$timeout, $timeout: ng.ITimeoutService,
) { ) {
super($timeout); super($timeout);
this.$element = $element; this.$element = $element;
this.$timeout = $timeout;
this.registerWindowUnloadStopper(); this.registerWindowUnloadStopper();
} }
@@ -23,8 +29,8 @@ class PasswordWizardCtrl extends PureCtrl {
super.$onInit(); super.$onInit();
this.initProps({ this.initProps({
type: this.type, type: this.type,
changePassword: this.type === 'change-pw', changePassword: this.type === PasswordWizardType.ChangePassword,
securityUpdate: this.type === 'upgrade-security' securityUpdate: this.type === PasswordWizardType.AccountUpgrade
}); });
this.setState({ this.setState({
formData: {}, formData: {},
@@ -41,7 +47,7 @@ class PasswordWizardCtrl extends PureCtrl {
/** Confirms with user before closing tab */ /** Confirms with user before closing tab */
registerWindowUnloadStopper() { registerWindowUnloadStopper() {
window.onbeforeunload = (e) => { window.onbeforeunload = () => {
return true; return true;
}; };
} }
@@ -86,7 +92,7 @@ class PasswordWizardCtrl extends PureCtrl {
}); });
} }
async setFormDataState(formData) { async setFormDataState(formData: any) {
return this.setState({ return this.setState({
formData: { formData: {
...this.state.formData, ...this.state.formData,
@@ -99,42 +105,42 @@ class PasswordWizardCtrl extends PureCtrl {
const currentPassword = this.state.formData.currentPassword; const currentPassword = this.state.formData.currentPassword;
const newPass = this.props.securityUpdate ? currentPassword : this.state.formData.newPassword; const newPass = this.props.securityUpdate ? currentPassword : this.state.formData.newPassword;
if (!currentPassword || currentPassword.length === 0) { if (!currentPassword || currentPassword.length === 0) {
this.application.alertService.alert({ this.application.alertService!.alert(
text: "Please enter your current password." "Please enter your current password."
}); );
return false; return false;
} }
if (this.props.changePassword) { if (this.props.changePassword) {
if (!newPass || newPass.length === 0) { if (!newPass || newPass.length === 0) {
this.application.alertService.alert({ this.application.alertService!.alert(
text: "Please enter a new password." "Please enter a new password."
}); );
return false; return false;
} }
if (newPass !== this.state.formData.newPasswordConfirmation) { if (newPass !== this.state.formData.newPasswordConfirmation) {
this.application.alertService.alert({ this.application.alertService!.alert(
text: "Your new password does not match its confirmation." "Your new password does not match its confirmation."
}); );
this.state.formData.status = null; this.state.formData.status = null;
return false; return false;
} }
} }
if (!this.application.getUser().email) { if (!this.application.getUser()?.email) {
this.application.alertService.alert({ this.application.alertService!.alert(
text: "We don't have your email stored. Please log out then log back in to fix this issue." "We don't have your email stored. Please log out then log back in to fix this issue."
}); );
this.state.formData.status = null; this.state.formData.status = null;
return false; return false;
} }
/** Validate current password */ /** Validate current password */
const success = await this.application.validateAccountPassword({ const success = await this.application.validateAccountPassword(
password: this.state.formData.currentPassword this.state.formData.currentPassword
}); );
if (!success) { if (!success) {
this.application.alertService.alert({ this.application.alertService!.alert(
text: "The current password you entered is not correct. Please try again." "The current password you entered is not correct. Please try again."
}); );
} }
return success; return success;
} }
@@ -150,21 +156,21 @@ class PasswordWizardCtrl extends PureCtrl {
const newPassword = this.props.securityUpdate const newPassword = this.props.securityUpdate
? this.state.formData.currentPassword ? this.state.formData.currentPassword
: this.state.formData.newPassword; : this.state.formData.newPassword;
const response = await this.application.changePassword({ const response = await this.application.changePassword(
currentPassword: this.state.formData.currentPassword, this.state.formData.currentPassword,
newPassword: newPassword newPassword
}); );
const success = !response.error; const success = !response || !response.error;
this.setFormDataState({ this.setFormDataState({
statusError: !success, statusError: !success,
processing: success processing: success
}); });
if (!success) { if (!success) {
this.application.alertService.alert({ this.application.alertService!.alert(
text: response.error.message response!.error.message
? response.error.message ? response!.error.message
: "There was an error changing your password. Please try again." : "There was an error changing your password. Please try again."
}); );
this.setFormDataState({ this.setFormDataState({
status: "Unable to process your password. Please try again." status: "Unable to process your password. Please try again."
}); });
@@ -184,9 +190,9 @@ class PasswordWizardCtrl extends PureCtrl {
dismiss() { dismiss() {
if (this.state.lockContinue) { if (this.state.lockContinue) {
this.application.alertService.alert({ this.application.alertService!.alert(
text: "Cannot close window until pending tasks are complete." "Cannot close window until pending tasks are complete."
}); );
} else { } else {
const elem = this.$element; const elem = this.$element;
const scope = elem.scope(); const scope = elem.scope();
@@ -196,8 +202,9 @@ class PasswordWizardCtrl extends PureCtrl {
} }
} }
export class PasswordWizard { export class PasswordWizard extends WebDirective {
constructor() { constructor() {
super();
this.restrict = 'E'; this.restrict = 'E';
this.template = template; this.template = template;
this.controller = PasswordWizardCtrl; this.controller = PasswordWizardCtrl;

View File

@@ -1,4 +1,4 @@
import { EncryptionIntents, ProtectedActions } from 'snjs'; import { EncryptionIntents, ProtectedAction } from 'snjs';
export class ArchiveManager { export class ArchiveManager {
constructor(application) { constructor(application) {
@@ -30,8 +30,8 @@ export class ArchiveManager {
}); });
}; };
if (await this.application.privilegesService.actionRequiresPrivilege(ProtectedActions.ManageBackups)) { if (await this.application.privilegesService.actionRequiresPrivilege(ProtectedAction.ManageBackups)) {
this.application.presentPrivilegesModal(ProtectedActions.ManageBackups, () => { this.application.presentPrivilegesModal(ProtectedAction.ManageBackups, () => {
run(); run();
}); });
} else { } else {

View File

@@ -210,8 +210,6 @@ export class DesktopManager extends ApplicationService {
} }
desktop_didFinishBackup(success) { desktop_didFinishBackup(success) {
this.application.getAppState().endedBackupDownload({ this.application.getAppState().endedBackupDownload(success);
success: success
});
} }
} }

View File

@@ -1,5 +1,5 @@
import { isDesktopApplication } from '@/utils'; import { isDesktopApplication } from '@/utils';
import { AppStateEvents } from '@/services/state'; import { AppStateEvent } from '@/services/state';
const MILLISECONDS_PER_SECOND = 1000; const MILLISECONDS_PER_SECOND = 1000;
const FOCUS_POLL_INTERVAL = 1 * MILLISECONDS_PER_SECOND; const FOCUS_POLL_INTERVAL = 1 * MILLISECONDS_PER_SECOND;
@@ -21,9 +21,9 @@ export class LockManager {
observeVisibility() { observeVisibility() {
this.unsubState = this.application.getAppState().addObserver((eventName) => { this.unsubState = this.application.getAppState().addObserver((eventName) => {
if(eventName === AppStateEvents.WindowDidBlur) { if(eventName === AppStateEvent.WindowDidBlur) {
this.documentVisibilityChanged(false); this.documentVisibilityChanged(false);
} else if(eventName === AppStateEvents.WindowDidFocus) { } else if(eventName === AppStateEvent.WindowDidFocus) {
this.documentVisibilityChanged(true); this.documentVisibilityChanged(true);
} }
}); });

View File

@@ -1,53 +1,76 @@
import { WebApplication } from './../application';
import { isDesktopApplication } from '@/utils'; import { isDesktopApplication } from '@/utils';
import pull from 'lodash/pull'; import pull from 'lodash/pull';
import { ProtectedActions, ApplicationEvent } from 'snjs'; import { ProtectedAction, ApplicationEvent, SNTag, SNNote, SNUserPrefs } from 'snjs';
export const AppStateEvents = { export enum AppStateEvent {
TagChanged: 1, TagChanged = 1,
NoteChanged: 2, NoteChanged = 2,
PreferencesChanged: 3, PreferencesChanged = 3,
PanelResized: 4, PanelResized = 4,
EditorFocused: 5, EditorFocused = 5,
BeganBackupDownload: 6, BeganBackupDownload = 6,
EndedBackupDownload: 7, EndedBackupDownload = 7,
DesktopExtsReady: 8, DesktopExtsReady = 8,
WindowDidFocus: 9, WindowDidFocus = 9,
WindowDidBlur: 10, WindowDidBlur = 10,
}; };
export const EventSources = { export enum EventSource {
UserInteraction: 1, UserInteraction = 1,
Script: 2 Script = 2
}; };
type ObserverCallback = (event: AppStateEvent, data?: any) => Promise<void>
export class AppState { export class AppState {
$rootScope: ng.IRootScopeService
$timeout: ng.ITimeoutService
application: WebApplication
observers: ObserverCallback[] = []
locked = true
unsubApp: any
rootScopeCleanup1: any
rootScopeCleanup2: any
onVisibilityChange: any
selectedTag?: SNTag
selectedNote?: SNNote
userPreferences?: SNUserPrefs
/* @ngInject */ /* @ngInject */
constructor( constructor(
$rootScope, $rootScope: ng.IRootScopeService,
$timeout, $timeout: ng.ITimeoutService,
application application: WebApplication
) { ) {
this.$timeout = $timeout; this.$timeout = $timeout;
this.$rootScope = $rootScope; this.$rootScope = $rootScope;
this.application = application; this.application = application;
this.observers = [];
this.locked = true;
this.registerVisibilityObservers(); this.registerVisibilityObservers();
this.addAppEventObserver(); this.addAppEventObserver();
const onVisibilityChange = () => {
const visible = document.visibilityState === "visible";
const event = visible
? AppStateEvent.WindowDidFocus
: AppStateEvent.WindowDidBlur;
this.notifyEvent(event);
}
this.onVisibilityChange = onVisibilityChange.bind(this);
} }
deinit() { deinit() {
this.unsubApp(); this.unsubApp();
this.unsubApp = null; this.unsubApp = undefined;
this.observers.length = 0; this.observers.length = 0;
if (this.rootScopeCleanup1) { if (this.rootScopeCleanup1) {
this.rootScopeCleanup1(); this.rootScopeCleanup1();
this.rootScopeCleanup2(); this.rootScopeCleanup2();
this.rootScopeCleanup1 = null; this.rootScopeCleanup1 = undefined;
this.rootScopeCleanup2 = null; this.rootScopeCleanup2 = undefined;
} }
document.removeEventListener('visibilitychange', this.onVisibilityChange); document.removeEventListener('visibilitychange', this.onVisibilityChange);
this.onVisibilityChange = null; this.onVisibilityChange = undefined;
} }
addAppEventObserver() { addAppEventObserver() {
@@ -67,10 +90,10 @@ export class AppState {
registerVisibilityObservers() { registerVisibilityObservers() {
if (isDesktopApplication()) { if (isDesktopApplication()) {
this.rootScopeCleanup1 = this.$rootScope.$on('window-lost-focus', () => { this.rootScopeCleanup1 = this.$rootScope.$on('window-lost-focus', () => {
this.notifyEvent(AppStateEvents.WindowDidBlur); this.notifyEvent(AppStateEvent.WindowDidBlur);
}); });
this.rootScopeCleanup2 = this.$rootScope.$on('window-gained-focus', () => { this.rootScopeCleanup2 = this.$rootScope.$on('window-gained-focus', () => {
this.notifyEvent(AppStateEvents.WindowDidFocus); this.notifyEvent(AppStateEvent.WindowDidFocus);
}); });
} else { } else {
/* Tab visibility listener, web only */ /* Tab visibility listener, web only */
@@ -79,23 +102,15 @@ export class AppState {
} }
} }
onVisibilityChange() {
const visible = document.visibilityState === "visible";
const event = visible
? AppStateEvents.WindowDidFocus
: AppStateEvents.WindowDidBlur;
this.notifyEvent(event);
}
/** @returns A function that unregisters this observer */ /** @returns A function that unregisters this observer */
addObserver(callback) { addObserver(callback: ObserverCallback) {
this.observers.push(callback); this.observers.push(callback);
return () => { return () => {
pull(this.observers, callback); pull(this.observers, callback);
}; };
} }
async notifyEvent(eventName, data) { async notifyEvent(eventName: AppStateEvent, data?: any) {
/** /**
* Timeout is particullary important so we can give all initial * Timeout is particullary important so we can give all initial
* controllers a chance to construct before propogting any events * * controllers a chance to construct before propogting any events *
@@ -110,14 +125,14 @@ export class AppState {
}); });
} }
setSelectedTag(tag) { setSelectedTag(tag: SNTag) {
if (this.selectedTag === tag) { if (this.selectedTag === tag) {
return; return;
} }
const previousTag = this.selectedTag; const previousTag = this.selectedTag;
this.selectedTag = tag; this.selectedTag = tag;
this.notifyEvent( this.notifyEvent(
AppStateEvents.TagChanged, AppStateEvent.TagChanged,
{ {
tag: tag, tag: tag,
previousTag: previousTag previousTag: previousTag
@@ -125,22 +140,22 @@ export class AppState {
); );
} }
async setSelectedNote(note) { async setSelectedNote(note: SNNote) {
const run = async () => { const run = async () => {
const previousNote = this.selectedNote; const previousNote = this.selectedNote;
this.selectedNote = note; this.selectedNote = note;
await this.notifyEvent( await this.notifyEvent(
AppStateEvents.NoteChanged, AppStateEvent.NoteChanged,
{ previousNote: previousNote } { previousNote: previousNote }
); );
}; };
if (note && note.content.protected && if (note && note.safeContent.protected &&
await this.application.application.privilegesService.actionRequiresPrivilege( await this.application.privilegesService!.actionRequiresPrivilege(
ProtectedActions.ViewProtectedNotes ProtectedAction.ViewProtectedNotes
)) { )) {
return new Promise((resolve) => { return new Promise((resolve) => {
this.application.presentPrivilegesModal( this.application.presentPrivilegesModal(
ProtectedActions.ViewProtectedNotes, ProtectedAction.ViewProtectedNotes,
() => { () => {
run().then(resolve); run().then(resolve);
} }
@@ -159,16 +174,16 @@ export class AppState {
return this.selectedNote; return this.selectedNote;
} }
setUserPreferences(preferences) { setUserPreferences(preferences: SNUserPrefs) {
this.userPreferences = preferences; this.userPreferences = preferences;
this.notifyEvent( this.notifyEvent(
AppStateEvents.PreferencesChanged AppStateEvent.PreferencesChanged
); );
} }
panelDidResize({ name, collapsed }) { panelDidResize(name: string, collapsed: boolean) {
this.notifyEvent( this.notifyEvent(
AppStateEvents.PanelResized, AppStateEvent.PanelResized,
{ {
panel: name, panel: name,
collapsed: collapsed collapsed: collapsed
@@ -176,22 +191,22 @@ export class AppState {
); );
} }
editorDidFocus(eventSource) { editorDidFocus(eventSource: EventSource) {
this.notifyEvent( this.notifyEvent(
AppStateEvents.EditorFocused, AppStateEvent.EditorFocused,
{ eventSource: eventSource } { eventSource: eventSource }
); );
} }
beganBackupDownload() { beganBackupDownload() {
this.notifyEvent( this.notifyEvent(
AppStateEvents.BeganBackupDownload AppStateEvent.BeganBackupDownload
); );
} }
endedBackupDownload({ success }) { endedBackupDownload(success: boolean) {
this.notifyEvent( this.notifyEvent(
AppStateEvents.EndedBackupDownload, AppStateEvent.EndedBackupDownload,
{ success: success } { success: success }
); );
} }
@@ -201,8 +216,7 @@ export class AppState {
*/ */
desktopExtensionsReady() { desktopExtensionsReady() {
this.notifyEvent( this.notifyEvent(
AppStateEvents.DesktopExtsReady AppStateEvent.DesktopExtsReady
); );
} }
} }

View File

@@ -5,7 +5,7 @@ import {
EncryptionIntents, EncryptionIntents,
ApplicationService, ApplicationService,
} from 'snjs'; } from 'snjs';
import { AppStateEvents } from '@/services/state'; import { AppStateEvent } from '@/services/state';
const CACHED_THEMES_KEY = 'cachedThemes'; const CACHED_THEMES_KEY = 'cachedThemes';
@@ -15,7 +15,7 @@ export class ThemeManager extends ApplicationService {
this.activeThemes = []; this.activeThemes = [];
setImmediate(() => { setImmediate(() => {
this.unsubState = this.application.getAppState().addObserver((eventName, data) => { this.unsubState = this.application.getAppState().addObserver((eventName, data) => {
if (eventName === AppStateEvents.DesktopExtsReady) { if (eventName === AppStateEvent.DesktopExtsReady) {
this.activateCachedThemes(); this.activateCachedThemes();
} }
}); });

View File

@@ -7,7 +7,7 @@
"strict": true, "strict": true,
"isolatedModules": true, "isolatedModules": true,
"esModuleInterop": true, "esModuleInterop": true,
"types": ["node", "../../../node_modules/snjs/dist/@types"], "types": ["node"],
"declaration": true, "declaration": true,
"declarationDir": "@types", "declarationDir": "@types",
"emitDeclarationOnly": true, "emitDeclarationOnly": true,
@@ -17,10 +17,5 @@
"@/*": ["./*"], "@/*": ["./*"],
"@Controllers/*": ["./controllers/*"] "@Controllers/*": ["./controllers/*"]
} }
}, }
"typeAcquisition": {
"include": [
"snjs"
]
}
} }

View File

@@ -1,4 +1,18 @@
export class WebDirective implements ng.IDirective {
controller?: string | ng.Injectable<ng.IControllerConstructor>;
controllerAs?: string;
bindToController?: boolean | { [boundProperty: string]: string };
restrict?: string;
scope?: boolean | { [boundProperty: string]: string };
template?: string | ((tElement: any, tAttrs: any) => string);
}
export enum PasswordWizardType { export enum PasswordWizardType {
ChangePassword = 1, ChangePassword = 1,
AccountUpgrade = 2 AccountUpgrade = 2
}
export interface PasswordWizardScope extends Partial<ng.IScope> {
type: PasswordWizardType,
application: any
} }

View File

@@ -0,0 +1,5 @@
declare module "*.pug" {
import { compileTemplate } from 'pug'
const content: compileTemplate;
export default content;
}

6
package-lock.json generated
View File

@@ -1670,6 +1670,12 @@
"integrity": "sha512-ASYsaKecA7TUsDrqIGPNk3JeEox0z/0XR/WsJJ8BIX/9+SkMSImQXKWfU/yBrSyc7ZSE/NPqLu36Nur0miCFfQ==", "integrity": "sha512-ASYsaKecA7TUsDrqIGPNk3JeEox0z/0XR/WsJJ8BIX/9+SkMSImQXKWfU/yBrSyc7ZSE/NPqLu36Nur0miCFfQ==",
"dev": true "dev": true
}, },
"@types/pug": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.4.tgz",
"integrity": "sha1-h3L80EGOPNLMFxVV1zAHQVBR9LI=",
"dev": true
},
"@typescript-eslint/eslint-plugin": { "@typescript-eslint/eslint-plugin": {
"version": "2.27.0", "version": "2.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.27.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.27.0.tgz",

View File

@@ -22,13 +22,14 @@
"@babel/plugin-proposal-class-properties": "^7.8.3", "@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.8.3", "@babel/plugin-transform-runtime": "^7.8.3",
"@babel/preset-env": "^7.8.7", "@babel/preset-env": "^7.8.7",
"@babel/runtime": "^7.8.7",
"@babel/preset-typescript": "^7.8.3", "@babel/preset-typescript": "^7.8.3",
"@babel/runtime": "^7.8.7",
"@types/angular": "^1.7.0", "@types/angular": "^1.7.0",
"@types/chai": "^4.2.11", "@types/chai": "^4.2.11",
"@types/lodash": "^4.14.149", "@types/lodash": "^4.14.149",
"@types/mocha": "^7.0.2", "@types/mocha": "^7.0.2",
"@types/node": "^12.12.30", "@types/node": "^12.12.30",
"@types/pug": "^2.0.4",
"@typescript-eslint/eslint-plugin": "^2.23.0", "@typescript-eslint/eslint-plugin": "^2.23.0",
"@typescript-eslint/parser": "^2.23.0", "@typescript-eslint/parser": "^2.23.0",
"angular": "1.7.9", "angular": "1.7.9",