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.1 to 1.2.2

esm/index.mjs

2

esm/macro.js

@@ -0,4 +1,4 @@

import { addNamed } from '@babel/helper-module-imports';
import * as t from '@babel/types';
import { createMacro, MacroError } from 'babel-plugin-macros';
import { addNamed } from '@babel/helper-module-imports';

@@ -5,0 +5,0 @@ const macro = ({ references }) => {

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

const proxyWithHistory = (initialValue) => {
const proxyWithHistory = (initialValue, skipSubscribe = false) => {
const proxyObject = proxy({

@@ -300,10 +300,13 @@ value: initialValue,

++proxyObject.history.index;
}
},
subscribe: () => subscribe(proxyObject, (ops) => {
if (ops.some((op) => op[1][0] === "value" && (op[0] !== "set" || op[2] !== proxyObject.history.wip))) {
proxyObject.saveHistory();
}
})
});
proxyObject.saveHistory();
subscribe(proxyObject, (ops) => {
if (ops.some((op) => op[1][0] === "value" && (op[0] !== "set" || op[2] !== proxyObject.history.wip))) {
proxyObject.saveHistory();
}
});
if (!skipSubscribe) {
proxyObject.subscribe();
}
return proxyObject;

@@ -310,0 +313,0 @@ };

@@ -24,3 +24,3 @@ /**

*/
export declare const proxyWithHistory: <V>(initialValue: V) => {
export declare const proxyWithHistory: <V>(initialValue: V, skipSubscribe?: boolean) => {
value: V;

@@ -37,2 +37,3 @@ history: {

saveHistory: () => void;
subscribe: () => () => void;
};

@@ -12,2 +12,2 @@ /**

*/
export declare const subscribeKey: <T extends object>(proxyObject: T, key: keyof T, callback: (value: T[keyof T]) => void, notifyInSync?: boolean | undefined) => () => void;
export declare const subscribeKey: <T extends object, K extends keyof T>(proxyObject: T, key: K, callback: (value: T[K]) => void, notifyInSync?: boolean | undefined) => () => void;

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

var getMutableSource = function getMutableSource(proxyObject) {
if (!mutableSourceCache.has(proxyObject)) {

@@ -95,0 +96,0 @@ mutableSourceCache.set(proxyObject, createMutableSource(proxyObject, vanilla.getVersion));

@@ -5,5 +5,5 @@ 'use strict';

var helperModuleImports = require('@babel/helper-module-imports');
var t = require('@babel/types');
var babelPluginMacros = require('babel-plugin-macros');
var helperModuleImports = require('@babel/helper-module-imports');

@@ -10,0 +10,0 @@ function _interopNamespace(e) {

{
"name": "valtio",
"private": false,
"version": "1.2.1",
"version": "1.2.2",
"description": "💊 Valtio makes proxy-state simple for React and Vanilla",
"main": "./index.js",
"module": "./esm/index.js",
"types": "./index.d.ts",

@@ -24,3 +23,3 @@ "typesVersions": {

"module": "./esm/index.js",
"import": "./esm/index.js",
"import": "./esm/index.mjs",
"default": "./index.js"

@@ -31,3 +30,3 @@ },

"module": "./esm/vanilla.js",
"import": "./esm/vanilla.js",
"import": "./esm/vanilla.mjs",
"default": "./vanilla.js"

@@ -38,3 +37,3 @@ },

"module": "./esm/utils.js",
"import": "./esm/utils.js",
"import": "./esm/utils.mjs",
"default": "./utils.js"

@@ -45,3 +44,3 @@ },

"module": "./esm/macro.js",
"import": "./esm/macro.js",
"import": "./esm/macro.mjs",
"default": "./macro.js"

@@ -48,0 +47,0 @@ }

@@ -307,2 +307,5 @@ <img src="logo.svg" alt="valtio">

The last use case fails to infer types in TypeScript
[#192](https://github.com/pmndrs/valtio/issues/192).
#### `proxyWithHistory` util

@@ -309,0 +312,0 @@

@@ -24,3 +24,3 @@ /**

*/
export declare const proxyWithHistory: <V>(initialValue: V) => {
export declare const proxyWithHistory: <V>(initialValue: V, skipSubscribe?: boolean) => {
value: V;

@@ -37,2 +37,3 @@ history: {

saveHistory: () => void;
subscribe: () => () => void;
};

@@ -12,2 +12,2 @@ /**

*/
export declare const subscribeKey: <T extends object>(proxyObject: T, key: keyof T, callback: (value: T[keyof T]) => void, notifyInSync?: boolean | undefined) => () => void;
export declare const subscribeKey: <T extends object, K extends keyof T>(proxyObject: T, key: K, callback: (value: T[K]) => void, notifyInSync?: boolean | undefined) => () => void;

@@ -24,3 +24,3 @@ /**

*/
export declare const proxyWithHistory: <V>(initialValue: V) => {
export declare const proxyWithHistory: <V>(initialValue: V, skipSubscribe?: boolean) => {
value: V;

@@ -37,2 +37,3 @@ history: {

saveHistory: () => void;
subscribe: () => () => void;
};

@@ -12,2 +12,2 @@ /**

*/
export declare const subscribeKey: <T extends object>(proxyObject: T, key: keyof T, callback: (value: T[keyof T]) => void, notifyInSync?: boolean | undefined) => () => void;
export declare const subscribeKey: <T extends object, K extends keyof T>(proxyObject: T, key: K, callback: (value: T[K]) => void, notifyInSync?: boolean | undefined) => () => void;

@@ -364,3 +364,7 @@ 'use strict';

var proxyWithHistory = function proxyWithHistory(initialValue) {
var proxyWithHistory = function proxyWithHistory(initialValue, skipSubscribe) {
if (skipSubscribe === void 0) {
skipSubscribe = false;
}
var proxyObject = vanilla.proxy({

@@ -395,12 +399,19 @@ value: initialValue,

++proxyObject.history.index;
},
subscribe: function subscribe() {
return vanilla.subscribe(proxyObject, function (ops) {
if (ops.some(function (op) {
return op[1][0] === 'value' && (op[0] !== 'set' || op[2] !== proxyObject.history.wip);
})) {
proxyObject.saveHistory();
}
});
}
});
proxyObject.saveHistory();
vanilla.subscribe(proxyObject, function (ops) {
if (ops.some(function (op) {
return op[1][0] === 'value' && (op[0] !== 'set' || op[2] !== proxyObject.history.wip);
})) {
proxyObject.saveHistory();
}
});
if (!skipSubscribe) {
proxyObject.subscribe();
}
return proxyObject;

@@ -407,0 +418,0 @@ };

@@ -24,3 +24,3 @@ /**

*/
export declare const proxyWithHistory: <V>(initialValue: V) => {
export declare const proxyWithHistory: <V>(initialValue: V, skipSubscribe?: boolean) => {
value: V;

@@ -37,2 +37,3 @@ history: {

saveHistory: () => void;
subscribe: () => () => void;
};

@@ -12,2 +12,2 @@ /**

*/
export declare const subscribeKey: <T extends object>(proxyObject: T, key: keyof T, callback: (value: T[keyof T]) => void, notifyInSync?: boolean | undefined) => () => void;
export declare const subscribeKey: <T extends object, K extends keyof T>(proxyObject: T, key: K, callback: (value: T[K]) => void, notifyInSync?: boolean | undefined) => () => void;
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