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

blac

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blac - npm Package Compare versions

Comparing version 1.0.8 to 1.0.10

src/addons/BlacAddon.d.ts

2

index.cjs.js

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

"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var l=(o=>(o.BLOC_DISPOSED="BLOC_DISPOSED",o.LISTENER_REMOVED="LISTENER_REMOVED",o.LISTENER_ADDED="LISTENER_ADDED",o.STATE_CHANGED="STATE_CHANGED",o.BLOC_CREATED="BLOC_CREATED",o))(l||{});const a=class u{constructor(t={}){this.blocInstanceMap=new Map,this.isolatedBlocMap=new Map,this.pluginList=[],this.postChangesToDocument=!1,this.addPlugin=e=>{this.pluginList.findIndex(n=>n.name===e.name)===-1&&this.pluginList.push(e)},this.reportToPlugins=(e,i,n)=>{this.pluginList.forEach(r=>{r.onEvent(e,i,n)})},this.report=(e,i,n)=>{const r=i.constructor;switch(e){case"BLOC_DISPOSED":this.disposeBloc(i);break;case"LISTENER_REMOVED":i.observer.size===0&&!r.keepAlive&&this.disposeBloc(i);break}this.reportToPlugins(e,i,n)},this.disposeBloc=e=>{e.constructor.isolated?this.unregisterIsolatedBlocInstance(e):this.unregisterBlocInstance(e)},this.getAllBlocs=(e,i={})=>{const n=e,{searchIsolated:r=n.isolated}=i;if(r){const d=this.isolatedBlocMap.get(e);if(d)return d}else return Array.from(this.blocInstanceMap.values()).filter(c=>c instanceof e);return[]},this.configure=e=>{e.exposeBlacInstance};const{__unsafe_ignore_singleton:s=!1}=t;if(u.instance&&!s)return u.instance;u.instance=this}static getInstance(){return u.instance}resetInstance(){u.instance=new u({__unsafe_ignore_singleton:!0})}createBlocInstanceMapKey(t,s){return`${t}:${s}`}unregisterBlocInstance(t){const s=this.createBlocInstanceMapKey(t.name,t.id);this.blocInstanceMap.delete(s)}registerBlocInstance(t){const s=this.createBlocInstanceMapKey(t.name,t.id);this.blocInstanceMap.set(s,t)}findRegisteredBlocInstance(t,s){if(t.isolated)return;const i=this.createBlocInstanceMapKey(t.name,s);return this.blocInstanceMap.get(i)}registerIsolatedBlocInstance(t){const s=t.constructor,e=this.isolatedBlocMap.get(s);e?e.push(t):this.isolatedBlocMap.set(s,[t])}unregisterIsolatedBlocInstance(t){const s=t.constructor,e=this.isolatedBlocMap.get(s);if(e){const i=e.findIndex(n=>n.id===t.id);e.splice(i,1),e.length===0&&this.isolatedBlocMap.delete(s)}}findIsolatedBlocInstance(t,s){const e=this.isolatedBlocMap.get(t);if(e)return e.find(i=>i.id===s)}createNewBlocInstance(t,s,e){const i=t,n=Object.prototype.hasOwnProperty.call(t,"create");i._propsOnInit=e;const r=n?i.create():new t;return r.updateId(s),i.isolated?(this.registerIsolatedBlocInstance(r),r):(this.registerBlocInstance(r),r)}getBloc(t,s={}){const i=t.isolated,n=s.id||t.name,r=i?this.findIsolatedBlocInstance(t,n):this.findRegisteredBlocInstance(t,n),{reconnect:d}=s;if(r)if(d)r.dispose();else return r;return this.createNewBlocInstance(t,n,s.props)}};a.instance=new a;a.getAllBlocs=a.instance.getAllBlocs;a.addPlugin=a.instance.addPlugin;a.configure=a.instance.configure;let I=a;class B{constructor(){this._observers=new Set}get size(){return this._observers.size}get observers(){return this._observers}subscribe(t){return this._observers.add(t),()=>this.unsubscribe(t)}unsubscribe(t){this._observers.delete(t)}notify(t,s){this._observers.forEach(e=>e(t,s))}dispose(){this._observers.clear()}}class f{constructor(t){this.isolated=!1,this.isBlacLive=!0,this.blac=I.getInstance(),this.createdAt=Date.now(),this.updateId=s=>{const e=this.id;!s||s===e||(this.id=s)},this.addEventListenerStateChange=s=>(this.blac.report(l.LISTENER_ADDED,this),this.observer.subscribe(s),()=>this.handleUnsubscribe(s)),this.handleUnsubscribe=s=>{this.observer.unsubscribe(s),this.blac.report(l.LISTENER_REMOVED,this)},this.observer=new B,this._state=t,this.blac.report(l.BLOC_CREATED,this),this.id=this.constructor.name,this.isolated=this.constructor.isolated}get props(){if(this.localProps)return this.localProps;const t=this.constructor._propsOnInit;if(t)return this.localProps=t,t}set props(t){this.localProps=t}get state(){return this._state}get name(){return this.constructor.name}dispose(){this.blac.report(l.BLOC_DISPOSED,this),this.isBlacLive=!1,this.observer.dispose()}}f.isolated=!1;f.keepAlive=!1;f.isBlacClass=!0;class b extends f{constructor(t){super(t),this.connectAddons=()=>{const{addons:s}=this;if(s)for(const e of s)e.onEmit&&this.observer.subscribe((i,n)=>{var r;(r=e.onEmit)==null||r.call(e,{newState:i,oldState:n,cubit:this})}),e.onInit&&e.onInit(this)},this.addons=this.constructor.addons,this.connectAddons()}emit(t){if(t===this.state)return;const s=this.state,e=t;this._state=t,this.observer.notify(e,s),this.blac.report(l.STATE_CHANGED,this,{newState:e,oldState:s})}patch(t,s=!1){let e=!1;if(!s)for(const i in t){const n=this.state[i];if(t[i]!==n){e=!0;break}}e&&this.emit({...this.state,...t})}}class E extends f{constructor(){super(...arguments),this.emit=t=>{const s=this.state,e=this.reducer(t,this.state);this._state=e,this.observer.notify(e,s),this.blac.report(l.STATE_CHANGED,this,{newState:e,oldState:s})}}}function S(o={}){const{localStoragePrefix:t="blac",localStorageKey:s,defaultValue:e}=o,i=c=>{console.log(t,c);const h=localStorage.getItem(`${t}:${c}`);if(!h)return e;try{return JSON.parse(JSON.parse(h)).persist}catch{return h}},n=c=>{const h=s??c.id,p=i(h);typeof p!==void 0&&c.emit(p)};let r="";return{name:"Persist",onInit:n,onEmit:({newState:c,cubit:h})=>{const p=s??h.id,g=JSON.stringify(`{"persist": ${c}}`);g!==r&&(localStorage.setItem(`${t}:${p}`,g),r=g)}}}exports.Blac=I;exports.BlacEvent=l;exports.BlacObservable=B;exports.Bloc=E;exports.BlocBase=f;exports.Cubit=b;exports.Persist=S;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var l=(c=>(c.BLOC_DISPOSED="BLOC_DISPOSED",c.LISTENER_REMOVED="LISTENER_REMOVED",c.LISTENER_ADDED="LISTENER_ADDED",c.STATE_CHANGED="STATE_CHANGED",c.BLOC_CREATED="BLOC_CREATED",c))(l||{});const o=class o{constructor(t={}){this.blocInstanceMap=new Map,this.isolatedBlocMap=new Map,this.pluginList=[],this.postChangesToDocument=!1,this.addPlugin=s=>{this.pluginList.findIndex(n=>n.name===s.name)===-1&&this.pluginList.push(s)},this.reportToPlugins=(s,i,n)=>{this.pluginList.forEach(r=>{r.onEvent(s,i,n)})},this.report=(s,i,n)=>{const r=i.constructor;switch(s){case"BLOC_DISPOSED":this.disposeBloc(i);break;case"LISTENER_REMOVED":i.observer.size===0&&!r.keepAlive&&this.disposeBloc(i);break}this.reportToPlugins(s,i,n)},this.disposeBloc=s=>{s.constructor.isolated?this.unregisterIsolatedBlocInstance(s):this.unregisterBlocInstance(s)},this.getAllBlocs=(s,i={})=>{const n=s,{searchIsolated:r=n.isolated}=i;if(r){const u=this.isolatedBlocMap.get(s);if(u)return u}else return Array.from(this.blocInstanceMap.values()).filter(a=>a instanceof s);return[]},this.configure=s=>{s.exposeBlacInstance};const{__unsafe_ignore_singleton:e=!1}=t;if(o.instance&&!e)return o.instance;o.instance=this}static getInstance(){return o.instance}resetInstance(){o.instance=new o({__unsafe_ignore_singleton:!0})}createBlocInstanceMapKey(t,e){return`${t}:${e}`}unregisterBlocInstance(t){const e=this.createBlocInstanceMapKey(t.name,t.id);this.blocInstanceMap.delete(e)}registerBlocInstance(t){const e=this.createBlocInstanceMapKey(t.name,t.id);this.blocInstanceMap.set(e,t)}findRegisteredBlocInstance(t,e){if(t.isolated)return;const i=this.createBlocInstanceMapKey(t.name,e);return this.blocInstanceMap.get(i)}registerIsolatedBlocInstance(t){const e=t.constructor,s=this.isolatedBlocMap.get(e);s?s.push(t):this.isolatedBlocMap.set(e,[t])}unregisterIsolatedBlocInstance(t){const e=t.constructor,s=this.isolatedBlocMap.get(e);if(s){const i=s.findIndex(n=>n.id===t.id);s.splice(i,1),s.length===0&&this.isolatedBlocMap.delete(e)}}findIsolatedBlocInstance(t,e){const s=this.isolatedBlocMap.get(t);if(s)return s.find(i=>i.id===e)}createNewBlocInstance(t,e,s){const i=t,n=Object.prototype.hasOwnProperty.call(t,"create");i._propsOnInit=s;const r=n?i.create():new t;return r.updateId(e),i.isolated?(this.registerIsolatedBlocInstance(r),r):(this.registerBlocInstance(r),r)}getBloc(t,e={}){const i=t.isolated,n=e.id||t.name,r=i?this.findIsolatedBlocInstance(t,n):this.findRegisteredBlocInstance(t,n),{reconnect:u}=e;if(r)if(u)r.dispose();else return r;return this.createNewBlocInstance(t,n,e.props)}};o.instance=new o,o.getAllBlocs=o.instance.getAllBlocs,o.addPlugin=o.instance.addPlugin,o.configure=o.instance.configure;let g=o;class b{constructor(){this._observers=new Set}get size(){return this._observers.size}get observers(){return this._observers}subscribe(t){return this._observers.add(t),()=>this.unsubscribe(t)}unsubscribe(t){this._observers.delete(t)}notify(t,e){this._observers.forEach(s=>s(t,e))}dispose(){this._observers.clear()}}const p=class p{constructor(t){this.isolated=!1,this.isBlacLive=!0,this.blac=g.getInstance(),this.createdAt=Date.now(),this.updateId=e=>{const s=this.id;!e||e===s||(this.id=e)},this.addEventListenerStateChange=e=>(this.blac.report(l.LISTENER_ADDED,this),this.observer.subscribe(e),()=>this.handleUnsubscribe(e)),this.handleUnsubscribe=e=>{this.observer.unsubscribe(e),this.blac.report(l.LISTENER_REMOVED,this)},this.observer=new b,this._state=t,this.blac.report(l.BLOC_CREATED,this),this.id=this.constructor.name,this.isolated=this.constructor.isolated}get props(){if(this.localProps)return this.localProps;const t=this.constructor._propsOnInit;if(t)return this.localProps=t,t}set props(t){this.localProps=t}get state(){return this._state}get name(){return this.constructor.name}dispose(){this.blac.report(l.BLOC_DISPOSED,this),this.isBlacLive=!1,this.observer.dispose()}};p.isolated=!1,p.keepAlive=!1,p.isBlacClass=!0;let f=p;class E extends f{constructor(t){super(t),this.connectAddons=()=>{const{addons:e}=this;if(e)for(const s of e)s.onEmit&&this.observer.subscribe((i,n)=>{var r;(r=s.onEmit)==null||r.call(s,{newState:i,oldState:n,cubit:this})}),s.onInit&&s.onInit(this)},this.addons=this.constructor.addons,this.connectAddons()}emit(t){if(t===this.state)return;const e=this.state,s=t;this._state=t,this.observer.notify(s,e),this.blac.report(l.STATE_CHANGED,this,{newState:s,oldState:e})}patch(t,e=!1){let s=!1;if(!e)for(const i in t){const n=this.state[i];if(t[i]!==n){s=!0;break}}s&&this.emit({...this.state,...t})}}class B extends f{constructor(){super(...arguments),this.emit=t=>{const e=this.state,s=this.reducer(t,this.state);this._state=s,this.observer.notify(s,e),this.blac.report(l.STATE_CHANGED,this,{newState:s,oldState:e})}}}function S(c={}){const{localStoragePrefix:t="blac",localStorageKey:e,defaultValue:s}=c,i=a=>{console.log(t,a);const h=localStorage.getItem(`${t}:${a}`);if(!h)return s;try{return JSON.parse(JSON.parse(h)).persist}catch{return h}},n=a=>{const h=e??a.id,d=i(h);typeof d!==void 0&&a.emit(d)};let r="";return{name:"Persist",onInit:n,onEmit:({newState:a,cubit:h})=>{const d=e??h.id,I=JSON.stringify(`{"persist": ${a}}`);I!==r&&(localStorage.setItem(`${t}:${d}`,I),r=I)}}}exports.Blac=g;exports.BlacEvent=l;exports.BlacObservable=b;exports.Bloc=B;exports.BlocBase=f;exports.Cubit=E;exports.Persist=S;
//# sourceMappingURL=index.cjs.js.map

@@ -1,105 +0,102 @@

var u = /* @__PURE__ */ ((o) => (o.BLOC_DISPOSED = "BLOC_DISPOSED", o.LISTENER_REMOVED = "LISTENER_REMOVED", o.LISTENER_ADDED = "LISTENER_ADDED", o.STATE_CHANGED = "STATE_CHANGED", o.BLOC_CREATED = "BLOC_CREATED", o))(u || {});
const a = class h {
var l = /* @__PURE__ */ ((c) => (c.BLOC_DISPOSED = "BLOC_DISPOSED", c.LISTENER_REMOVED = "LISTENER_REMOVED", c.LISTENER_ADDED = "LISTENER_ADDED", c.STATE_CHANGED = "STATE_CHANGED", c.BLOC_CREATED = "BLOC_CREATED", c))(l || {});
const o = class o {
constructor(t = {}) {
this.blocInstanceMap = /* @__PURE__ */ new Map(), this.isolatedBlocMap = /* @__PURE__ */ new Map(), this.pluginList = [], this.postChangesToDocument = !1, this.addPlugin = (e) => {
this.pluginList.findIndex((i) => i.name === e.name) === -1 && this.pluginList.push(e);
}, this.reportToPlugins = (e, n, i) => {
this.blocInstanceMap = /* @__PURE__ */ new Map(), this.isolatedBlocMap = /* @__PURE__ */ new Map(), this.pluginList = [], this.postChangesToDocument = !1, this.addPlugin = (s) => {
this.pluginList.findIndex((n) => n.name === s.name) === -1 && this.pluginList.push(s);
}, this.reportToPlugins = (s, i, n) => {
this.pluginList.forEach((r) => {
r.onEvent(e, n, i);
r.onEvent(s, i, n);
});
}, this.report = (e, n, i) => {
const r = n.constructor;
switch (e) {
}, this.report = (s, i, n) => {
const r = i.constructor;
switch (s) {
case "BLOC_DISPOSED":
this.disposeBloc(n);
this.disposeBloc(i);
break;
case "LISTENER_REMOVED":
n.observer.size === 0 && !r.keepAlive && this.disposeBloc(n);
i.observer.size === 0 && !r.keepAlive && this.disposeBloc(i);
break;
}
this.reportToPlugins(e, n, i);
}, this.disposeBloc = (e) => {
e.constructor.isolated ? this.unregisterIsolatedBlocInstance(e) : this.unregisterBlocInstance(e);
}, this.getAllBlocs = (e, n = {}) => {
const i = e, { searchIsolated: r = i.isolated } = n;
this.reportToPlugins(s, i, n);
}, this.disposeBloc = (s) => {
s.constructor.isolated ? this.unregisterIsolatedBlocInstance(s) : this.unregisterBlocInstance(s);
}, this.getAllBlocs = (s, i = {}) => {
const n = s, { searchIsolated: r = n.isolated } = i;
if (r) {
const d = this.isolatedBlocMap.get(e);
if (d)
return d;
const u = this.isolatedBlocMap.get(s);
if (u)
return u;
} else
return Array.from(this.blocInstanceMap.values()).filter((c) => c instanceof e);
return Array.from(this.blocInstanceMap.values()).filter((a) => a instanceof s);
return [];
}, this.configure = (e) => {
e.exposeBlacInstance;
}, this.configure = (s) => {
s.exposeBlacInstance;
};
const { __unsafe_ignore_singleton: s = !1 } = t;
if (h.instance && !s)
return h.instance;
h.instance = this;
const { __unsafe_ignore_singleton: e = !1 } = t;
if (o.instance && !e)
return o.instance;
o.instance = this;
}
static getInstance() {
return h.instance;
return o.instance;
}
resetInstance() {
h.instance = new h({
o.instance = new o({
__unsafe_ignore_singleton: !0
});
}
createBlocInstanceMapKey(t, s) {
return `${t}:${s}`;
createBlocInstanceMapKey(t, e) {
return `${t}:${e}`;
}
unregisterBlocInstance(t) {
const s = this.createBlocInstanceMapKey(t.name, t.id);
this.blocInstanceMap.delete(s);
const e = this.createBlocInstanceMapKey(t.name, t.id);
this.blocInstanceMap.delete(e);
}
registerBlocInstance(t) {
const s = this.createBlocInstanceMapKey(t.name, t.id);
this.blocInstanceMap.set(s, t);
const e = this.createBlocInstanceMapKey(t.name, t.id);
this.blocInstanceMap.set(e, t);
}
findRegisteredBlocInstance(t, s) {
findRegisteredBlocInstance(t, e) {
if (t.isolated)
return;
const n = this.createBlocInstanceMapKey(t.name, s);
return this.blocInstanceMap.get(n);
const i = this.createBlocInstanceMapKey(t.name, e);
return this.blocInstanceMap.get(i);
}
registerIsolatedBlocInstance(t) {
const s = t.constructor, e = this.isolatedBlocMap.get(s);
e ? e.push(t) : this.isolatedBlocMap.set(s, [t]);
const e = t.constructor, s = this.isolatedBlocMap.get(e);
s ? s.push(t) : this.isolatedBlocMap.set(e, [t]);
}
unregisterIsolatedBlocInstance(t) {
const s = t.constructor, e = this.isolatedBlocMap.get(s);
if (e) {
const n = e.findIndex((i) => i.id === t.id);
e.splice(n, 1), e.length === 0 && this.isolatedBlocMap.delete(s);
const e = t.constructor, s = this.isolatedBlocMap.get(e);
if (s) {
const i = s.findIndex((n) => n.id === t.id);
s.splice(i, 1), s.length === 0 && this.isolatedBlocMap.delete(e);
}
}
findIsolatedBlocInstance(t, s) {
const e = this.isolatedBlocMap.get(t);
if (e)
return e.find((n) => n.id === s);
findIsolatedBlocInstance(t, e) {
const s = this.isolatedBlocMap.get(t);
if (s)
return s.find((i) => i.id === e);
}
createNewBlocInstance(t, s, e) {
const n = t, i = Object.prototype.hasOwnProperty.call(
createNewBlocInstance(t, e, s) {
const i = t, n = Object.prototype.hasOwnProperty.call(
t,
"create"
);
n._propsOnInit = e;
const r = i ? n.create() : new t();
return r.updateId(s), n.isolated ? (this.registerIsolatedBlocInstance(r), r) : (this.registerBlocInstance(r), r);
i._propsOnInit = s;
const r = n ? i.create() : new t();
return r.updateId(e), i.isolated ? (this.registerIsolatedBlocInstance(r), r) : (this.registerBlocInstance(r), r);
}
getBloc(t, s = {}) {
const n = t.isolated, i = s.id || t.name, r = n ? this.findIsolatedBlocInstance(t, i) : this.findRegisteredBlocInstance(t, i), { reconnect: d } = s;
getBloc(t, e = {}) {
const i = t.isolated, n = e.id || t.name, r = i ? this.findIsolatedBlocInstance(t, n) : this.findRegisteredBlocInstance(t, n), { reconnect: u } = e;
if (r)
if (d)
if (u)
r.dispose();
else
return r;
return this.createNewBlocInstance(t, i, s.props);
return this.createNewBlocInstance(t, n, e.props);
}
};
a.instance = new a();
a.getAllBlocs = a.instance.getAllBlocs;
a.addPlugin = a.instance.addPlugin;
a.configure = a.instance.configure;
let g = a;
o.instance = new o(), o.getAllBlocs = o.instance.getAllBlocs, o.addPlugin = o.instance.addPlugin, o.configure = o.instance.configure;
let g = o;
class b {

@@ -121,4 +118,4 @@ constructor() {

}
notify(t, s) {
this._observers.forEach((e) => e(t, s));
notify(t, e) {
this._observers.forEach((s) => s(t, e));
}

@@ -129,12 +126,12 @@ dispose() {

}
class f {
const p = class p {
// onConnect(): void;
// onDisconnect(): void;
constructor(t) {
this.isolated = !1, this.isBlacLive = !0, this.blac = g.getInstance(), this.createdAt = Date.now(), this.updateId = (s) => {
const e = this.id;
!s || s === e || (this.id = s);
}, this.addEventListenerStateChange = (s) => (this.blac.report(u.LISTENER_ADDED, this), this.observer.subscribe(s), () => this.handleUnsubscribe(s)), this.handleUnsubscribe = (s) => {
this.observer.unsubscribe(s), this.blac.report(u.LISTENER_REMOVED, this);
}, this.observer = new b(), this._state = t, this.blac.report(u.BLOC_CREATED, this), this.id = this.constructor.name, this.isolated = this.constructor.isolated;
this.isolated = !1, this.isBlacLive = !0, this.blac = g.getInstance(), this.createdAt = Date.now(), this.updateId = (e) => {
const s = this.id;
!e || e === s || (this.id = e);
}, this.addEventListenerStateChange = (e) => (this.blac.report(l.LISTENER_ADDED, this), this.observer.subscribe(e), () => this.handleUnsubscribe(e)), this.handleUnsubscribe = (e) => {
this.observer.unsubscribe(e), this.blac.report(l.LISTENER_REMOVED, this);
}, this.observer = new b(), this._state = t, this.blac.report(l.BLOC_CREATED, this), this.id = this.constructor.name, this.isolated = this.constructor.isolated;
}

@@ -158,22 +155,21 @@ get props() {

dispose() {
this.blac.report(u.BLOC_DISPOSED, this), this.isBlacLive = !1, this.observer.dispose();
this.blac.report(l.BLOC_DISPOSED, this), this.isBlacLive = !1, this.observer.dispose();
}
}
f.isolated = !1;
f.keepAlive = !1;
f.isBlacClass = !0;
class B extends f {
};
p.isolated = !1, p.keepAlive = !1, p.isBlacClass = !0;
let f = p;
class E extends f {
constructor(t) {
super(t), this.connectAddons = () => {
const { addons: s } = this;
if (s)
for (const e of s)
e.onEmit && this.observer.subscribe((n, i) => {
const { addons: e } = this;
if (e)
for (const s of e)
s.onEmit && this.observer.subscribe((i, n) => {
var r;
(r = e.onEmit) == null || r.call(e, {
newState: n,
oldState: i,
(r = s.onEmit) == null || r.call(s, {
newState: i,
oldState: n,
cubit: this
});
}), e.onInit && e.onInit(this);
}), s.onInit && s.onInit(this);
}, this.addons = this.constructor.addons, this.connectAddons();

@@ -188,6 +184,6 @@ }

return;
const s = this.state, e = t;
this._state = t, this.observer.notify(e, s), this.blac.report(u.STATE_CHANGED, this, {
newState: e,
oldState: s
const e = this.state, s = t;
this._state = t, this.observer.notify(s, e), this.blac.report(l.STATE_CHANGED, this, {
newState: s,
oldState: e
});

@@ -200,22 +196,22 @@ }

**/
patch(t, s = !1) {
let e = !1;
if (!s)
for (const n in t) {
const i = this.state[n];
if (t[n] !== i) {
e = !0;
patch(t, e = !1) {
let s = !1;
if (!e)
for (const i in t) {
const n = this.state[i];
if (t[i] !== n) {
s = !0;
break;
}
}
e && this.emit({ ...this.state, ...t });
s && this.emit({ ...this.state, ...t });
}
}
class E extends f {
class S extends f {
constructor() {
super(...arguments), this.emit = (t) => {
const s = this.state, e = this.reducer(t, this.state);
this._state = e, this.observer.notify(e, s), this.blac.report(u.STATE_CHANGED, this, {
newState: e,
oldState: s
const e = this.state, s = this.reducer(t, this.state);
this._state = s, this.observer.notify(s, e), this.blac.report(l.STATE_CHANGED, this, {
newState: s,
oldState: e
});

@@ -225,20 +221,20 @@ };

}
function _(o = {}) {
function D(c = {}) {
const {
localStoragePrefix: t = "blac",
localStorageKey: s,
defaultValue: e
} = o, n = (c) => {
console.log(t, c);
const l = localStorage.getItem(`${t}:${c}`);
if (!l)
return e;
localStorageKey: e,
defaultValue: s
} = c, i = (a) => {
console.log(t, a);
const h = localStorage.getItem(`${t}:${a}`);
if (!h)
return s;
try {
return JSON.parse(JSON.parse(l)).persist;
return JSON.parse(JSON.parse(h)).persist;
} catch {
return l;
return h;
}
}, i = (c) => {
const l = s ?? c.id, p = n(l);
typeof p !== void 0 && c.emit(p);
}, n = (a) => {
const h = e ?? a.id, d = i(h);
typeof d !== void 0 && a.emit(d);
};

@@ -248,6 +244,6 @@ let r = "";

name: "Persist",
onInit: i,
onEmit: ({ newState: c, cubit: l }) => {
const p = s ?? l.id, I = JSON.stringify(`{"persist": ${c}}`);
I !== r && (localStorage.setItem(`${t}:${p}`, I), r = I);
onInit: n,
onEmit: ({ newState: a, cubit: h }) => {
const d = e ?? h.id, I = JSON.stringify(`{"persist": ${a}}`);
I !== r && (localStorage.setItem(`${t}:${d}`, I), r = I);
}

@@ -258,9 +254,9 @@ };

g as Blac,
u as BlacEvent,
l as BlacEvent,
b as BlacObservable,
E as Bloc,
S as Bloc,
f as BlocBase,
B as Cubit,
_ as Persist
E as Cubit,
D as Persist
};
//# sourceMappingURL=index.es.js.map
{
"name": "blac",
"version": "1.0.8",
"version": "1.0.10",
"license": "MIT",

@@ -31,14 +31,13 @@ "main": "index.cjs.js",

"devDependencies": {
"vite-plugin-dts": "^3.6.4",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"vite-plugin-dts": "^3.7.1",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"@vitejs/plugin-react-refresh": "^1.3.6",
"@vitest/browser": "^0.34.1",
"@vitest/coverage-c8": "^0.33.0",
"@vitest/coverage-v8": "^1.1.0",
"eslint": "^8.47.0",
"prettier": "^3.0.1",
"typescript": "^5.1.6",
"vitest": "^0.34.1"
"@vitest/browser": "^1.2.1",
"@vitest/coverage-v8": "^1.2.1",
"eslint": "^8.56.0",
"prettier": "^3.2.4",
"typescript": "^5.3.3",
"vitest": "^1.2.1"
}
}

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