@blac/react 0.0.51 → 0.0.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var j=Object.defineProperty;var m=(t,e,s)=>e in t?j(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var S=(t,e,s)=>m(t,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("blac"),d=require("react"),B=(t,e)=>({subscribe:s=>{const c=t.addSubscriber({fn:()=>{try{s(t.state)}catch(u){console.error({e:u,bloc:t,dependencyArray:e})}},dependencyArray:e});return()=>{c()}},getSnapshot:()=>t.state,getServerSnapshot:()=>t.state}),o=class o{static useBloc(e,s){const c=d.useId(),u=o.getUsedKeys(c);let l=r=>{if(typeof r!="object")return[r];const n=[];for(const b of u)b in r&&n.push(r[b]);return n},y,f;typeof s=="object"&&(l=s.dependencySelector??l,y=s.id,f=s.props??f),e.isolated&&(y=c);const a=h.Blac.getInstance().getBloc(e,{id:y,props:f,reconnect:!1});if(!a)throw new Error(`useBloc: could not resolve: ${e.name||e}`);const{subscribe:p,getSnapshot:U,getServerSnapshot:v}=d.useMemo(()=>B(a,l),[a.createdAt]),i=d.useSyncExternalStore(p,U,v),g=new Set,I=d.useMemo(()=>{try{if(typeof i=="object")return new Proxy(i,{get(r,n){return u.add(n),g.add(n),Reflect.get(r,n)}})}catch(r){h.Blac.instance.log("useBloc Error",r)}return i},[i]);return d.useLayoutEffect(()=>{o.getUsedKeys(c).clear();for(const r of g)o.getUsedKeys(c).add(r)},[g,c]),[I,a]}};S(o,"ridUsedKeys",new Map),S(o,"getUsedKeys",e=>(o.ridUsedKeys.has(e)||o.ridUsedKeys.set(e,new Set),o.ridUsedKeys.get(e)));let K=o;const x=K.useBloc;exports.externalBlocStore=B;exports.useBloc=x;
1
+ "use strict";var m=Object.defineProperty;var x=(s,e,t)=>e in s?m(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var S=(s,e,t)=>x(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("blac"),d=require("react"),B=(s,e)=>({subscribe:t=>{const n=s.addSubscriber({fn:()=>{try{t(s.state)}catch(u){console.error({e:u,bloc:s,dependencyArray:e})}},dependencyArray:e});return()=>{n()}},getSnapshot:()=>s.state,getServerSnapshot:()=>s.state}),c=class c{static useBloc(e,t){const n=d.useId(),u=c.getUsedKeys(n);let y=t!=null&&t.inferStateUsage?r=>{if(typeof r!="object")return[r];const a=[];for(const b of u)b in r&&a.push(r[b]);return a}:r=>[r],f,g;typeof t=="object"&&(y=t.dependencySelector??y,f=t.id,g=t.props??g),e.isolated&&(f=n);const o=h.Blac.getInstance().getBloc(e,{id:f,props:g,reconnect:!1});if(!o)throw new Error(`useBloc: could not resolve: ${e.name||e}`);const{subscribe:U,getSnapshot:v,getServerSnapshot:I}=d.useMemo(()=>B(o,y),[o.createdAt]),l=d.useSyncExternalStore(U,v,I),i=new Set,j=d.useMemo(()=>{try{if(t!=null&&t.inferStateUsage&&typeof l=="object")return new Proxy(l,{get(r,a){return u.add(a),i.add(a),Reflect.get(r,a)}})}catch(r){h.Blac.instance.log("useBloc Error",r)}return l},[l]);return d.useLayoutEffect(()=>{c.getUsedKeys(n).clear();for(const r of i)c.getUsedKeys(n).add(r)},[i,n]),[j,o]}};S(c,"ridUsedKeys",new Map),S(c,"getUsedKeys",e=>(c.ridUsedKeys.has(e)||c.ridUsedKeys.set(e,new Set),c.ridUsedKeys.get(e)));let K=c;const E=K.useBloc;exports.externalBlocStore=B;exports.useBloc=E;
2
2
  //# sourceMappingURL=index.cjs.js.map
package/index.cjs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/externalBlocStore.ts","../src/useBloc.tsx"],"sourcesContent":["import { BlocGeneric, BlocHookDependencyArrayFn, BlocState } from 'blac';\n\nexport interface ExternalStore<\n B extends BlocGeneric<any, any>,\n S extends BlocState<B>,\n> {\n subscribe: (onStoreChange: () => void) => () => void;\n getSnapshot: () => S;\n getServerSnapshot?: () => S;\n}\n\nconst externalBlocStore = <\n B extends BlocGeneric<any, any>,\n S extends BlocState<B>,\n>(\n bloc: B,\n dependencyArray: BlocHookDependencyArrayFn<InstanceType<any>>,\n): ExternalStore<B, S> => {\n return {\n subscribe: (listener: (state: S) => void) => {\n const unSub = bloc.addSubscriber({\n fn: () => {\n try {\n listener(bloc.state);\n } catch (e) {\n console.error({\n e,\n bloc,\n dependencyArray,\n });\n }\n },\n dependencyArray,\n });\n\n return () => {\n unSub();\n };\n },\n getSnapshot: (): S => bloc.state,\n getServerSnapshot: (): S => bloc.state,\n };\n};\n\nexport default externalBlocStore;\n","import {\n Blac,\n BlocBase,\n BlocConstructor,\n BlocGeneric,\n BlocHookDependencyArrayFn,\n BlocInstanceId,\n BlocState,\n InferPropsFromGeneric,\n} from 'blac';\nimport { useId, useLayoutEffect, useMemo, useSyncExternalStore } from 'react';\nimport externalBlocStore from './externalBlocStore';\n\n// export type BlocHookData<B extends BlocBase<S>, S> = [\n// value: ValueType<B>,\n// instance: B,\n// ];\n\ntype HookTypes<B extends BlocConstructor<BlocGeneric>> = [\n BlocState<InstanceType<B>>,\n InstanceType<B>,\n];\n\n// type BlocHookData<B extends BlocBase<S>, S> = [S, InstanceType<B>]; // B is the bloc class, S is the state of the bloc\n// type UseBlocClassResult<B, S> = BlocHookData<B, S>;\n\nexport interface BlocHookOptions<B extends BlocGeneric<any, any>> {\n id?: string;\n dependencySelector?: BlocHookDependencyArrayFn<B>;\n props?: InferPropsFromGeneric<B>;\n}\n\nexport class UseBlocClass {\n static ridUsedKeys: Map<string, Set<string>> = new Map();\n static getUsedKeys = (rid: string): Set<string> => {\n if (!UseBlocClass.ridUsedKeys.has(rid)) {\n UseBlocClass.ridUsedKeys.set(rid, new Set());\n }\n return UseBlocClass.ridUsedKeys.get(rid) as Set<string>;\n };\n\n static useBloc<\n B extends BlocConstructor<BlocGeneric>,\n O extends BlocHookOptions<InstanceType<B>>,\n >(bloc: B, options?: O): HookTypes<B> {\n const rid = useId();\n const usedKeys = UseBlocClass.getUsedKeys(rid);\n\n // default options\n let dependencyArray: BlocHookDependencyArrayFn<InstanceType<B>> = (\n newState,\n ) => {\n if (typeof newState !== 'object') {\n return [newState] as unknown[];\n }\n\n const used: string[] = [];\n for (const key of usedKeys) {\n if (key in newState) {\n used.push(newState[key as keyof typeof newState]);\n }\n }\n return used;\n };\n let blocId: BlocInstanceId | undefined;\n let props: ConstructorParameters<BlocConstructor<B>> | undefined;\n\n if (typeof options === 'object') {\n dependencyArray = options.dependencySelector ?? dependencyArray;\n blocId = options.id;\n props = options.props ?? props;\n }\n\n const base = bloc as unknown as BlocBase<B, O['props']>;\n const isIsolated = base.isolated;\n if (isIsolated) {\n blocId = rid;\n }\n\n const resolvedBloc = Blac.getInstance().getBloc(bloc, {\n id: blocId,\n props: props as any,\n reconnect: false,\n }) as InstanceType<B>;\n\n if (!resolvedBloc) {\n throw new Error(`useBloc: could not resolve: ${bloc.name || bloc}`);\n }\n\n const { subscribe, getSnapshot, getServerSnapshot } = useMemo(\n () => externalBlocStore(resolvedBloc, dependencyArray),\n [resolvedBloc.createdAt],\n );\n\n const state = useSyncExternalStore<BlocState<InstanceType<B>>>(\n subscribe,\n getSnapshot,\n getServerSnapshot,\n );\n\n const currentRenderUsedKeys = new Set<string>();\n const returnState: BlocState<InstanceType<B>> = useMemo(() => {\n try {\n if (typeof state === 'object') {\n return new Proxy(state as any, {\n get(target, prop) {\n usedKeys.add(prop as string);\n currentRenderUsedKeys.add(prop as string);\n return Reflect.get(target, prop);\n },\n });\n }\n } catch (error) {\n Blac.instance.log('useBloc Error', error);\n }\n return state;\n }, [state]);\n\n useLayoutEffect(() => {\n UseBlocClass.getUsedKeys(rid).clear();\n for (const key of currentRenderUsedKeys) {\n UseBlocClass.getUsedKeys(rid).add(key);\n }\n }, [currentRenderUsedKeys, rid]);\n\n return [returnState, resolvedBloc];\n }\n}\n\nconst useBloc = UseBlocClass.useBloc;\n\nexport default useBloc;\n"],"names":["externalBlocStore","bloc","dependencyArray","listener","unSub","e","_UseBlocClass","options","rid","useId","usedKeys","newState","used","key","blocId","props","resolvedBloc","Blac","subscribe","getSnapshot","getServerSnapshot","useMemo","state","useSyncExternalStore","currentRenderUsedKeys","returnState","target","prop","error","useLayoutEffect","__publicField","UseBlocClass","useBloc"],"mappings":"+RAWMA,EAAoB,CAIxBC,EACAC,KAEO,CACL,UAAYC,GAAiC,CACrC,MAAAC,EAAQH,EAAK,cAAc,CAC/B,GAAI,IAAM,CACJ,GAAA,CACFE,EAASF,EAAK,KAAK,QACZI,EAAG,CACV,QAAQ,MAAM,CACZ,EAAAA,EACA,KAAAJ,EACA,gBAAAC,CAAA,CACD,CACH,CACF,EACA,gBAAAA,CAAA,CACD,EAED,MAAO,IAAM,CACLE,GAAA,CAEV,EACA,YAAa,IAASH,EAAK,MAC3B,kBAAmB,IAASA,EAAK,KAAA,GCRxBK,EAAN,MAAMA,CAAa,CASxB,OAAO,QAGLL,EAASM,EAA2B,CACpC,MAAMC,EAAMC,EAAAA,QACNC,EAAWJ,EAAa,YAAYE,CAAG,EAGzC,IAAAN,EACFS,GACG,CACC,GAAA,OAAOA,GAAa,SACtB,MAAO,CAACA,CAAQ,EAGlB,MAAMC,EAAiB,CAAA,EACvB,UAAWC,KAAOH,EACZG,KAAOF,GACJC,EAAA,KAAKD,EAASE,CAA4B,CAAC,EAG7C,OAAAD,CAAA,EAELE,EACAC,EAEA,OAAOR,GAAY,WACrBL,EAAkBK,EAAQ,oBAAsBL,EAChDY,EAASP,EAAQ,GACjBQ,EAAQR,EAAQ,OAASQ,GAGdd,EACW,WAEba,EAAAN,GAGX,MAAMQ,EAAeC,EAAA,KAAK,YAAY,EAAE,QAAQhB,EAAM,CACpD,GAAIa,EACJ,MAAAC,EACA,UAAW,EAAA,CACZ,EAED,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,+BAA+Bf,EAAK,MAAQA,CAAI,EAAE,EAGpE,KAAM,CAAE,UAAAiB,EAAW,YAAAC,EAAa,kBAAAC,CAAsB,EAAAC,EAAA,QACpD,IAAMrB,EAAkBgB,EAAcd,CAAe,EACrD,CAACc,EAAa,SAAS,CAAA,EAGnBM,EAAQC,EAAA,qBACZL,EACAC,EACAC,CAAA,EAGII,MAA4B,IAC5BC,EAA0CJ,EAAAA,QAAQ,IAAM,CACxD,GAAA,CACE,GAAA,OAAOC,GAAU,SACZ,OAAA,IAAI,MAAMA,EAAc,CAC7B,IAAII,EAAQC,EAAM,CAChB,OAAAjB,EAAS,IAAIiB,CAAc,EAC3BH,EAAsB,IAAIG,CAAc,EACjC,QAAQ,IAAID,EAAQC,CAAI,CACjC,CAAA,CACD,QAEIC,EAAO,CACTX,EAAAA,KAAA,SAAS,IAAI,gBAAiBW,CAAK,CAC1C,CACO,OAAAN,CAAA,EACN,CAACA,CAAK,CAAC,EAEVO,OAAAA,EAAAA,gBAAgB,IAAM,CACPvB,EAAA,YAAYE,CAAG,EAAE,MAAM,EACpC,UAAWK,KAAOW,EAChBlB,EAAa,YAAYE,CAAG,EAAE,IAAIK,CAAG,CACvC,EACC,CAACW,EAAuBhB,CAAG,CAAC,EAExB,CAACiB,EAAaT,CAAY,CACnC,CACF,EA9FEc,EADWxB,EACJ,cAAwC,IAAI,KACnDwB,EAFWxB,EAEJ,cAAeE,IACfF,EAAa,YAAY,IAAIE,CAAG,GACnCF,EAAa,YAAY,IAAIE,EAAK,IAAI,GAAK,EAEtCF,EAAa,YAAY,IAAIE,CAAG,IANpC,IAAMuB,EAANzB,EAiGP,MAAM0B,EAAUD,EAAa"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/externalBlocStore.ts","../src/useBloc.tsx"],"sourcesContent":["import { BlocGeneric, BlocHookDependencyArrayFn, BlocState } from 'blac';\n\nexport interface ExternalStore<\n B extends BlocGeneric<any, any>,\n S extends BlocState<B>,\n> {\n subscribe: (onStoreChange: () => void) => () => void;\n getSnapshot: () => S;\n getServerSnapshot?: () => S;\n}\n\nconst externalBlocStore = <\n B extends BlocGeneric<any, any>,\n S extends BlocState<B>,\n>(\n bloc: B,\n dependencyArray: BlocHookDependencyArrayFn<InstanceType<any>>,\n): ExternalStore<B, S> => {\n return {\n subscribe: (listener: (state: S) => void) => {\n const unSub = bloc.addSubscriber({\n fn: () => {\n try {\n listener(bloc.state);\n } catch (e) {\n console.error({\n e,\n bloc,\n dependencyArray,\n });\n }\n },\n dependencyArray,\n });\n\n return () => {\n unSub();\n };\n },\n getSnapshot: (): S => bloc.state,\n getServerSnapshot: (): S => bloc.state,\n };\n};\n\nexport default externalBlocStore;\n","import {\n Blac,\n BlocBase,\n BlocConstructor,\n BlocGeneric,\n BlocHookDependencyArrayFn,\n BlocInstanceId,\n BlocState,\n InferPropsFromGeneric,\n} from 'blac';\nimport { useId, useLayoutEffect, useMemo, useSyncExternalStore } from 'react';\nimport externalBlocStore from './externalBlocStore';\n\n// export type BlocHookData<B extends BlocBase<S>, S> = [\n// value: ValueType<B>,\n// instance: B,\n// ];\n\ntype HookTypes<B extends BlocConstructor<BlocGeneric>> = [\n BlocState<InstanceType<B>>,\n InstanceType<B>,\n];\n\n// type BlocHookData<B extends BlocBase<S>, S> = [S, InstanceType<B>]; // B is the bloc class, S is the state of the bloc\n// type UseBlocClassResult<B, S> = BlocHookData<B, S>;\n\nexport interface BlocHookOptions<B extends BlocGeneric<any, any>> {\n id?: string;\n dependencySelector?: BlocHookDependencyArrayFn<B>;\n props?: InferPropsFromGeneric<B>;\n inferStateUsage?: boolean;\n}\n\nexport class UseBlocClass {\n static ridUsedKeys: Map<string, Set<string>> = new Map();\n static getUsedKeys = (rid: string): Set<string> => {\n if (!UseBlocClass.ridUsedKeys.has(rid)) {\n UseBlocClass.ridUsedKeys.set(rid, new Set());\n }\n return UseBlocClass.ridUsedKeys.get(rid) as Set<string>;\n };\n\n static useBloc<\n B extends BlocConstructor<BlocGeneric>,\n O extends BlocHookOptions<InstanceType<B>>,\n >(bloc: B, options?: O): HookTypes<B> {\n const rid = useId();\n const usedKeys = UseBlocClass.getUsedKeys(rid);\n\n // default options\n let dependencyArray: BlocHookDependencyArrayFn<InstanceType<B>> =\n options?.inferStateUsage\n ? (newState) => {\n if (typeof newState !== 'object') {\n return [newState] as unknown[];\n }\n\n const used: string[] = [];\n for (const key of usedKeys) {\n if (key in newState) {\n used.push(newState[key as keyof typeof newState]);\n }\n }\n return used;\n }\n : (s) => [s];\n let blocId: BlocInstanceId | undefined;\n let props: ConstructorParameters<BlocConstructor<B>> | undefined;\n\n if (typeof options === 'object') {\n dependencyArray = options.dependencySelector ?? dependencyArray;\n blocId = options.id;\n props = options.props ?? props;\n }\n\n const base = bloc as unknown as BlocBase<B, O['props']>;\n const isIsolated = base.isolated;\n if (isIsolated) {\n blocId = rid;\n }\n\n const resolvedBloc = Blac.getInstance().getBloc(bloc, {\n id: blocId,\n props: props as any,\n reconnect: false,\n }) as InstanceType<B>;\n\n if (!resolvedBloc) {\n throw new Error(`useBloc: could not resolve: ${bloc.name || bloc}`);\n }\n\n const { subscribe, getSnapshot, getServerSnapshot } = useMemo(\n () => externalBlocStore(resolvedBloc, dependencyArray),\n [resolvedBloc.createdAt],\n );\n\n const state = useSyncExternalStore<BlocState<InstanceType<B>>>(\n subscribe,\n getSnapshot,\n getServerSnapshot,\n );\n\n const currentRenderUsedKeys = new Set<string>();\n const returnState: BlocState<InstanceType<B>> = useMemo(() => {\n try {\n if (options?.inferStateUsage && typeof state === 'object') {\n return new Proxy(state as any, {\n get(target, prop) {\n usedKeys.add(prop as string);\n currentRenderUsedKeys.add(prop as string);\n return Reflect.get(target, prop);\n },\n });\n }\n } catch (error) {\n Blac.instance.log('useBloc Error', error);\n }\n return state;\n }, [state]);\n\n useLayoutEffect(() => {\n UseBlocClass.getUsedKeys(rid).clear();\n for (const key of currentRenderUsedKeys) {\n UseBlocClass.getUsedKeys(rid).add(key);\n }\n }, [currentRenderUsedKeys, rid]);\n\n return [returnState, resolvedBloc];\n }\n}\n\nconst useBloc = UseBlocClass.useBloc;\n\nexport default useBloc;\n"],"names":["externalBlocStore","bloc","dependencyArray","listener","unSub","e","_UseBlocClass","options","rid","useId","usedKeys","newState","used","key","s","blocId","props","resolvedBloc","Blac","subscribe","getSnapshot","getServerSnapshot","useMemo","state","useSyncExternalStore","currentRenderUsedKeys","returnState","target","prop","error","useLayoutEffect","__publicField","UseBlocClass","useBloc"],"mappings":"+RAWMA,EAAoB,CAIxBC,EACAC,KAEO,CACL,UAAYC,GAAiC,CACrC,MAAAC,EAAQH,EAAK,cAAc,CAC/B,GAAI,IAAM,CACJ,GAAA,CACFE,EAASF,EAAK,KAAK,QACZI,EAAG,CACV,QAAQ,MAAM,CACZ,EAAAA,EACA,KAAAJ,EACA,gBAAAC,CAAA,CACD,CACH,CACF,EACA,gBAAAA,CAAA,CACD,EAED,MAAO,IAAM,CACLE,GAAA,CAEV,EACA,YAAa,IAASH,EAAK,MAC3B,kBAAmB,IAASA,EAAK,KAAA,GCPxBK,EAAN,MAAMA,CAAa,CASxB,OAAO,QAGLL,EAASM,EAA2B,CACpC,MAAMC,EAAMC,EAAAA,QACNC,EAAWJ,EAAa,YAAYE,CAAG,EAG7C,IAAIN,EACFK,GAAA,MAAAA,EAAS,gBACJI,GAAa,CACR,GAAA,OAAOA,GAAa,SACtB,MAAO,CAACA,CAAQ,EAGlB,MAAMC,EAAiB,CAAA,EACvB,UAAWC,KAAOH,EACZG,KAAOF,GACJC,EAAA,KAAKD,EAASE,CAA4B,CAAC,EAG7C,OAAAD,CAAA,EAERE,GAAM,CAACA,CAAC,EACXC,EACAC,EAEA,OAAOT,GAAY,WACrBL,EAAkBK,EAAQ,oBAAsBL,EAChDa,EAASR,EAAQ,GACjBS,EAAQT,EAAQ,OAASS,GAGdf,EACW,WAEbc,EAAAP,GAGX,MAAMS,EAAeC,EAAA,K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= Object.defineProperty;
2
- var v = (t, e, s) => e in t ? I(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
- var g = (t, e, s) => v(t, typeof e != "symbol" ? e + "" : e, s);
4
- import { Blac as K } from "blac";
5
- import { useId as x, useMemo as h, useSyncExternalStore as E, useLayoutEffect as j } from "react";
6
- const w = (t, e) => ({
7
- subscribe: (s) => {
8
- const n = t.addSubscriber({
1
+ var v = Object.defineProperty;
2
+ var x = (s, e, t) => e in s ? v(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var i = (s, e, t) => x(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Blac as h } from "blac";
5
+ import { useId as E, useMemo as U, useSyncExternalStore as j, useLayoutEffect as w } from "react";
6
+ const k = (s, e) => ({
7
+ subscribe: (t) => {
8
+ const n = s.addSubscriber({
9
9
  fn: () => {
10
10
  try {
11
- s(t.state);
12
- } catch (d) {
11
+ t(s.state);
12
+ } catch (a) {
13
13
  console.error({
14
- e: d,
15
- bloc: t,
14
+ e: a,
15
+ bloc: s,
16
16
  dependencyArray: e
17
17
  });
18
18
  }
@@ -23,59 +23,59 @@ const w = (t, e) => ({
23
23
  n();
24
24
  };
25
25
  },
26
- getSnapshot: () => t.state,
27
- getServerSnapshot: () => t.state
28
- }), o = class o {
29
- static useBloc(e, s) {
30
- const n = x(), d = o.getUsedKeys(n);
31
- let i = (r) => {
26
+ getSnapshot: () => s.state,
27
+ getServerSnapshot: () => s.state
28
+ }), c = class c {
29
+ static useBloc(e, t) {
30
+ const n = E(), a = c.getUsedKeys(n);
31
+ let f = t != null && t.inferStateUsage ? (r) => {
32
32
  if (typeof r != "object")
33
33
  return [r];
34
- const c = [];
35
- for (const p of d)
36
- p in r && c.push(r[p]);
37
- return c;
38
- }, f, y;
39
- typeof s == "object" && (i = s.dependencySelector ?? i, f = s.id, y = s.props ?? y), e.isolated && (f = n);
40
- const a = K.getInstance().getBloc(e, {
41
- id: f,
42
- props: y,
34
+ const d = [];
35
+ for (const K of a)
36
+ K in r && d.push(r[K]);
37
+ return d;
38
+ } : (r) => [r], y, g;
39
+ typeof t == "object" && (f = t.dependencySelector ?? f, y = t.id, g = t.props ?? g), e.isolated && (y = n);
40
+ const u = h.getInstance().getBloc(e, {
41
+ id: y,
42
+ props: g,
43
43
  reconnect: !1
44
44
  });
45
- if (!a)
45
+ if (!u)
46
46
  throw new Error(`useBloc: could not resolve: ${e.name || e}`);
47
- const { subscribe: b, getSnapshot: m, getServerSnapshot: B } = h(
48
- () => w(a, i),
49
- [a.createdAt]
50
- ), u = E(
47
+ const { subscribe: b, getSnapshot: m, getServerSnapshot: B } = U(
48
+ () => k(u, f),
49
+ [u.createdAt]
50
+ ), o = j(
51
51
  b,
52
52
  m,
53
53
  B
54
- ), l = /* @__PURE__ */ new Set(), U = h(() => {
54
+ ), l = /* @__PURE__ */ new Set(), I = U(() => {
55
55
  try {
56
- if (typeof u == "object")
57
- return new Proxy(u, {
58
- get(r, c) {
59
- return d.add(c), l.add(c), Reflect.get(r, c);
56
+ if (t != null && t.inferStateUsage && typeof o == "object")
57
+ return new Proxy(o, {
58
+ get(r, d) {
59
+ return a.add(d), l.add(d), Reflect.get(r, d);
60
60
  }
61
61
  });
62
62
  } catch (r) {
63
- K.instance.log("useBloc Error", r);
63
+ h.instance.log("useBloc Error", r);
64
64
  }
65
- return u;
66
- }, [u]);
67
- return j(() => {
68
- o.getUsedKeys(n).clear();
65
+ return o;
66
+ }, [o]);
67
+ return w(() => {
68
+ c.getUsedKeys(n).clear();
69
69
  for (const r of l)
70
- o.getUsedKeys(n).add(r);
71
- }, [l, n]), [U, a];
70
+ c.getUsedKeys(n).add(r);
71
+ }, [l, n]), [I, u];
72
72
  }
73
73
  };
74
- g(o, "ridUsedKeys", /* @__PURE__ */ new Map()), g(o, "getUsedKeys", (e) => (o.ridUsedKeys.has(e) || o.ridUsedKeys.set(e, /* @__PURE__ */ new Set()), o.ridUsedKeys.get(e)));
75
- let S = o;
76
- const P = S.useBloc;
74
+ i(c, "ridUsedKeys", /* @__PURE__ */ new Map()), i(c, "getUsedKeys", (e) => (c.ridUsedKeys.has(e) || c.ridUsedKeys.set(e, /* @__PURE__ */ new Set()), c.ridUsedKeys.get(e)));
75
+ let S = c;
76
+ const $ = S.useBloc;
77
77
  export {
78
- w as externalBlocStore,
79
- P as useBloc
78
+ k as externalBlocStore,
79
+ $ as useBloc
80
80
  };
81
81
  //# sourceMappingURL=index.es.js.map
package/index.es.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/externalBlocStore.ts","../src/useBloc.tsx"],"sourcesContent":["import { BlocGeneric, BlocHookDependencyArrayFn, BlocState } from 'blac';\n\nexport interface ExternalStore<\n B extends BlocGeneric<any, any>,\n S extends BlocState<B>,\n> {\n subscribe: (onStoreChange: () => void) => () => void;\n getSnapshot: () => S;\n getServerSnapshot?: () => S;\n}\n\nconst externalBlocStore = <\n B extends BlocGeneric<any, any>,\n S extends BlocState<B>,\n>(\n bloc: B,\n dependencyArray: BlocHookDependencyArrayFn<InstanceType<any>>,\n): ExternalStore<B, S> => {\n return {\n subscribe: (listener: (state: S) => void) => {\n const unSub = bloc.addSubscriber({\n fn: () => {\n try {\n listener(bloc.state);\n } catch (e) {\n console.error({\n e,\n bloc,\n dependencyArray,\n });\n }\n },\n dependencyArray,\n });\n\n return () => {\n unSub();\n };\n },\n getSnapshot: (): S => bloc.state,\n getServerSnapshot: (): S => bloc.state,\n };\n};\n\nexport default externalBlocStore;\n","import {\n Blac,\n BlocBase,\n BlocConstructor,\n BlocGeneric,\n BlocHookDependencyArrayFn,\n BlocInstanceId,\n BlocState,\n InferPropsFromGeneric,\n} from 'blac';\nimport { useId, useLayoutEffect, useMemo, useSyncExternalStore } from 'react';\nimport externalBlocStore from './externalBlocStore';\n\n// export type BlocHookData<B extends BlocBase<S>, S> = [\n// value: ValueType<B>,\n// instance: B,\n// ];\n\ntype HookTypes<B extends BlocConstructor<BlocGeneric>> = [\n BlocState<InstanceType<B>>,\n InstanceType<B>,\n];\n\n// type BlocHookData<B extends BlocBase<S>, S> = [S, InstanceType<B>]; // B is the bloc class, S is the state of the bloc\n// type UseBlocClassResult<B, S> = BlocHookData<B, S>;\n\nexport interface BlocHookOptions<B extends BlocGeneric<any, any>> {\n id?: string;\n dependencySelector?: BlocHookDependencyArrayFn<B>;\n props?: InferPropsFromGeneric<B>;\n}\n\nexport class UseBlocClass {\n static ridUsedKeys: Map<string, Set<string>> = new Map();\n static getUsedKeys = (rid: string): Set<string> => {\n if (!UseBlocClass.ridUsedKeys.has(rid)) {\n UseBlocClass.ridUsedKeys.set(rid, new Set());\n }\n return UseBlocClass.ridUsedKeys.get(rid) as Set<string>;\n };\n\n static useBloc<\n B extends BlocConstructor<BlocGeneric>,\n O extends BlocHookOptions<InstanceType<B>>,\n >(bloc: B, options?: O): HookTypes<B> {\n const rid = useId();\n const usedKeys = UseBlocClass.getUsedKeys(rid);\n\n // default options\n let dependencyArray: BlocHookDependencyArrayFn<InstanceType<B>> = (\n newState,\n ) => {\n if (typeof newState !== 'object') {\n return [newState] as unknown[];\n }\n\n const used: string[] = [];\n for (const key of usedKeys) {\n if (key in newState) {\n used.push(newState[key as keyof typeof newState]);\n }\n }\n return used;\n };\n let blocId: BlocInstanceId | undefined;\n let props: ConstructorParameters<BlocConstructor<B>> | undefined;\n\n if (typeof options === 'object') {\n dependencyArray = options.dependencySelector ?? dependencyArray;\n blocId = options.id;\n props = options.props ?? props;\n }\n\n const base = bloc as unknown as BlocBase<B, O['props']>;\n const isIsolated = base.isolated;\n if (isIsolated) {\n blocId = rid;\n }\n\n const resolvedBloc = Blac.getInstance().getBloc(bloc, {\n id: blocId,\n props: props as any,\n reconnect: false,\n }) as InstanceType<B>;\n\n if (!resolvedBloc) {\n throw new Error(`useBloc: could not resolve: ${bloc.name || bloc}`);\n }\n\n const { subscribe, getSnapshot, getServerSnapshot } = useMemo(\n () => externalBlocStore(resolvedBloc, dependencyArray),\n [resolvedBloc.createdAt],\n );\n\n const state = useSyncExternalStore<BlocState<InstanceType<B>>>(\n subscribe,\n getSnapshot,\n getServerSnapshot,\n );\n\n const currentRenderUsedKeys = new Set<string>();\n const returnState: BlocState<InstanceType<B>> = useMemo(() => {\n try {\n if (typeof state === 'object') {\n return new Proxy(state as any, {\n get(target, prop) {\n usedKeys.add(prop as string);\n currentRenderUsedKeys.add(prop as string);\n return Reflect.get(target, prop);\n },\n });\n }\n } catch (error) {\n Blac.instance.log('useBloc Error', error);\n }\n return state;\n }, [state]);\n\n useLayoutEffect(() => {\n UseBlocClass.getUsedKeys(rid).clear();\n for (const key of currentRenderUsedKeys) {\n UseBlocClass.getUsedKeys(rid).add(key);\n }\n }, [currentRenderUsedKeys, rid]);\n\n return [returnState, resolvedBloc];\n }\n}\n\nconst useBloc = UseBlocClass.useBloc;\n\nexport default useBloc;\n"],"names":["externalBlocStore","bloc","dependencyArray","listener","unSub","e","_UseBlocClass","options","rid","useId","usedKeys","newState","used","key","blocId","props","resolvedBloc","Blac","subscribe","getSnapshot","getServerSnapshot","useMemo","state","useSyncExternalStore","currentRenderUsedKeys","returnState","target","prop","error","useLayoutEffect","__publicField","UseBlocClass","useBloc"],"mappings":";;;;;AAWM,MAAAA,IAAoB,CAIxBC,GACAC,OAEO;AAAA,EACL,WAAW,CAACC,MAAiC;AACrC,UAAAC,IAAQH,EAAK,cAAc;AAAA,MAC/B,IAAI,MAAM;AACJ,YAAA;AACF,UAAAE,EAASF,EAAK,KAAK;AAAA,iBACZI,GAAG;AACV,kBAAQ,MAAM;AAAA,YACZ,GAAAA;AAAA,YACA,MAAAJ;AAAA,YACA,iBAAAC;AAAA,UAAA,CACD;AAAA,QACH;AAAA,MACF;AAAA,MACA,iBAAAA;AAAA,IAAA,CACD;AAED,WAAO,MAAM;AACL,MAAAE;IAAA;AAAA,EAEV;AAAA,EACA,aAAa,MAASH,EAAK;AAAA,EAC3B,mBAAmB,MAASA,EAAK;AAAA,IC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W,CAAK;AAAA,MAC1C;AACO,aAAAN;AAAA,IAAA,GACN,CAACA,CAAK,CAAC;AAEV,WAAAO,EAAgB,MAAM;AACP,MAAAvB,EAAA,YAAYE,CAAG,EAAE,MAAM;AACpC,iBAAWK,KAAOW;AAChB,QAAAlB,EAAa,YAAYE,CAAG,EAAE,IAAIK,CAAG;AAAA,IACvC,GACC,CAACW,GAAuBhB,CAAG,CAAC,GAExB,CAACiB,GAAaT,CAAY;AAAA,EACnC;AACF;AA9FEc,EADWxB,GACJ,eAAwC,oBAAI,QACnDwB,EAFWxB,GAEJ,eAAc,CAACE,OACfF,EAAa,YAAY,IAAIE,CAAG,KACnCF,EAAa,YAAY,IAAIE,GAAK,oBAAI,IAAK,CAAA,GAEtCF,EAAa,YAAY,IAAIE,CAAG;AANpC,IAAMuB,IAANzB;AAiGP,MAAM0B,IAAUD,EAAa;"}
1
+ {"version":3,"file":"index.es.js","sources":["../src/externalBlocStore.ts","../src/useBloc.tsx"],"sourcesContent":["import { BlocGeneric, BlocHookDependencyArrayFn, BlocState } from 'blac';\n\nexport interface ExternalStore<\n B extends BlocGeneric<any, any>,\n S extends BlocState<B>,\n> {\n subscribe: (onStoreChange: () => void) => () => void;\n getSnapshot: () => S;\n getServerSnapshot?: () => S;\n}\n\nconst externalBlocStore = <\n B extends BlocGeneric<any, any>,\n S extends BlocState<B>,\n>(\n bloc: B,\n dependencyArray: BlocHookDependencyArrayFn<InstanceType<any>>,\n): ExternalStore<B, S> => {\n return {\n subscribe: (listener: (state: S) => void) => {\n const unSub = bloc.addSubscriber({\n fn: () => {\n try {\n listener(bloc.state);\n } catch (e) {\n console.error({\n e,\n bloc,\n dependencyArray,\n });\n }\n },\n dependencyArray,\n });\n\n return () => {\n unSub();\n };\n },\n getSnapshot: (): S => bloc.state,\n getServerSnapshot: (): S => bloc.state,\n };\n};\n\nexport default externalBlocStore;\n","import {\n Blac,\n BlocBase,\n BlocConstructor,\n BlocGeneric,\n BlocHookDependencyArrayFn,\n BlocInstanceId,\n BlocState,\n InferPropsFromGeneric,\n} from 'blac';\nimport { useId, useLayoutEffect, useMemo, useSyncExternalStore } from 'react';\nimport externalBlocStore from './externalBlocStore';\n\n// export type BlocHookData<B extends BlocBase<S>, S> = [\n// value: ValueType<B>,\n// instance: B,\n// ];\n\ntype HookTypes<B extends BlocConstructor<BlocGeneric>> = [\n BlocState<InstanceType<B>>,\n InstanceType<B>,\n];\n\n// type BlocHookData<B extends BlocBase<S>, S> = [S, InstanceType<B>]; // B is the bloc class, S is the state of the bloc\n// type UseBlocClassResult<B, S> = BlocHookData<B, S>;\n\nexport interface BlocHookOptions<B extends BlocGeneric<any, any>> {\n id?: string;\n dependencySelector?: BlocHookDependencyArrayFn<B>;\n props?: InferPropsFromGeneric<B>;\n inferStateUsage?: boolean;\n}\n\nexport class UseBlocClass {\n static ridUsedKeys: Map<string, Set<string>> = new Map();\n static getUsedKeys = (rid: string): Set<string> => {\n if (!UseBlocClass.ridUsedKeys.has(rid)) {\n UseBlocClass.ridUsedKeys.set(rid, new Set());\n }\n return UseBlocClass.ridUsedKeys.get(rid) as Set<string>;\n };\n\n static useBloc<\n B extends BlocConstructor<BlocGeneric>,\n O extends BlocHookOptions<InstanceType<B>>,\n >(bloc: B, options?: O): HookTypes<B> {\n const rid = useId();\n const usedKeys = UseBlocClass.getUsedKeys(rid);\n\n // default options\n let dependencyArray: BlocHookDependencyArrayFn<InstanceType<B>> =\n options?.inferStateUsage\n ? (newState) => {\n if (typeof newState !== 'object') {\n return [newState] as unknown[];\n }\n\n const used: string[] = [];\n for (const key of usedKeys) {\n if (key in newState) {\n used.push(newState[key as keyof typeof newState]);\n }\n }\n return used;\n }\n : (s) => [s];\n let blocId: BlocInstanceId | undefined;\n let props: ConstructorParameters<BlocConstructor<B>> | undefined;\n\n if (typeof options === 'object') {\n dependencyArray = options.dependencySelector ?? dependencyArray;\n blocId = options.id;\n props = options.props ?? props;\n }\n\n const base = bloc as unknown as BlocBase<B, O['props']>;\n const isIsolated = base.isolated;\n if (isIsolated) {\n blocId = rid;\n }\n\n const resolvedBloc = Blac.getInstance().getBloc(bloc, {\n id: blocId,\n props: props as any,\n reconnect: false,\n }) as InstanceType<B>;\n\n if (!resolvedBloc) {\n throw new Error(`useBloc: could not resolve: ${bloc.name || bloc}`);\n }\n\n const { subscribe, getSnapshot, getServerSnapshot } = useMemo(\n () => externalBlocStore(resolvedBloc, dependencyArray),\n [resolvedBloc.createdAt],\n );\n\n const state = useSyncExternalStore<BlocState<InstanceType<B>>>(\n subscribe,\n getSnapshot,\n getServerSnapshot,\n );\n\n const currentRenderUsedKeys = new Set<string>();\n const returnState: BlocState<InstanceType<B>> = useMemo(() => {\n try {\n if (options?.inferStateUsage && typeof state === 'object') {\n return new Proxy(state as any, {\n get(target, prop) {\n usedKeys.add(prop as string);\n currentRenderUsedKeys.add(prop as string);\n return Reflect.get(target, prop);\n },\n });\n }\n } catch (error) {\n Blac.instance.log('useBloc Error', error);\n }\n return state;\n }, [state]);\n\n useLayoutEffect(() => {\n UseBlocClass.getUsedKeys(rid).clear();\n for (const key of currentRenderUsedKeys) {\n UseBlocClass.getUsedKeys(rid).add(key);\n }\n }, [currentRenderUsedKeys, rid]);\n\n return [returnState, resolvedBloc];\n }\n}\n\nconst useBloc = UseBlocClass.useBloc;\n\nexport default useBloc;\n"],"names":["externalBlocStore","bloc","dependencyArray","listener","unSub","e","_UseBlocClass","options","rid","useId","usedKeys","newState","used","key","s","blocId","props","resolvedBloc","Blac","subscribe","getSnapshot","getServerSnapshot","useMemo","state","useSyncExternalStore","currentRenderUsedKeys","returnState","target","prop","error","useLayoutEffect","__publicField","UseBlocClass","useBloc"],"mappings":";;;;;AAWM,MAAAA,IAAoB,CAIxBC,GACAC,OAEO;AAAA,EACL,WAAW,CAACC,MAAiC;AACrC,UAAAC,IAAQH,EAAK,cAAc;AAAA,MAC/B,IAAI,MAAM;AACJ,YAAA;AACF,UAAAE,EAASF,EAAK,KAAK;AAAA,iBACZI,GAAG;AAC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4B,OAC5BC,IAA0CJ,EAAQ,MAAM;AACxD,UAAA;AACF,YAAIf,KAAA,QAAAA,EAAS,mBAAmB,OAAOgB,KAAU;AACxC,iBAAA,IAAI,MAAMA,GAAc;AAAA,YAC7B,IAAII,GAAQC,GAAM;AAChB,qBAAAlB,EAAS,IAAIkB,CAAc,GAC3BH,EAAsB,IAAIG,CAAc,GACjC,QAAQ,IAAID,GAAQC,CAAI;AAAA,YACjC;AAAA,UAAA,CACD;AAAA,eAEIC,GAAO;AACT,QAAAX,EAAA,SAAS,IAAI,iBAAiBW,CAAK;AAAA,MAC1C;AACO,aAAAN;AAAA,IAAA,GACN,CAACA,CAAK,CAAC;AAEV,WAAAO,EAAgB,MAAM;AACP,MAAAxB,EAAA,YAAYE,CAAG,EAAE,MAAM;AACpC,iBAAWK,KAAOY;AAChB,QAAAnB,EAAa,YAAYE,CAAG,EAAE,IAAIK,CAAG;AAAA,IACvC,GACC,CAACY,GAAuBjB,CAAG,CAAC,GAExB,CAACkB,GAAaT,CAAY;AAAA,EACnC;AACF;AA/FEc,EADWzB,GACJ,eAAwC,oBAAI,QACnDyB,EAFWzB,GAEJ,eAAc,CAACE,OACfF,EAAa,YAAY,IAAIE,CAAG,KACnCF,EAAa,YAAY,IAAIE,GAAK,oBAAI,IAAK,CAAA,GAEtCF,EAAa,YAAY,IAAIE,CAAG;AANpC,IAAMwB,IAAN1B;AAkGP,MAAM2B,IAAUD,EAAa;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blac/react",
3
- "version": "0.0.51",
3
+ "version": "0.0.52",
4
4
  "license": "MIT",
5
5
  "main": "index.cjs.js",
6
6
  "module": "index.es.js",
package/useBloc.d.ts CHANGED
@@ -8,6 +8,7 @@ export interface BlocHookOptions<B extends BlocGeneric<any, any>> {
8
8
  id?: string;
9
9
  dependencySelector?: BlocHookDependencyArrayFn<B>;
10
10
  props?: InferPropsFromGeneric<B>;
11
+ inferStateUsage?: boolean;
11
12
  }
12
13
  export declare class UseBlocClass {
13
14
  static ridUsedKeys: Map<string, Set<string>>;