Comparing version 0.0.12 to 0.0.13
@@ -1,3 +0,73 @@ | ||
import { ProxyLens } from "./proxy-lens"; | ||
export { stateful, stateless, useStateful } from "./react"; | ||
export declare type Lens<A> = Omit<ProxyLens<A>, symbol>; | ||
declare type Listener = () => void; | ||
declare type Unsubscribe = () => void; | ||
declare type Updater$1<A> = (a: A) => A; | ||
declare type Store<A> = { | ||
getSnapshot(): A; | ||
subscribe(onStoreChange: Listener): Unsubscribe; | ||
update(updater: Updater$1<A>): void; | ||
}; | ||
declare type ShouldUpdateBoolean = boolean; | ||
declare type ShouldUpdateArray<A> = (keyof A)[]; | ||
declare type ShouldUpdateObject<A> = { | ||
[K in keyof A]?: A[K] extends any[] ? ShouldUpdate<A[K][number]> : ShouldUpdate<A[K]>; | ||
}; | ||
declare type ShouldUpdateFunction<A> = (prev: A, next: A) => boolean; | ||
declare type ShouldUpdate<A> = ShouldUpdateBoolean | ShouldUpdateFunction<A> | ShouldUpdateArray<A> | ShouldUpdateObject<A>; | ||
declare type AnyObject = { | ||
[key: string | number | symbol]: JSON; | ||
}; | ||
declare type AnyArray = JSON[]; | ||
declare type AnyPrimitive = number | bigint | string | boolean | null | void | symbol; | ||
declare type JSON = AnyArray | AnyObject | AnyPrimitive; | ||
declare type Updater<A> = (a: A) => A; | ||
declare type Update<A> = (updater: Updater<A>) => void; | ||
declare type UseLensProxy<A> = (shouldUpdate?: ShouldUpdate<A>) => readonly [ProxyValue<A>, Update<A>]; | ||
declare type BaseProxyValue<A> = { | ||
toJSON(): A; | ||
toLens(): ProxyLens<A>; | ||
}; | ||
declare type ArrayProxyValue<A extends AnyArray> = BaseProxyValue<A> & Array<ProxyValue<A[number]>>; | ||
declare type ObjectProxyValue<A extends AnyObject> = BaseProxyValue<A> & { | ||
[K in keyof A]: ProxyValue<A[K]>; | ||
}; | ||
declare type ProxyValue<A> = A extends AnyArray ? ArrayProxyValue<A> : A extends AnyObject ? ObjectProxyValue<A> : A extends AnyPrimitive ? A : never; | ||
declare type BaseProxyLens<A> = { | ||
/** | ||
* Collapses the `ProxyLens<A>` into a `ProxyValue<A>`. | ||
*/ | ||
use: UseLensProxy<A>; | ||
/** | ||
* A unique key for cases when you need a key. e.g. A React list. | ||
* | ||
* @example | ||
* const [list] = state.use(); | ||
* | ||
* list.map(value => { | ||
* const lens = value.toLens(); | ||
* | ||
* return <ListItem key={lens.$key} state={lens} />; | ||
* }); | ||
*/ | ||
$key: string; | ||
/** | ||
* Internal. Only called by `ProxyValue#toLens`. | ||
*/ | ||
[WRAP_IN_FUNC](): ProxyLens<A>; | ||
}; | ||
declare type ArrayProxyLens<A extends AnyArray> = BaseProxyLens<A> & { | ||
[K in number]: ProxyLens<A[K]>; | ||
}; | ||
declare type ObjectProxyLens<A extends AnyObject> = BaseProxyLens<A> & { | ||
[K in keyof A]: ProxyLens<A[K]>; | ||
}; | ||
declare type PrimitiveProxyLens<A extends AnyPrimitive> = BaseProxyLens<A>; | ||
declare type ProxyLens<A> = A extends AnyArray ? ArrayProxyLens<A> : A extends AnyObject ? ObjectProxyLens<A> : A extends AnyPrimitive ? PrimitiveProxyLens<A> : never; | ||
declare const WRAP_IN_FUNC: unique symbol; | ||
declare type Lens<A> = Omit<ProxyLens<A>, symbol>; | ||
declare const concave: <S>(initialState: S) => [Lens<S>, Store<S>]; | ||
declare const useConcave: <S>(initialState: S) => [Lens<S>, Store<S>]; | ||
export { Lens, concave, useConcave }; |
{ | ||
"name": "concave", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "A Lens-like interface for state management in React", | ||
"main": "dist/concave.umd.js", | ||
"module": "dist/concave.es.js", | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./dist/concave.es.js", | ||
"require": "./dist/concave.umd.js" | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js" | ||
} | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"author": "Gabe Scholz", | ||
"license": "MIT", | ||
"sideEffects": false, | ||
"files": [ | ||
"dist" | ||
], | ||
"keywords": [ | ||
@@ -35,3 +35,3 @@ "react", | ||
"typecheck": "tsc --noEmit", | ||
"build": "rm -rf dist && vite build", | ||
"build": "tsup", | ||
"prepublish": "yarn test && yarn typecheck && yarn build" | ||
@@ -41,3 +41,2 @@ }, | ||
"devDependencies": { | ||
"@rollup/plugin-typescript": "^8.3.0", | ||
"@testing-library/react": "^13.0.0-alpha.5", | ||
@@ -51,10 +50,9 @@ "@types/jest": "^27.0.3", | ||
"ts-jest": "^27.1.2", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.5.4", | ||
"vite": "^2.7.4" | ||
"tsup": "^5.11.7", | ||
"typescript": "^4.5.4" | ||
}, | ||
"peerDependencies": { | ||
"react": "^18.0.0-rc.0", | ||
"react-dom": "^18.0.0-rc.0" | ||
"@types/react": "^17.0.37", | ||
"react": "^18.0.0-rc.0" | ||
} | ||
} |
@@ -13,3 +13,3 @@ # 🧐 Concave | ||
### `stateful<S>(initialState: S): [Lens<S>, MutableRefObject<S>]` | ||
### `concave<S>(initialState: S): [Lens<S>, Store<S>]` | ||
@@ -16,0 +16,0 @@ ### `stateless<S>(): [Lens<S>, LensProvider<S>]` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
107024
10
1052
2
7
1