7 Commits

5 changed files with 2612 additions and 47 deletions

2
dist/build.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,4 @@
var RemoteStorage = require('remotestoragejs'); var ChatMessages = function (privateClient, publicClient) {
RemoteStorage.defineModule("chat-messages", function (privateClient, publicClient) {
/** /**
* Schema: chat-messages/daily * Schema: chat-messages/daily
@@ -362,7 +360,7 @@ RemoteStorage.defineModule("chat-messages", function (privateClient, publicClien
* Updates and writes an existing archive document * Updates and writes an existing archive document
*/ */
_updateDocument: function(archive, messages) { _updateDocument: function(archive, messages) {
RemoteStorage.log('[chat-messages] Updating archive document', archive); console.debug('[chat-messages] Updating archive document', archive);
if (Array.isArray(messages)) { if (Array.isArray(messages)) {
messages.forEach(function(message) { messages.forEach(function(message) {
@@ -381,7 +379,7 @@ RemoteStorage.defineModule("chat-messages", function (privateClient, publicClien
* Creates and writes a new archive document * Creates and writes a new archive document
*/ */
_createDocument: function(messages) { _createDocument: function(messages) {
RemoteStorage.log('[chat-messages] Creating new archive document'); console.debug('[chat-messages] Creating new archive document');
let archive = this._buildArchiveObject(); let archive = this._buildArchiveObject();
if (Array.isArray(messages)) { if (Array.isArray(messages)) {
@@ -456,11 +454,11 @@ RemoteStorage.defineModule("chat-messages", function (privateClient, publicClien
let path = this.path.substring(0, this.path.length-this.dateId.length)+archive.today['@id']; let path = this.path.substring(0, this.path.length-this.dateId.length)+archive.today['@id'];
return this.client.storeObject('daily-archive', path, archive).then(() => { return this.client.storeObject('daily-archive', path, archive).then(() => {
RemoteStorage.log('[chat-messages] Previous archive written to remote storage', path, archive); console.debug('[chat-messages] Previous archive written to remote storage', path, archive);
return archive; return archive;
}); });
} else { } else {
RemoteStorage.log('[chat-messages] Previous archive not found'); console.debug('[chat-messages] Previous archive not found');
return false; return false;
} }
}); });
@@ -536,13 +534,13 @@ RemoteStorage.defineModule("chat-messages", function (privateClient, publicClien
* Write archive document * Write archive document
*/ */
_sync: function(obj) { _sync: function(obj) {
RemoteStorage.log('[chat-messages] Writing archive object', obj); console.debug('[chat-messages] Writing archive object', obj);
return this.client.storeObject('daily-archive', this.path, obj).then(function(){ return this.client.storeObject('daily-archive', this.path, obj).then(function(){
RemoteStorage.log('[chat-messages] Archive written to remote storage'); console.debug('[chat-messages] Archive written to remote storage');
return true; return true;
},function(error){ },function(error){
console.log('[chat-messages] Error trying to store object', error); console.warn('[chat-messages] Error trying to store object', error);
return error; return error;
}); });
} }
@@ -570,4 +568,7 @@ RemoteStorage.defineModule("chat-messages", function (privateClient, publicClien
// Return public functions // Return public functions
return { exports: exports }; return { exports: exports };
});
};
export default { name: 'chat-messages', builder: ChatMessages };

2565
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,26 +1,26 @@
{ {
"name": "remotestorage-module-chat-messages", "name": "remotestorage-module-chat-messages",
"version": "0.8.0", "version": "1.0.1",
"description": "Stores chat messages in daily archive files", "description": "Stores chat messages in daily archive files",
"main": "./dist/build.js", "main": "./dist/build.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "build": "NODE_ENV=production webpack",
"dev": "webpack -w", "dev": "webpack -w",
"build": "NODE_ENV=production webpack" "start": "npm run dev",
"test": "echo \"Error: no test specified\" && exit 1",
"version": "npm run build && git add dist/"
}, },
"author": "Kosmos Developers <mail@kosmos.org> (https://kosmos.org)", "author": "Kosmos Contributors <mail@kosmos.org> (https://kosmos.org)",
"contributors": [
"Sebastian Kippe <sebastian@kip.pe>"
],
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/67P/remotestorage-module-chat-messages.git" "url": "https://github.com/67P/remotestorage-module-chat-messages.git"
}, },
"devDependencies": { "devDependencies": {
"babel-core": "^6.18.2", "@babel/core": "^7.14.8",
"babel-loader": "^6.2.7", "@babel/preset-env": "^7.14.9",
"babel-preset-es2015": "^6.18.0", "babel-loader": "^8.2.2",
"webpack": "^1.13.2" "webpack": "^5.48.0",
"webpack-cli": "^4.8.0"
} }
} }

View File

@@ -1,32 +1,31 @@
var webpack = require('webpack'); /* global __dirname */
var isProd = (process.env.NODE_ENV === 'production'); const isProd = (process.env.NODE_ENV === 'production');
const path = require('path');
// minimize only in production
var plugins = isProd ? [new webpack.optimize.UglifyJsPlugin({minimize: true })] : []
module.exports = { module.exports = {
entry: './index.js', entry: ['./index.js'],
// source map not in production
devtool: !isProd && 'source-map',
output: { output: {
filename: __dirname + '/dist/build.js', path: path.resolve(__dirname, 'dist'),
libraryTarget: 'umd' filename: 'build.js',
}, library: 'ChatMessages',
externals: { libraryTarget: 'umd',
"remotestoragejs": { libraryExport: 'default'
root: "RemoteStorage", // <script src='remotestorage.js'> will resolve in this.RemoteStorage
commonjs2: "remotestoragejs", // require('remotestoragejs')
commonjs: "remotestoragejs", // require('remotestoragejs')
amd: "remotestoragejs" // define(['remotestoragejs'], ...)
}
}, },
mode: isProd ? 'production' : 'development',
devtool: isProd ? 'source-map' : 'eval-source-map',
module: { module: {
loaders: [ rules: [
{ test: /\.js$/, exclude: '/node_modules|dist/', loader: 'babel?presets[]=es2015' }, {
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
] ]
}, },
resolve: { // plugins: plugins
extensions: ['', '.js']
},
plugins: plugins
}; };