Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Part of lucidity project.
Replace 'require' by 'live.require' to constantly update the required code or assets as the source file changes.
Usage example:
const live = require ( 'lucy-live' )
// expects foo.js library to return "obj"
live.load
( 'foo.js'
, function ( obj )
{
console.log ( 'foo changed: ' + obj )
}
)
live.path
( 'image.jpg'
, function ( imgPath )
{ // do something with new image taking
// care of Browser cache
}
)
// Start listening for changes in '.'
live.watch ( '.' )
The module definition needs to take into account that it may be reloaded by
reusing module.exports
and updating it. Simply exporting a new module will not
work because the newly created module will not be linked to existing objects.
Example of a module exporting a simple Person class where methods are live
coded. The code shown here is just one way to implement this behaviour. The only
thing to notice is that loaded
is false on first load and true on reload:
// Person.js
if ( ! exports.loaded )
{ // Initial code loading is used to create a simple function wrapping a call
// to an initialize method.
module.exports = function ()
{ this.init.apply ( arguments )
}
}
// Code from here is executed on every file change.
const Person = module.exports.prototype
Person.init = function ( name )
{ this._name = name
}
Person.sayHello = function ()
{ console.log ( `Hello, I am ${ this._name }.` )
}
Person usage:
const live = require ( 'lucy-live' )
const Person = live.require ( './Person' )
let o = new Person ( 'Georg Groddeck' )
o.sayHello ()
setTimeout
( function ()
{ o.sayHello () // will call the updated 'sayHello' method
} // when Person.js is changed
, 2
)
// To only call a method when the file is loaded (always called at least once)
// one can use live.path:
live.path
( './Person'
, function ( path )
{ console.log ( `Path '${ path }' changed.` )
o.sayHello ()
}
)
// Start watching for changes in this file's directory.
live.watch ( '.' )
Real world example of GLSL shader live coding (taken from Lucidity.
const ShaderEffect = require ( 'lucy-compose' ).ShaderEffect
const THREE = require ( 'three' )
const live = require ( 'lucy-live' )
if (!exports.loaded) {
// On first load, we create the effect
module.exports = new ShaderEffect
}
const self = module.exports
// We simply update the shaders when the glsl files change.
live.read
( './vert.glsl'
, function ( s )
{ self.material.vertexShader = s
self.material.needsUpdate = true
}
)
live.read
( './frag.glsl'
, function ( s )
{ self.material.fragmentShader = s
self.material.needsUpdate = true
}
)
// We could customize a method like this:
self.render = function ( context, target )
{
// ...
}
npm install lucy-live --save
npm test
Please use 'jessy style'.
Add unit tests for any new or changed functionality.
FAQs
A library for live coding.
The npm package lucy-live receives a total of 1 weekly downloads. As such, lucy-live popularity was classified as not popular.
We found that lucy-live demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.