mirror of
https://github.com/tenrok/vue-native-websocket.git
synced 2026-06-23 16:50:35 +03:00
Merge pull request #158 from nsano-rururu/babel6to7_webpack3to5
Babel 6 to 7, webpack 3 to 5 etc
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
root: true,
|
root: true,
|
||||||
parser: 'babel-eslint',
|
parser: '@babel/eslint-parser',
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
sourceType: 'module'
|
sourceType: 'module'
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules/
|
node_modules/
|
||||||
|
dist
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"presets": ["@babel/preset-env"]
|
||||||
|
}
|
||||||
Vendored
+2
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Generated
+12631
-6241
File diff suppressed because it is too large
Load Diff
+28
-27
@@ -4,7 +4,7 @@
|
|||||||
"description": "native websocket implemantation for vuejs and vuex",
|
"description": "native websocket implemantation for vuejs and vuex",
|
||||||
"main": "dist/build.js",
|
"main": "dist/build.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "eslint --ext .js src && webpack --progress --hide-modules",
|
"build": "eslint --ext .js src && webpack --progress",
|
||||||
"lint": "eslint --ext .js src",
|
"lint": "eslint --ext .js src",
|
||||||
"unit": "karma start test/unit/karma.conf.js",
|
"unit": "karma start test/unit/karma.conf.js",
|
||||||
"test": "karma start test/unit/karma.conf.js --single-run "
|
"test": "karma start test/unit/karma.conf.js --single-run "
|
||||||
@@ -30,33 +30,34 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/nathantsoi/vue-native-websocket#readme",
|
"homepage": "https://github.com/nathantsoi/vue-native-websocket#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-cli": "^6.24.1",
|
"@babel/cli": "^7.18.9",
|
||||||
"babel-eslint": "^7.2.3",
|
"@babel/core": "^7.18.9",
|
||||||
"babel-loader": "^7.0.0",
|
"@babel/eslint-parser": "^7.18.9",
|
||||||
"babel-preset-es2015": "^6.24.1",
|
"@babel/preset-env": "^7.18.9",
|
||||||
"chai": "^4.0.2",
|
"babel-loader": "^8.2.5",
|
||||||
"eslint": "^3.19.0",
|
"chai": "^4.3.6",
|
||||||
"eslint-config-standard": "^10.2.1",
|
"eslint": "^8.20.0",
|
||||||
"eslint-plugin-import": "^2.2.0",
|
"eslint-config-standard": "^17.0.0",
|
||||||
"eslint-plugin-node": "^4.2.2",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-promise": "^3.5.0",
|
"eslint-plugin-n": "^15.2.4",
|
||||||
"eslint-plugin-standard": "^3.0.1",
|
"eslint-plugin-promise": "^6.0.0",
|
||||||
"exports-loader": "^0.6.4",
|
"exports-loader": "^0.6.4",
|
||||||
"karma": "^1.7.0",
|
"karma": "^6.4.0",
|
||||||
"karma-chrome-launcher": "^2.2.0",
|
"karma-chrome-launcher": "^3.1.1",
|
||||||
"karma-coverage": "^1.1.1",
|
"karma-coverage": "^2.2.0",
|
||||||
"karma-mocha": "^1.3.0",
|
"karma-mocha": "^2.0.1",
|
||||||
"karma-sinon-chai": "^1.3.1",
|
"karma-sinon-chai": "^2.0.2",
|
||||||
"karma-sourcemap-loader": "^0.3.7",
|
"karma-sourcemap-loader": "^0.3.8",
|
||||||
"karma-spec-reporter": "^0.0.31",
|
"karma-spec-reporter": "^0.0.33",
|
||||||
"karma-webpack": "^2.0.3",
|
"karma-webpack": "^5.0.0",
|
||||||
"mocha": "^3.4.2",
|
"mocha": "^9.2.1",
|
||||||
"mock-socket": "^6.1.0",
|
"mock-socket": "^6.1.0",
|
||||||
"script-loader": "^0.7.0",
|
"script-loader": "^0.7.0",
|
||||||
"sinon": "^2.3.6",
|
"sinon": "^13.0.1",
|
||||||
"sinon-chai": "^2.11.0",
|
"sinon-chai": "^3.7.0",
|
||||||
"vue": "^2.3.4",
|
"terser-webpack-plugin": "^5.3.3",
|
||||||
"webpack": "^3.0.0"
|
"vue": "^2.7.7",
|
||||||
},
|
"webpack": "^5.73.0",
|
||||||
"dependencies": {}
|
"webpack-cli": "^4.10.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+3
-3
@@ -6,14 +6,14 @@ class Emitter {
|
|||||||
addListener (label, callback, vm) {
|
addListener (label, callback, vm) {
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
this.listeners.has(label) || this.listeners.set(label, [])
|
this.listeners.has(label) || this.listeners.set(label, [])
|
||||||
this.listeners.get(label).push({callback: callback, vm: vm})
|
this.listeners.get(label).push({ callback, vm })
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
removeListener (label, callback, vm) {
|
removeListener (label, callback, vm) {
|
||||||
let listeners = this.listeners.get(label)
|
const listeners = this.listeners.get(label)
|
||||||
let index
|
let index
|
||||||
|
|
||||||
if (listeners && listeners.length) {
|
if (listeners && listeners.length) {
|
||||||
@@ -34,7 +34,7 @@ class Emitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit (label, ...args) {
|
emit (label, ...args) {
|
||||||
let listeners = this.listeners.get(label)
|
const listeners = this.listeners.get(label)
|
||||||
|
|
||||||
if (listeners && listeners.length) {
|
if (listeners && listeners.length) {
|
||||||
listeners.forEach((listener) => {
|
listeners.forEach((listener) => {
|
||||||
|
|||||||
+3
-3
@@ -37,8 +37,8 @@ export default {
|
|||||||
|
|
||||||
Vue.mixin({
|
Vue.mixin({
|
||||||
created () {
|
created () {
|
||||||
let vm = this
|
const vm = this
|
||||||
let sockets = this.$options['sockets']
|
const sockets = this.$options.sockets
|
||||||
|
|
||||||
if (hasProxy) {
|
if (hasProxy) {
|
||||||
this.$options.sockets = new Proxy({}, {
|
this.$options.sockets = new Proxy({}, {
|
||||||
@@ -71,7 +71,7 @@ export default {
|
|||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
if (hasProxy) {
|
if (hasProxy) {
|
||||||
let sockets = this.$options['sockets']
|
const sockets = this.$options.sockets
|
||||||
|
|
||||||
if (sockets) {
|
if (sockets) {
|
||||||
Object.keys(sockets).forEach((key) => {
|
Object.keys(sockets).forEach((key) => {
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ export default class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect (connectionUrl, opts = {}) {
|
connect (connectionUrl, opts = {}) {
|
||||||
let protocol = opts.protocol || ''
|
const protocol = opts.protocol || ''
|
||||||
this.WebSocket = opts.WebSocket || (protocol === '' ? new WebSocket(connectionUrl) : new WebSocket(connectionUrl, protocol))
|
this.WebSocket = opts.WebSocket || (protocol === '' ? new WebSocket(connectionUrl) : new WebSocket(connectionUrl, protocol))
|
||||||
if (this.format === 'json') {
|
if (this.format === 'json') {
|
||||||
if (!('sendObj' in this.WebSocket)) {
|
if (!('sendObj' in this.WebSocket)) {
|
||||||
|
|||||||
+9
-14
@@ -1,36 +1,31 @@
|
|||||||
var path = require('path')
|
var path = require('path')
|
||||||
var webpack = require('webpack')
|
const TerserPlugin = require('terser-webpack-plugin')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: ['./src/Main.js'],
|
entry: ['./src/Main.js'],
|
||||||
|
mode: 'production',
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, './dist'),
|
path: path.resolve(__dirname, './dist'),
|
||||||
filename: 'build.js',
|
filename: 'build.js',
|
||||||
library: ['VueNativeSock'],
|
library: ['VueNativeSock'],
|
||||||
libraryTarget: 'umd'
|
libraryTarget: 'umd'
|
||||||
},
|
},
|
||||||
devtool: "source-map",
|
devtool: 'source-map',
|
||||||
plugins: [
|
optimization: {
|
||||||
new webpack.optimize.UglifyJsPlugin({
|
minimize: true,
|
||||||
compress: {
|
minimizer: [new TerserPlugin()]
|
||||||
warnings: false
|
},
|
||||||
}
|
|
||||||
})
|
|
||||||
],
|
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@': path.resolve(__dirname, './src'),
|
'@': path.resolve(__dirname, './src'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
loaders: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
loader: 'babel-loader',
|
use: ['babel-loader']
|
||||||
query: {
|
|
||||||
presets: ['es2015']
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user