From d087b724b7ea53c7b7cf6d7855171fadd9e4ed02 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sat, 9 Feb 2019 20:26:20 +0100 Subject: [PATCH] use wct-datatables-net and simply dependencies --- .npmrc | 1 + package.json | 11 +++-------- server.js | 13 ------------- src/index.html | 4 ---- src/packets-live-viewer.js | 39 +++++++++++++------------------------- webpack.config.js | 33 ++------------------------------ 6 files changed, 19 insertions(+), 82 deletions(-) create mode 100644 .npmrc delete mode 100644 server.js diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/package.json b/package.json index 28d1deb..7ea1975 100644 --- a/package.json +++ b/package.json @@ -9,19 +9,14 @@ "url": "https://github.com/MephisTools/diablo2-live-viewer" }, "dependencies": { - "lit-element": "^2.0.0-rc.3", - "@webcomponents/webcomponentsjs": "^2.2.1", - "datatables.net": "^1.10.19", - "datatables.net-dt": "^1.10.19", "diablo2-data": "^1.0.0", - "express": "^4.16.3", "leaflet": "^1.4.0", "leaflet-search": "^2.9.8", "leaflet.awesome-markers": "^2.0.5", - "lit-html": "^1.0.0-rc.2", + "lit-element": "^2.0.1", + "lit-html": "^1.0.0", "page": "^1.11.3", - "promise-polyfill": "^8.0.0", - "whatwg-fetch": "^2.0.4" + "wct-datatables-net": "^1.1.0" }, "devDependencies": { "clean-webpack-plugin": "^0.1.19", diff --git a/server.js b/server.js deleted file mode 100644 index a77ab61..0000000 --- a/server.js +++ /dev/null @@ -1,13 +0,0 @@ -const express = require('express') -const app = express() -const path = require('path') - -app.use(express.static('dist')) - -app.get('*', function (req, res) { - res.sendFile(path.join(__dirname, '/dist/index.html')) -}) - -app.listen(process.env.PORT || 8000, function () { - console.log('Express server is running on port 8000') -}) diff --git a/src/index.html b/src/index.html index 6ecf0a7..0adeb3a 100644 --- a/src/index.html +++ b/src/index.html @@ -15,10 +15,6 @@ padding: 0; } - - - - diff --git a/src/packets-live-viewer.js b/src/packets-live-viewer.js index 7b3d1da..449f4e4 100644 --- a/src/packets-live-viewer.js +++ b/src/packets-live-viewer.js @@ -2,14 +2,13 @@ import { LitElement, html } from 'lit-element' -import datatablesCss from 'datatables.net-dt/css/jquery.dataTables.min.css' -import $ from 'jquery' -import 'datatables.net' +import 'wct-datatables-net' class PacketsLiveViewer extends LitElement { static get properties () { return { - ws: { type: Object } + ws: { type: Object }, + table: { type: Object } } } @@ -20,15 +19,6 @@ class PacketsLiveViewer extends LitElement { firstUpdated () { this.displayPacketsTable() - this.packetsTable = $(this.shadowRoot.querySelector('#myTable')).DataTable({ - 'order': [[ 0, 'desc' ]], - 'columns': [ - null, - null, - null, - { width: '70%' } - ] - }) } displayPacketsTable () { @@ -59,19 +49,16 @@ class PacketsLiveViewer extends LitElement { } render () { - return html` - - - - - - - - - - - -
TimeProtocolNameParams
+ return html` + { this.packetsTable = e.detail.table }}> ` } } diff --git a/webpack.config.js b/webpack.config.js index 414c017..1fe4cfe 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,6 @@ 'use strict' -const { resolve, join } = require('path') +const { resolve } = require('path') const merge = require('webpack-merge') const CopyWebpackPlugin = require('copy-webpack-plugin') const HtmlWebpackPlugin = require('html-webpack-plugin') @@ -12,8 +12,6 @@ const ENV = process.argv.find(arg => arg.includes('production')) const OUTPUT_PATH = ENV === 'production' ? resolve('dist') : resolve('src') const INDEX_TEMPLATE = resolve('./src/index.html') -const webcomponentsjs = './node_modules/@webcomponents/webcomponentsjs' - const assets = [ { from: resolve('./src/assets'), @@ -21,32 +19,6 @@ const assets = [ } ] -const polyfills = [ - { - from: resolve(`${webcomponentsjs}/webcomponents-*.js`), - to: join(OUTPUT_PATH, 'vendor'), - flatten: true - }, - { - from: resolve(`${webcomponentsjs}/bundles/*.js`), - to: join(OUTPUT_PATH, 'vendor', 'bundles'), - flatten: true - }, - { - from: resolve(`${webcomponentsjs}/custom-elements-es5-adapter.js`), - to: join(OUTPUT_PATH, 'vendor'), - flatten: true - }, - { - from: resolve('./node_modules/whatwg-fetch/fetch.js'), - to: join(OUTPUT_PATH, 'vendor') - }, - { - from: resolve('./node_modules/promise-polyfill/dist/polyfill.min.js'), - to: join(OUTPUT_PATH, 'vendor') - } -] - const commonConfig = merge([ { entry: './src/diablo2-live-viewer.js', @@ -90,7 +62,6 @@ const developmentConfig = merge([ { devtool: 'cheap-module-source-map', plugins: [ - new CopyWebpackPlugin(polyfills), new HtmlWebpackPlugin({ template: INDEX_TEMPLATE }) @@ -112,7 +83,7 @@ const productionConfig = merge([ devtool: 'nosources-source-map', plugins: [ new CleanWebpackPlugin([OUTPUT_PATH], { verbose: true }), - new CopyWebpackPlugin([...polyfills, ...assets]), + new CopyWebpackPlugin([...assets]), new HtmlWebpackPlugin({ template: INDEX_TEMPLATE, minify: {