Merge branch '004' into crypto-refactor

# Conflicts:
#	package.json
This commit is contained in:
Baptiste Grob
2020-06-09 16:52:01 +02:00
12 changed files with 75 additions and 45 deletions

View File

@@ -1,15 +1,9 @@
{
"presets": [
"@babel/typescript",
[
"@babel/preset-env",
{
"targets": "> 0.25%, not dead"
}
]
"@babel/preset-env"
],
"plugins": [
"@babel/plugin-transform-runtime",
"@babel/plugin-proposal-class-properties",
"angularjs-annotate"
]

6
.browserslistrc Normal file
View File

@@ -0,0 +1,6 @@
chrome 80 # electron 8.2
last 2 Firefox versions
last 2 Edge versions
last 2 Safari versions
last 2 Opera versions
Firefox ESR

View File

@@ -49,6 +49,7 @@ import {
} from './directives/views';
import { trusted } from './filters';
import { isDev } from './utils';
angular.module('app', ['ngSanitize']);
@@ -109,3 +110,14 @@ angular
// Services
angular.module('app').service('mainApplicationGroup', ApplicationGroup);
// Debug
if (isDev) {
Object.defineProperties(window, {
application: {
get: () =>
(angular.element(document).injector().get('mainApplicationGroup') as any)
.application,
},
});
}

View File

@@ -82,6 +82,10 @@ export class Editor {
}
}
public clearNoteChangeListener() {
this._onNoteChange = undefined;
}
/**
* Register to be notified when the editor's note's values change
* (and thus a new object reference is created)

View File

@@ -1,3 +1,5 @@
export const isDev = process.env.NODE_ENV === 'development';
export function getParameterByName(name: string, url: string) {
name = name.replace(/[[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');

View File

@@ -17,13 +17,13 @@ export class PureViewCtrl {
/* @ngInject */
constructor($timeout: ng.ITimeoutService) {
this.$timeout = $timeout;
/* Allow caller constructor to finish setting instance variables */
setImmediate(() => {
this.state = this.getInitialState();
});
}
$onInit() {
this.state = {
...this.getInitialState(),
...this.state,
}
this.addAppEventObserver();
this.addAppStateObserver();
}
@@ -33,7 +33,6 @@ export class PureViewCtrl {
this.unsubState();
this.unsubApp = undefined;
this.unsubState = undefined;
(this.application as any) = undefined;
if (this.stateTimeout) {
this.$timeout.cancel(this.stateTimeout);
}
@@ -141,4 +140,4 @@ export class PureViewCtrl {
/** Optional override */
}
}
}

View File

@@ -144,6 +144,7 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
}
deinit() {
this.editor.clearNoteChangeListener();
this.removeTagsObserver();
this.removeComponentsObserver();
(this.removeTagsObserver as any) = undefined;

21
package-lock.json generated
View File

@@ -1285,18 +1285,6 @@
"@babel/helper-plugin-utils": "^7.8.3"
}
},
"@babel/plugin-transform-runtime": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.8.3.tgz",
"integrity": "sha512-/vqUt5Yh+cgPZXXjmaG9NT8aVfThKk7G4OqkVhrXqwsC5soMn/qTCxs36rZ2QFhpfTJcjw4SNDIZ4RUb8OL4jQ==",
"dev": true,
"requires": {
"@babel/helper-module-imports": "^7.8.3",
"@babel/helper-plugin-utils": "^7.8.3",
"resolve": "^1.8.1",
"semver": "^5.5.1"
}
},
"@babel/plugin-transform-shorthand-properties": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.8.3.tgz",
@@ -11415,6 +11403,15 @@
"uuid": "^3.3.2"
}
},
"webpack-merge": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-4.2.2.tgz",
"integrity": "sha512-TUE1UGoTX2Cd42j3krGYqObZbOD+xF7u28WB7tfUordytSjbWTIjK/8V0amkBfTYN4/pB/GIDlJZZ657BGG19g==",
"dev": true,
"requires": {
"lodash": "^4.17.15"
}
},
"webpack-sources": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.3.tgz",

View File

@@ -7,12 +7,11 @@
"url": "https://github.com/standardnotes/web"
},
"scripts": {
"start": "webpack-dev-server --progress",
"watch": "webpack --mode development -w",
"bundle": "webpack --mode production",
"start": "webpack-dev-server --progress --config webpack.dev.js",
"watch": "webpack -w --config webpack.dev.js",
"bundle": "webpack --config webpack.prod.js",
"build": "bundle install && npm install && npm run bundle",
"submodules": "git submodule update --init --force --remote",
"test": "karma start karma.conf.js --single-run",
"lint": "eslint --fix app/assets/javascripts/**/*.js",
"tsc": "tsc --project app/assets/javascripts/tsconfig.json"
},
@@ -20,10 +19,8 @@
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.7",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.8.3",
"@babel/preset-env": "^7.8.7",
"@babel/preset-typescript": "^7.8.3",
"@babel/runtime": "^7.8.7",
"@types/angular": "^1.7.0",
"@types/chai": "^4.2.11",
"@types/lodash": "^4.14.149",
@@ -50,6 +47,7 @@
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"file-loader": "^5.1.0",
"lodash": "^4.17.15",
"mini-css-extract-plugin": "^0.9.0",
"mocha": "^7.1.0",
"ng-cache-loader": "0.0.26",
@@ -58,15 +56,15 @@
"pug-loader": "^2.4.0",
"sass-loader": "^8.0.2",
"serve-static": "^1.14.1",
"snjs": "github:standardnotes/snjs#0c306de70c5afffe16096424c6c3326eaa1dd4fd",
"sn-stylekit": "2.0.22",
"snjs": "github:standardnotes/snjs#0c306de70c5afffe16096424c6c3326eaa1dd4fd",
"ts-loader": "^6.2.2",
"typescript": "^3.8.3",
"typescript-eslint": "0.0.1-alpha.0",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3",
"lodash": "^4.17.15"
"webpack-merge": "^4.2.2"
},
"dependencies": {
"sncrypto": "github:standardnotes/sncrypto#7e76ab9977f85039d9399b935aecfe495a951edb"

View File

@@ -2,20 +2,12 @@ const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
entry: './app/assets/javascripts/index.ts',
output: {
filename: './javascripts/app.js'
},
devServer: {
proxy: {
'/extensions': {
target: 'http://localhost:3001',
pathRewrite: { '^/extensions': '/public/extensions' }
}
},
port: 3001
},
plugins: [
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(require('./package.json').version)
@@ -27,10 +19,9 @@ module.exports = {
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
filename: './stylesheets/app.css',
ignoreOrder: false // Enable to remove warnings about conflicting order
ignoreOrder: true // Enable to remove warnings about conflicting order
})
],
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.js'],
alias: {
@@ -46,7 +37,7 @@ module.exports = {
rules: [
{
test: /\.(js|ts)$/,
exclude: /node_modules/,
exclude: /(node_modules|snjs)/,
use: {
loader: 'babel-loader'
}

19
webpack.dev.js Normal file
View File

@@ -0,0 +1,19 @@
const merge = require('webpack-merge');
const config = require('./webpack.config.js');
module.exports = (_env, argv) => {
const port = argv.port || 3001;
return merge(config, {
mode: 'development',
devServer: {
publicPath: '/dist/',
proxy: {
'/extensions': {
target: `http://localhost:${port}`,
pathRewrite: { '^/extensions': '/public/extensions' }
}
},
port,
}
});
};

7
webpack.prod.js Normal file
View File

@@ -0,0 +1,7 @@
const merge = require('webpack-merge');
const config = require('./webpack.config.js');
module.exports = merge(config, {
mode: 'production',
devtool: 'source-map',
});