
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Browserify transform to process .choo files as isolated, stateless choo components
WIP - Browserify transform to process .choo files as isolated, stateless choo components
require
.choo files.
this
.npm install --save chooify
Run it as any Browserify transform
$ browserify -e index.js -o bundle.js -t chooify
var fs = require("fs")
var browserify = require('browserify')
var chooify = require('chooify')
browserify('./main.js')
.transform(chooify)
.bundle()
.pipe(fs.createWriteStream("bundle.js"))
The above transform allows you to write choo stateless components like this
// my-component.choo -> yep, .choo files
/* choo-view */
<main onload=${(e) => send('toggle')}>
<h1 class="${this.active ? 'active' : ''}">${state.title}</h1>
</main>
/* choo-model */
{
local: {
active: false
},
effects: {
toggle: (data, state, send, done) => {
this.active = !this.active
}
}
}
// main.js
const choo = require('choo')
const init = require('chooify/init')
const state = require('./state')
const mainComponent = require('./components/main.choo')({ active: true })
const app = choo()
init(app, state)
app.model(mainComponent.model)
app.router(route => [
route('/', mainComponent.view)
])
Tha main idea is to have components that manage local data without polluting the global state, and that are completly reusable.
To do this, I created the .choo
files, which is a javascript file with two sections, the view and the model, which are also exported, when required, as an object with two properties, view and model.
When required, the choo components receive an object as input, and return an object with the view and model, for choo app.
The input object, is the local data for that component.
Starts whit a comment like this /* choo-model */
and ends with the end of the file or the start of the view section. It must contain an object definition, which is a choo model, with some litle differences.
namespace
support.state
property is ignored.local
property added. The component local data, not binded to the global app state, can be initialized here and/or by passing it when required. IF initialized in both places, like in the example, the input data takes preference. Anything passed that is not defined in the model part will be ignored.this
in effects, reducers and subscriptionsStarts whit a comment like this /* choo-view */
and ends with the end of the file or the start of the model section. It must contain a string to be parsed by bel.
You can access to the state, prev, send
arguments, as any other choo view, and to any data defined in the component local property of the model, as the active
local data in the example.
Components ignore the state
property of choo model, so to initialize a global state, this module also expose an init
method that implement the wrapInitialState
hook, so your global state is in a single place and not splitted in different models.
There is no required section for components. You can have a choo file with no model section or without view section, also you could use a component view outside of the router inside another component. You can even pass a full component as local data of another component (maybe we could have an extend
property in the model section?).
Effects and reducers are still global, to make them local, we must define a way of communication between components.
MIT
Crafted with <3 by Yerko Palma.
This package was initially generated with yeoman and the p generator.
FAQs
Browserify transform to process .choo files as isolated, stateless choo components
We found that chooify 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.