Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@twist/core
Advanced tools
[![Build Status](https://travis-ci.org/adobe/twist.svg?branch=master)](https://travis-ci.org/adobe/twist)
A web application is a lot like an iceberg - what you see on the surface is just a tiny fraction of the complexity that lies beneath the waves. To a casual observer, it's easy to get absorbed by beautiful designs, and be amazed by how a little CSS and JavaScript can give rise to such immersive experiences. But the more complex an application becomes, the more critically it depends on a solid foundation - the nuts and bolts of component hierarchies, state management, and caching layers that hold the whole thing together.
Twist is a library that arose in light of these problems, by focusing on application state, and how it gets bound to reusable UI components. Twist is not a UI framework in its own right, but it does provide a syntax for writing components that's compatible with other frameworks, such as React. It uses a structured reactive approach, so that you easily scale your application, while maintaining an easy way of binding to the view - you'll recognize concepts that were inspired by Mobx and Redux, which are both very popular state-management libraries for React.
To give you a feel for what Twist looks like, here's a small fragment of code, showing part of a model (a store), and part of a view (a component). Notice that stores can nest other stores (DOB
and Address
are also stores, but aren't shown):
@Store
class User {
@State.byVal name;
@State.byVal description;
@State.byRef(DOB) birthday;
@State.byRef(Address) address;
@Action CHANGE_DESCRIPTION(newDescription) {
this.description = newDescription;
}
}
@Component
class ProfileView {
@Attribute user;
@Observable newDescription;
constructor() {
super();
this.newDescription = this.user.description;
}
render() {
return <g>
<div>Hello { this.user.name }!</div>
<if condition={ this.user.birthday.isToday() }>
<div>Happy Birthday!!</div>
</if>
<div>About yourself: <input bind:value={ this.newDescription }/></div>
<button onClick={ () => this.user.dispatch('CHANGE_DESCRIPTION', this.newDescription) }>Save</button>
</g>;
}
}
The Twist Documentation explains everything in great detail, but here's a preview of the main concepts:
@State.xxx
decorators tell Twist how to serialize each property (which can itself be another store).@State.xxx
is implicitly observable).While the state portion of Twist is framework-agnostic, the implementation of components depends on which UI framework is used. Right now, Twist only supports React, via React-Twist, but it's designed so that there can be other implementations in the future (and we encourage contributions if you're interested in helping with this!). This would allow the same component to work with multiple UI frameworks, which would be great for shared component libraries! Even today, React-Twist makes it really easy to use Twist stores with React, and also adds a bunch of features on top of React to make your life easier. See here for a complete description of the features.
Note: In case you're wondering, React-Twist components are React components - they just automatically optimize when to re-render, so you don't need to think about it. If you write a component in React-Twist, it can be used directly by a normal React application. Similarly, React-Twist components can use normal React components directly - everything is rendered via React and ReactDOM.
If you want to use both the state-management and component layers of Twist, you'll need to install the following (via NPM or Yarn):
@twist/core
- This includes support for stores, data binding, and application state management.@twist/react
- The React implementation of Twist components.@twist/react-webpack-plugin
- A webpack plugin that compiles Twist files (Twist has its own Babel transform that runs before React's).If you're not using webpack, you can also get hold of the Babel configuration directly, using @twist/configuration
(this is done automatically by the webpack plugin).
After that, the only thing you need is a .twistrc
file in the root of your project, that tells Twist which libraries to include (this is also used by the Twist ESLint plugin). There are a number of advanced options, but to get up and running, you just need to tell Twist that you're using React-Twist:
{
"libraries": [
"@twist/react"
]
}
In your webpack.conf.js
you can now include the React Twist plugin - by default this will compile all files that end in .jsx
with Twist and React:
const ReactTwistPlugin = require('@twist/react-webpack-plugin');
module.exports = {
...
plugins: [
new ReactTwistPlugin(),
...
],
...
};
FAQs
[![Build Status](https://travis-ci.org/adobe/twist.svg?branch=master)](https://travis-ci.org/adobe/twist)
The npm package @twist/core receives a total of 3 weekly downloads. As such, @twist/core popularity was classified as not popular.
We found that @twist/core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.