Socket
Socket
Sign inDemoInstall

onek

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onek - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

18

package.json
{
"version": "0.0.12",
"version": "0.0.13",
"description": "⚡️1.7KB full-featured state management inspired by MobX and Solid, batteries included ⚡️",

@@ -30,4 +30,5 @@ "repository": {

"publish": "yarn run build && npm publish",
"build": "yarn exec microbundle",
"build-full": "yarn exec microbundle --no-compress",
"build": "yarn exec microbundle --generateTypes=false",
"build:full": "yarn exec microbundle --generateTypes=false --no-compress",
"build:types": "yarn exec tsc -p ./types.tsconfig.json",
"test": "yarn exec jest"

@@ -96,11 +97,4 @@ },

"devDependencies": {
"@types/jest": "^29.4.0",
"@types/react": ">=16.8.0",
"jest": "^29.0.3",
"microbundle": "^0.15.1",
"prettier": "^2.8.7",
"react": ">=18.0.0",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1"
"@types/react": ">=18.0.0"
}
}
}

@@ -1,3 +0,198 @@

export * from "./core";
export { shallowEquals } from "./core/utils/shallowEquals";
export { useObserver, Observer } from "./react/useObserver";
declare module "core/constants" {
export const enum State {
NOT_INITIALIZED = 0,
CLEAN = 1,
MAYBE_DIRTY = 2,
DIRTY = 3,
COMPUTING = 4,
PASSIVE = 5,
DESTROYED = 6
}
export const MAX_REACTION_ITERATIONS = 100;
}
declare module "core/types" {
import { State } from "core/constants";
export type Subscriber = ComputedImpl | ReactionImpl;
export type Subscription = ObservableImpl | ComputedImpl;
export type Revision = {};
export class ObservableImpl<T = any> {
constructor(value: T, checkFn?: boolean | CheckFn<T>);
_addSubscriber(subscriber: Subscriber): boolean;
_removeSubscriber(subscriber: Subscriber): void;
_getRevision(): Revision;
_getValue(_subscriber?: Subscriber): T;
_setValue(newValue?: T | UpdaterFn<T>, asIs?: boolean): void;
}
export class ComputedImpl<T = any> {
constructor(fn: () => T, checkFn?: boolean | CheckFn<T>);
_addSubscription(subscription: Subscription): void;
_addSubscriber(subscriber: Subscriber): boolean;
_removeSubscriber(subscriber: Subscriber): void;
_checkSubscribersAndPassivate(): void;
_notify(state: State, subscription: Subscription): void;
_actualizeAndRecompute(): void;
_destroy(): void;
_getRevision(): Revision;
_getValue(_subscriber?: Subscriber): T;
}
export type Destructor = (() => void) | null | undefined | void;
export type ReactionFn = () => Destructor;
export type Disposer = (() => void) & {
run: () => void;
};
export class ReactionImpl {
constructor(fn: ReactionFn, manager?: () => void);
_addSubscription(subscription: Subscription): void;
_notify(state: State, subscription: Subscription): void;
_subscribe(): void;
_unsubscribe(): void;
_runManager(): void;
_destroy(): void;
_run(): void;
}
export type CheckFn<T> = (prev: T, next: T) => boolean;
export type UpdaterFn<T> = (prevValue: T) => T;
export interface Getter<T> {
(subscriber?: Subscriber): T;
}
export interface Setter<T> {
(value?: T | UpdaterFn<T>, asIs?: boolean): void;
}
export interface ObservableGetter<T> extends Getter<T> {
$$observable: ObservableImpl<T>;
}
export interface ComputedGetter<T> extends Getter<T> {
$$computed: ComputedImpl<T>;
destroy(): void;
}
export type Options = {
reactionScheduler?: (runner: () => void) => void;
reactionExceptionHandler?: (exception: Error) => void;
};
}
declare module "core/subscriber" {
import type { Subscriber } from "core/types";
export let subscriber: Subscriber | null;
export function setSubscriber(newSubscriber: Subscriber | null): Subscriber | null;
}
declare module "core/schedulers/reaction" {
import { Computed, Reaction } from "core/classes/index";
import { Options } from "core/types";
export function configure(options: Options): void;
export function scheduleReaction(reaction: Reaction): void;
export function scheduleStateActualization(computed: Computed): void;
export function scheduleSubscribersCheck(computed: Computed): void;
export function scheduleReactionRunner(): void;
}
declare module "core/transaction" {
import { Subscriber } from "core/types";
export let txDepth: number;
export function tx(fn: () => void): void;
export function utx<T>(fn: () => T, subscriber?: Subscriber | null): T;
export function untracked<Args extends any[], T>(fn: (...args: Args) => T): (...args: Args) => T;
export function action<Args extends any[], T>(fn: (...args: Args) => T): (...args: Args) => T;
}
declare module "core/utils/shallowEquals" {
export function shallowEquals<T>(prev: T, next: T): boolean;
}
declare module "core/classes/computed" {
import { CheckFn, ComputedGetter, ComputedImpl, Revision, Subscriber, Subscription } from "core/types";
import { State } from "core/constants";
export type ComputedState = State.NOT_INITIALIZED | State.CLEAN | State.MAYBE_DIRTY | State.DIRTY | State.COMPUTING | State.PASSIVE;
export class Computed<T = any> implements ComputedImpl<T> {
private _value;
private _revision;
private _subscribers;
private _revisions;
private _subscriptions;
private _subscriptionsToActualize;
private _state;
private _shouldSubscribe;
private readonly _fn;
private readonly _checkFn?;
constructor(fn: () => T, checkFn?: boolean | CheckFn<T>);
_addSubscription(subscription: Subscription): void;
_addSubscriber(subscriber: Subscriber): boolean;
_removeSubscriber(subscriber: Subscriber): void;
_checkSubscribers(): void;
_checkSubscribersAndPassivate(): void;
_notify(state: State, subscription: Subscription): void;
_actualizeAndRecompute(): void;
_destroy(): void;
_getRevision(): Revision;
_getValue(_subscriber?: Subscriber | null): T;
private _subscribe;
private _unsubscribe;
private _notifySubscribers;
private _passivate;
private _resurrect;
}
export function computed<T>(fn: () => T, checkFn?: boolean | CheckFn<T>): ComputedGetter<T>;
}
declare module "core/classes/observable" {
import { CheckFn, ObservableGetter, ObservableImpl, Revision, Setter, Subscriber, UpdaterFn } from "core/types";
export class Observable<T = any> implements ObservableImpl<T> {
private _revision;
private _subscribers;
private _value;
private readonly _checkFn?;
constructor(value: T, checkFn?: boolean | CheckFn<T>);
_addSubscriber(subscriber: Subscriber): boolean;
_removeSubscriber(subscriber: Subscriber): void;
_getRevision(): Revision;
_getValue(_subscriber?: Subscriber | null): T;
_setValue(newValue?: T | UpdaterFn<T>, asIs?: boolean): void;
private _notifyChanged;
}
export function observable<T>(value: T, checkFn?: boolean | CheckFn<T>): readonly [ObservableGetter<T>, Setter<T>];
}
declare module "core/classes/reaction" {
import { Disposer, ReactionFn, ReactionImpl, Subscription } from "core/types";
import { State } from "core/constants";
export type ReactionState = State.CLEAN | State.DIRTY | State.DESTROYED;
export class Reaction implements ReactionImpl {
private _fn;
private _manager?;
private _subscriptions;
private _destructor;
private _state;
private _runnerFn;
constructor(_fn: ReactionFn, _manager?: (() => void) | undefined);
_addSubscription(subscription: Subscription): void;
_notify(state: State, subscription: Subscription): void;
_subscribe(): void;
_unsubscribe(): void;
_unsubscribeAndRemove(): void;
_runManager(): void;
_destroy(): void;
_run(): void;
}
export function reaction(fn: ReactionFn, manager?: () => void): Disposer;
}
declare module "core/classes/index" {
export { Observable, observable } from "core/classes/observable";
export { Computed, computed } from "core/classes/computed";
export { Reaction, reaction } from "core/classes/reaction";
}
declare module "core/index" {
export { observable, computed, reaction } from "core/classes/index";
export { configure } from "core/schedulers/reaction";
export { tx, utx, untracked, action } from "core/transaction";
export type { CheckFn, UpdaterFn, Getter, ObservableGetter, ComputedGetter, Setter, Disposer, } from "core/types";
export { Options } from "core/types";
export { shallowEquals } from "core/utils/shallowEquals";
}
declare module "react/abandonedRendererCleanup" {
import { Reaction } from "core/classes/index";
export function addAbandonedRenderCleanup(reaction: Reaction): void;
export function removeAbandonedRenderCleanup(reaction: Reaction): void;
}
declare module "react/useObserver" {
import { Reaction } from "core/classes/index";
export type Observer = Reaction | undefined;
export function useObserver(): Observer;
}
declare module "index" {
export * from "core/index";
export { useObserver, Observer } from "react/useObserver";
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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