Merge branch 'release/3.5.8'

This commit is contained in:
Baptiste Grob
2020-11-12 12:02:14 +01:00
17 changed files with 156 additions and 366 deletions

76
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at help@standardnotes.org. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

View File

@@ -18,7 +18,7 @@ import {
TagsView,
NotesView,
FooterView,
ChallengeModal
ChallengeModal,
} from '@/views';
import {
@@ -30,7 +30,7 @@ import {
infiniteScroll,
lowercase,
selectOnFocus,
snEnter
snEnter,
} from './directives/functional';
import {
@@ -48,27 +48,23 @@ import {
PrivilegesManagementModal,
RevisionPreviewModal,
HistoryMenu,
SyncResolutionMenu
SyncResolutionMenu,
} from './directives/views';
import { trusted } from './filters';
import { isDev } from './utils';
import { Bridge, BrowserBridge } from './services/bridge';
import { startErrorReporting } from './services/errorReporting';
import { alertDialog } from './services/alertService';
if (__WEB__) {
startApplication(
(window as any)._default_sync_server,
new BrowserBridge()
);
startApplication((window as any)._default_sync_server, new BrowserBridge());
} else {
(window as any).startApplication = startApplication;
}
async function startApplication(
defaultSyncServerHost: string,
bridge: Bridge
) {
async function startApplication(defaultSyncServerHost: string, bridge: Bridge) {
notifyBetaPeriodEnd();
SNLog.onLog = console.log;
startErrorReporting();
@@ -92,7 +88,7 @@ async function startApplication(
.directive('editorView', () => new EditorView())
.directive('tagsView', () => new TagsView())
.directive('notesView', () => new NotesView())
.directive('footerView', () => new FooterView())
.directive('footerView', () => new FooterView());
// Directives - Functional
angular
@@ -123,15 +119,16 @@ async function startApplication(
.directive('passwordWizard', () => new PasswordWizard())
.directive('permissionsModal', () => new PermissionsModal())
.directive('privilegesAuthModal', () => new PrivilegesAuthModal())
.directive('privilegesManagementModal', () => new PrivilegesManagementModal())
.directive(
'privilegesManagementModal',
() => new PrivilegesManagementModal()
)
.directive('revisionPreviewModal', () => new RevisionPreviewModal())
.directive('historyMenu', () => new HistoryMenu())
.directive('syncResolutionMenu', () => new SyncResolutionMenu());
// Filters
angular
.module('app')
.filter('trusted', ['$sce', trusted]);
angular.module('app').filter('trusted', ['$sce', trusted]);
// Services
angular.module('app').service('mainApplicationGroup', ApplicationGroup);
@@ -141,8 +138,10 @@ async function startApplication(
Object.defineProperties(window, {
application: {
get: () =>
(angular.element(document).injector().get('mainApplicationGroup') as any)
.primaryApplication
(angular
.element(document)
.injector()
.get('mainApplicationGroup') as any).primaryApplication,
},
});
}
@@ -151,3 +150,16 @@ async function startApplication(
angular.bootstrap(document, ['app']);
});
}
function notifyBetaPeriodEnd() {
if (window.location.hostname === 'app-beta.standardnotes.org') {
alertDialog({
title: 'Beta period has ended',
text:
'Thank you for trying this beta version. Please sign out, then ' +
'sign in to <a href="https://app.standardnotes.org" target="_blank">' +
'app.standardnotes.org</a> ' +
'to continue using Standard Notes.',
});
}
}

View File

@@ -1,280 +0,0 @@
import template from '%/directives/component-view.pug';
import { isDesktopApplication } from '../../utils';
/**
* The maximum amount of time we'll wait for a component
* to load before displaying error
*/
const MAX_LOAD_THRESHOLD = 4000;
const VISIBILITY_CHANGE_LISTENER_KEY = 'visibilitychange';
class ComponentViewCtrl {
/* @ngInject */
constructor(
$scope,
$rootScope,
$timeout,
componentManager,
desktopManager,
themeManager
) {
this.$rootScope = $rootScope;
this.$timeout = $timeout;
this.themeManager = themeManager;
this.desktopManager = desktopManager;
this.componentManager = componentManager;
this.componentValid = true;
this.destroyed = false;
$scope.$watch('ctrl.component', (component, prevComponent) => {
this.componentValueDidSet(component, prevComponent);
});
$scope.$on('ext-reload-complete', () => {
this.reloadStatus(false);
});
$scope.$on('$destroy', () => {
this.destroyed = true;
this.destroy();
});
}
$onInit() {
this.registerComponentHandlers();
this.registerPackageUpdateObserver();
};
registerPackageUpdateObserver() {
this.updateObserver = this.desktopManager
.registerUpdateObserver((component) => {
if(component === this.component && component.active) {
this.reloadComponent();
}
});
}
registerComponentHandlers() {
this.themeHandlerIdentifier = 'component-view-' + Math.random();
this.componentManager.registerHandler({
identifier: this.themeHandlerIdentifier,
areas: ['themes'],
activationHandler: (component) => {
this.reloadThemeStatus();
}
});
this.identifier = 'component-view-' + Math.random();
this.componentManager.registerHandler({
identifier: this.identifier,
areas: [this.component.area],
activationHandler: (component) => {
if(component !== this.component) {
return;
}
this.$timeout(() => {
this.handleActivation();
});
},
actionHandler: (component, action, data) => {
if(action === 'set-size') {
this.componentManager.handleSetSizeEvent(component, data);
}
}
});
}
onVisibilityChange() {
if(document.visibilityState === 'hidden') {
return;
}
if(this.issueLoading) {
this.reloadComponent();
}
}
async reloadComponent() {
this.componentValid = false;
await this.componentManager.reloadComponent(this.component);
if (this.destroyed) return;
this.reloadStatus();
}
reloadStatus(doManualReload = true) {
this.reloading = true;
const component = this.component;
const previouslyValid = this.componentValid;
const offlineRestricted = component.offlineOnly && !isDesktopApplication();
const hasUrlError = function(){
if(isDesktopApplication()) {
return !component.local_url && !component.hasValidHostedUrl();
} else {
return !component.hasValidHostedUrl();
}
}();
this.expired = component.valid_until && component.valid_until <= new Date();
if(!component.lockReadonly) {
component.readonly = this.expired;
}
this.componentValid = !offlineRestricted && !hasUrlError;
if(!this.componentValid) {
this.loading = false;
}
if(offlineRestricted) {
this.error = 'offline-restricted';
} else if(hasUrlError) {
this.error = 'url-missing';
} else {
this.error = null;
}
if(this.componentValid !== previouslyValid) {
if(this.componentValid) {
this.componentManager.reloadComponent(component, true);
}
}
if(this.expired && doManualReload) {
this.$rootScope.$broadcast('reload-ext-data');
}
this.reloadThemeStatus();
this.$timeout(() => {
this.reloading = false;
}, 500);
}
handleActivation() {
if(!this.component.active) {
return;
}
const iframe = this.componentManager.iframeForComponent(
this.component
);
if(!iframe) {
return;
}
this.loading = true;
if(this.loadTimeout) {
this.$timeout.cancel(this.loadTimeout);
}
this.loadTimeout = this.$timeout(() => {
this.handleIframeLoadTimeout();
}, MAX_LOAD_THRESHOLD);
iframe.onload = (event) => {
this.handleIframeLoad(iframe);
};
}
async handleIframeLoadTimeout() {
if(this.loading) {
this.loading = false;
this.issueLoading = true;
if(!this.didAttemptReload) {
this.didAttemptReload = true;
this.reloadComponent();
} else {
document.addEventListener(
VISIBILITY_CHANGE_LISTENER_KEY,
this.onVisibilityChange.bind(this)
);
}
}
}
async handleIframeLoad(iframe) {
let desktopError = false;
if(isDesktopApplication()) {
try {
/** Accessing iframe.contentWindow.origin only allowed in desktop app. */
if(!iframe.contentWindow.origin || iframe.contentWindow.origin === 'null') {
desktopError = true;
}
} catch (e) {}
}
this.$timeout.cancel(this.loadTimeout);
await this.componentManager.registerComponentWindow(
this.component,
iframe.contentWindow
);
const avoidFlickerTimeout = 7;
this.$timeout(() => {
this.loading = false;
// eslint-disable-next-line no-unneeded-ternary
this.issueLoading = desktopError ? true : false;
this.onLoad && this.onLoad(this.component);
}, avoidFlickerTimeout);
}
componentValueDidSet(component, prevComponent) {
const dontSync = true;
if(prevComponent && component !== prevComponent) {
this.componentManager.deactivateComponent(
prevComponent,
dontSync
);
}
if(component) {
this.componentManager.activateComponent(
component,
dontSync
);
this.reloadStatus();
}
}
reloadThemeStatus() {
if(this.component.acceptsThemes()) {
return;
}
if(this.themeManager.hasActiveTheme()) {
if(!this.dismissedNoThemesMessage) {
this.showNoThemesMessage = true;
}
} else {
this.showNoThemesMessage = false;
}
}
dismissNoThemesMessage() {
this.showNoThemesMessage = false;
this.dismissedNoThemesMessage = true;
}
disableActiveTheme() {
this.themeManager.deactivateAllThemes();
this.dismissNoThemesMessage();
}
getUrl() {
const url = this.componentManager.urlForComponent(this.component);
this.component.runningLocally = (url === this.component.local_url);
return url;
}
destroy() {
this.componentManager.deregisterHandler(this.themeHandlerIdentifier);
this.componentManager.deregisterHandler(this.identifier);
if(this.component && !this.manualDealloc) {
const dontSync = true;
this.componentManager.deactivateComponent(this.component, dontSync);
}
this.desktopManager.deregisterUpdateObserver(this.updateObserver);
document.removeEventListener(
VISIBILITY_CHANGE_LISTENER_KEY,
this.onVisibilityChange.bind(this)
);
}
}
export class ComponentView {
constructor() {
this.restrict = 'E';
this.template = template;
this.scope = {
component: '=',
onLoad: '=?',
manualDealloc: '=?'
};
this.controller = ComponentViewCtrl;
this.controllerAs = 'ctrl';
this.bindToController = true;
}
}

View File

@@ -76,7 +76,7 @@ class ApplicationViewCtrl extends PureViewCtrl {
async onAppLaunch() {
super.onAppLaunch();
this.setState({ needsUnlock: false });
this.handleAutoSignInFromParams();
this.handleDemoSignInFromParams();
}
onUpdateAvailable() {
@@ -142,28 +142,19 @@ class ApplicationViewCtrl extends PureViewCtrl {
}
}
async handleAutoSignInFromParams() {
const params = this.$location!.search();
const server = params.server;
const email = params.email;
const password = params.pw;
if (!server || !email || !password) return;
const user = this.application!.getUser();
if (user) {
if (user.email === email && await this.application!.getHost() === server) {
/** Already signed in, return */
return;
} else {
/** Sign out */
await this.application!.signOut();
}
async handleDemoSignInFromParams() {
if (
this.$location!.search().demo === 'true' &&
!this.application.hasAccount()
) {
await this.application!.setHost(
'https://syncing-server-demo.standardnotes.org'
);
this.application!.signIn(
'demo@standardnotes.org',
'password',
);
}
await this.application!.setHost(server);
this.application!.signIn(
email,
password,
);
}
}

View File

@@ -1,6 +1,6 @@
import { RootScopeMessages } from './../../messages';
import { ApplicationGroup } from '@/ui_models/application_group';
import { FooterStatus, WebDirective } from '@/types';
import { WebDirective } from '@/types';
import { dateToLocalizedString, preventRefreshing } from '@/utils';
import {
ApplicationEvent,
@@ -10,10 +10,7 @@ import {
SNComponent,
SNTheme,
ComponentArea,
ComponentAction,
topLevelCompare,
CollectionSort,
ComponentMutator
} from 'snjs';
import template from './footer-view.pug';
import { AppStateEvent, EventSource } from '@/ui_models/app_state';

View File

@@ -53,7 +53,7 @@ module Web
media_src: %w('self'),
object_src: %w('self'),
plugin_types: %w(),
script_src: %w('self' 'unsafe-inline' 'wasm-eval' 'unsafe-eval'),
script_src: %w('self' 'unsafe-inline' 'unsafe-eval'),
style_src: %w(* 'unsafe-inline'),
upgrade_insecure_requests: false, # see https://www.w3.org/TR/upgrade-insecure-requests/
}

View File

@@ -1,6 +1,6 @@
import { ApplicationService } from 'snjs';
export declare class AutolockService extends ApplicationService {
private unsubState;
private unsubState?;
private pollFocusInterval;
private lastFocusState?;
private lockAfterDate?;

View File

@@ -0,0 +1 @@
export declare function startErrorReporting(): void;

View File

@@ -0,0 +1,8 @@
export declare enum StorageKey {
DisableErrorReporting = "DisableErrorReporting"
}
export declare const storage: {
get(key: StorageKey): any;
set(key: StorageKey, value: unknown): void;
remove(key: StorageKey): void;
};

View File

@@ -1,11 +1,13 @@
import { WebApplication } from '@/ui_models/application';
import { ApplicationService, WebPrefKey } from 'snjs';
import { ApplicationService, WebPrefKey, ApplicationEvent } from 'snjs';
export declare class PreferencesManager extends ApplicationService {
private userPreferences;
private loadingPrefs;
private unubscribeStreamItems?;
private needsSingletonReload;
/** @override */
onAppLaunch(): Promise<void>;
onAppEvent(event: ApplicationEvent): Promise<void>;
deinit(): void;
get webApplication(): WebApplication;
streamPreferences(): void;

View File

@@ -14,6 +14,8 @@ export declare const STRING_INVALID_NOTE = "The note you are attempting to save
export declare const STRING_ELLIPSES = "...";
export declare const STRING_GENERIC_SAVE_ERROR = "There was an error saving your note. Please try again.";
export declare 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 declare const STRING_ARCHIVE_LOCKED_ATTEMPT = "This note is locked. If you'd like to archive it, unlock it, and try again.";
export declare const STRING_UNARCHIVE_LOCKED_ATTEMPT = "This note is locked. If you'd like to archive it, unlock it, and try again.";
export declare const STRING_DELETE_LOCKED_ATTEMPT = "This note is locked. If you'd like to delete it, unlock it, and try again.";
export declare function StringDeleteNote(title: string, permanently: boolean): string;
export declare function StringEmptyTrash(count: number): string;

View File

@@ -1,5 +1,5 @@
/// <reference types="angular" />
import { SNTag, SNNote, SNUserPrefs } from 'snjs';
import { SNTag, SNNote, SNUserPrefs, DeinitSource, UuidString } from 'snjs';
import { WebApplication } from '@/ui_models/application';
import { Editor } from '@/ui_models/editor';
export declare enum AppStateEvent {
@@ -18,6 +18,12 @@ export declare enum EventSource {
Script = 2
}
declare type ObserverCallback = (event: AppStateEvent, data?: any) => Promise<void>;
declare class ActionsMenuState {
hiddenExtensions: Record<UuidString, boolean>;
constructor();
toggleExtensionVisibility(uuid: UuidString): void;
deinit(): void;
}
export declare class AppState {
$rootScope: ng.IRootScopeService;
$timeout: ng.ITimeoutService;
@@ -31,8 +37,14 @@ export declare class AppState {
selectedTag?: SNTag;
userPreferences?: SNUserPrefs;
multiEditorEnabled: boolean;
showBetaWarning: boolean;
actionsMenu: ActionsMenuState;
constructor($rootScope: ng.IRootScopeService, $timeout: ng.ITimeoutService, application: WebApplication);
deinit(): void;
deinit(source: DeinitSource): void;
disableBetaWarning(): void;
enableBetaWarning(): void;
clearBetaWarning(): void;
private determineBetaWarningValue;
/**
* Creates a new editor if one doesn't exist. If one does, we'll replace the
* editor's note with an empty one.

View File

@@ -7,7 +7,7 @@ export declare class WebDeviceInterface extends DeviceInterface {
setApplication(application: SNApplication): void;
private databaseForIdentifier;
deinit(): void;
getRawStorageValue(key: string): Promise<string | null>;
getRawStorageValue(key: string): Promise<any>;
getAllRawStorageKeyValues(): Promise<{
key: string;
value: any;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

6
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "standard-notes-web",
"version": "3.5.6",
"version": "3.5.8",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -11028,8 +11028,8 @@
"from": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad"
},
"snjs": {
"version": "github:standardnotes/snjs#d6556503aae3d1ac6ca4c8f2c116430fe8f1a91b",
"from": "github:standardnotes/snjs#d6556503aae3d1ac6ca4c8f2c116430fe8f1a91b"
"version": "github:standardnotes/snjs#9e212add83688f65267c9300d7b9d2b1e5772a27",
"from": "github:standardnotes/snjs#9e212add83688f65267c9300d7b9d2b1e5772a27"
},
"sockjs": {
"version": "0.3.20",

View File

@@ -1,6 +1,6 @@
{
"name": "standard-notes-web",
"version": "3.5.6",
"version": "3.5.8",
"license": "AGPL-3.0-or-later",
"repository": {
"type": "git",
@@ -72,6 +72,6 @@
"@bugsnag/js": "^7.5.1",
"mobx": "^6.0.1",
"sncrypto": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad",
"snjs": "github:standardnotes/snjs#d6556503aae3d1ac6ca4c8f2c116430fe8f1a91b"
"snjs": "github:standardnotes/snjs#9e212add83688f65267c9300d7b9d2b1e5772a27"
}
}