Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

realar

Package Overview
Dependencies
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

realar - npm Package Compare versions

Comparing version 0.6.0-alpha.5 to 0.6.0-alpha.6

109

build/index.js

@@ -119,2 +119,4 @@ "use strict";

const key_wrap = 'wrap';
const key_has_default = new_symbol();
const key_func = 'func';
const obj_def_prop_value = (obj, key, value) => (obj_def_prop(obj, key, { value }), value);

@@ -209,20 +211,7 @@ const obj_def_prop_trait = (obj, key, trait) => obj_def_prop(obj, key, {

};
const make_trait_ent_pure_fn_untrack = (trait_fn) => (ctx, fn) => trait_fn(ctx, fn && ((a, b, c) => {
const finish = internal_untrack();
try {
return fn(a, b, c);
}
finally {
finish();
}
}));
const make_trait_ent_untrack = (trait_fn) => (ctx, fn) => trait_fn(ctx, fn && ((a, b) => {
const finish = internal_untrack();
try {
return (fn[key_get] ? fn[key_get]() : fn(a, b));
}
finally {
finish();
}
}));
const make_trait_ent_pure_fn_untrack = (trait_fn) => (ctx, fn, a, b) => trait_fn(ctx, fn && untracked_function(fn), a, b);
const make_trait_ent_untrack = (trait_fn) => (ctx, fn, a, b) => ((fn && fn[key_get] && (fn = fn[key_get])), trait_fn(ctx, fn && untracked_function(fn), a, b));
const make_trait_ent_with_second_arg_empty_value = (trait_fn) => function (ctx, fn, empty) {
return trait_fn(ctx, fn, empty, arguments.length > 3);
};
const op_trait_if_not_signal = (trait_if_not_signal, trait_if_signal) => ((ctx) => ctx[key_handler][key_is_signal] ? trait_if_signal : trait_if_not_signal);

@@ -239,4 +228,6 @@ const make_proto_for_trackable_ns = (trait_track, trait_untrack) => (obj_def_prop_trait_ns(obj_def_prop_trait_ns(obj_create(pure_fn), key_track, trait_track), key_untrack, trait_untrack));

};
const trait_ent_update = (ctx, fn) => ctx[key_set](fn ? fn(untrack(ctx[key_get])) : untrack(ctx[key_get]));
const trait_ent_update_untrack = make_trait_ent_pure_fn_untrack(trait_ent_update);
const trait_ent_update = (ctx, fn) => ctx[key_set](fn
? fn[key_get] ? fn[key_get]() : fn(untrack(ctx[key_get]))
: untrack(ctx[key_get]));
const trait_ent_update_untrack = make_trait_ent_untrack(trait_ent_update);
const trait_ent_update_by = (ctx, src, fn) => (reactionable_subscribe(src, fn

@@ -280,7 +271,5 @@ ? (src_value, src_prev_value) => ctx[key_set](fn(ctx[key_get](), src_value, src_prev_value))

const trait_ent_select_multiple_untrack = (ctx, cfg) => obj_keys(cfg).reduce((ret, key) => ((ret[key] = trait_ent_select_untrack(ctx, cfg[key])), ret), obj_empty_from(cfg));
const trait_ent_map = (ctx, fn) => (fill_entity(ctx[key_handler], ctx[key_proto], 0, 0, fn
? ctx[key_handler][key_is_signal]
? () => fn(ctx[key_get]())
: sel(() => fn(ctx[key_get]()))[0]
: ctx[key_get], ctx[key_set] && ctx[key_set].bind()));
const trait_ent_map = (ctx, fn) => (ctx[key_handler][key_is_signal]
? trait_ent_flow_int(ctx, fn)
: fill_entity(ctx[key_handler], ctx[key_proto], 0, 0, fn ? sel(() => fn(ctx[key_get]()))[0] : ctx[key_get], ctx[key_set] && ctx[key_set].bind()));
const trait_ent_map_untrack = make_trait_ent_pure_fn_untrack(trait_ent_map);

@@ -304,32 +293,35 @@ const trait_ent_map_to = (ctx, val) => trait_ent_map(ctx, () => val);

const trait_ent_wrap_untrack = (ctx, fn_pre, fn_map) => (trait_ent_map_untrack(trait_ent_pre_untrack(ctx, fn_pre), fn_map));
const trait_ent_flow = (ctx, fn, empty_val) => {
const trait_ent_flow_int = (ctx, fn, empty_val, has_empty) => {
fn || (fn = pure_arrow_fn_returns_arg);
let started, prev;
const is_signal = ctx[key_handler][key_is_signal];
let is_not_first_run, first_run_result, prev;
const f = un_flow(() => {
const v = ctx[key_get]();
try {
return fn(v, prev);
}
finally {
prev = v;
}
const real_prev = prev;
prev = ctx[key_get]();
return is_not_first_run ? fn(prev, real_prev)
: (first_run_result =
(is_signal && !ctx[key_handler][key_has_default]) ? internal_flow_stop : fn(prev, real_prev));
}, empty_val, is_signal && pure_arrow_fn_returns_undef);
const h = [
() => ((started || (f[0](), (started = 1))), f[1]()),
ctx[key_set] && ctx[key_set].bind()
];
f[0]();
const h = [f[1], ctx[key_set] && ctx[key_set].bind()];
h[key_is_signal] = is_signal;
if (!is_not_first_run) {
is_not_first_run = 1;
h[key_has_default] = (first_run_result !== internal_flow_stop) || has_empty;
}
return fill_entity(h, h[1] ? proto_entity_writtable : proto_entity_readable);
};
const trait_ent_flow_untrack = make_trait_ent_pure_fn_untrack(trait_ent_flow);
const trait_ent_filter = (ctx, fn, empty_val) => (trait_ent_flow(ctx, fn
const trait_ent_flow = make_trait_ent_with_second_arg_empty_value(trait_ent_flow_int);
const trait_ent_flow_untrack = make_trait_ent_with_second_arg_empty_value(make_trait_ent_pure_fn_untrack(trait_ent_flow_int));
const trait_ent_filter_int = (ctx, fn, empty_val, has_empty) => (trait_ent_flow_int(ctx, fn
? (fn[key_get] && (fn = fn[key_get]),
(v, prev) => (fn(v, prev) ? v : internal_flow_stop))
: (v) => v || internal_flow_stop, empty_val));
const trait_ent_filter_untrack = make_trait_ent_untrack(trait_ent_filter);
const trait_ent_filter_not = (ctx, fn, empty_val) => (trait_ent_filter(ctx, fn
: (v) => v || internal_flow_stop, empty_val, has_empty));
const trait_ent_filter = make_trait_ent_with_second_arg_empty_value(trait_ent_filter_int);
const trait_ent_filter_untrack = make_trait_ent_with_second_arg_empty_value(make_trait_ent_untrack(trait_ent_filter_int));
const trait_ent_filter_not_int = (ctx, fn, empty_val, has_empty) => (trait_ent_filter_int(ctx, fn
? (fn[key_get] && (fn = fn[key_get]), (v) => !fn(v))
: pure_arrow_fn_returns_not_arg, empty_val));
const trait_ent_filter_not_untrack = make_trait_ent_untrack(trait_ent_filter_not);
: pure_arrow_fn_returns_not_arg, empty_val, has_empty));
const trait_ent_filter_not = make_trait_ent_with_second_arg_empty_value(trait_ent_filter_not_int);
const trait_ent_filter_not_untrack = make_trait_ent_with_second_arg_empty_value(make_trait_ent_untrack(trait_ent_filter_not_int));
const trait_ent_as_value = (ctx) => (value_from(ctx[key_get], ctx[key_set]));

@@ -442,9 +434,10 @@ const trait_ent_op = (ctx, f) => ((f = f(ctx)), (f === const_undef ? ctx : f));

const make_trigger = (initial, has_inverted_to, is_signal) => {
const handler = box(initial, () => (handler[key_touched_internal] = 1), is_signal && pure_arrow_fn_returns_undef);
const h = box(initial, () => (h[key_touched_internal] = 1), is_signal && pure_arrow_fn_returns_undef);
const set = has_inverted_to
? () => { handler[key_touched_internal] || handler[1](!untrack(handler[0])); }
: (v) => { handler[key_touched_internal] || handler[1](v); };
handler[key_reset_promise_by_reset] = 1;
handler[key_is_signal] = is_signal;
return fill_entity(handler, proto_entity_writtable_leaf, 1, initial, 0, set);
? () => { h[key_touched_internal] || h[1](!untrack(h[0])); }
: (v) => { h[key_touched_internal] || h[1](v); };
h[key_reset_promise_by_reset] = 1;
h[key_is_signal] = is_signal;
h[key_has_default] = 1;
return fill_entity(h, proto_entity_writtable_leaf, 1, initial, 0, set);
};

@@ -476,5 +469,6 @@ const get_getter_to_reactionable_or_custom = (re) => ((re && re[key_get]) || (typeof re === const_string_function ? re : () => re));

value[key_combine] = value_combine;
const signal = ((initial) => {
const signal = (function (initial) {
const h = box(initial, 0, pure_arrow_fn_returns_undef);
h[key_is_signal] = 1;
h[key_has_default] = arguments.length > 0;
return fill_entity(h, proto_entity_writtable_leaf, 1, initial);

@@ -489,2 +483,3 @@ });

h[key_is_signal] = 1;
h[key_has_default] = 1;
if (set)

@@ -515,2 +510,11 @@ h[1] = set[key_set] ? set[key_set].bind() : (v) => set(v, untrack(ctx[key_get]));

};
const untracked_function = (fn) => function () {
const finish = internal_untrack();
try {
return fn.apply(this, arguments);
}
finally {
finish();
}
};
//

@@ -541,2 +545,3 @@ // Realar exportable api

untrack[key_unsafe] = internal_untrack;
untrack[key_func] = untracked_function;
const isolate = ((fn) => {

@@ -543,0 +548,0 @@ let unsubs;

@@ -166,3 +166,5 @@ import { FC } from 'react';

(func?: (value: O) => I): void;
(re: Re<I>): void;
track(func?: (value: O) => I): void;
track(re: Re<I>): void;
by: {

@@ -236,4 +238,4 @@ <T>(re: Re<Will<T>>, updater?: (state: O, reValue: T, rePrev: WillExpand<Will<T>>) => I): any;

map: {
<R>(func: (value: WillExpand<O>) => R): Signal<I, R>;
track<R>(func: (value: WillExpand<O>) => R): Signal<I, R>;
<R>(func: (value: WillExtract<O>) => R): Signal<I, R>;
track<R>(func: (value: WillExtract<O>) => R): Signal<I, R>;
to(): Signal<I, void>;

@@ -247,4 +249,4 @@ to<R>(value: R): Signal<I, R>;

wrap: {
<N, R>(pre: (value: N, state: WillExpand<O>) => I, map: (value: WillExpand<O>) => R): Signal<N, R>;
track<N, R>(pre: (value: N, state: WillExpand<O>) => I, map: (value: WillExpand<O>) => R): Signal<N, R>;
<N, R>(pre: (value: N, state: WillExpand<O>) => I, map: (value: WillExtract<O>) => R): Signal<N, R>;
track<N, R>(pre: (value: N, state: WillExpand<O>) => I, map: (value: WillExtract<O>) => R): Signal<N, R>;
};

@@ -257,4 +259,4 @@ as: {

map: {
<R>(func: (value: WillExpand<O>) => R): SignalReadonly<R>;
track<R>(func: (value: WillExpand<O>) => R): SignalReadonly<R>;
<R>(func: (value: WillExtract<O>) => R): SignalReadonly<R>;
track<R>(func: (value: WillExtract<O>) => R): SignalReadonly<R>;
to(): SignalReadonly<void>;

@@ -267,3 +269,3 @@ to<R>(value: R): SignalReadonly<R>;

}
declare type Value<I = void, O = I> = E_SetPartial<I> & E_ValPartial<I, WillExpand<O>> & E_Value<I, O>;
declare type Value<I = undefined, O = I> = E_SetPartial<I> & E_ValPartial<I, WillExpand<O>> & E_Value<I, O>;
declare type Signal<I = void, O = I> = E_SetPartial<I> & E_ValPartial<I, WillExpand<O>> & E_Signal<I, O>;

@@ -274,7 +276,5 @@ declare type ValueReadonly<O> = E_ValReadonlyPartial<WillExpand<O>> & E_ValueReadonly<O>;

(): Value;
<T>(): Value<T, Will<T>>;
<T>(initial: T): Value<T>;
trigger: {
(): Value;
<T>(): Value<T, Will<T>>;
<T>(initial: T): Value<T>;

@@ -281,0 +281,0 @@ flag: {

{
"name": "realar",
"version": "0.6.0-alpha.5",
"version": "0.6.0-alpha.6",
"description": "Advanced state manager for React",

@@ -91,3 +91,3 @@ "repository": {

},
"gitHead": "8085e77339a4ec8b40cf8cda999a3bde0dc82fe7"
"gitHead": "59c78b1e196a3a977fe684d44d66ed85d9231fc6"
}

@@ -186,2 +186,4 @@ import React, { Context, FC } from 'react';

const key_wrap = 'wrap';
const key_has_default = new_symbol();
const key_func = 'func';

@@ -302,15 +304,12 @@

const make_trait_ent_pure_fn_untrack = (trait_fn) =>
(ctx, fn) => trait_fn(ctx, fn && ((a,b,c) => {
const finish = internal_untrack();
try { return fn(a,b,c); }
finally { finish() }
}));
(ctx, fn, a?, b?) => trait_fn(ctx, fn && untracked_function(fn), a, b);
const make_trait_ent_untrack = (trait_fn) =>
(ctx, fn) => trait_fn(ctx, fn && ((a,b) => {
const finish = internal_untrack();
try { return (fn[key_get] ? fn[key_get]() : fn(a,b)) }
finally { finish() }
}));
(ctx, fn, a?, b?) => ((fn && fn[key_get] && (fn = fn[key_get])), trait_fn(ctx, fn && untracked_function(fn), a, b));
const make_trait_ent_with_second_arg_empty_value = (trait_fn) =>
function(ctx, fn, empty) {
return trait_fn(ctx, fn, empty, arguments.length > 3)
};
const op_trait_if_not_signal = (trait_if_not_signal, trait_if_signal) => (

@@ -341,4 +340,6 @@ (ctx) => ctx[key_handler][key_is_signal] ? trait_if_signal : trait_if_not_signal

const trait_ent_update = (ctx, fn) => ctx[key_set](fn ? fn(untrack(ctx[key_get])) : untrack(ctx[key_get]));
const trait_ent_update_untrack = make_trait_ent_pure_fn_untrack(trait_ent_update);
const trait_ent_update = (ctx, fn) => ctx[key_set](fn
? fn[key_get] ? fn[key_get]() : fn(untrack(ctx[key_get]))
: untrack(ctx[key_get]));
const trait_ent_update_untrack = make_trait_ent_untrack(trait_ent_update);
const trait_ent_update_by = (ctx, src, fn) => (

@@ -406,11 +407,9 @@ reactionable_subscribe(src, fn

const trait_ent_map = (ctx, fn) => (
fill_entity(ctx[key_handler], ctx[key_proto],
0, 0,
fn
? ctx[key_handler][key_is_signal]
? () => fn(ctx[key_get]())
: sel(() => fn(ctx[key_get]()))[0]
: ctx[key_get],
ctx[key_set] && ctx[key_set].bind()
)
ctx[key_handler][key_is_signal]
? trait_ent_flow_int(ctx, fn)
: fill_entity(ctx[key_handler], ctx[key_proto],
0, 0,
fn ? sel(() => fn(ctx[key_get]()))[0] : ctx[key_get],
ctx[key_set] && ctx[key_set].bind()
)
);

@@ -455,16 +454,25 @@ const trait_ent_map_untrack = make_trait_ent_pure_fn_untrack(trait_ent_map);

const trait_ent_flow = (ctx, fn, empty_val) => {
const trait_ent_flow_int = (ctx, fn, empty_val?, has_empty?) => {
fn || (fn = pure_arrow_fn_returns_arg);
let started, prev;
const is_signal = ctx[key_handler][key_is_signal];
let is_not_first_run, first_run_result, prev;
const f = un_flow(() => {
const v = ctx[key_get]();
try { return fn(v, prev) }
finally { prev = v }
const real_prev = prev;
prev = ctx[key_get]();
return is_not_first_run ? fn(prev, real_prev)
: (first_run_result =
(is_signal && !ctx[key_handler][key_has_default]) ? internal_flow_stop : fn(prev, real_prev)
)
}, empty_val, is_signal && pure_arrow_fn_returns_undef);
const h = [
() => ((started || (f[0](), (started = 1))), f[1]()),
ctx[key_set] && ctx[key_set].bind()
];
f[0]();
const h = [f[1], ctx[key_set] && ctx[key_set].bind()];
h[key_is_signal] = is_signal;
if (!is_not_first_run) {
is_not_first_run = 1;
h[key_has_default] = (first_run_result !== internal_flow_stop) || has_empty
}
return fill_entity(h,

@@ -474,5 +482,6 @@ h[1] ? proto_entity_writtable : proto_entity_readable

};
const trait_ent_flow_untrack = make_trait_ent_pure_fn_untrack(trait_ent_flow);
const trait_ent_filter = (ctx, fn, empty_val) => (
trait_ent_flow(ctx, fn
const trait_ent_flow = make_trait_ent_with_second_arg_empty_value(trait_ent_flow_int);
const trait_ent_flow_untrack = make_trait_ent_with_second_arg_empty_value(make_trait_ent_pure_fn_untrack(trait_ent_flow_int));
const trait_ent_filter_int = (ctx, fn, empty_val, has_empty) => (
trait_ent_flow_int(ctx, fn
? (fn[key_get] && (fn = fn[key_get]),

@@ -483,14 +492,18 @@ (v, prev) => (

: (v) => v || internal_flow_stop,
empty_val
empty_val,
has_empty
)
);
const trait_ent_filter_untrack = make_trait_ent_untrack(trait_ent_filter)
const trait_ent_filter_not = (ctx, fn, empty_val) => (
trait_ent_filter(ctx, fn
const trait_ent_filter = make_trait_ent_with_second_arg_empty_value(trait_ent_filter_int);
const trait_ent_filter_untrack = make_trait_ent_with_second_arg_empty_value(make_trait_ent_untrack(trait_ent_filter_int))
const trait_ent_filter_not_int = (ctx, fn, empty_val, has_empty) => (
trait_ent_filter_int(ctx, fn
? (fn[key_get] && (fn = fn[key_get]), (v) => !fn(v))
: pure_arrow_fn_returns_not_arg,
empty_val
empty_val,
has_empty
)
);
const trait_ent_filter_not_untrack = make_trait_ent_untrack(trait_ent_filter_not)
const trait_ent_filter_not = make_trait_ent_with_second_arg_empty_value(trait_ent_filter_not_int);
const trait_ent_filter_not_untrack = make_trait_ent_with_second_arg_empty_value(make_trait_ent_untrack(trait_ent_filter_not_int))

@@ -734,9 +747,10 @@ const trait_ent_as_value = (ctx) => (

const make_trigger = (initial, has_inverted_to?, is_signal?) => {
const handler = box(initial, () => (handler[key_touched_internal] = 1), is_signal && pure_arrow_fn_returns_undef);
const h = box(initial, () => (h[key_touched_internal] = 1), is_signal && pure_arrow_fn_returns_undef);
const set = has_inverted_to
? () => { handler[key_touched_internal] || handler[1](!untrack(handler[0])) }
: (v) => { handler[key_touched_internal] || handler[1](v) };
handler[key_reset_promise_by_reset] = 1;
handler[key_is_signal] = is_signal;
return fill_entity(handler, proto_entity_writtable_leaf, 1, initial, 0, set);
? () => { h[key_touched_internal] || h[1](!untrack(h[0])) }
: (v) => { h[key_touched_internal] || h[1](v) };
h[key_reset_promise_by_reset] = 1;
h[key_is_signal] = is_signal;
h[key_has_default] = 1;
return fill_entity(h, proto_entity_writtable_leaf, 1, initial, 0, set);
}

@@ -781,5 +795,6 @@

const signal: SignalEntry = ((initial) => {
const signal: SignalEntry = (function (initial) {
const h = box(initial, 0 as any, pure_arrow_fn_returns_undef);
h[key_is_signal] = 1;
h[key_has_default] = arguments.length > 0;
return fill_entity(h, proto_entity_writtable_leaf, 1, initial)

@@ -794,2 +809,3 @@ }) as any;

h[key_is_signal] = 1
h[key_has_default] = 1;
if (set) h[1] = set[key_set] ? set[key_set].bind() : (v) => set(v, untrack(ctx[key_get]));

@@ -825,2 +841,8 @@ const ctx = fill_entity(h, set ? proto_entity_writtable : proto_entity_readable);

const untracked_function = (fn) => function (this: any) {
const finish = internal_untrack();
try { return fn.apply(this, arguments); }
finally { finish() }
}
//

@@ -843,2 +865,3 @@ // Realar exportable api

untrack[key_unsafe] = internal_untrack;
untrack[key_func] = untracked_function;

@@ -845,0 +868,0 @@ const isolate = ((fn?: any) => {

@@ -214,3 +214,6 @@ import { FC } from 'react';

(func?: (value: O) => I): void // untracked by default
(re: Re<I>): void
track(func?: (value: O) => I): void
track(re: Re<I>): void
by: {

@@ -310,4 +313,4 @@ <T>(re: Re<Will<T>>, updater?: (state: O, reValue: T, rePrev: WillExpand<Will<T>>) => I)

map: {
<R>(func: (value: WillExpand<O>) => R): Signal<I, R> // untracked by default
track<R>(func: (value: WillExpand<O>) => R): Signal<I, R>
<R>(func: (value: WillExtract<O>) => R): Signal<I, R> // untracked by default
track<R>(func: (value: WillExtract<O>) => R): Signal<I, R>

@@ -322,4 +325,4 @@ to(): Signal<I, void>

wrap: {
<N, R>(pre: (value: N, state: WillExpand<O>) => I, map: (value: WillExpand<O>) => R): Signal<N, R> // untracked by default
track<N, R>(pre: (value: N, state: WillExpand<O>) => I, map: (value: WillExpand<O>) => R): Signal<N, R>
<N, R>(pre: (value: N, state: WillExpand<O>) => I, map: (value: WillExtract<O>) => R): Signal<N, R> // untracked by default
track<N, R>(pre: (value: N, state: WillExpand<O>) => I, map: (value: WillExtract<O>) => R): Signal<N, R>
}

@@ -337,4 +340,4 @@ as: {

map: {
<R>(func: (value: WillExpand<O>) => R): SignalReadonly<R> // untracked by default
track<R>(func: (value: WillExpand<O>) => R): SignalReadonly<R>
<R>(func: (value: WillExtract<O>) => R): SignalReadonly<R> // untracked by default
track<R>(func: (value: WillExtract<O>) => R): SignalReadonly<R>

@@ -351,3 +354,3 @@ to(): SignalReadonly<void>

type Value<I = void, O = I> = E_SetPartial<I> & E_ValPartial<I, WillExpand<O>> & E_Value<I, O>
type Value<I = undefined, O = I> = E_SetPartial<I> & E_ValPartial<I, WillExpand<O>> & E_Value<I, O>
type Signal<I = void, O = I> = E_SetPartial<I> & E_ValPartial<I, WillExpand<O>> & E_Signal<I, O>

@@ -368,3 +371,2 @@

(): Value;
<T>(): Value<T, Will<T>>;
<T>(initial: T): Value<T>;

@@ -374,3 +376,2 @@

(): Value;
<T>(): Value<T, Will<T>>;
<T>(initial: T): Value<T>;

@@ -377,0 +378,0 @@

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