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');
RemoteStorage.defineModule("chat-messages", function (privateClient, publicClient) {
var ChatMessages = function (privateClient, publicClient) {
/**
* Schema: chat-messages/daily
@@ -362,7 +360,7 @@ RemoteStorage.defineModule("chat-messages", function (privateClient, publicClien
* Updates and writes an existing archive document
*/
_updateDocument: function(archive, messages) {
RemoteStorage.log('[chat-messages] Updating archive document', archive);
console.debug('[chat-messages] Updating archive document', archive);
if (Array.isArray(messages)) {
messages.forEach(function(message) {
@@ -381,7 +379,7 @@ RemoteStorage.defineModule("chat-messages", function (privateClient, publicClien
* Creates and writes a new archive document
*/
_createDocument: function(messages) {
RemoteStorage.log('[chat-messages] Creating new archive document');
console.debug('[chat-messages] Creating new archive document');
let archive = this._buildArchiveObject();
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'];
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;
});
} else {
RemoteStorage.log('[chat-messages] Previous archive not found');
console.debug('[chat-messages] Previous archive not found');
return false;
}
});
@@ -536,13 +534,13 @@ RemoteStorage.defineModule("chat-messages", function (privateClient, publicClien
* Write archive document
*/
_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(){
RemoteStorage.log('[chat-messages] Archive written to remote storage');
console.debug('[chat-messages] Archive written to remote storage');
return true;
},function(error){
console.log('[chat-messages] Error trying to store object', error);
console.warn('[chat-messages] Error trying to store object', error);
return error;
});
}
@@ -570,4 +568,7 @@ RemoteStorage.defineModule("chat-messages", function (privateClient, publicClien
// Return public functions
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",
"version": "0.8.0",
"version": "1.0.1",
"description": "Stores chat messages in daily archive files",
"main": "./dist/build.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "NODE_ENV=production webpack",
"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)",
"contributors": [
"Sebastian Kippe <sebastian@kip.pe>"
],
"author": "Kosmos Contributors <mail@kosmos.org> (https://kosmos.org)",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/67P/remotestorage-module-chat-messages.git"
},
"devDependencies": {
"babel-core": "^6.18.2",
"babel-loader": "^6.2.7",
"babel-preset-es2015": "^6.18.0",
"webpack": "^1.13.2"
"@babel/core": "^7.14.8",
"@babel/preset-env": "^7.14.9",
"babel-loader": "^8.2.2",
"webpack": "^5.48.0",
"webpack-cli": "^4.8.0"
}
}

View File

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