Socket
Socket
Sign inDemoInstall

valtio

Package Overview
Dependencies
Maintainers
2
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

valtio - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

21

esm/utils.js

@@ -58,2 +58,3 @@ import { subscribe, snapshot, proxy, getVersion, ref } from 'valtio/vanilla';

const DEVTOOLS = Symbol();
const devtools = (proxyObject, name) => {

@@ -73,7 +74,16 @@ let extension;

const devtools2 = extension.connect({ name });
const unsub1 = subscribe(proxyObject, () => {
const unsub1 = subscribe(proxyObject, (ops) => {
const action = ops.filter(([_, path]) => path[0] !== DEVTOOLS).map(([op, path]) => `${op}:${path.map(String).join(".")}`).join(", ");
if (!action) {
return;
}
if (isTimeTraveling) {
isTimeTraveling = false;
} else {
devtools2.send(`Update - ${new Date().toLocaleString()}`, snapshot(proxyObject));
const snapWithoutDevtools = Object.assign({}, snapshot(proxyObject));
delete snapWithoutDevtools[DEVTOOLS];
devtools2.send({
type: action,
updatedAt: new Date().toLocaleString()
}, snapWithoutDevtools);
}

@@ -87,6 +97,3 @@ });

}
const nextValue = JSON.parse(message.state);
Object.keys(nextValue).forEach((key) => {
proxyObject[key] = nextValue[key];
});
proxyObject[DEVTOOLS] = message;
} else if (message.type === "DISPATCH" && ((_c = message.payload) == null ? void 0 : _c.type) === "COMMIT") {

@@ -99,3 +106,3 @@ devtools2.init(snapshot(proxyObject));

computedStates.forEach(({ state }, index) => {
const action = actions[index] || `Update - ${new Date().toLocaleString()}`;
const action = actions[index] || "No action found";
Object.keys(state).forEach((key) => {

@@ -102,0 +109,0 @@ proxyObject[key] = state[key];

{
"name": "valtio",
"private": false,
"version": "1.2.2",
"version": "1.2.3",
"description": "💊 Valtio makes proxy-state simple for React and Vanilla",

@@ -26,19 +26,7 @@ "main": "./index.js",

},
"./vanilla": {
"types": "./vanilla.d.ts",
"module": "./esm/vanilla.js",
"import": "./esm/vanilla.mjs",
"default": "./vanilla.js"
},
"./utils": {
"types": "./utils.d.ts",
"module": "./esm/utils.js",
"import": "./esm/utils.mjs",
"default": "./utils.js"
},
"./macro": {
"types": "./macro.d.ts",
"module": "./esm/macro.js",
"import": "./esm/macro.mjs",
"default": "./macro.js"
"./*": {
"types": "./*.d.ts",
"module": "./esm/*.js",
"import": "./esm/*.mjs",
"default": "./*.js"
}

@@ -50,2 +38,5 @@ },

"sideEffects": false,
"engines": {
"node": ">=12"
},
"repository": {

@@ -52,0 +43,0 @@ "type": "git",

@@ -125,3 +125,3 @@ <img src="logo.svg" alt="valtio">

const stop = watch((get) => {
console.log('state has changed to', get(state))) // auto-subscribe on use
console.log('state has changed to', get(state)) // auto-subscribe on use
})

@@ -316,2 +316,4 @@ ```

```js
import { proxyWithHistory } from 'valtio/utils'
const state = proxyWithHistory({ count: 0 })

@@ -334,1 +336,3 @@ console.log(state.value) // ---> { count: 0 }

- [How to persist states](https://github.com/pmndrs/valtio/wiki/How-to-persist-states)
- [How to use with context](https://github.com/pmndrs/valtio/wiki/How-to-use-with-context)
- [How to split and compose states](https://github.com/pmndrs/valtio/wiki/How-to-split-and-compose-states)

@@ -75,2 +75,3 @@ 'use strict';

var DEVTOOLS = Symbol();
var devtools = function devtools(proxyObject, name) {

@@ -95,7 +96,26 @@ var extension;

});
var unsub1 = vanilla.subscribe(proxyObject, function () {
var unsub1 = vanilla.subscribe(proxyObject, function (ops) {
var action = ops.filter(function (_ref) {
_ref[0];
var path = _ref[1];
return path[0] !== DEVTOOLS;
}).map(function (_ref2) {
var op = _ref2[0],
path = _ref2[1];
return op + ":" + path.map(String).join('.');
}).join(', ');
if (!action) {
return;
}
if (isTimeTraveling) {
isTimeTraveling = false;
} else {
devtools.send("Update - " + new Date().toLocaleString(), vanilla.snapshot(proxyObject));
var snapWithoutDevtools = Object.assign({}, vanilla.snapshot(proxyObject));
delete snapWithoutDevtools[DEVTOOLS];
devtools.send({
type: action,
updatedAt: new Date().toLocaleString()
}, snapWithoutDevtools);
}

@@ -112,7 +132,3 @@ });

}
var nextValue = JSON.parse(message.state);
Object.keys(nextValue).forEach(function (key) {
proxyObject[key] = nextValue[key];
});
proxyObject[DEVTOOLS] = message;
} else if (message.type === 'DISPATCH' && ((_message$payload3 = message.payload) == null ? void 0 : _message$payload3.type) === 'COMMIT') {

@@ -126,5 +142,5 @@ devtools.init(vanilla.snapshot(proxyObject));

isTimeTraveling = true;
computedStates.forEach(function (_ref, index) {
var state = _ref.state;
var action = actions[index] || "Update - " + new Date().toLocaleString();
computedStates.forEach(function (_ref3, index) {
var state = _ref3.state;
var action = actions[index] || 'No action found';
Object.keys(state).forEach(function (key) {

@@ -131,0 +147,0 @@ proxyObject[key] = state[key];

Sorry, the diff of this file is not supported yet

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