New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hydroxide

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hydroxide - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

14

dist/dev-cjs.d.ts

@@ -76,3 +76,3 @@ declare global {

(): T;
deps: Set<Reactive>;
deps: Set<Reactive<any>>;
value: T;

@@ -126,3 +126,3 @@ };

detectorEnabled: boolean;
detected: Set<Reactive>;
detected: Set<Reactive<any>>;
};

@@ -150,3 +150,3 @@ type errorProps = {

declare function detect<T>(fn: () => T): [
Set<Reactive>,
Set<Reactive<any>>,
T

@@ -192,4 +192,4 @@ ];

*/
declare function subscribe(reactive: Reactive, callback: Function, phase: Phase, context?: Context): void;
declare function unsubscribe(reactive: Reactive, callback: Function, phase: Phase): void;
declare function subscribe(reactive: Reactive<any>, callback: Function, phase: Phase, context?: Context): void;
declare function unsubscribe(reactive: Reactive<any>, callback: Function, phase: Phase): void;
type Key = string | number;

@@ -201,4 +201,4 @@ type Obj = Record<Key, any>;

];
declare const globalInfo: GlobalInfo;
export { ErrorBoundary, List, onConnect, onDisconnect, onError, detect, effect, memo, reactive, batch, batching, invalidate, CONNECTION_PHASE, LIST_PHASE, RENDER_PHASE, USER_EFFECT_PHASE, subscribe, unsubscribe, targetKey, globalInfo };
declare const coreInfo: GlobalInfo;
export { ErrorBoundary, List, onConnect, onDisconnect, onError, detect, effect, memo, reactive, batch, batching, invalidate, CONNECTION_PHASE, LIST_PHASE, RENDER_PHASE, USER_EFFECT_PHASE, subscribe, unsubscribe, targetKey, coreInfo };
export type { ListProps, Context, GlobalInfo, Path, Phase, Reactive };

@@ -22,3 +22,3 @@ 'use strict';

function checkInvalidHookUsage(hookName) {
if (!globalInfo.context) {
if (!coreInfo.context) {
throw new Error(`Invalid Hook Usage: Can not use ${hookName}() hook outside of a component`);

@@ -35,7 +35,7 @@ }

}
if (globalInfo.context.onConnect) {
globalInfo.context.onConnect.push(cb);
if (coreInfo.context.onConnect) {
coreInfo.context.onConnect.push(cb);
}
else {
globalInfo.context.onConnect = [cb];
coreInfo.context.onConnect = [cb];
}

@@ -51,7 +51,7 @@ }

}
if (globalInfo.context.onDisconnect) {
globalInfo.context.onDisconnect.push(cb);
if (coreInfo.context.onDisconnect) {
coreInfo.context.onDisconnect.push(cb);
}
else {
globalInfo.context.onDisconnect = [cb];
coreInfo.context.onDisconnect = [cb];
}

@@ -62,7 +62,7 @@ }

checkInvalidHookUsage('onError');
if (globalInfo.context.onError) {
globalInfo.context.onError.push(handleError);
if (coreInfo.context.onError) {
coreInfo.context.onError.push(handleError);
}
else {
globalInfo.context.onError = [handleError];
coreInfo.context.onError = [handleError];
}

@@ -72,10 +72,10 @@ }

function detect(fn) {
const outerDetected = globalInfo.detected;
const outerDetectorEnabled = globalInfo.detectorEnabled;
const outerDetected = coreInfo.detected;
const outerDetectorEnabled = coreInfo.detectorEnabled;
// set new detector
globalInfo.detectorEnabled = true;
globalInfo.detected = new Set();
coreInfo.detectorEnabled = true;
coreInfo.detected = new Set();
// run fn
const returnValue = fn();
const dependencies = globalInfo.detected;
const dependencies = coreInfo.detected;
// add the detected dependencies of inner to outer

@@ -88,4 +88,4 @@ if (outerDetectorEnabled) {

// reset original detector
globalInfo.detectorEnabled = outerDetectorEnabled;
globalInfo.detected = outerDetected;
coreInfo.detectorEnabled = outerDetectorEnabled;
coreInfo.detected = outerDetected;
// return detected dependencies and returnValue from fn

@@ -184,3 +184,3 @@ return [dependencies, returnValue];

*/
function subscribe(reactive, callback, phase, context = globalInfo.context) {
function subscribe(reactive, callback, phase, context = coreInfo.context) {
if (!context) {

@@ -233,3 +233,3 @@ throw new Error('subscriptions can only be created inside a context');

};
const effectContext = globalInfo.context;
const effectContext = coreInfo.context;
if (!effectContext) {

@@ -299,5 +299,5 @@ console.error('invalid effect:', callback);

// if the detector is enabled, push the computed's deps
else if (globalInfo.detectorEnabled) {
else if (coreInfo.detectorEnabled) {
state.deps.forEach((dep) => {
globalInfo.detected.add(dep);
coreInfo.detected.add(dep);
});

@@ -664,4 +664,4 @@ }

// detect
if (globalInfo.detectorEnabled) {
globalInfo.detected.add(state);
if (coreInfo.detectorEnabled) {
coreInfo.detected.add(state);
}

@@ -672,3 +672,3 @@ return state.value;

state.subs = new Array(4);
state.context = globalInfo.context;
state.context = coreInfo.context;
state.updateCount = 0;

@@ -702,3 +702,3 @@ state.mutable = true;

const globalInfo = {
const coreInfo = {
context: null,

@@ -717,5 +717,5 @@ detectorEnabled: false,

exports.batching = batching;
exports.coreInfo = coreInfo;
exports.detect = detect;
exports.effect = effect;
exports.globalInfo = globalInfo;
exports.invalidate = invalidate;

@@ -722,0 +722,0 @@ exports.memo = memo;

@@ -76,3 +76,3 @@ declare global {

(): T;
deps: Set<Reactive>;
deps: Set<Reactive<any>>;
value: T;

@@ -126,3 +126,3 @@ };

detectorEnabled: boolean;
detected: Set<Reactive>;
detected: Set<Reactive<any>>;
};

@@ -150,3 +150,3 @@ type errorProps = {

declare function detect<T>(fn: () => T): [
Set<Reactive>,
Set<Reactive<any>>,
T

@@ -192,4 +192,4 @@ ];

*/
declare function subscribe(reactive: Reactive, callback: Function, phase: Phase, context?: Context): void;
declare function unsubscribe(reactive: Reactive, callback: Function, phase: Phase): void;
declare function subscribe(reactive: Reactive<any>, callback: Function, phase: Phase, context?: Context): void;
declare function unsubscribe(reactive: Reactive<any>, callback: Function, phase: Phase): void;
type Key = string | number;

@@ -201,4 +201,4 @@ type Obj = Record<Key, any>;

];
declare const globalInfo: GlobalInfo;
export { ErrorBoundary, List, onConnect, onDisconnect, onError, detect, effect, memo, reactive, batch, batching, invalidate, CONNECTION_PHASE, LIST_PHASE, RENDER_PHASE, USER_EFFECT_PHASE, subscribe, unsubscribe, targetKey, globalInfo };
declare const coreInfo: GlobalInfo;
export { ErrorBoundary, List, onConnect, onDisconnect, onError, detect, effect, memo, reactive, batch, batching, invalidate, CONNECTION_PHASE, LIST_PHASE, RENDER_PHASE, USER_EFFECT_PHASE, subscribe, unsubscribe, targetKey, coreInfo };
export type { ListProps, Context, GlobalInfo, Path, Phase, Reactive };

@@ -18,3 +18,3 @@ function ErrorBoundary(props) {

function checkInvalidHookUsage(hookName) {
if (!globalInfo.context) {
if (!coreInfo.context) {
throw new Error(`Invalid Hook Usage: Can not use ${hookName}() hook outside of a component`);

@@ -31,7 +31,7 @@ }

}
if (globalInfo.context.onConnect) {
globalInfo.context.onConnect.push(cb);
if (coreInfo.context.onConnect) {
coreInfo.context.onConnect.push(cb);
}
else {
globalInfo.context.onConnect = [cb];
coreInfo.context.onConnect = [cb];
}

@@ -47,7 +47,7 @@ }

}
if (globalInfo.context.onDisconnect) {
globalInfo.context.onDisconnect.push(cb);
if (coreInfo.context.onDisconnect) {
coreInfo.context.onDisconnect.push(cb);
}
else {
globalInfo.context.onDisconnect = [cb];
coreInfo.context.onDisconnect = [cb];
}

@@ -58,7 +58,7 @@ }

checkInvalidHookUsage('onError');
if (globalInfo.context.onError) {
globalInfo.context.onError.push(handleError);
if (coreInfo.context.onError) {
coreInfo.context.onError.push(handleError);
}
else {
globalInfo.context.onError = [handleError];
coreInfo.context.onError = [handleError];
}

@@ -68,10 +68,10 @@ }

function detect(fn) {
const outerDetected = globalInfo.detected;
const outerDetectorEnabled = globalInfo.detectorEnabled;
const outerDetected = coreInfo.detected;
const outerDetectorEnabled = coreInfo.detectorEnabled;
// set new detector
globalInfo.detectorEnabled = true;
globalInfo.detected = new Set();
coreInfo.detectorEnabled = true;
coreInfo.detected = new Set();
// run fn
const returnValue = fn();
const dependencies = globalInfo.detected;
const dependencies = coreInfo.detected;
// add the detected dependencies of inner to outer

@@ -84,4 +84,4 @@ if (outerDetectorEnabled) {

// reset original detector
globalInfo.detectorEnabled = outerDetectorEnabled;
globalInfo.detected = outerDetected;
coreInfo.detectorEnabled = outerDetectorEnabled;
coreInfo.detected = outerDetected;
// return detected dependencies and returnValue from fn

@@ -180,3 +180,3 @@ return [dependencies, returnValue];

*/
function subscribe(reactive, callback, phase, context = globalInfo.context) {
function subscribe(reactive, callback, phase, context = coreInfo.context) {
if (!context) {

@@ -229,3 +229,3 @@ throw new Error('subscriptions can only be created inside a context');

};
const effectContext = globalInfo.context;
const effectContext = coreInfo.context;
if (!effectContext) {

@@ -295,5 +295,5 @@ console.error('invalid effect:', callback);

// if the detector is enabled, push the computed's deps
else if (globalInfo.detectorEnabled) {
else if (coreInfo.detectorEnabled) {
state.deps.forEach((dep) => {
globalInfo.detected.add(dep);
coreInfo.detected.add(dep);
});

@@ -660,4 +660,4 @@ }

// detect
if (globalInfo.detectorEnabled) {
globalInfo.detected.add(state);
if (coreInfo.detectorEnabled) {
coreInfo.detected.add(state);
}

@@ -668,3 +668,3 @@ return state.value;

state.subs = new Array(4);
state.context = globalInfo.context;
state.context = coreInfo.context;
state.updateCount = 0;

@@ -698,3 +698,3 @@ state.mutable = true;

const globalInfo = {
const coreInfo = {
context: null,

@@ -705,2 +705,2 @@ detectorEnabled: false,

export { CONNECTION_PHASE, ErrorBoundary, LIST_PHASE, List, RENDER_PHASE, USER_EFFECT_PHASE, batch, batching, detect, effect, globalInfo, invalidate, memo, onConnect, onDisconnect, onError, reactive, subscribe, targetKey, unsubscribe };
export { CONNECTION_PHASE, ErrorBoundary, LIST_PHASE, List, RENDER_PHASE, USER_EFFECT_PHASE, batch, batching, coreInfo, detect, effect, invalidate, memo, onConnect, onDisconnect, onError, reactive, subscribe, targetKey, unsubscribe };

@@ -76,3 +76,3 @@ declare global {

(): T;
deps: Set<Reactive>;
deps: Set<Reactive<any>>;
value: T;

@@ -126,3 +126,3 @@ };

detectorEnabled: boolean;
detected: Set<Reactive>;
detected: Set<Reactive<any>>;
};

@@ -150,3 +150,3 @@ type errorProps = {

declare function detect<T>(fn: () => T): [
Set<Reactive>,
Set<Reactive<any>>,
T

@@ -192,4 +192,4 @@ ];

*/
declare function subscribe(reactive: Reactive, callback: Function, phase: Phase, context?: Context): void;
declare function unsubscribe(reactive: Reactive, callback: Function, phase: Phase): void;
declare function subscribe(reactive: Reactive<any>, callback: Function, phase: Phase, context?: Context): void;
declare function unsubscribe(reactive: Reactive<any>, callback: Function, phase: Phase): void;
type Key = string | number;

@@ -201,4 +201,4 @@ type Obj = Record<Key, any>;

];
declare const globalInfo: GlobalInfo;
export { ErrorBoundary, List, onConnect, onDisconnect, onError, detect, effect, memo, reactive, batch, batching, invalidate, CONNECTION_PHASE, LIST_PHASE, RENDER_PHASE, USER_EFFECT_PHASE, subscribe, unsubscribe, targetKey, globalInfo };
declare const coreInfo: GlobalInfo;
export { ErrorBoundary, List, onConnect, onDisconnect, onError, detect, effect, memo, reactive, batch, batching, invalidate, CONNECTION_PHASE, LIST_PHASE, RENDER_PHASE, USER_EFFECT_PHASE, subscribe, unsubscribe, targetKey, coreInfo };
export type { ListProps, Context, GlobalInfo, Path, Phase, Reactive };

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

"use strict";function e(e){const n=k.detected,t=k.detectorEnabled;k.detectorEnabled=!0,k.detected=new Set;const o=e(),s=k.detected;return t&&s.forEach((e=>{n.add(e)})),k.detectorEnabled=t,k.detected=n,[s,o]}Object.defineProperty(exports,"__esModule",{value:!0});const n=new Set,t={enabled:!1,cloned:new Set},o=[],s=[],c=[];function u(e,n){for(let t=0;t<n;t++){const n=e[t];for(const e of n)e()}e.splice(0,n)}function r(){n.clear();const e=o.length,t=s.length,l=c.length;0!==e&&u(o,e),0!==t&&u(s,t),0!==l&&u(c,l),0!==n.size&&r()}function l(e){t.enabled?n.has(e)||(n.add(e),e.subs[1]&&o.push(e.subs[1]),e.subs[2]&&s.push(e.subs[2]),e.subs[3]&&c.push(e.subs[3])):(e.subs[1]?.forEach((e=>e())),e.subs[2]?.forEach((e=>e())),e.subs[3]?.forEach((e=>e())),e.updateCount++)}function a(e,n,t,o=k.context){const s=e.subs[t]||(e.subs[t]=new Set);if(s.add(n),o!==e.context){const e=()=>{s.delete(n)},t=()=>{s.add(n)};o.onDisconnect?o.onDisconnect.push(e):o.onDisconnect=[e],o.onConnect?o.onConnect.push(t):o.onConnect=[t]}}function i(e,n,t){e.subs[t].delete(n)}function d(e){let n=0;return e.forEach((e=>{n+=e.updateCount})),n}function f(e,n,t){const o=e[n];e[n]=e[t],e[t]=o}function p(e,n){if(1===n.length)return[e,n[0]];const t=n.length-1;let o=e;for(let e=0;e<t;e++)o=o[n[e]];return[o,n[t]]}function h(e,n,t=0,o=n.length-1){let s=e;for(let e=t;e<=o;e++)s=s[n[e]];return s}function b(e,n,o){if(t.enabled&&t.cloned.has(e))return e.splice(n,o),e;const s=[...e.slice(0,n),...e.slice(n+o)];return t.enabled&&t.cloned.add(s),s}function v(e,n,o){let s;t.enabled&&t.cloned.has(e)?s=e:(s=g(e),t.cloned.add(s));const c=n.length-1;let u=s;for(let e=0;e<c;e++)u[n[e]]=g(u[n[e]]),u=u[n[e]];return u[n[c]]=o,s}function E(e,n,o){if(t.enabled&&t.cloned.has(e))return void e.splice(n,0,...o);const s=[...e.slice(0,n),...o,...e.slice(n)];return t.enabled&&t.cloned.add(s),s}function x(e,n,o){if(t.enabled&&t.cloned.has(e))return f(e,n,o),e;const s=[...e];return t.enabled&&t.cloned.add(s),f(s,n,o),s}function g(e){return Array.isArray(e)?[...e]:{...e}}let m,C;function w(e){const n=C||this,t=m;if(t)if(n.mutable){const o=t.length-1;let s=n.value;for(let e=0;e<o;e++)s=s[t[e]];e!==s[t[o]]&&(s[t[o]]=e)}else n.value=v(n.value,t,e);else e!==n.value&&(n.value=e);return n.subs[0]?.forEach((n=>n("set",t,e))),l(n),m=null,C=null,n}function S(e){const n=C||this,t=m;if(t){const o=h(n.value,t),s=e(o);return o===s?n:n.set(s)}{const t=e(n.value);return n.value===t?n:n.set(t)}}function y(e,n){const t=C||this,o=m;if(o){const s=h(t.value,o),c=e<0?s.length+e+1:e;t.mutable?s.splice(c,0,...n):t.value=v(t,o,E(s,c,n))}else{const o=e<0?t.value.length+e+1:e;t.mutable?t.value.splice(o,0,...n):t.value=E(t.value,o,n),t.subs[0]?.forEach((e=>{e("insert",o,n)}))}return m=null,C=null,l(t),t}function A(e,n){return C=C||this,y(e,[n])}function D(e){return C=C||this,y(-1,[e])}function _(e){return C=C||this,y(-1,e)}function L(e,n=1){const t=C||this,o=m;if(o){const s=h(t.value,o),c=e<0?s.length+e:e;t.mutable?s.splice(c,n):t.value=v(t.value,o,b(s,c,n))}else{const o=e<0?t.value.length+e:e;t.mutable?t.value.splice(o,n):t.value=b(t.value,o,n),t.subs[0]?.forEach((e=>e("remove",o,n)))}return m=null,C=null,l(t),t}function H(e=1){return C=C||this,L(-1*e,e)}function P(){const e=C||this,n=m;if(n)if(e.mutable){const[t,o]=p(e.value,n);0!==t[o].length&&(t[o]=[],l(e))}else 0!==e.value.length&&(e.value=v(e.value,n,[]),l(e));else 0!==e.value.length&&(e.value=[],e.subs[0]?.forEach((e=>e("clear"))),l(e));return m=null,C=null,e}function I(e,n){const t=C||this,o=m;if(o){const s=h(t.value,o);if(t.mutable)f(s,e,n);else{const s=h(t.value,o);t.value=v(C,o,x(s,e,n))}}else t.mutable?f(t.value,e,n):t.value=x(t.value,e,n),t.subs[0]?.forEach((t=>t("swap",e,n)));return m=null,C=null,t}const N={set:w,insert:A,insertList:y,remove:L,push:D,pushList:_,swap:I,clear:P,perform:S,pop:H};function $(...e){return C=this,m=e,N}const k={context:null,detectorEnabled:!1,detected:new Set};exports.CONNECTION_PHASE=1,exports.ErrorBoundary=function(e){try{return e.children}catch(n){return e.fallback||"Error"}},exports.LIST_PHASE=0,exports.List=function(e){return{$$list:e}},exports.RENDER_PHASE=2,exports.USER_EFFECT_PHASE=3,exports.batch=function(e){t.enabled=!0,e(),t.enabled=!1,t.cloned.clear(),r()},exports.batching=t,exports.detect=e,exports.effect=function(n,t=3){const o={deps:new Set},s=k.context;function c(){const[u]=e(n);o.deps.forEach((e=>{u.has(e)||i(e,c,t)})),u.forEach((e=>{o.deps.has(e)||a(e,c,t,s)})),o.deps=u}function u(){o.deps=e(n)[0],o.deps.forEach((e=>a(e,c,t,s)))}return 2===t?(o.deps=e(n)[0],o.deps.forEach((e=>a(e,n,t,s)))):s.onConnect?s.onConnect.push(u):s.onConnect=[u],o},exports.globalInfo=k,exports.invalidate=l,exports.memo=function(n){const t=function(){const s=d(t.deps);return o===s?k.detectorEnabled&&t.deps.forEach((e=>{k.detected.add(e)})):([t.deps,t.value]=e(n),o=d(t.deps)),t.value};[t.deps,t.value]=e(n);let o=d(t.deps);return t},exports.onConnect=function(e){k.context.onConnect?k.context.onConnect.push(e):k.context.onConnect=[e]},exports.onDisconnect=function(e){k.context.onDisconnect?k.context.onDisconnect.push(e):k.context.onDisconnect=[e]},exports.onError=function(e){!function(e){if(!k.context)throw new Error(`Invalid Hook Usage: Can not use ${e}() hook outside of a component`)}("onError"),k.context.onError?k.context.onError.push(e):k.context.onError=[e]},exports.reactive=function(e){const n=function(){return k.detectorEnabled&&k.detected.add(n),n.value};return n.value=e,n.subs=new Array(4),n.context=k.context,n.updateCount=0,n.mutable=!0,n.$=$,n.set=w,n.perform=S,Array.isArray(e)&&(n.insertList=y,n.push=D,n.pushList=_,n.insert=A,n.remove=L,n.clear=P,n.swap=I,n.pop=H),n},exports.subscribe=a,exports.targetKey=p,exports.unsubscribe=i;
"use strict";function e(e){const n=k.detected,t=k.detectorEnabled;k.detectorEnabled=!0,k.detected=new Set;const o=e(),s=k.detected;return t&&s.forEach((e=>{n.add(e)})),k.detectorEnabled=t,k.detected=n,[s,o]}Object.defineProperty(exports,"__esModule",{value:!0});const n=new Set,t={enabled:!1,cloned:new Set},o=[],s=[],c=[];function r(e,n){for(let t=0;t<n;t++){const n=e[t];for(const e of n)e()}e.splice(0,n)}function u(){n.clear();const e=o.length,t=s.length,l=c.length;0!==e&&r(o,e),0!==t&&r(s,t),0!==l&&r(c,l),0!==n.size&&u()}function l(e){t.enabled?n.has(e)||(n.add(e),e.subs[1]&&o.push(e.subs[1]),e.subs[2]&&s.push(e.subs[2]),e.subs[3]&&c.push(e.subs[3])):(e.subs[1]?.forEach((e=>e())),e.subs[2]?.forEach((e=>e())),e.subs[3]?.forEach((e=>e())),e.updateCount++)}function a(e,n,t,o=k.context){const s=e.subs[t]||(e.subs[t]=new Set);if(s.add(n),o!==e.context){const e=()=>{s.delete(n)},t=()=>{s.add(n)};o.onDisconnect?o.onDisconnect.push(e):o.onDisconnect=[e],o.onConnect?o.onConnect.push(t):o.onConnect=[t]}}function i(e,n,t){e.subs[t].delete(n)}function d(e){let n=0;return e.forEach((e=>{n+=e.updateCount})),n}function f(e,n,t){const o=e[n];e[n]=e[t],e[t]=o}function p(e,n){if(1===n.length)return[e,n[0]];const t=n.length-1;let o=e;for(let e=0;e<t;e++)o=o[n[e]];return[o,n[t]]}function h(e,n,t=0,o=n.length-1){let s=e;for(let e=t;e<=o;e++)s=s[n[e]];return s}function b(e,n,o){if(t.enabled&&t.cloned.has(e))return e.splice(n,o),e;const s=[...e.slice(0,n),...e.slice(n+o)];return t.enabled&&t.cloned.add(s),s}function v(e,n,o){let s;t.enabled&&t.cloned.has(e)?s=e:(s=g(e),t.cloned.add(s));const c=n.length-1;let r=s;for(let e=0;e<c;e++)r[n[e]]=g(r[n[e]]),r=r[n[e]];return r[n[c]]=o,s}function E(e,n,o){if(t.enabled&&t.cloned.has(e))return void e.splice(n,0,...o);const s=[...e.slice(0,n),...o,...e.slice(n)];return t.enabled&&t.cloned.add(s),s}function x(e,n,o){if(t.enabled&&t.cloned.has(e))return f(e,n,o),e;const s=[...e];return t.enabled&&t.cloned.add(s),f(s,n,o),s}function g(e){return Array.isArray(e)?[...e]:{...e}}let m,C;function w(e){const n=C||this,t=m;if(t)if(n.mutable){const o=t.length-1;let s=n.value;for(let e=0;e<o;e++)s=s[t[e]];e!==s[t[o]]&&(s[t[o]]=e)}else n.value=v(n.value,t,e);else e!==n.value&&(n.value=e);return n.subs[0]?.forEach((n=>n("set",t,e))),l(n),m=null,C=null,n}function S(e){const n=C||this,t=m;if(t){const o=h(n.value,t),s=e(o);return o===s?n:n.set(s)}{const t=e(n.value);return n.value===t?n:n.set(t)}}function y(e,n){const t=C||this,o=m;if(o){const s=h(t.value,o),c=e<0?s.length+e+1:e;t.mutable?s.splice(c,0,...n):t.value=v(t,o,E(s,c,n))}else{const o=e<0?t.value.length+e+1:e;t.mutable?t.value.splice(o,0,...n):t.value=E(t.value,o,n),t.subs[0]?.forEach((e=>{e("insert",o,n)}))}return m=null,C=null,l(t),t}function A(e,n){return C=C||this,y(e,[n])}function D(e){return C=C||this,y(-1,[e])}function _(e){return C=C||this,y(-1,e)}function L(e,n=1){const t=C||this,o=m;if(o){const s=h(t.value,o),c=e<0?s.length+e:e;t.mutable?s.splice(c,n):t.value=v(t.value,o,b(s,c,n))}else{const o=e<0?t.value.length+e:e;t.mutable?t.value.splice(o,n):t.value=b(t.value,o,n),t.subs[0]?.forEach((e=>e("remove",o,n)))}return m=null,C=null,l(t),t}function H(e=1){return C=C||this,L(-1*e,e)}function P(){const e=C||this,n=m;if(n)if(e.mutable){const[t,o]=p(e.value,n);0!==t[o].length&&(t[o]=[],l(e))}else 0!==e.value.length&&(e.value=v(e.value,n,[]),l(e));else 0!==e.value.length&&(e.value=[],e.subs[0]?.forEach((e=>e("clear"))),l(e));return m=null,C=null,e}function I(e,n){const t=C||this,o=m;if(o){const s=h(t.value,o);if(t.mutable)f(s,e,n);else{const s=h(t.value,o);t.value=v(C,o,x(s,e,n))}}else t.mutable?f(t.value,e,n):t.value=x(t.value,e,n),t.subs[0]?.forEach((t=>t("swap",e,n)));return m=null,C=null,t}const N={set:w,insert:A,insertList:y,remove:L,push:D,pushList:_,swap:I,clear:P,perform:S,pop:H};function $(...e){return C=this,m=e,N}const k={context:null,detectorEnabled:!1,detected:new Set};exports.CONNECTION_PHASE=1,exports.ErrorBoundary=function(e){try{return e.children}catch(n){return e.fallback||"Error"}},exports.LIST_PHASE=0,exports.List=function(e){return{$$list:e}},exports.RENDER_PHASE=2,exports.USER_EFFECT_PHASE=3,exports.batch=function(e){t.enabled=!0,e(),t.enabled=!1,t.cloned.clear(),u()},exports.batching=t,exports.coreInfo=k,exports.detect=e,exports.effect=function(n,t=3){const o={deps:new Set},s=k.context;function c(){const[r]=e(n);o.deps.forEach((e=>{r.has(e)||i(e,c,t)})),r.forEach((e=>{o.deps.has(e)||a(e,c,t,s)})),o.deps=r}function r(){o.deps=e(n)[0],o.deps.forEach((e=>a(e,c,t,s)))}return 2===t?(o.deps=e(n)[0],o.deps.forEach((e=>a(e,n,t,s)))):s.onConnect?s.onConnect.push(r):s.onConnect=[r],o},exports.invalidate=l,exports.memo=function(n){const t=function(){const s=d(t.deps);return o===s?k.detectorEnabled&&t.deps.forEach((e=>{k.detected.add(e)})):([t.deps,t.value]=e(n),o=d(t.deps)),t.value};[t.deps,t.value]=e(n);let o=d(t.deps);return t},exports.onConnect=function(e){k.context.onConnect?k.context.onConnect.push(e):k.context.onConnect=[e]},exports.onDisconnect=function(e){k.context.onDisconnect?k.context.onDisconnect.push(e):k.context.onDisconnect=[e]},exports.onError=function(e){!function(e){if(!k.context)throw new Error(`Invalid Hook Usage: Can not use ${e}() hook outside of a component`)}("onError"),k.context.onError?k.context.onError.push(e):k.context.onError=[e]},exports.reactive=function(e){const n=function(){return k.detectorEnabled&&k.detected.add(n),n.value};return n.value=e,n.subs=new Array(4),n.context=k.context,n.updateCount=0,n.mutable=!0,n.$=$,n.set=w,n.perform=S,Array.isArray(e)&&(n.insertList=y,n.push=D,n.pushList=_,n.insert=A,n.remove=L,n.clear=P,n.swap=I,n.pop=H),n},exports.subscribe=a,exports.targetKey=p,exports.unsubscribe=i;

@@ -76,3 +76,3 @@ declare global {

(): T;
deps: Set<Reactive>;
deps: Set<Reactive<any>>;
value: T;

@@ -126,3 +126,3 @@ };

detectorEnabled: boolean;
detected: Set<Reactive>;
detected: Set<Reactive<any>>;
};

@@ -150,3 +150,3 @@ type errorProps = {

declare function detect<T>(fn: () => T): [
Set<Reactive>,
Set<Reactive<any>>,
T

@@ -192,4 +192,4 @@ ];

*/
declare function subscribe(reactive: Reactive, callback: Function, phase: Phase, context?: Context): void;
declare function unsubscribe(reactive: Reactive, callback: Function, phase: Phase): void;
declare function subscribe(reactive: Reactive<any>, callback: Function, phase: Phase, context?: Context): void;
declare function unsubscribe(reactive: Reactive<any>, callback: Function, phase: Phase): void;
type Key = string | number;

@@ -201,4 +201,4 @@ type Obj = Record<Key, any>;

];
declare const globalInfo: GlobalInfo;
export { ErrorBoundary, List, onConnect, onDisconnect, onError, detect, effect, memo, reactive, batch, batching, invalidate, CONNECTION_PHASE, LIST_PHASE, RENDER_PHASE, USER_EFFECT_PHASE, subscribe, unsubscribe, targetKey, globalInfo };
declare const coreInfo: GlobalInfo;
export { ErrorBoundary, List, onConnect, onDisconnect, onError, detect, effect, memo, reactive, batch, batching, invalidate, CONNECTION_PHASE, LIST_PHASE, RENDER_PHASE, USER_EFFECT_PHASE, subscribe, unsubscribe, targetKey, coreInfo };
export type { ListProps, Context, GlobalInfo, Path, Phase, Reactive };

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

function e(e){try{return e.children}catch(n){return e.fallback||"Error"}}function n(e){return{$$list:e}}function t(e){T.context.onConnect?T.context.onConnect.push(e):T.context.onConnect=[e]}function o(e){T.context.onDisconnect?T.context.onDisconnect.push(e):T.context.onDisconnect=[e]}function c(e){!function(e){if(!T.context)throw new Error(`Invalid Hook Usage: Can not use ${e}() hook outside of a component`)}("onError"),T.context.onError?T.context.onError.push(e):T.context.onError=[e]}function u(e){const n=T.detected,t=T.detectorEnabled;T.detectorEnabled=!0,T.detected=new Set;const o=e(),c=T.detected;return t&&c.forEach((e=>{n.add(e)})),T.detectorEnabled=t,T.detected=n,[c,o]}const s=new Set,l=0,r=1,a=2,i=3,d={enabled:!1,cloned:new Set},f=[],h=[],p=[];function b(e,n){for(let t=0;t<n;t++){const n=e[t];for(const e of n)e()}e.splice(0,n)}function v(){s.clear();const e=f.length,n=h.length,t=p.length;0!==e&&b(f,e),0!==n&&b(h,n),0!==t&&b(p,t),0!==s.size&&v()}function E(e){d.enabled=!0,e(),d.enabled=!1,d.cloned.clear(),v()}function x(e){d.enabled?s.has(e)||(s.add(e),e.subs[1]&&f.push(e.subs[1]),e.subs[2]&&h.push(e.subs[2]),e.subs[3]&&p.push(e.subs[3])):(e.subs[1]?.forEach((e=>e())),e.subs[2]?.forEach((e=>e())),e.subs[3]?.forEach((e=>e())),e.updateCount++)}function g(e,n,t,o=T.context){const c=e.subs[t]||(e.subs[t]=new Set);if(c.add(n),o!==e.context){const e=()=>{c.delete(n)},t=()=>{c.add(n)};o.onDisconnect?o.onDisconnect.push(e):o.onDisconnect=[e],o.onConnect?o.onConnect.push(t):o.onConnect=[t]}}function m(e,n,t){e.subs[t].delete(n)}function C(e,n=3){const t={deps:new Set},o=T.context;function c(){const[s]=u(e);t.deps.forEach((e=>{s.has(e)||m(e,c,n)})),s.forEach((e=>{t.deps.has(e)||g(e,c,n,o)})),t.deps=s}function s(){t.deps=u(e)[0],t.deps.forEach((e=>g(e,c,n,o)))}return 2===n?(t.deps=u(e)[0],t.deps.forEach((t=>g(t,e,n,o)))):o.onConnect?o.onConnect.push(s):o.onConnect=[s],t}function w(e){const n=function(){const o=y(n.deps);return t===o?T.detectorEnabled&&n.deps.forEach((e=>{T.detected.add(e)})):([n.deps,n.value]=u(e),t=y(n.deps)),n.value};[n.deps,n.value]=u(e);let t=y(n.deps);return n}function y(e){let n=0;return e.forEach((e=>{n+=e.updateCount})),n}function D(e,n,t){const o=e[n];e[n]=e[t],e[t]=o}function S(e,n){if(1===n.length)return[e,n[0]];const t=n.length-1;let o=e;for(let e=0;e<t;e++)o=o[n[e]];return[o,n[t]]}function A(e,n,t=0,o=n.length-1){let c=e;for(let e=t;e<=o;e++)c=c[n[e]];return c}function L(e,n,t){if(d.enabled&&d.cloned.has(e))return e.splice(n,t),e;const o=[...e.slice(0,n),...e.slice(n+t)];return d.enabled&&d.cloned.add(o),o}function $(e,n,t){let o;d.enabled&&d.cloned.has(e)?o=e:(o=H(e),d.cloned.add(o));const c=n.length-1;let u=o;for(let e=0;e<c;e++)u[n[e]]=H(u[n[e]]),u=u[n[e]];return u[n[c]]=t,o}function k(e,n,t){if(d.enabled&&d.cloned.has(e))return void e.splice(n,0,...t);const o=[...e.slice(0,n),...t,...e.slice(n)];return d.enabled&&d.cloned.add(o),o}function z(e,n,t){if(d.enabled&&d.cloned.has(e))return D(e,n,t),e;const o=[...e];return d.enabled&&d.cloned.add(o),D(o,n,t),o}function H(e){return Array.isArray(e)?[...e]:{...e}}let I,U;function j(e){const n=U||this,t=I;if(t)if(n.mutable){const o=t.length-1;let c=n.value;for(let e=0;e<o;e++)c=c[t[e]];e!==c[t[o]]&&(c[t[o]]=e)}else n.value=$(n.value,t,e);else e!==n.value&&(n.value=e);return n.subs[0]?.forEach((n=>n("set",t,e))),x(n),I=null,U=null,n}function q(e){const n=U||this,t=I;if(t){const o=A(n.value,t),c=e(o);return o===c?n:n.set(c)}{const t=e(n.value);return n.value===t?n:n.set(t)}}function B(e,n){const t=U||this,o=I;if(o){const c=A(t.value,o),u=e<0?c.length+e+1:e;t.mutable?c.splice(u,0,...n):t.value=$(t,o,k(c,u,n))}else{const o=e<0?t.value.length+e+1:e;t.mutable?t.value.splice(o,0,...n):t.value=k(t.value,o,n),t.subs[0]?.forEach((e=>{e("insert",o,n)}))}return I=null,U=null,x(t),t}function F(e,n){return U=U||this,B(e,[n])}function G(e){return U=U||this,B(-1,[e])}function J(e){return U=U||this,B(-1,e)}function K(e,n=1){const t=U||this,o=I;if(o){const c=A(t.value,o),u=e<0?c.length+e:e;t.mutable?c.splice(u,n):t.value=$(t.value,o,L(c,u,n))}else{const o=e<0?t.value.length+e:e;t.mutable?t.value.splice(o,n):t.value=L(t.value,o,n),t.subs[0]?.forEach((e=>e("remove",o,n)))}return I=null,U=null,x(t),t}function M(e=1){return U=U||this,K(-1*e,e)}function N(){const e=U||this,n=I;if(n)if(e.mutable){const[t,o]=S(e.value,n);0!==t[o].length&&(t[o]=[],x(e))}else 0!==e.value.length&&(e.value=$(e.value,n,[]),x(e));else 0!==e.value.length&&(e.value=[],e.subs[0]?.forEach((e=>e("clear"))),x(e));return I=null,U=null,e}function O(e,n){const t=U||this,o=I;if(o){const c=A(t.value,o);if(t.mutable)D(c,e,n);else{const c=A(t.value,o);t.value=$(U,o,z(c,e,n))}}else t.mutable?D(t.value,e,n):t.value=z(t.value,e,n),t.subs[0]?.forEach((t=>t("swap",e,n)));return I=null,U=null,t}const P={set:j,insert:F,insertList:B,remove:K,push:G,pushList:J,swap:O,clear:N,perform:q,pop:M};function Q(...e){return U=this,I=e,P}function R(e){const n=function(){return T.detectorEnabled&&T.detected.add(n),n.value};return n.value=e,n.subs=new Array(4),n.context=T.context,n.updateCount=0,n.mutable=!0,n.$=Q,n.set=j,n.perform=q,Array.isArray(e)&&(n.insertList=B,n.push=G,n.pushList=J,n.insert=F,n.remove=K,n.clear=N,n.swap=O,n.pop=M),n}const T={context:null,detectorEnabled:!1,detected:new Set};export{r as CONNECTION_PHASE,e as ErrorBoundary,l as LIST_PHASE,n as List,a as RENDER_PHASE,i as USER_EFFECT_PHASE,E as batch,d as batching,u as detect,C as effect,T as globalInfo,x as invalidate,w as memo,t as onConnect,o as onDisconnect,c as onError,R as reactive,g as subscribe,S as targetKey,m as unsubscribe};
function e(e){try{return e.children}catch(n){return e.fallback||"Error"}}function n(e){return{$$list:e}}function t(e){T.context.onConnect?T.context.onConnect.push(e):T.context.onConnect=[e]}function o(e){T.context.onDisconnect?T.context.onDisconnect.push(e):T.context.onDisconnect=[e]}function c(e){!function(e){if(!T.context)throw new Error(`Invalid Hook Usage: Can not use ${e}() hook outside of a component`)}("onError"),T.context.onError?T.context.onError.push(e):T.context.onError=[e]}function u(e){const n=T.detected,t=T.detectorEnabled;T.detectorEnabled=!0,T.detected=new Set;const o=e(),c=T.detected;return t&&c.forEach((e=>{n.add(e)})),T.detectorEnabled=t,T.detected=n,[c,o]}const s=new Set,l=0,r=1,a=2,i=3,d={enabled:!1,cloned:new Set},f=[],h=[],p=[];function b(e,n){for(let t=0;t<n;t++){const n=e[t];for(const e of n)e()}e.splice(0,n)}function v(){s.clear();const e=f.length,n=h.length,t=p.length;0!==e&&b(f,e),0!==n&&b(h,n),0!==t&&b(p,t),0!==s.size&&v()}function E(e){d.enabled=!0,e(),d.enabled=!1,d.cloned.clear(),v()}function x(e){d.enabled?s.has(e)||(s.add(e),e.subs[1]&&f.push(e.subs[1]),e.subs[2]&&h.push(e.subs[2]),e.subs[3]&&p.push(e.subs[3])):(e.subs[1]?.forEach((e=>e())),e.subs[2]?.forEach((e=>e())),e.subs[3]?.forEach((e=>e())),e.updateCount++)}function g(e,n,t,o=T.context){const c=e.subs[t]||(e.subs[t]=new Set);if(c.add(n),o!==e.context){const e=()=>{c.delete(n)},t=()=>{c.add(n)};o.onDisconnect?o.onDisconnect.push(e):o.onDisconnect=[e],o.onConnect?o.onConnect.push(t):o.onConnect=[t]}}function m(e,n,t){e.subs[t].delete(n)}function C(e,n=3){const t={deps:new Set},o=T.context;function c(){const[s]=u(e);t.deps.forEach((e=>{s.has(e)||m(e,c,n)})),s.forEach((e=>{t.deps.has(e)||g(e,c,n,o)})),t.deps=s}function s(){t.deps=u(e)[0],t.deps.forEach((e=>g(e,c,n,o)))}return 2===n?(t.deps=u(e)[0],t.deps.forEach((t=>g(t,e,n,o)))):o.onConnect?o.onConnect.push(s):o.onConnect=[s],t}function w(e){const n=function(){const o=y(n.deps);return t===o?T.detectorEnabled&&n.deps.forEach((e=>{T.detected.add(e)})):([n.deps,n.value]=u(e),t=y(n.deps)),n.value};[n.deps,n.value]=u(e);let t=y(n.deps);return n}function y(e){let n=0;return e.forEach((e=>{n+=e.updateCount})),n}function D(e,n,t){const o=e[n];e[n]=e[t],e[t]=o}function S(e,n){if(1===n.length)return[e,n[0]];const t=n.length-1;let o=e;for(let e=0;e<t;e++)o=o[n[e]];return[o,n[t]]}function A(e,n,t=0,o=n.length-1){let c=e;for(let e=t;e<=o;e++)c=c[n[e]];return c}function L(e,n,t){if(d.enabled&&d.cloned.has(e))return e.splice(n,t),e;const o=[...e.slice(0,n),...e.slice(n+t)];return d.enabled&&d.cloned.add(o),o}function $(e,n,t){let o;d.enabled&&d.cloned.has(e)?o=e:(o=H(e),d.cloned.add(o));const c=n.length-1;let u=o;for(let e=0;e<c;e++)u[n[e]]=H(u[n[e]]),u=u[n[e]];return u[n[c]]=t,o}function k(e,n,t){if(d.enabled&&d.cloned.has(e))return void e.splice(n,0,...t);const o=[...e.slice(0,n),...t,...e.slice(n)];return d.enabled&&d.cloned.add(o),o}function z(e,n,t){if(d.enabled&&d.cloned.has(e))return D(e,n,t),e;const o=[...e];return d.enabled&&d.cloned.add(o),D(o,n,t),o}function H(e){return Array.isArray(e)?[...e]:{...e}}let I,U;function j(e){const n=U||this,t=I;if(t)if(n.mutable){const o=t.length-1;let c=n.value;for(let e=0;e<o;e++)c=c[t[e]];e!==c[t[o]]&&(c[t[o]]=e)}else n.value=$(n.value,t,e);else e!==n.value&&(n.value=e);return n.subs[0]?.forEach((n=>n("set",t,e))),x(n),I=null,U=null,n}function q(e){const n=U||this,t=I;if(t){const o=A(n.value,t),c=e(o);return o===c?n:n.set(c)}{const t=e(n.value);return n.value===t?n:n.set(t)}}function B(e,n){const t=U||this,o=I;if(o){const c=A(t.value,o),u=e<0?c.length+e+1:e;t.mutable?c.splice(u,0,...n):t.value=$(t,o,k(c,u,n))}else{const o=e<0?t.value.length+e+1:e;t.mutable?t.value.splice(o,0,...n):t.value=k(t.value,o,n),t.subs[0]?.forEach((e=>{e("insert",o,n)}))}return I=null,U=null,x(t),t}function F(e,n){return U=U||this,B(e,[n])}function G(e){return U=U||this,B(-1,[e])}function J(e){return U=U||this,B(-1,e)}function K(e,n=1){const t=U||this,o=I;if(o){const c=A(t.value,o),u=e<0?c.length+e:e;t.mutable?c.splice(u,n):t.value=$(t.value,o,L(c,u,n))}else{const o=e<0?t.value.length+e:e;t.mutable?t.value.splice(o,n):t.value=L(t.value,o,n),t.subs[0]?.forEach((e=>e("remove",o,n)))}return I=null,U=null,x(t),t}function M(e=1){return U=U||this,K(-1*e,e)}function N(){const e=U||this,n=I;if(n)if(e.mutable){const[t,o]=S(e.value,n);0!==t[o].length&&(t[o]=[],x(e))}else 0!==e.value.length&&(e.value=$(e.value,n,[]),x(e));else 0!==e.value.length&&(e.value=[],e.subs[0]?.forEach((e=>e("clear"))),x(e));return I=null,U=null,e}function O(e,n){const t=U||this,o=I;if(o){const c=A(t.value,o);if(t.mutable)D(c,e,n);else{const c=A(t.value,o);t.value=$(U,o,z(c,e,n))}}else t.mutable?D(t.value,e,n):t.value=z(t.value,e,n),t.subs[0]?.forEach((t=>t("swap",e,n)));return I=null,U=null,t}const P={set:j,insert:F,insertList:B,remove:K,push:G,pushList:J,swap:O,clear:N,perform:q,pop:M};function Q(...e){return U=this,I=e,P}function R(e){const n=function(){return T.detectorEnabled&&T.detected.add(n),n.value};return n.value=e,n.subs=new Array(4),n.context=T.context,n.updateCount=0,n.mutable=!0,n.$=Q,n.set=j,n.perform=q,Array.isArray(e)&&(n.insertList=B,n.push=G,n.pushList=J,n.insert=F,n.remove=K,n.clear=N,n.swap=O,n.pop=M),n}const T={context:null,detectorEnabled:!1,detected:new Set};export{r as CONNECTION_PHASE,e as ErrorBoundary,l as LIST_PHASE,n as List,a as RENDER_PHASE,i as USER_EFFECT_PHASE,E as batch,d as batching,T as coreInfo,u as detect,C as effect,x as invalidate,w as memo,t as onConnect,o as onDisconnect,c as onError,R as reactive,g as subscribe,S as targetKey,m as unsubscribe};
{
"name": "hydroxide",
"description": "Next Generation Reactive Framework",
"version": "0.2.1",
"version": "0.3.0",
"author": "Manan Tank",

@@ -35,5 +35,7 @@ "license": "MIT",

"scripts": {
"clean": "rimraf dist",
"build": "rollup -c",
"ts-check": "tsc --noEmit --project tsconfig.json",
"test": "jest"
"test": "jest",
"prepublishOnly": "npm run clean && npm run build"
},

@@ -44,2 +46,3 @@ "devDependencies": {

"jest": "^27.4.5",
"rimraf": "^3.0.2",
"rollup": "^2.76.0",

@@ -46,0 +49,0 @@ "rollup-plugin-terser": "^7.0.2",

@@ -1,6 +0,6 @@

import { globalInfo } from '../index'
import { coreInfo } from '../index'
/** a hook must be used inside a context */
export function checkInvalidHookUsage(hookName: string) {
if (!globalInfo.context) {
if (!coreInfo.context) {
throw new Error(

@@ -7,0 +7,0 @@ `Invalid Hook Usage: Can not use ${hookName}() hook outside of a component`

import { checkInvalidHookUsage } from '../dev/checkInvalidHookUsage'
import { globalInfo } from '../index'
import { coreInfo } from '../index'

@@ -12,7 +12,7 @@ /**

if (globalInfo.context!.onConnect) {
globalInfo.context!.onConnect.push(cb)
if (coreInfo.context!.onConnect) {
coreInfo.context!.onConnect.push(cb)
} else {
globalInfo.context!.onConnect = [cb]
coreInfo.context!.onConnect = [cb]
}
}
import { checkInvalidHookUsage } from '../dev/checkInvalidHookUsage'
import { globalInfo } from '../index'
import { coreInfo } from '../index'

@@ -12,7 +12,7 @@ /**

if (globalInfo.context!.onDisconnect) {
globalInfo.context!.onDisconnect.push(cb)
if (coreInfo.context!.onDisconnect) {
coreInfo.context!.onDisconnect.push(cb)
} else {
globalInfo.context!.onDisconnect = [cb]
coreInfo.context!.onDisconnect = [cb]
}
}
import { checkInvalidHookUsage } from '../dev/checkInvalidHookUsage'
import { globalInfo } from '../index'
import { coreInfo } from '../index'

@@ -7,7 +7,7 @@ export function onError(handleError: (error: any) => void) {

if (globalInfo.context!.onError) {
globalInfo.context!.onError.push(handleError)
if (coreInfo.context!.onError) {
coreInfo.context!.onError.push(handleError)
} else {
globalInfo.context!.onError = [handleError]
coreInfo.context!.onError = [handleError]
}
}

@@ -25,3 +25,3 @@ import { GlobalInfo } from './types'

export const globalInfo: GlobalInfo = {
export const coreInfo: GlobalInfo = {
context: null,

@@ -28,0 +28,0 @@ detectorEnabled: false,

@@ -13,3 +13,3 @@ import { Path, Paths, PathTarget, Reactive, ReactiveMethods } from '../types'

let $path: Path | null
let $reactive: Reactive | null
let $reactive: Reactive<any> | null

@@ -16,0 +16,0 @@ /** set new value */

@@ -1,11 +0,11 @@

import { globalInfo } from '../index'
import { coreInfo } from '../index'
import { Reactive } from '../types'
export function detect<T>(fn: () => T): [Set<Reactive>, T] {
const outerDetected = globalInfo.detected
const outerDetectorEnabled = globalInfo.detectorEnabled
export function detect<T>(fn: () => T): [Set<Reactive<any>>, T] {
const outerDetected = coreInfo.detected
const outerDetectorEnabled = coreInfo.detectorEnabled
// set new detector
globalInfo.detectorEnabled = true
globalInfo.detected = new Set()
coreInfo.detectorEnabled = true
coreInfo.detected = new Set()

@@ -15,3 +15,3 @@ // run fn

const dependencies = globalInfo.detected
const dependencies = coreInfo.detected

@@ -26,4 +26,4 @@ // add the detected dependencies of inner to outer

// reset original detector
globalInfo.detectorEnabled = outerDetectorEnabled
globalInfo.detected = outerDetected
coreInfo.detectorEnabled = outerDetectorEnabled
coreInfo.detected = outerDetected

@@ -30,0 +30,0 @@ // return detected dependencies and returnValue from fn

@@ -1,2 +0,2 @@

import { globalInfo } from '../index'
import { coreInfo } from '../index'
import type { Reactive } from '../types'

@@ -19,5 +19,5 @@ import { Phase } from '../types'

const info = {
deps: new Set() as Set<Reactive>
deps: new Set() as Set<Reactive<any>>
}
const effectContext = globalInfo.context
const effectContext = coreInfo.context

@@ -24,0 +24,0 @@ if (DEV && !effectContext) {

@@ -1,2 +0,2 @@

import { globalInfo } from '../index'
import { coreInfo } from '../index'
import { Computed, Reactive } from '../types'

@@ -29,5 +29,5 @@ import { detect } from './detector'

// if the detector is enabled, push the computed's deps
else if (globalInfo.detectorEnabled) {
else if (coreInfo.detectorEnabled) {
state.deps.forEach((dep) => {
globalInfo.detected.add(dep)
coreInfo.detected.add(dep)
})

@@ -46,3 +46,3 @@ }

function computeCacheId(deps: Set<Reactive>): number {
function computeCacheId(deps: Set<Reactive<any>>): number {
let cacheId = 0

@@ -49,0 +49,0 @@ deps.forEach((dep) => {

@@ -1,2 +0,2 @@

import { globalInfo } from '../index'
import { coreInfo } from '../index'
import { Reactive, Subs } from '../types'

@@ -21,4 +21,4 @@ import {

// detect
if (globalInfo.detectorEnabled) {
globalInfo.detected.add(state)
if (coreInfo.detectorEnabled) {
coreInfo.detected.add(state)
}

@@ -31,3 +31,3 @@

state.subs = new Array(4) as Subs
state.context = globalInfo.context
state.context = coreInfo.context
state.updateCount = 0

@@ -34,0 +34,0 @@

@@ -1,2 +0,2 @@

import { globalInfo } from '../index'
import { coreInfo } from '../index'
import type { Context, Reactive } from '../types'

@@ -11,6 +11,6 @@ import { Phase } from '../types'

export function subscribe(
reactive: Reactive,
reactive: Reactive<any>,
callback: Function,
phase: Phase,
context: Context = globalInfo.context!
context: Context = coreInfo.context!
) {

@@ -52,4 +52,4 @@ if (DEV && !context) {

export function unsubscribe(reactive: Reactive, callback: Function, phase: Phase) {
export function unsubscribe(reactive: Reactive<any>, callback: Function, phase: Phase) {
reactive.subs[phase]!.delete(callback)
}

@@ -67,3 +67,3 @@ declare global {

enabled: boolean
detected: Set<Reactive>
detected: Set<Reactive<any>>
}

@@ -80,3 +80,3 @@

export type Reactive<T = any> = {
export type Reactive<T> = {
(): T

@@ -93,3 +93,3 @@ value: T

(): T
deps: Set<Reactive>
deps: Set<Reactive<any>>
value: T

@@ -170,7 +170,7 @@ }

detectorEnabled: boolean
detected: Set<Reactive>
detected: Set<Reactive<any>>
}
export type EffectInfo = {
deps: Set<Reactive>
deps: Set<Reactive<any>>
}

@@ -1,8 +0,8 @@

import { Context, globalInfo } from '../../src/index'
import { Context, coreInfo } from '../../src/index'
export function inContext(fn: Function, connect = false) {
globalInfo.context = { isConnected: true } as Context
const context = globalInfo.context
coreInfo.context = { isConnected: true } as Context
const context = coreInfo.context
fn()
globalInfo.context = null
coreInfo.context = null
if (connect) {

@@ -9,0 +9,0 @@ if (context.onConnect) {

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