Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-ws-sender

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-ws-sender - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

7

index.js

@@ -1,8 +0,3 @@

const server = require('./src/server')
const broadcast = require('./src/broadcast')
module.exports = {
server,
broadcast
}
module.exports = broadcast

10

package.json
{
"name": "gulp-ws-sender",
"version": "1.1.0",
"description": "to send js and css to your websocket server",
"version": "1.1.1",
"description": "start the websocket server and send your js and css to it ^^",
"main": "index.js",

@@ -14,3 +14,3 @@ "scripts": {

"chalk": "^2.4.1",
"gulp-util": "^3.0.8",
"plugin-error": "^1.0.1",
"through2": "^3.0.0",

@@ -20,5 +20,5 @@ "ws": "^6.1.0"

"repository": {
"type" : "git",
"url" : "https://github.com/bercly0b/gulp-ws-sender"
"type": "git",
"url": "https://github.com/bercly0b/gulp-ws-sender"
}
}
## usage
```sh
const gulp = require('gulp')
const broadcast = require('gulp-ws-sender').broadcast(port)
const server = require('gulp-ws-sender').server
const sender = require('gulp-ws-sender')(9999) // port
gulp.task('styles', () => {
return gulp.src('src/**/*.css')
.pipe(sender({
type: 'css'
}))
.pipe(sender({ type: 'css' })) // or type: 'js'
.pipe(gulp.dest('public'))
})
gulp.task('server', () => server({ port: port }))
```
For live injection of your script and styles on any page. Use with [chrome extention](https://github.com/bercly0b/injector-chrome-extension)

@@ -1,4 +0,5 @@

const gutil = require('gulp-util')
const PluginError = require('plugin-error');
const through = require('through2')
const WebSocket = require('ws')
const server = require('./server')
const getMessage = require('./helper').getClientMessage

@@ -8,7 +9,9 @@

module.exports = port => {
server(port)
const ws = new WebSocket('ws://localhost:' + port)
return options => {
const { type } = options
// const { client: ws, type } = options
return through.obj(function(file, enc, cb) {

@@ -22,3 +25,3 @@

if (file.isStream()) {
cb(new gutil.PluginError('gulp-ws-sender', 'Streaming not supported'))
cb(new PluginError('gulp-ws-sender', 'Streaming not supported'))
return

@@ -35,3 +38,3 @@ }

} catch (err) {
this.emit('error', new gutil.PluginError('gulp-ws-sender', err))
this.emit('error', new PluginError('gulp-ws-sender', err, { showStack: true }))
console.log(err)

@@ -38,0 +41,0 @@ }

const WebSocket = require('ws')
const chalk = require('chalk')
const getMessage = require('./helper').getServerMessage
module.exports = options => {
module.exports = port => {
const { port } = options
const clients = {}

@@ -16,6 +13,6 @@ let needHandler = true

const client = clients.gulp ? 'browser' : 'gulp'
const client = clients.sender ? 'browser' : 'sender'
clients[client] = ws
console.log(getMessage('Connected', client))
ws.on('close', () => {

@@ -26,5 +23,5 @@ delete clients[client]

if (needHandler && clients.gulp) {
if (needHandler && clients.sender) {
needHandler = false
clients.gulp.on('message', message => {
clients.sender.on('message', message => {
// console.log(getMessage('Received message from', client), `: ${message}`)

@@ -31,0 +28,0 @@ clients.browser && clients.browser.send(message)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc