
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@gira-de/svelte-undo
Advanced tools
Provides low-level utility functions to use Svelte Stores in combination with redo/undo capabilities. Relies on immer.js.
# using npm
npm install -D @gira-de/svelte-undo
# or using pnpm
pnpm install -D @gira-de/svelte-undo
# or using yarn
yarn add -D @gira-de/svelte-undo
import { undoStack, SetAction } from '@gira-de/svelte-undo';
// create undo stack
const myUndoStack = undoStack('first stack message');
const msgStore = writable('old value');
// create a new action to update the store value
const action = new SetAction(msgStore, 'new value', 'set new value');
// apply the action
action.apply();
console.log($msgStore); // 'new value'
// push action onto the undo stack
myUndoStack.push(action);
// call undo() to revert the changes
myUndoStack.undo();
console.log($msgStore); // 'old value'
Creating actions and manually pushing them to the undo stack might create a lot of boilerplate code. The use of a Transaction simplifies this.
import { undoStack, transactionCtrl } from '@gira-de/svelte-undo';
// create a store as usual
const personStore = writable({ name: 'John', age: '23' });
// create undo stack and a transaction controller
const myUndoStack = undoStack('created');
const myTransactionCtrl = transactionCtrl(myUndoStack);
// apply model changes on the draft state
let personDraft = myTransactionCtrl.draft(personStore);
personDraft['age'] = 24;
// apply all changes made to the drafts
myTransactionCtrl.commit('happy birthday');
console.log($personStore); // { name: 'John', age: '24' }
// call undo() to revert the changes
myUndoStack.undo();
console.log($personStore); // { name: 'John', age: '23' }
Limitations: The transaction controller can only be used with Svelte stores that hold an Object-like value (object, array, map, set).
import { undoStack, transactionCtrl } from '@gira-de/svelte-undo';
// push an undo step to the undo stack
const myUndoStack = undoStack('created');
const myTransactionCtrl = transactionCtrl(myUndoStack);
const personStore = writable({ name: 'John', age: '23' });
myTransactionCtrl.draft(personStore)['age'] = 24;
myTransactionCtrl.commit('happy birthday');
// provide a store id for each store used in the undo stack
const stores = {
person: personStore,
};
// create a snapshot
const undoStackSnapshot = myUndoStack.createSnapshot(stores);
// snapshot can easily be stringified to json
const json = JSON.stringify(undoStackSnapshot);
console.log(json);
// {
// index: 1,
// actions: [
// { type: 'init', msg: 'created' },
// { type: 'mutate', msg: 'happy birthday', storeId: 'person', data: ... }
// ]
// }
// later: load the undo stack snapshot
myUndoStack.loadSnapshot(JSON.parse(json), stores);
The undoStack is basically a Svelte store with various properties and functions. It always contains at least one undo step (action).
const myUndoStack = undoStack('first undo stack message');
const myUndoStack = undoStack({ user: 'xyz', msg: 'project created' });
const myTransactionCtrl = transactionCtrl(myUndoStack);
Contributions are always welcome! Please have a look at our CONTRIBUTING.md
1.3.0
FAQs
Low level undo functionality for Svelte
The npm package @gira-de/svelte-undo receives a total of 24 weekly downloads. As such, @gira-de/svelte-undo popularity was classified as not popular.
We found that @gira-de/svelte-undo demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.