react-rock 3.1.3 → 3.1.5
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/Finder.js +2 -0
- package/Finder.js.map +7 -0
- package/{dist/index.d.ts → index.d.ts} +2 -2
- package/index.js +2 -0
- package/index.js.map +7 -0
- package/package.json +31 -36
- package/readme.md +230 -0
- package/types.js +1 -0
- package/types.js.map +7 -0
- package/LICENSE +0 -21
- package/README.md +0 -195
- package/dist/Finder.js +0 -88
- package/dist/Finder.js.map +0 -1
- package/dist/index.js +0 -203
- package/dist/index.js.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- /package/{dist/Finder.d.ts → Finder.d.ts} +0 -0
- /package/{dist/types.d.ts → types.d.ts} +0 -0
package/Finder.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const p=e=>typeof e=="object"&&!Array.isArray(e)&&e!==null,u=e=>typeof e=="number",h={contain:(e,t)=>typeof e=="string"&&e.search(t)!==-1,startWith:(e,t)=>typeof e=="string"&&e.startsWith(t),endWith:(e,t)=>typeof e=="string"&&e.endsWith(t),equalWith:(e,t)=>e===t,notEqualWith:(e,t)=>e!==t,lt:(e,t)=>u(e)&&e<t,gt:(e,t)=>u(e)&&e>t,lte:(e,t)=>u(e)&&e<=t,gte:(e,t)=>u(e)&&e>=t},d=(e,t)=>{let n=!0;for(let i in t){let r=t[i];const o=h[i];if(o&&!o(e,r)){n=!1;break}}return n},w=(e,t,n)=>{let i=[],r=[],o=[];for(let l=0;l<e.length;l++){let a=e[l],s=!1;if(p(t))for(let y in t){let f=t[y];if(!(y in a))break;if(p(f))if(d(a[y],f))s=!0;else{s=!1;break}else if(a[y]===f)s=!0;else{s=!1;break}}else s=!0;if(s){if(n?.getRow){let y=n.getRow({...a},l);if(y)a=y;else continue}i.push({...a,_index:l}),r.push(l),o.push(a._id)}}const c=n?.take||i.length,k=n?.skip||0;return n?.take&&n?.skip?i=i.splice(k,c):!n?.skip&&n?.take?i.splice(n.take):!n?.take&&n?.skip&&(i=i.splice(n.skip)),{rows:i,indexes:r,ids:o}};var Q=w;export{Q as default,p as isOb};
|
|
2
|
+
//# sourceMappingURL=Finder.js.map
|
package/Finder.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/Finder.ts"],
|
|
4
|
+
"sourcesContent": ["import { FinderArgsType, QueryType, QueryValueType } from \"./types\"\r\n\r\nexport const isOb = (ob: any) => typeof ob === \"object\" && !Array.isArray(ob) && ob !== null\r\nconst isNum = (n: any) => typeof n === 'number'\r\nconst excuteQuery: any = {\r\n contain: (v: any, qv: any) => typeof v === 'string' && v.search(qv) !== -1,\r\n startWith: (v: any, qv: any) => typeof v === 'string' && v.startsWith(qv),\r\n endWith: (v: any, qv: any) => typeof v === 'string' && v.endsWith(qv),\r\n equalWith: (v: any, qv: any) => v === qv,\r\n notEqualWith: (v: any, qv: any) => v !== qv,\r\n lt: (v: any, qv: any) => isNum(v) && v < qv,\r\n gt: (v: any, qv: any) => isNum(v) && v > qv,\r\n lte: (v: any, qv: any) => isNum(v) && v <= qv,\r\n gte: (v: any, qv: any) => isNum(v) && v >= qv,\r\n}\r\n\r\nconst isInQuery = <Row>(rowVal: Row, queryObject: QueryValueType) => {\r\n let match = true\r\n for (let queryKey in queryObject) {\r\n let qVal = (queryObject as any)[queryKey]\r\n const qcb = excuteQuery[queryKey]\r\n if (qcb && !qcb(rowVal, qVal)) {\r\n match = false;\r\n break;\r\n }\r\n }\r\n return match\r\n}\r\n\r\nconst Finder = <Row extends object>(rows: Row[], query: null | QueryType<Row>, args?: FinderArgsType<Row>) => {\r\n let result: Row[] = []\r\n let indexes: number[] = []\r\n let ids: string[] = []\r\n\r\n for (let i = 0; i < rows.length; i++) {\r\n let row = rows[i]\r\n let found = false;\r\n if (isOb(query)) {\r\n for (let rowKey in query) {\r\n let queryVal = query[rowKey]\r\n if (!(rowKey in row)) break;\r\n\r\n if (isOb(queryVal)) {\r\n if (isInQuery(row[rowKey], queryVal as any)) {\r\n found = true\r\n } else {\r\n found = false\r\n break;\r\n }\r\n } else if (row[rowKey] === queryVal) {\r\n found = true;\r\n } else {\r\n found = false\r\n break;\r\n }\r\n }\r\n } else {\r\n found = true\r\n }\r\n\r\n if (found) {\r\n if (args?.getRow) {\r\n let r = args.getRow({ ...row }, i)\r\n if (r) {\r\n row = r\r\n } else {\r\n continue;\r\n }\r\n }\r\n result.push({ ...row, _index: i })\r\n indexes.push(i)\r\n ids.push((row as any)._id)\r\n }\r\n }\r\n\r\n const take = args?.take || result.length\r\n const skip = args?.skip || 0\r\n\r\n if (args?.take && args?.skip) {\r\n result = result.splice(skip, take)\r\n } else if (!args?.skip && args?.take) {\r\n result.splice(args.take)\r\n } else if (!args?.take && args?.skip) {\r\n result = result.splice(args.skip)\r\n }\r\n\r\n return { rows: result, indexes, ids }\r\n}\r\n\r\nexport default Finder"],
|
|
5
|
+
"mappings": "AAEO,MAAMA,EAAQC,GAAY,OAAOA,GAAO,UAAY,CAAC,MAAM,QAAQA,CAAE,GAAKA,IAAO,KAClFC,EAASC,GAAW,OAAOA,GAAM,SACjCC,EAAmB,CACrB,QAAS,CAACC,EAAQC,IAAY,OAAOD,GAAM,UAAYA,EAAE,OAAOC,CAAE,IAAM,GACxE,UAAW,CAACD,EAAQC,IAAY,OAAOD,GAAM,UAAYA,EAAE,WAAWC,CAAE,EACxE,QAAS,CAACD,EAAQC,IAAY,OAAOD,GAAM,UAAYA,EAAE,SAASC,CAAE,EACpE,UAAW,CAACD,EAAQC,IAAYD,IAAMC,EACtC,aAAc,CAACD,EAAQC,IAAYD,IAAMC,EACzC,GAAI,CAACD,EAAQC,IAAYJ,EAAMG,CAAC,GAAKA,EAAIC,EACzC,GAAI,CAACD,EAAQC,IAAYJ,EAAMG,CAAC,GAAKA,EAAIC,EACzC,IAAK,CAACD,EAAQC,IAAYJ,EAAMG,CAAC,G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OAAIA,GAAM,MAAQA,GAAM,KACpBC,EAASA,EAAO,OAAOU,EAAMD,CAAI,EAC1B,CAACV,GAAM,MAAQA,GAAM,KAC5BC,EAAO,OAAOD,EAAK,IAAI,EAChB,CAACA,GAAM,MAAQA,GAAM,OAC5BC,EAASA,EAAO,OAAOD,EAAK,IAAI,GAG7B,CAAE,KAAMC,EAAQ,QAAAC,EAAS,IAAAC,CAAI,CACxC,EAEA,IAAOS,EAAQf",
|
|
6
|
+
"names": ["isOb", "ob", "isNum", "n", "excuteQuery", "v", "qv", "isInQuery", "rowVal", "queryObject", "match", "queryKey", "qVal", "qcb", "Finder", "rows", "query", "args", "result", "indexes", "ids", "i", "row", "found", "rowKey", "queryVal", "r", "take", "skip", "Finder_default"]
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
2
|
import { IStateHandler } from './types';
|
|
3
3
|
export * from './types';
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class StoreComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> {
|
|
5
5
|
constructor(props: P);
|
|
6
6
|
}
|
|
7
|
-
export declare const createStore: <Row extends object, MetaProps extends object = {}>() => IStateHandler<Row, MetaProps>;
|
|
7
|
+
export declare const createStore: <Row extends object, MetaProps extends object = {}>(rows: Row[], meta: MetaProps) => IStateHandler<Row, MetaProps>;
|
package/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";import{useEffect as h,useId as y,useState as R,createElement as m,Fragment as b,Component as M}from"react";import d,{isOb as T}from"./Finder";export*from"./types";class F extends M{constructor(l){super(l);const e=this.render.bind(this);this.render=()=>m(b,null,m(e,null))}}const w=()=>Date.now()+Math.floor(1e3+Math.random()*9e3),P=()=>w().toString(32).replace("-","").substring(0,15),p=c=>{if(!T(c))throw new Error(`State row must be an object. given ${typeof c}: ${c}`);return{...c,_id:c._id||P(),_observe:c._observe||w()}},j=(c,l)=>{const e={data:{state:[],meta:new Map},dispatches:{state:new Map,meta:new Map},observe:{state:Math.random(),meta:Math.random()},cache:new Map},n=r=>{e.observe[r]=Math.random(),e.dispatches[r].forEach((t,a)=>{try{t()}catch{e.dispatches[r].delete(a)}})},f=r=>{const t=y(),[,a]=R(0);h(()=>(e.dispatches[r].set(t,()=>a(Math.random())),()=>{e.dispatches[r].delete(t)}),[])};for(let r of c)e.data.state.push(p(r));for(let r in l)e.data.meta.set(r,l[r]);class u{static create(t,a){const o=p(t);return e.data.state.push(o),a||n("state"),o}static createMany(t,a){const o=[];for(let s of t){const i=p(s);e.data.state.push(i),o.push(i)}return a||n("state"),o}static update(t,a,o){d(e.data.state,a,{getRow:(s,i)=>{e.data.state[i]=p({...s,...t})}}),o||n("state")}static updateAll(t,a){for(let o=0;o<e.data.state.length;o++)e.data.state[o]=p({...e.data.state[o],...t});a||n("state")}static delete(t,a){const o=d(e.data.state,t);e.data.state=e.data.state.filter(s=>!o.ids.includes(s._id)),a||n("state")}static move(t,a,o){const s=e.data.state[t];s&&(e.data.state.splice(t,1),e.data.state.splice(a,0,p(s)),o||n("state"))}static clearAll(t){e.data.state=[],t||n("state")}static getAll(t){try{t?.freeze||f("state");const a=e.observe.state.toString()+(t?.skip||"")+(t?.take||""),o=e.cache.get(a);if(o?.length)return o;const s=d(e.data.state,null,t).rows;return e.cache.set(a,s),s}catch{return d(e.data.state,null,t)}}static find(t,a){try{a?.freeze||f("state");const o=e.observe.state.toString()+(a?.skip||"")+(a?.take||"")+JSON.stringify(t);e.cache.get(o)?.length;const i=d(e.data.state,t,a).rows;return e.cache.set(o,i),i}catch{return d(e.data.state,t,a).rows}}static findFirst(t,a){return u.find(t,{freeze:a})[0]}static findById(t,a){return u.findFirst({_id:t},a)}static setMeta(t,a,o){e.data.meta.set(t,a),o||n("meta")}static getMeta(t,a){try{return a||f("meta"),e.data.meta.get(t)}catch{return e.data.meta.get(t)}}static getAllMeta(t){try{return t||f("meta"),Object.fromEntries(e.data.meta)}catch{return Object.fromEntries(e.data.meta)}}static deleteMeta(t,a){e.data.meta.delete(t),a||n("meta")}static clearMeta(t){e.data.meta.clear(),t||n("meta")}}return u};export{F as StoreComponent,j as createStore};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\r\nimport { useEffect, useId, useState, createElement, Fragment, Component } from 'react'\r\nimport { ArgsType, IStateHandler, RowType, StateDataType, WhereType } from './types';\r\nimport Finder, { isOb } from './Finder';\r\nexport * from './types'\r\n\r\nexport class StoreComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> {\r\n constructor(props: P) {\r\n super(props)\r\n const R = this.render.bind(this) as any\r\n this.render = () => createElement(Fragment, null, createElement(R, null))\r\n }\r\n}\r\n\r\nconst _random = () => Date.now() + Math.floor(1000 + Math.random() * 9000)\r\nconst _uid = () => _random().toString(32).replace(\"-\", \"\").substring(0, 15)\r\nconst _row = <R>(row: Partial<RowType<R>>): RowType<R> => {\r\n if (!isOb(row)) throw new Error(`State row must be an object. given ${typeof row}: ${row}`);\r\n return { ...row, _id: row._id || _uid(), _observe: row._observe || _random() } as any\r\n}\r\n\r\nexport const createStore = <Row extends object, MetaProps extends object = {}>(rows: Row[], meta: MetaProps) => {\r\n\r\n const factory = {\r\n data: {\r\n state: [] as RowType<Row>[],\r\n meta: new Map<keyof MetaProps, any>()\r\n },\r\n dispatches: {\r\n state: new Map<string, Function>(),\r\n meta: new Map<string, Function>()\r\n },\r\n observe: {\r\n state: Math.random(),\r\n meta: Math.random()\r\n },\r\n cache: new Map<string, RowType<Row>[]>()\r\n }\r\n\r\n const fire = (type: StateDataType) => {\r\n factory.observe[type] = Math.random()\r\n factory.dispatches[type].forEach((cb, key) => {\r\n try {\r\n cb()\r\n } catch (_err) {\r\n factory.dispatches[type].delete(key)\r\n }\r\n })\r\n }\r\n\r\n const useHook = (type: StateDataType) => {\r\n const id = useId()\r\n const [, dispatch] = useState(0)\r\n useEffect(() => {\r\n factory.dispatches[type].set(id, () => dispatch(Math.random()))\r\n return () => {\r\n factory.dispatches[type].delete(id)\r\n }\r\n }, [])\r\n }\r\n\r\n for (let row of rows) {\r\n factory.data.state.push(_row(row))\r\n }\r\n for (let key in meta) {\r\n factory.data.meta.set(key, meta[key])\r\n }\r\n\r\n abstract class StateHandler {\r\n\r\n static create(row: Row, freeze?: boolean): RowType<Row> {\r\n const r = _row<Row>(row as any)\r\n factory.data.state.push(r)\r\n if (!freeze) {\r\n fire(\"state\")\r\n }\r\n return r\r\n }\r\n\r\n static createMany(rows: Row[], freeze?: boolean): RowType<Row>[] {\r\n\r\n const rs = []\r\n for (let row of rows) {\r\n const r = _row<Row>(row)\r\n factory.data.state.push(r)\r\n rs.push(r)\r\n }\r\n if (!freeze) {\r\n fire(\"state\")\r\n }\r\n return rs\r\n }\r\n\r\n static update(row: Partial<Row>, where: WhereType<Row>, freeze?: boolean) {\r\n Finder(factory.data.state, where, {\r\n getRow: (r, index) => {\r\n factory.data.state[index] = _row<Row>({ ...r, ...row })\r\n }\r\n })\r\n\r\n if (!freeze) {\r\n fire(\"state\")\r\n }\r\n }\r\n\r\n static updateAll(row: Partial<Row>, freeze?: boolean) {\r\n\r\n for (let i = 0; i < factory.data.state.length; i++) {\r\n factory.data.state[i] = _row<Row>({ ...factory.data.state[i], ...row })\r\n }\r\n if (!freeze) {\r\n fire(\"state\")\r\n }\r\n }\r\n\r\n static delete(where: WhereType<Row>, freeze?: boolean) {\r\n const found = Finder(factory.data.state, where)\r\n factory.data.state = factory.data.state.filter((row) => !found.ids.includes(row._id))\r\n\r\n if (!freeze) {\r\n fire(\"state\")\r\n }\r\n }\r\n static move(oldIdx: number, newIdx: number, freeze?: boolean) {\r\n const row: any = factory.data.state[oldIdx]\r\n if (row) {\r\n factory.data.state.splice(oldIdx, 1)\r\n factory.data.state.splice(newIdx, 0, _row(row))\r\n if (!freeze) {\r\n fire(\"state\")\r\n }\r\n }\r\n }\r\n static clearAll(freeze?: boolean) {\r\n factory.data.state = []\r\n if (!freeze) {\r\n fire(\"state\")\r\n }\r\n }\r\n\r\n static getAll(args?: ArgsType<Row>) {\r\n try {\r\n if (!args?.freeze) {\r\n useHook(\"state\")\r\n }\r\n const cacheKey = factory.observe.state.toString() + (args?.skip || \"\") + (args?.take || \"\")\r\n const items = factory.cache.get(cacheKey)\r\n if (items?.length) {\r\n return items\r\n }\r\n const rows = Finder(factory.data.state, null, args).rows\r\n factory.cache.set(cacheKey, rows)\r\n return rows\r\n } catch (error) {\r\n return Finder(factory.data.state, null, args)\r\n }\r\n }\r\n\r\n static find(where: WhereType<Row>, args?: ArgsType<Row>): RowType<Row>[] {\r\n try {\r\n if (!args?.freeze) {\r\n useHook(\"state\")\r\n }\r\n const cacheKey = factory.observe.state.toString() + (args?.skip || \"\") + (args?.take || \"\") + JSON.stringify(where)\r\n const items = factory.cache.get(cacheKey)\r\n if (items?.length) {\r\n // return items\r\n }\r\n const rows = Finder(factory.data.state, where, args).rows\r\n factory.cache.set(cacheKey, rows)\r\n return rows\r\n } catch (error) {\r\n return Finder(factory.data.state, where, args).rows\r\n }\r\n }\r\n\r\n static findFirst(where: WhereType<Row>, freeze?: boolean) {\r\n return StateHandler.find(where, { freeze })[0]\r\n }\r\n\r\n static findById(_id: string, freeze?: boolean) {\r\n return StateHandler.findFirst({ _id }, freeze)\r\n }\r\n\r\n static setMeta<T extends keyof MetaProps>(key: T, value: MetaProps[T], freeze?: boolean) {\r\n factory.data.meta.set(key, value)\r\n if (!freeze) {\r\n fire(\"meta\")\r\n }\r\n }\r\n\r\n static getMeta<T extends keyof MetaProps>(key: T, freeze?: boolean): MetaProps[T] {\r\n try {\r\n if (!freeze) {\r\n useHook(\"meta\")\r\n }\r\n return factory.data.meta.get(key)\r\n } catch (error) {\r\n return factory.data.meta.get(key)\r\n }\r\n }\r\n\r\n static getAllMeta(freeze?: boolean): MetaProps {\r\n try {\r\n if (!freeze) {\r\n useHook(\"meta\")\r\n }\r\n return Object.fromEntries(factory.data.meta) as MetaProps\r\n } catch (error) {\r\n return Object.fromEntries(factory.data.meta) as MetaProps\r\n }\r\n }\r\n\r\n static deleteMeta<T extends keyof MetaProps>(key: T, freeze?: boolean) {\r\n factory.data.meta.delete(key)\r\n if (!freeze) {\r\n fire(\"meta\")\r\n }\r\n }\r\n\r\n static clearMeta(freeze?: boolean) {\r\n factory.data.meta.clear()\r\n if (!freeze) {\r\n fire(\"meta\")\r\n }\r\n }\r\n }\r\n\r\n return StateHandler as IStateHandler<Row, MetaProps>\r\n}\r\n\r\n"],
|
|
5
|
+
"mappings": "aACA,OAAS,aAAAA,EAAW,SAAAC,EAAO,YAAAC,EAAU,iBAAAC,EAAe,YAAAC,EAAU,aAAAC,MAAiB,QAE/E,OAAOC,GAAU,QAAAC,MAAY,WAC7B,WAAc,UAEP,MAAMC,UAAiDH,CAAoB,CAC9E,YAAYI,EAAU,CAClB,MAAMA,CAAK,EACX,MAAMC,EAAI,KAAK,OAAO,KAAK,IAAI,EAC/B,KAAK,OAAS,IAAMP,EAAcC,EAAU,KAAMD,EAAcO,EAAG,IAAI,CAAC,CAC5E,CACJ,CAEA,MAAMC,EAAU,IAAM,KAAK,IAAI,EAAI,KAAK,MAAM,IAAO,KAAK,OAAO,EAAI,GAAI,EACnEC,EAAO,IAAMD,EAAQ,EAAE,SAAS,EAAE,EAAE,QAAQ,IAAK,EAAE,EAAE,UAAU,EAAG,EAAE,EACpEE,EAAWC,GAAyC,CACtD,GAAI,CAACP,EAAKO,CAAG,EAAG,MAAM,IAAI,MAAM,sCAAsC,OAAOA,CAAG,KAAKA,CAAG,EAAE,EAC1F,MAAO,CAAE,GAAGA,EAAK,IAAKA,EAAI,KAAOF,EAAK,EAAG,SAAUE,EAAI,UAAYH,EAAQ,CAAE,CACjF,EAEaI,EAAc,CAAoDC,EAAaC,IAAoB,CAE5G,MAAMC,EAA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J,EAAQ,KAAK,KAAK,IAAII,CAAG,CACpC,CACJ,CAEA,OAAO,WAAWK,EAA6B,CAC3C,GAAI,CACA,OAAKA,GACDJ,EAAQ,MAAM,EAEX,OAAO,YAAYL,EAAQ,KAAK,IAAI,CAC/C,MAAgB,CACZ,OAAO,OAAO,YAAYA,EAAQ,KAAK,IAAI,CAC/C,CACJ,CAEA,OAAO,WAAsCI,EAAQK,EAAkB,CACnET,EAAQ,KAAK,KAAK,OAAOI,CAAG,EACvBK,GACDR,EAAK,MAAM,CAEnB,CAEA,OAAO,UAAUQ,EAAkB,CAC/BT,EAAQ,KAAK,KAAK,MAAM,EACnBS,GACDR,EAAK,MAAM,CAEnB,CACJ,CAEA,OAAOO,CACX",
|
|
6
|
+
"names": ["useEffect", "useId", "useState", "createElement", "Fragment", "Component", "Finder", "isOb", "StoreComponent", "props", "R", "_random", "_uid", "_row", "row", "createStore", "rows", "meta", "factory", "fire", "type", "cb", "key", "useHook", "id", "dispatch", "StateHandler", "freeze", "r", "rs", "where", "index", "i", "found", "oldIdx", "newIdx", "args", "cacheKey", "items", "_id", "value"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,37 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"author": "Naxrul Ahmed",
|
|
5
|
-
"
|
|
6
|
-
"main": "
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"@
|
|
30
|
-
"@types/react": "^
|
|
31
|
-
|
|
32
|
-
"parcel": "^2.12.0",
|
|
33
|
-
"react": "^18.3.1",
|
|
34
|
-
"react-dom": "^18.3.1",
|
|
35
|
-
"typescript": "^5.5.3"
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "react-rock",
|
|
3
|
+
"version": "3.1.5",
|
|
4
|
+
"author": "Naxrul Ahmed",
|
|
5
|
+
"description": "React-Rock is a modern, lightweight state management library designed to simplify handling global state in React applications. With a minimal API and powerful features like freezing data updates for optimized re-renders, React-Rock allows you to manage state more efficiently while ensuring your app remains fast and responsive.",
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "makepack serve",
|
|
9
|
+
"pack": "makepack pack",
|
|
10
|
+
"publish:pack": "makepack pack -p"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"react",
|
|
14
|
+
"state management",
|
|
15
|
+
"react state",
|
|
16
|
+
"react hooks",
|
|
17
|
+
"state library"
|
|
18
|
+
],
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/devnax/react-rock/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/devnax/react-rock#readme",
|
|
23
|
+
"dependencies": {},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"makepack": "latest",
|
|
26
|
+
"react": "^19.0.0",
|
|
27
|
+
"react-dom": "^19.0.0",
|
|
28
|
+
"typescript": "^4.4.2",
|
|
29
|
+
"@types/react": "^19.0.2",
|
|
30
|
+
"@types/react-dom": "^19.0.2"
|
|
31
|
+
}
|
|
37
32
|
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img width="120" src="https://raw.githubusercontent.com/devnax/react-rock/main/logo.png" alt="React Rock logo">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">React Rock</h1>
|
|
6
|
+
|
|
7
|
+
React-Rock is a lightweight package for managing global state in React applications. It simplifies handling data by providing a store with rows and metadata, while offering methods to perform CRUD operations and more. It enables easy integration with React components, making it an ideal solution for managing complex state in large applications.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
To install the React-Rock package, run the following command in your project:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install react-rock
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- **Global Store Management**: Manage rows and meta data in a global store.
|
|
21
|
+
- **CRUD Operations**: Perform create, read, update, and delete operations on rows.
|
|
22
|
+
- **Meta Management**: Set, get, and delete meta data.
|
|
23
|
+
- **Optimized Re-renders**: Control component re-renders with the `freeze` option.
|
|
24
|
+
- **Class Component Support**: Use the `StoreComponent` for integrating store data into class components.
|
|
25
|
+
|
|
26
|
+
## Basic Example: Creating a Store and Adding Records
|
|
27
|
+
|
|
28
|
+
To create a new store and add a record, use the `createStore` function. Here's an example:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { createStore } from 'react-rock';
|
|
32
|
+
|
|
33
|
+
// Define RowType and MetaType
|
|
34
|
+
type RowType = { name: string, age: number };
|
|
35
|
+
type MetaType = { totalRecords: number };
|
|
36
|
+
|
|
37
|
+
// Create a store
|
|
38
|
+
const users = createStore<RowType, MetaType>({ name: '', age: 0 }, { totalRecords: 0 });
|
|
39
|
+
|
|
40
|
+
// Add a new row to the store
|
|
41
|
+
users.create({ name: 'John Doe', age: 30 });
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### RowType Explained
|
|
45
|
+
|
|
46
|
+
When a row is created, it will have the following properties:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
type RowType<Row> = Row & {
|
|
50
|
+
_id: string; // Unique identifier for the row
|
|
51
|
+
_index: number; // Index of the row in the store
|
|
52
|
+
_observe: number; // Internal property to track changes
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Each row will include the original data (`Row`) and some additional properties like `_id`, `_index`, and `_observe`.
|
|
57
|
+
|
|
58
|
+
## Methods
|
|
59
|
+
|
|
60
|
+
Here’s a table with all available methods and their descriptions:
|
|
61
|
+
|
|
62
|
+
| Method | Description |
|
|
63
|
+
| ------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
64
|
+
| `create(row, freeze?)` | Adds a new record to the store. Optionally, prevents re-rendering if `freeze` is `true`. |
|
|
65
|
+
| `createMany(rows, freeze?)` | Adds multiple records to the store. Optionally, prevents re-rendering if `freeze` is `true`. |
|
|
66
|
+
| `update(row, where, freeze?)` | Updates records based on the condition specified in `where`. |
|
|
67
|
+
| `updateAll(row, freeze?)` | Updates all records in the store. Optionally, prevents re-rendering if `freeze` is `true`. |
|
|
68
|
+
| `delete(where, freeze?)` | Deletes records based on the condition specified in `where`. |
|
|
69
|
+
| `move(oldIdx, newIdx, freeze?)` | Moves a record from one index to another. |
|
|
70
|
+
| `clearAll(freeze?)` | Clears all records from the store. Optionally, prevents re-rendering if `freeze` is `true`. |
|
|
71
|
+
| `getAll(args?)` | Retrieves all rows from the store. |
|
|
72
|
+
| `find(where, args?)` | Finds rows based on a condition specified in `where`. |
|
|
73
|
+
| `findFirst(where, freeze?)` | Finds the first row that matches the condition in `where`. |
|
|
74
|
+
| `findById(_id, freeze?)` | Finds a row by its `_id`. |
|
|
75
|
+
| `setMeta(key, value, freeze?)` | Sets a value for a specific meta key. |
|
|
76
|
+
| `getMeta(key, freeze?)` | Retrieves the value of a specific meta key. |
|
|
77
|
+
| `getAllMeta(freeze?)` | Retrieves all meta data from the store. |
|
|
78
|
+
| `deleteMeta(key, freeze?)` | Deletes a specific meta key. |
|
|
79
|
+
| `clearMeta(freeze?)` | Clears all meta data from the store. |
|
|
80
|
+
|
|
81
|
+
### Example of the `find` Method
|
|
82
|
+
|
|
83
|
+
The `find` method allows you to search for rows in the store based on specific conditions:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const foundUsers = users.find({ name: { equalWith: 'John Doe' } });
|
|
87
|
+
console.log(foundUsers);
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
### Re-rendering in React Components
|
|
92
|
+
|
|
93
|
+
React-Rock optimizes re-renders by offering a freeze mechanism. When a store update occurs and the `freeze` option is enabled, React components that access the store using methods like `find` or `findFirst` will not automatically re-render. This gives you control over when your components should re-render, improving performance in large applications.
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
## WhereType
|
|
97
|
+
|
|
98
|
+
The `WhereType` is used to specify conditions when querying rows. It defines a query structure for filtering rows.
|
|
99
|
+
|
|
100
|
+
### QueryValueType
|
|
101
|
+
|
|
102
|
+
The `QueryValueType` is used within `WhereType` to define possible conditions for querying:
|
|
103
|
+
|
|
104
|
+
| Property | Description |
|
|
105
|
+
| -------------- | ----------------------------------------------------------------- |
|
|
106
|
+
| `contain` | Finds values containing the specified string, number, or boolean. |
|
|
107
|
+
| `startWith` | Finds values that start with the specified string or number. |
|
|
108
|
+
| `endWith` | Finds values that end with the specified string or number. |
|
|
109
|
+
| `equalWith` | Finds values that are exactly equal to the specified value. |
|
|
110
|
+
| `notEqualWith` | Finds values that are not equal to the specified value. |
|
|
111
|
+
| `gt` | Finds values greater than the specified number. |
|
|
112
|
+
| `lt` | Finds values less than the specified number. |
|
|
113
|
+
| `gte` | Finds values greater than or equal to the specified number. |
|
|
114
|
+
| `lte` | Finds values less than or equal to the specified number. |
|
|
115
|
+
|
|
116
|
+
### Example of WhereType
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
const usersOver30 = users.find({ age: { gt: 30 } });
|
|
120
|
+
console.log(usersOver30);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## ArgsType
|
|
124
|
+
|
|
125
|
+
The `ArgsType` defines options for customizing query behavior, such as selecting specific rows or skipping rows.
|
|
126
|
+
|
|
127
|
+
| Property | Description |
|
|
128
|
+
| -------- | --------------------------------------------------------- |
|
|
129
|
+
| `getRow` | Custom function to process rows before returning them. |
|
|
130
|
+
| `skip` | Number of rows to skip. |
|
|
131
|
+
| `take` | Number of rows to return. |
|
|
132
|
+
| `freeze` | If `true`, prevents re-rendering when accessing the data. |
|
|
133
|
+
|
|
134
|
+
## Example with Class Component
|
|
135
|
+
|
|
136
|
+
To use the store in a class component, extend the `StoreComponent` class:
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import { StoreComponent } from 'react-rock';
|
|
140
|
+
|
|
141
|
+
class UserList extends StoreComponent {
|
|
142
|
+
render() {
|
|
143
|
+
const allUsers = users.getAll();
|
|
144
|
+
return (
|
|
145
|
+
<div>
|
|
146
|
+
{allUsers.map(user => <div key={user._id}>{user.name}</div>)}
|
|
147
|
+
</div>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## CRUD Example
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
// Create a new user
|
|
157
|
+
users.create({ name: 'Alice', age: 25 });
|
|
158
|
+
|
|
159
|
+
// Update a user
|
|
160
|
+
users.update({ age: 26 }, { name: { equalWith: 'Alice' } });
|
|
161
|
+
|
|
162
|
+
// Delete a user
|
|
163
|
+
users.delete({ name: { equalWith: 'Alice' } });
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Examples with `find` and Query
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
// Find users over the age of 25
|
|
170
|
+
const usersOver25 = users.find({ age: { gt: 25 } });
|
|
171
|
+
console.log(usersOver25);
|
|
172
|
+
|
|
173
|
+
// Find the first user with the name 'Alice'
|
|
174
|
+
const alice = users.findFirst({ name: { equalWith: 'Alice' } });
|
|
175
|
+
console.log(alice);
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Example of Using the Store in Multiple Components
|
|
179
|
+
|
|
180
|
+
React-Rock allows you to share the same store across multiple components, ensuring a consistent state throughout the app:
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { StoreComponent } from 'react-rock';
|
|
184
|
+
|
|
185
|
+
class UserList extends StoreComponent {
|
|
186
|
+
render() {
|
|
187
|
+
const users = this.store.getAll();
|
|
188
|
+
return (
|
|
189
|
+
<div>
|
|
190
|
+
{users.map(user => <div key={user._id}>{user.name}</div>)}
|
|
191
|
+
</div>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
class UserProfile extends StoreComponent {
|
|
197
|
+
render() {
|
|
198
|
+
const user = this.store.findFirst({ name: { equalWith: 'John Doe' } });
|
|
199
|
+
return <div>{user ? user.name : 'User not found'}</div>;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
## Explanation of Types
|
|
207
|
+
|
|
208
|
+
- **RowType**: Represents a record with an `_id`, `_index`, and `_observe` along with user-defined data fields.
|
|
209
|
+
- **ArgsType**: Defines the options for querying rows with flexibility like skipping, taking, and custom row processing.
|
|
210
|
+
- **WhereType**: Represents the conditions for querying records, using fields like `contain`, `equalWith`, and range queries like `gt`, `lt`, etc.
|
|
211
|
+
- **QueryValueType**: Specifies the allowed condition types for filtering rows based on field values.
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
## License
|
|
215
|
+
|
|
216
|
+
This package is licensed under the MIT License.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
This documentation should provide a concise overview of how to use the `react-rock` package effectively.
|
|
221
|
+
|
|
222
|
+
## 🤝 Contributing
|
|
223
|
+
|
|
224
|
+
Contributions are welcome! Please check out the [contribution guidelines](https://github.com/devnax/react-rock).
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## 📄 License
|
|
229
|
+
|
|
230
|
+
This project is licensed under the [MIT License](https://opensource.org/licenses/MIT).
|
package/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
package/types.js.map
ADDED
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Naxrul Ahmed
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
# React Rock Documentation
|
|
2
|
-
|
|
3
|
-
**React Rock** is a lightweight state management library designed for React applications. It simplifies state handling with a straightforward API, allowing developers to efficiently manage complex states.
|
|
4
|
-
|
|
5
|
-
- **NPM**: [react-rock](https://www.npmjs.com/package/react-rock)
|
|
6
|
-
- **GitHub**: [React Rock Repository](https://github.com/devnax/react-rock)
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## Installation
|
|
11
|
-
|
|
12
|
-
To get started, install React Rock via npm:
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
npm install react-rock
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Core Concept
|
|
19
|
-
|
|
20
|
-
The core of React Rock is the `createStore` function. It enables developers to manage application state using an intuitive API for creating, updating, deleting, and querying state records.
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## Usage
|
|
25
|
-
|
|
26
|
-
### Creating a Store
|
|
27
|
-
|
|
28
|
-
```tsx
|
|
29
|
-
import { createStore } from "react-rock";
|
|
30
|
-
|
|
31
|
-
// Define the shape of your state
|
|
32
|
-
interface Todo {
|
|
33
|
-
title: string;
|
|
34
|
-
completed: boolean;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Create a store for managing Todos
|
|
38
|
-
const todoStore = createStore<Todo>();
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Adding Data
|
|
42
|
-
|
|
43
|
-
#### Single Record
|
|
44
|
-
|
|
45
|
-
```tsx
|
|
46
|
-
todoStore.create({ title: "Learn React Rock", completed: false });
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
#### Multiple Records
|
|
50
|
-
|
|
51
|
-
```tsx
|
|
52
|
-
todoStore.createMany([
|
|
53
|
-
{ title: "Write Documentation", completed: true },
|
|
54
|
-
{ title: "Push to GitHub", completed: false },
|
|
55
|
-
]);
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Querying Data
|
|
59
|
-
|
|
60
|
-
#### Retrieve All Records
|
|
61
|
-
|
|
62
|
-
```tsx
|
|
63
|
-
const allTodos = todoStore.getAll();
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
#### Find Records by Criteria
|
|
67
|
-
|
|
68
|
-
```tsx
|
|
69
|
-
const completedTodos = todoStore.find({ completed: true });
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
#### Find a Single Record by ID
|
|
73
|
-
|
|
74
|
-
```tsx
|
|
75
|
-
const todo = todoStore.findById("unique_id");
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### Updating Data
|
|
79
|
-
|
|
80
|
-
#### Update Matching Records
|
|
81
|
-
|
|
82
|
-
```tsx
|
|
83
|
-
todoStore.update({ completed: true }, { title: "Push to GitHub" });
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
#### Update All Records
|
|
87
|
-
|
|
88
|
-
```tsx
|
|
89
|
-
todoStore.updateAll({ completed: false });
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Deleting Data
|
|
93
|
-
|
|
94
|
-
#### Delete Matching Records
|
|
95
|
-
|
|
96
|
-
```tsx
|
|
97
|
-
todoStore.delete({ completed: true });
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
#### Delete All Records
|
|
101
|
-
|
|
102
|
-
```tsx
|
|
103
|
-
todoStore.clearAll();
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### Meta Data Management
|
|
107
|
-
|
|
108
|
-
React Rock supports storing metadata alongside your state:
|
|
109
|
-
|
|
110
|
-
#### Set Metadata
|
|
111
|
-
|
|
112
|
-
```tsx
|
|
113
|
-
todoStore.setMeta("lastUpdated", new Date());
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
#### Get Metadata
|
|
117
|
-
|
|
118
|
-
```tsx
|
|
119
|
-
const lastUpdated = todoStore.getMeta("lastUpdated");
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
#### Clear Metadata
|
|
123
|
-
|
|
124
|
-
```tsx
|
|
125
|
-
todoStore.clearMeta();
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
|
-
## Advanced Examples
|
|
131
|
-
|
|
132
|
-
### Pagination
|
|
133
|
-
|
|
134
|
-
```tsx
|
|
135
|
-
const paginatedTodos = todoStore.getAll({ skip: 0, take: 5 });
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Moving Records
|
|
139
|
-
|
|
140
|
-
```tsx
|
|
141
|
-
todoStore.move(0, 1); // Move record from index 0 to index 1
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
### Observing State Changes
|
|
145
|
-
|
|
146
|
-
React Rock integrates seamlessly with React hooks for real-time updates:
|
|
147
|
-
|
|
148
|
-
```tsx
|
|
149
|
-
const TodoList = () => {
|
|
150
|
-
const todos = todoStore.getAll();
|
|
151
|
-
|
|
152
|
-
return (
|
|
153
|
-
<ul>
|
|
154
|
-
{todos.map(todo => (
|
|
155
|
-
<li key={todo._id}>{todo.title}</li>
|
|
156
|
-
))}
|
|
157
|
-
</ul>
|
|
158
|
-
);
|
|
159
|
-
};
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## API Reference
|
|
165
|
-
|
|
166
|
-
### `createStore`
|
|
167
|
-
|
|
168
|
-
Creates a new store for managing state.
|
|
169
|
-
|
|
170
|
-
#### Methods
|
|
171
|
-
|
|
172
|
-
- **`create(row: Row)`**: Adds a new record.
|
|
173
|
-
- **`createMany(rows: Row[])`**: Adds multiple records.
|
|
174
|
-
- **`update(row: Partial<Row>, where: WhereType<Row>)`**: Updates matching records.
|
|
175
|
-
- **`updateAll(row: Partial<Row>)`**: Updates all records.
|
|
176
|
-
- **`delete(where: WhereType<Row>)`**: Deletes matching records.
|
|
177
|
-
- **`clearAll()`**: Clears all records.
|
|
178
|
-
- **`find(where: WhereType<Row>)`**: Finds matching records.
|
|
179
|
-
- **`findById(id: string)`**: Finds a record by its ID.
|
|
180
|
-
- **`setMeta(key, value)`**: Sets metadata.
|
|
181
|
-
- **`getMeta(key)`**: Retrieves metadata.
|
|
182
|
-
- **`clearMeta()`**: Clears metadata.
|
|
183
|
-
|
|
184
|
-
---
|
|
185
|
-
|
|
186
|
-
## Contributing
|
|
187
|
-
|
|
188
|
-
Contributions are welcome! Feel free to open an issue or submit a pull request on the [GitHub repository](https://github.com/devnax/react-rock).
|
|
189
|
-
|
|
190
|
-
---
|
|
191
|
-
|
|
192
|
-
## License
|
|
193
|
-
|
|
194
|
-
React Rock is licensed under the MIT License.
|
|
195
|
-
|
package/dist/Finder.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
export const isOb = (ob) => typeof ob === "object" && !Array.isArray(ob) && ob !== null;
|
|
2
|
-
const isNum = (n) => typeof n === 'number';
|
|
3
|
-
const excuteQuery = {
|
|
4
|
-
contain: (v, qv) => typeof v === 'string' && v.search(qv) !== -1,
|
|
5
|
-
startWith: (v, qv) => typeof v === 'string' && v.startsWith(qv),
|
|
6
|
-
endWith: (v, qv) => typeof v === 'string' && v.endsWith(qv),
|
|
7
|
-
equalWith: (v, qv) => v === qv,
|
|
8
|
-
notEqualWith: (v, qv) => v !== qv,
|
|
9
|
-
lt: (v, qv) => isNum(v) && v < qv,
|
|
10
|
-
gt: (v, qv) => isNum(v) && v > qv,
|
|
11
|
-
lte: (v, qv) => isNum(v) && v <= qv,
|
|
12
|
-
gte: (v, qv) => isNum(v) && v >= qv,
|
|
13
|
-
};
|
|
14
|
-
const isInQuery = (rowVal, queryObject) => {
|
|
15
|
-
let match = true;
|
|
16
|
-
for (let queryKey in queryObject) {
|
|
17
|
-
let qVal = queryObject[queryKey];
|
|
18
|
-
const qcb = excuteQuery[queryKey];
|
|
19
|
-
if (qcb && !qcb(rowVal, qVal)) {
|
|
20
|
-
match = false;
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return match;
|
|
25
|
-
};
|
|
26
|
-
const Finder = (rows, query, args) => {
|
|
27
|
-
let result = [];
|
|
28
|
-
let indexes = [];
|
|
29
|
-
let ids = [];
|
|
30
|
-
for (let i = 0; i < rows.length; i++) {
|
|
31
|
-
let row = rows[i];
|
|
32
|
-
let found = false;
|
|
33
|
-
if (isOb(query)) {
|
|
34
|
-
for (let rowKey in query) {
|
|
35
|
-
let queryVal = query[rowKey];
|
|
36
|
-
if (!(rowKey in row))
|
|
37
|
-
break;
|
|
38
|
-
if (isOb(queryVal)) {
|
|
39
|
-
if (isInQuery(row[rowKey], queryVal)) {
|
|
40
|
-
found = true;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
found = false;
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else if (row[rowKey] === queryVal) {
|
|
48
|
-
found = true;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
found = false;
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
found = true;
|
|
58
|
-
}
|
|
59
|
-
if (found) {
|
|
60
|
-
if (args?.getRow) {
|
|
61
|
-
let r = args.getRow({ ...row }, i);
|
|
62
|
-
if (r) {
|
|
63
|
-
row = r;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
result.push({ ...row, _index: i });
|
|
70
|
-
indexes.push(i);
|
|
71
|
-
ids.push(row._id);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
const take = args?.take || result.length;
|
|
75
|
-
const skip = args?.skip || 0;
|
|
76
|
-
if (args?.take && args?.skip) {
|
|
77
|
-
result = result.splice(skip, take);
|
|
78
|
-
}
|
|
79
|
-
else if (!args?.skip && args?.take) {
|
|
80
|
-
result.splice(args.take);
|
|
81
|
-
}
|
|
82
|
-
else if (!args?.take && args?.skip) {
|
|
83
|
-
result = result.splice(args.skip);
|
|
84
|
-
}
|
|
85
|
-
return { rows: result, indexes, ids };
|
|
86
|
-
};
|
|
87
|
-
export default Finder;
|
|
88
|
-
//# sourceMappingURL=Finder.js.map
|
package/dist/Finder.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Finder.js","sourceRoot":"","sources":["../src/Finder.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,EAAO,EAAE,EAAE,CAA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A;IAC5B,CAAC;SAAM,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,IAAI,EAAE,CAAC;QACnC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAA;AACzC,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
|
package/dist/index.js
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect, useId, useState, createElement, Fragment, Component } from 'react';
|
|
3
|
-
import Finder, { isOb } from './Finder';
|
|
4
|
-
export * from './types';
|
|
5
|
-
export class StateComponent extends Component {
|
|
6
|
-
constructor(props) {
|
|
7
|
-
super(props);
|
|
8
|
-
const R = this.render.bind(this);
|
|
9
|
-
this.render = () => createElement(Fragment, null, createElement(R, null));
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const _random = () => Date.now() + Math.floor(1000 + Math.random() * 9000);
|
|
13
|
-
const _uid = () => _random().toString(32).replace("-", "").substring(0, 15);
|
|
14
|
-
const _row = (row) => {
|
|
15
|
-
if (!isOb(row))
|
|
16
|
-
throw new Error(`State row must be an object. given ${typeof row}: ${row}`);
|
|
17
|
-
return { ...row, _id: row._id || _uid(), _observe: row._observe || _random() };
|
|
18
|
-
};
|
|
19
|
-
export const createStore = () => {
|
|
20
|
-
const factory = {
|
|
21
|
-
data: {
|
|
22
|
-
state: [],
|
|
23
|
-
meta: new Map()
|
|
24
|
-
},
|
|
25
|
-
dispatches: {
|
|
26
|
-
state: new Map(),
|
|
27
|
-
meta: new Map()
|
|
28
|
-
},
|
|
29
|
-
observe: {
|
|
30
|
-
state: Math.random(),
|
|
31
|
-
meta: Math.random()
|
|
32
|
-
},
|
|
33
|
-
cache: new Map()
|
|
34
|
-
};
|
|
35
|
-
const fire = (type) => {
|
|
36
|
-
factory.observe[type] = Math.random();
|
|
37
|
-
factory.dispatches[type].forEach((cb, key) => {
|
|
38
|
-
try {
|
|
39
|
-
cb();
|
|
40
|
-
}
|
|
41
|
-
catch (_err) {
|
|
42
|
-
factory.dispatches[type].delete(key);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
const useHook = (type) => {
|
|
47
|
-
const id = useId();
|
|
48
|
-
const [, dispatch] = useState(0);
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
factory.dispatches[type].set(id, () => dispatch(Math.random()));
|
|
51
|
-
return () => {
|
|
52
|
-
factory.dispatches[type].delete(id);
|
|
53
|
-
};
|
|
54
|
-
}, []);
|
|
55
|
-
};
|
|
56
|
-
class StateHandler {
|
|
57
|
-
static create(row, freeze) {
|
|
58
|
-
const r = _row(row);
|
|
59
|
-
factory.data.state.push(r);
|
|
60
|
-
if (!freeze) {
|
|
61
|
-
fire("state");
|
|
62
|
-
}
|
|
63
|
-
return r;
|
|
64
|
-
}
|
|
65
|
-
static createMany(rows, freeze) {
|
|
66
|
-
const rs = [];
|
|
67
|
-
for (let row of rows) {
|
|
68
|
-
const r = _row(row);
|
|
69
|
-
factory.data.state.push(r);
|
|
70
|
-
rs.push(r);
|
|
71
|
-
}
|
|
72
|
-
if (!freeze) {
|
|
73
|
-
fire("state");
|
|
74
|
-
}
|
|
75
|
-
return rs;
|
|
76
|
-
}
|
|
77
|
-
static update(row, where, freeze) {
|
|
78
|
-
Finder(factory.data.state, where, {
|
|
79
|
-
getRow: (r, index) => {
|
|
80
|
-
factory.data.state[index] = _row({ ...r, ...row });
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
if (!freeze) {
|
|
84
|
-
fire("state");
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
static updateAll(row, freeze) {
|
|
88
|
-
for (let i = 0; i < factory.data.state.length; i++) {
|
|
89
|
-
factory.data.state[i] = _row({ ...factory.data.state[i], ...row });
|
|
90
|
-
}
|
|
91
|
-
if (!freeze) {
|
|
92
|
-
fire("state");
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
static delete(where, freeze) {
|
|
96
|
-
const found = Finder(factory.data.state, where);
|
|
97
|
-
factory.data.state = factory.data.state.filter((row) => !found.ids.includes(row._id));
|
|
98
|
-
if (!freeze) {
|
|
99
|
-
fire("state");
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
static move(oldIdx, newIdx, freeze) {
|
|
103
|
-
const row = factory.data.state[oldIdx];
|
|
104
|
-
if (row) {
|
|
105
|
-
factory.data.state.splice(oldIdx, 1);
|
|
106
|
-
factory.data.state.splice(newIdx, 0, _row(row));
|
|
107
|
-
if (!freeze) {
|
|
108
|
-
fire("state");
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
static clearAll(freeze) {
|
|
113
|
-
factory.data.state = [];
|
|
114
|
-
if (!freeze) {
|
|
115
|
-
fire("state");
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
static getAll(args) {
|
|
119
|
-
try {
|
|
120
|
-
if (!args?.freeze) {
|
|
121
|
-
useHook("state");
|
|
122
|
-
}
|
|
123
|
-
const cacheKey = factory.observe.state.toString() + (args?.skip || "") + (args?.take || "");
|
|
124
|
-
const items = factory.cache.get(cacheKey);
|
|
125
|
-
if (items?.length) {
|
|
126
|
-
return items;
|
|
127
|
-
}
|
|
128
|
-
const rows = Finder(factory.data.state, null, args).rows;
|
|
129
|
-
factory.cache.set(cacheKey, rows);
|
|
130
|
-
return rows;
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
return Finder(factory.data.state, null, args);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
static find(where, args) {
|
|
137
|
-
try {
|
|
138
|
-
if (!args?.freeze) {
|
|
139
|
-
useHook("state");
|
|
140
|
-
}
|
|
141
|
-
const cacheKey = factory.observe.state.toString() + (args?.skip || "") + (args?.take || "") + JSON.stringify(where);
|
|
142
|
-
const items = factory.cache.get(cacheKey);
|
|
143
|
-
if (items?.length) {
|
|
144
|
-
// return items
|
|
145
|
-
}
|
|
146
|
-
const rows = Finder(factory.data.state, where, args).rows;
|
|
147
|
-
factory.cache.set(cacheKey, rows);
|
|
148
|
-
return rows;
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
return Finder(factory.data.state, where, args).rows;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
static findFirst(where, freeze) {
|
|
155
|
-
return StateHandler.find(where, { freeze })[0];
|
|
156
|
-
}
|
|
157
|
-
static findById(_id, freeze) {
|
|
158
|
-
return StateHandler.findFirst({ _id }, freeze);
|
|
159
|
-
}
|
|
160
|
-
static setMeta(key, value, freeze) {
|
|
161
|
-
factory.data.meta.set(key, value);
|
|
162
|
-
if (!freeze) {
|
|
163
|
-
fire("meta");
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
static getMeta(key, freeze) {
|
|
167
|
-
try {
|
|
168
|
-
if (!freeze) {
|
|
169
|
-
useHook("meta");
|
|
170
|
-
}
|
|
171
|
-
return factory.data.meta.get(key);
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
return factory.data.meta.get(key);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
static getAllMeta(freeze) {
|
|
178
|
-
try {
|
|
179
|
-
if (!freeze) {
|
|
180
|
-
useHook("meta");
|
|
181
|
-
}
|
|
182
|
-
return Object.fromEntries(factory.data.meta);
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
return Object.fromEntries(factory.data.meta);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
static deleteMeta(key, freeze) {
|
|
189
|
-
factory.data.meta.delete(key);
|
|
190
|
-
if (!freeze) {
|
|
191
|
-
fire("meta");
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
static clearMeta(freeze) {
|
|
195
|
-
factory.data.meta.clear();
|
|
196
|
-
if (!freeze) {
|
|
197
|
-
fire("meta");
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return StateHandler;
|
|
202
|
-
};
|
|
203
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AACZ,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtF,OAAO,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACxC,cAAc,SAAS,CAAA;AAEvB,MAAM,OAAO,cAAyC,SAAQ,SAAmB;IAC7E,YAAY,KAAQ;QAChB,KAAK,CAAC,KAAK,CAAC,CAAA;QACZ,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAQ,CAAA;QACvC,IAAI,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;IAC7E,CAAC;CACJ;AAED,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAA;AAC1E,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAC3E,MAAM,IAAI,GAAG,CAAI,GAAwB,EAAc,EAAE;IACrD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK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L,CAAC;QAED,MAAM,CAAC,UAAU,CAA4B,GAAM,EAAE,MAAgB;YACjE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;gBACV,IAAI,CAAC,MAAM,CAAC,CAAA;YAChB,CAAC;QACL,CAAC;QAED,MAAM,CAAC,SAAS,CAAC,MAAgB;YAC7B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;YACzB,IAAI,CAAC,MAAM,EAAE,CAAC;gBACV,IAAI,CAAC,MAAM,CAAC,CAAA;YAChB,CAAC;QACL,CAAC;KACJ;IAED,OAAO,YAA6C,CAAA;AACxD,CAAC,CAAA"}
|
package/dist/types.js
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
File without changes
|