react-rock 3.2.6 → 3.2.7

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.
@@ -1,10 +1,12 @@
1
1
  "use client";
2
- import { useId, useState, useEffect } from 'react';
3
- import { xv } from 'xanv';
2
+ 'use strict';
4
3
 
5
- const uid = useId;
6
- const ustate = useState;
7
- const ueffect = useEffect;
4
+ var react = require('react');
5
+ var xanv = require('xanv');
6
+
7
+ const uid = react.useId;
8
+ const ustate = react.useState;
9
+ const ueffect = react.useEffect;
8
10
  class Store {
9
11
  constructor(rowSchema, metaSchema) {
10
12
  this._rows = [];
@@ -36,7 +38,7 @@ class Store {
36
38
  });
37
39
  }, 0);
38
40
  };
39
- this._row_schema = Object.assign(Object.assign({}, rowSchema), { rid: xv.number(), vid: xv.number().default(() => Math.round((Math.random() + Math.random()) * 9999999999)) });
41
+ this._row_schema = Object.assign(Object.assign({}, rowSchema), { rid: xanv.xv.number(), vid: xanv.xv.number().default(() => Math.round((Math.random() + Math.random()) * 9999999999)) });
40
42
  this._meta_schema = metaSchema;
41
43
  }
42
44
  rows(observe = true) {
@@ -230,9 +232,7 @@ class Store {
230
232
  return -1;
231
233
  }
232
234
  move(fromIndex, toIndex, observe = true) {
233
- if (fromIndex < 0 || fromIndex >= this._rows.length)
234
- return false;
235
- if (toIndex < 0 || toIndex >= this._rows.length)
235
+ if (fromIndex < 0 || toIndex < 0)
236
236
  return false;
237
237
  const [movedRow] = this._rows.splice(fromIndex, 1);
238
238
  this._rows.splice(toIndex, 0, movedRow);
@@ -258,5 +258,5 @@ class Store {
258
258
  }
259
259
  }
260
260
 
261
- export { Store as default };
262
- //# sourceMappingURL=Store.mjs.map
261
+ module.exports = Store;
262
+ //# sourceMappingURL=Store.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Store.mjs","sources":["../src/Store.ts"],"sourcesContent":["\"use client\"\r\nimport { useEffect, useId, useState } from \"react\"\r\nimport { MakeMetaType, MakeRowType, MetaSchema, RowSchema, WhereType } from \"./types\"\r\nimport { Infer, xv } from \"xanv\"\r\n\r\nconst uid = useId as any\r\nconst ustate = useState as any\r\nconst ueffect = useEffect as any\r\n\r\n\r\nclass Store<RS extends RowSchema, MS extends MetaSchema | undefined = undefined> {\r\n private _rows: MakeRowType<RS>[] = []\r\n private _meta: Map<keyof MakeMetaType<MS>, MakeMetaType<MS>[keyof MakeMetaType<MS>]> = new Map()\r\n private _hooks: Map<string, Function> = new Map()\r\n private _timer: any = null\r\n private _row_schema: RS\r\n private _meta_schema?: MS\r\n private _last_id = 0\r\n\r\n constructor(rowSchema: RS, metaSchema?: MS) {\r\n this._row_schema = {\r\n ...rowSchema,\r\n rid: xv.number(),\r\n vid: xv.number().default(() => Math.round((Math.random() + Math.random()) * 9999999999)),\r\n }\r\n this._meta_schema = metaSchema\r\n }\r\n\r\n private observe = () => {\r\n try {\r\n const hid = uid()\r\n const [, dispatch] = ustate(0)\r\n this._hooks.set(hid, () => dispatch(Math.random()))\r\n ueffect(() => () => {\r\n this._hooks.delete(hid)\r\n }, [])\r\n } catch (error) { }\r\n }\r\n\r\n private dispatch = () => {\r\n clearTimeout(this._timer)\r\n this._timer = setTimeout(() => {\r\n this._hooks.forEach((cb, key) => {\r\n try {\r\n cb()\r\n } catch (_err) {\r\n this._hooks.delete(key)\r\n }\r\n })\r\n }, 0)\r\n }\r\n\r\n rows(observe = true) {\r\n observe && this.observe()\r\n return this._rows\r\n }\r\n\r\n metas(observe = true) {\r\n observe && this.observe()\r\n return this._meta\r\n }\r\n\r\n // Row Methods\r\n create(row: Partial<MakeRowType<RS>>, observe?: boolean): MakeRowType<RS>\r\n create(row: Partial<MakeRowType<RS>>[], observe?: boolean): MakeRowType<RS>[]\r\n create(row: Partial<MakeRowType<RS>> | Partial<MakeRowType<RS>>[], observe = true): MakeRowType<RS> | MakeRowType<RS>[] {\r\n if (Array.isArray(row)) {\r\n const rows: MakeRowType<RS>[] = []\r\n for (const r of row) {\r\n rows.push(this.create(r, false))\r\n }\r\n observe && this.dispatch()\r\n return rows\r\n }\r\n\r\n // validate and create row\r\n let r: any = {} as MakeRowType<RS>\r\n for (let key in this._row_schema) {\r\n if (key === \"rid\" || key === \"vid\") continue;\r\n const schema = this._row_schema[key]\r\n r[key] = schema.parse(row[key])\r\n }\r\n\r\n this._last_id = this._last_id + 1;\r\n const _row: MakeRowType<RS> = {\r\n ...r,\r\n rid: this._last_id,\r\n vid: this._row_schema.vid.parse(undefined),\r\n }\r\n\r\n this._rows.push(_row)\r\n observe && this.dispatch()\r\n return _row\r\n }\r\n\r\n\r\n // update\r\n update(row: Partial<MakeRowType<RS>>, where?: WhereType<RS> | null, observe = true): MakeRowType<RS>[] | null {\r\n\r\n // validate row\r\n let r: any = {} as MakeRowType<RS>\r\n for (let key in row) {\r\n if (key === \"rid\" || key === 'vid') continue;\r\n const schema = this._row_schema[key]\r\n r[key] = schema.parse(row[key])\r\n }\r\n\r\n const rows = this.find(where)\r\n if (rows.length > 0) {\r\n for (let index = 0; index < rows.length; index++) {\r\n const _row = rows[index];\r\n const rid = _row.rid\r\n\r\n rows[index] = {\r\n ..._row,\r\n ...r,\r\n rid,\r\n vid: this._row_schema.vid.parse(undefined),\r\n }\r\n const rowIndex = this._rows.findIndex(r => r.rid === rid)\r\n this._rows[rowIndex] = rows[index]\r\n }\r\n observe && this.dispatch()\r\n }\r\n return this.find(where)\r\n }\r\n\r\n // delete\r\n delete(where?: WhereType<RS> | null, observe = true): number {\r\n const rows = this.find(where, false)\r\n\r\n let deletedCount = 0\r\n if (rows.length > 0) {\r\n this._rows = this._rows.filter(r => !rows.find(dr => dr.rid === r.rid))\r\n deletedCount = rows.length\r\n observe && this.dispatch()\r\n }\r\n return deletedCount\r\n }\r\n\r\n // find\r\n find(where?: WhereType<RS> | null, observe = true): MakeRowType<RS>[] {\r\n observe && this.observe()\r\n\r\n if (!where) {\r\n return this._rows\r\n }\r\n\r\n const rows: MakeRowType<RS>[] = []\r\n for (let key in where) {\r\n const wv = (where as any)[key]\r\n if (typeof wv === \"object\" && wv !== null) {\r\n // QueryValueType\r\n for (let row of this._rows) {\r\n let match = true\r\n const rvalue = (row as any)[key]\r\n if (wv.contain !== undefined) {\r\n if (typeof rvalue === \"string\" && typeof wv.contain === \"string\") {\r\n if (!rvalue.includes(wv.contain)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.startWith !== undefined) {\r\n if (typeof rvalue === \"string\" && typeof wv.startWith === \"string\") {\r\n if (!rvalue.startsWith(wv.startWith)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.endWith !== undefined) {\r\n if (typeof rvalue === \"string\" && typeof wv.endWith === \"string\") {\r\n if (!rvalue.endsWith(wv.endWith)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.equalWith !== undefined) {\r\n if (rvalue !== wv.equalWith) {\r\n match = false\r\n }\r\n }\r\n if (wv.notEqualWith !== undefined) {\r\n if (rvalue === wv.notEqualWith) {\r\n match = false\r\n }\r\n }\r\n if (wv.gt !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue > wv.gt)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.lt !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue < wv.lt)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.gte !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue >= wv.gte)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.lte !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue <= wv.lte)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (match) {\r\n rows.push(row)\r\n }\r\n }\r\n } else {\r\n // RowvType\r\n for (let row of this._rows) {\r\n if ((row as any)[key] === wv) {\r\n rows.push(row)\r\n }\r\n }\r\n }\r\n }\r\n return rows\r\n }\r\n\r\n findOne(where: WhereType<RS>, observe = true): MakeRowType<RS> | null {\r\n const rows = this.find(where, observe)\r\n return rows.length > 0 ? rows[0] : null\r\n }\r\n\r\n findById(rid: string, observe = true): MakeRowType<RS> | null {\r\n return this.findOne({ rid }, observe)\r\n }\r\n\r\n getIndex(where: WhereType<RS>, observe = true): number {\r\n observe && this.observe()\r\n const row = this.findOne(where, false)\r\n if (row) {\r\n return this._rows.findIndex(r => r.rid === row.rid)\r\n }\r\n return -1\r\n }\r\n\r\n move(fromIndex: number, toIndex: number, observe = true): boolean {\r\n if (fromIndex < 0 || fromIndex >= this._rows.length) return false\r\n if (toIndex < 0 || toIndex >= this._rows.length) return false\r\n const [movedRow] = this._rows.splice(fromIndex, 1)\r\n this._rows.splice(toIndex, 0, movedRow)\r\n observe && this.dispatch()\r\n return true\r\n }\r\n\r\n // Meta Methods\r\n setMeta<T extends keyof Infer<MS>>(key: T, value: Infer<MS>[T], observe = true) {\r\n this._meta.set(key, this._meta_schema ? (this._meta_schema[key] as any).parse(value) : value)\r\n observe && this.dispatch()\r\n }\r\n\r\n getMeta<T extends keyof Infer<MS>>(key: T, observe = true): Infer<MS>[T] | undefined {\r\n observe && this.observe()\r\n return this._meta.get(key) as Infer<MS>[T] | undefined\r\n }\r\n\r\n deleteMeta<T extends keyof Infer<MS>>(key: T, observe = true) {\r\n this._meta.delete(key)\r\n observe && this.dispatch()\r\n }\r\n\r\n clearMeta(observe = true) {\r\n this._meta.clear()\r\n observe && this.dispatch()\r\n }\r\n}\r\n\r\nexport default Store"],"names":[],"mappings":";;;;AAKA;AACA;AACA;AAGA;;;AAEW;AACA;;;;;AAiBF;;AAEA;AACA;AACG;;AAEL;;AACJ;;AAGG;AACA;;;AAGS;AACF;AAAC;AACC;AACF;AACJ;;AAEN;;AAzBG;;;AA4BA;;;;AAKA;;;AAOH;AACG;;AAEG;AACG;AACF;AACD;AACA;AACF;;;AAID;AACG;;;AAEA;AACF;;;AASD;AACA;AACA;;;AAKH;;;AAIG;AACG;;;AAEA;AACF;;AAGD;AACG;AACG;AACA;;AAQA;;AAEF;AACD;AACF;AACD;;;AAIH;;;AAIG;AACG;AACA;AACA;AACF;AACD;;;AAIH;AACG;;;AAIC;;AAGD;AACG;;;AAGG;;AAEG;AACA;;;;AAIO;AACH;AAAM;;AAEN;AACH;AACD;;;;AAIO;AACH;AAAM;;AAEN;AACH;AACD;;;;AAIO;AACH;AAAM;;AAEN;AACH;AACD;AACG;;AAEC;AACH;AACD;AACG;;AAEC;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;AACF;AACH;AACH;AAAM;;AAEJ;AACG;AACG;AACF;AACH;AACH;AACH;AACD;;AAGH;;AAEG;;AAGH;;;AAIA;AACG;;AAEA;AACG;AACF;;;AAIJ;;AACwD;;AACJ;AACjD;;AAEA;AACA;;;AAIH;AACG;AACA;;AAGH;AACG;;;AAIH;AACG;AACA;;;AAIA;AACA;;AAEL;;"}
1
+ {"version":3,"file":"Store.cjs","sources":["../src/Store.ts"],"sourcesContent":["\"use client\"\r\nimport { useEffect, useId, useState } from \"react\"\r\nimport { MakeMetaType, MakeRowType, MetaSchema, RowSchema, WhereType } from \"./types\"\r\nimport { Infer, xv } from \"xanv\"\r\n\r\nconst uid = useId as any\r\nconst ustate = useState as any\r\nconst ueffect = useEffect as any\r\n\r\n\r\nclass Store<RS extends RowSchema, MS extends MetaSchema | undefined = undefined> {\r\n private _rows: MakeRowType<RS>[] = []\r\n private _meta: Map<keyof MakeMetaType<MS>, MakeMetaType<MS>[keyof MakeMetaType<MS>]> = new Map()\r\n private _hooks: Map<string, Function> = new Map()\r\n private _timer: any = null\r\n private _row_schema: RS\r\n private _meta_schema?: MS\r\n private _last_id = 0\r\n\r\n constructor(rowSchema: RS, metaSchema?: MS) {\r\n this._row_schema = {\r\n ...rowSchema,\r\n rid: xv.number(),\r\n vid: xv.number().default(() => Math.round((Math.random() + Math.random()) * 9999999999)),\r\n }\r\n this._meta_schema = metaSchema\r\n }\r\n\r\n private observe = () => {\r\n try {\r\n const hid = uid()\r\n const [, dispatch] = ustate(0)\r\n this._hooks.set(hid, () => dispatch(Math.random()))\r\n ueffect(() => () => {\r\n this._hooks.delete(hid)\r\n }, [])\r\n } catch (error) { }\r\n }\r\n\r\n private dispatch = () => {\r\n clearTimeout(this._timer)\r\n this._timer = setTimeout(() => {\r\n this._hooks.forEach((cb, key) => {\r\n try {\r\n cb()\r\n } catch (_err) {\r\n this._hooks.delete(key)\r\n }\r\n })\r\n }, 0)\r\n }\r\n\r\n rows(observe = true) {\r\n observe && this.observe()\r\n return this._rows\r\n }\r\n\r\n metas(observe = true) {\r\n observe && this.observe()\r\n return this._meta\r\n }\r\n\r\n // Row Methods\r\n create(row: Partial<MakeRowType<RS>>, observe?: boolean): MakeRowType<RS>\r\n create(row: Partial<MakeRowType<RS>>[], observe?: boolean): MakeRowType<RS>[]\r\n create(row: Partial<MakeRowType<RS>> | Partial<MakeRowType<RS>>[], observe = true): MakeRowType<RS> | MakeRowType<RS>[] {\r\n if (Array.isArray(row)) {\r\n const rows: MakeRowType<RS>[] = []\r\n for (const r of row) {\r\n rows.push(this.create(r, false))\r\n }\r\n observe && this.dispatch()\r\n return rows\r\n }\r\n\r\n // validate and create row\r\n let r: any = {} as MakeRowType<RS>\r\n for (let key in this._row_schema) {\r\n if (key === \"rid\" || key === \"vid\") continue;\r\n const schema = this._row_schema[key]\r\n r[key] = schema.parse(row[key])\r\n }\r\n\r\n this._last_id = this._last_id + 1;\r\n const _row: MakeRowType<RS> = {\r\n ...r,\r\n rid: this._last_id,\r\n vid: this._row_schema.vid.parse(undefined),\r\n }\r\n\r\n this._rows.push(_row)\r\n observe && this.dispatch()\r\n return _row\r\n }\r\n\r\n\r\n // update\r\n update(row: Partial<MakeRowType<RS>>, where?: WhereType<RS> | null, observe = true): MakeRowType<RS>[] | null {\r\n\r\n // validate row\r\n let r: any = {} as MakeRowType<RS>\r\n for (let key in row) {\r\n if (key === \"rid\" || key === 'vid') continue;\r\n const schema = this._row_schema[key]\r\n r[key] = schema.parse(row[key])\r\n }\r\n\r\n const rows = this.find(where)\r\n if (rows.length > 0) {\r\n for (let index = 0; index < rows.length; index++) {\r\n const _row = rows[index];\r\n const rid = _row.rid\r\n\r\n rows[index] = {\r\n ..._row,\r\n ...r,\r\n rid,\r\n vid: this._row_schema.vid.parse(undefined),\r\n }\r\n const rowIndex = this._rows.findIndex(r => r.rid === rid)\r\n this._rows[rowIndex] = rows[index]\r\n }\r\n observe && this.dispatch()\r\n }\r\n return this.find(where)\r\n }\r\n\r\n // delete\r\n delete(where?: WhereType<RS> | null, observe = true): number {\r\n const rows = this.find(where, false)\r\n\r\n let deletedCount = 0\r\n if (rows.length > 0) {\r\n this._rows = this._rows.filter(r => !rows.find(dr => dr.rid === r.rid))\r\n deletedCount = rows.length\r\n observe && this.dispatch()\r\n }\r\n return deletedCount\r\n }\r\n\r\n // find\r\n find(where?: WhereType<RS> | null, observe = true): MakeRowType<RS>[] {\r\n observe && this.observe()\r\n\r\n if (!where) {\r\n return this._rows\r\n }\r\n\r\n const rows: MakeRowType<RS>[] = []\r\n for (let key in where) {\r\n const wv = (where as any)[key]\r\n if (typeof wv === \"object\" && wv !== null) {\r\n // QueryValueType\r\n for (let row of this._rows) {\r\n let match = true\r\n const rvalue = (row as any)[key]\r\n if (wv.contain !== undefined) {\r\n if (typeof rvalue === \"string\" && typeof wv.contain === \"string\") {\r\n if (!rvalue.includes(wv.contain)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.startWith !== undefined) {\r\n if (typeof rvalue === \"string\" && typeof wv.startWith === \"string\") {\r\n if (!rvalue.startsWith(wv.startWith)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.endWith !== undefined) {\r\n if (typeof rvalue === \"string\" && typeof wv.endWith === \"string\") {\r\n if (!rvalue.endsWith(wv.endWith)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.equalWith !== undefined) {\r\n if (rvalue !== wv.equalWith) {\r\n match = false\r\n }\r\n }\r\n if (wv.notEqualWith !== undefined) {\r\n if (rvalue === wv.notEqualWith) {\r\n match = false\r\n }\r\n }\r\n if (wv.gt !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue > wv.gt)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.lt !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue < wv.lt)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.gte !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue >= wv.gte)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.lte !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue <= wv.lte)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (match) {\r\n rows.push(row)\r\n }\r\n }\r\n } else {\r\n // RowvType\r\n for (let row of this._rows) {\r\n if ((row as any)[key] === wv) {\r\n rows.push(row)\r\n }\r\n }\r\n }\r\n }\r\n return rows\r\n }\r\n\r\n findOne(where: WhereType<RS>, observe = true): MakeRowType<RS> | null {\r\n const rows = this.find(where, observe)\r\n return rows.length > 0 ? rows[0] : null\r\n }\r\n\r\n findById(rid: string, observe = true): MakeRowType<RS> | null {\r\n return this.findOne({ rid }, observe)\r\n }\r\n\r\n getIndex(where: WhereType<RS>, observe = true): number {\r\n observe && this.observe()\r\n const row = this.findOne(where, false)\r\n if (row) {\r\n return this._rows.findIndex(r => r.rid === row.rid)\r\n }\r\n return -1\r\n }\r\n\r\n move(fromIndex: number, toIndex: number, observe = true): boolean {\r\n if (fromIndex < 0 || toIndex < 0) return false\r\n const [movedRow] = this._rows.splice(fromIndex, 1)\r\n this._rows.splice(toIndex, 0, movedRow)\r\n observe && this.dispatch()\r\n return true\r\n }\r\n\r\n // Meta Methods\r\n setMeta<T extends keyof Infer<MS>>(key: T, value: Infer<MS>[T], observe = true) {\r\n this._meta.set(key, this._meta_schema ? (this._meta_schema[key] as any).parse(value) : value)\r\n observe && this.dispatch()\r\n }\r\n\r\n getMeta<T extends keyof Infer<MS>>(key: T, observe = true): Infer<MS>[T] | undefined {\r\n observe && this.observe()\r\n return this._meta.get(key) as Infer<MS>[T] | undefined\r\n }\r\n\r\n deleteMeta<T extends keyof Infer<MS>>(key: T, observe = true) {\r\n this._meta.delete(key)\r\n observe && this.dispatch()\r\n }\r\n\r\n clearMeta(observe = true) {\r\n this._meta.clear()\r\n observe && this.dispatch()\r\n }\r\n}\r\n\r\nexport default Store"],"names":[],"mappings":";;;;;;AAKA;AACA;AACA;AAGA;;;AAEW;AACA;;;;;AAiBF;;AAEA;AACA;AACG;;AAEL;;AACJ;;AAGG;AACA;;;AAGS;AACF;AAAC;AACC;AACF;AACJ;;AAEN;;AAzBG;;;AA4BA;;;;AAKA;;;AAOH;AACG;;AAEG;AACG;AACF;AACD;AACA;AACF;;;AAID;AACG;;;AAEA;AACF;;;AASD;AACA;AACA;;;AAKH;;;AAIG;AACG;;;AAEA;AACF;;AAGD;AACG;AACG;AACA;;AAQA;;AAEF;AACD;AACF;AACD;;;AAIH;;;AAIG;AACG;AACA;AACA;AACF;AACD;;;AAIH;AACG;;;AAIC;;AAGD;AACG;;;AAGG;;AAEG;AACA;;;;AAIO;AACH;AAAM;;AAEN;AACH;AACD;;;;AAIO;AACH;AAAM;;AAEN;AACH;AACD;;;;AAIO;AACH;AAAM;;AAEN;AACH;AACD;AACG;;AAEC;AACH;AACD;AACG;;AAEC;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;AACF;AACH;AACH;AAAM;;AAEJ;AACG;AACG;AACF;AACH;AACH;AACH;AACD;;AAGH;;AAEG;;AAGH;;;AAIA;AACG;;AAEA;AACG;AACF;;;AAIJ;AACG;AAAkC;AAClC;;AAEA;AACA;;;AAIH;AACG;AACA;;AAGH;AACG;;;AAIH;AACG;AACA;;;AAIA;AACA;;AAEL;;"}
package/Store.js CHANGED
@@ -1,12 +1,10 @@
1
1
  "use client";
2
- 'use strict';
2
+ import { useId, useState, useEffect } from 'react';
3
+ import { xv } from 'xanv';
3
4
 
4
- var react = require('react');
5
- var xanv = require('xanv');
6
-
7
- const uid = react.useId;
8
- const ustate = react.useState;
9
- const ueffect = react.useEffect;
5
+ const uid = useId;
6
+ const ustate = useState;
7
+ const ueffect = useEffect;
10
8
  class Store {
11
9
  constructor(rowSchema, metaSchema) {
12
10
  this._rows = [];
@@ -38,7 +36,7 @@ class Store {
38
36
  });
39
37
  }, 0);
40
38
  };
41
- this._row_schema = Object.assign(Object.assign({}, rowSchema), { rid: xanv.xv.number(), vid: xanv.xv.number().default(() => Math.round((Math.random() + Math.random()) * 9999999999)) });
39
+ this._row_schema = Object.assign(Object.assign({}, rowSchema), { rid: xv.number(), vid: xv.number().default(() => Math.round((Math.random() + Math.random()) * 9999999999)) });
42
40
  this._meta_schema = metaSchema;
43
41
  }
44
42
  rows(observe = true) {
@@ -232,9 +230,7 @@ class Store {
232
230
  return -1;
233
231
  }
234
232
  move(fromIndex, toIndex, observe = true) {
235
- if (fromIndex < 0 || fromIndex >= this._rows.length)
236
- return false;
237
- if (toIndex < 0 || toIndex >= this._rows.length)
233
+ if (fromIndex < 0 || toIndex < 0)
238
234
  return false;
239
235
  const [movedRow] = this._rows.splice(fromIndex, 1);
240
236
  this._rows.splice(toIndex, 0, movedRow);
@@ -260,5 +256,5 @@ class Store {
260
256
  }
261
257
  }
262
258
 
263
- module.exports = Store;
259
+ export { Store as default };
264
260
  //# sourceMappingURL=Store.js.map
package/Store.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Store.js","sources":["../src/Store.ts"],"sourcesContent":["\"use client\"\r\nimport { useEffect, useId, useState } from \"react\"\r\nimport { MakeMetaType, MakeRowType, MetaSchema, RowSchema, WhereType } from \"./types\"\r\nimport { Infer, xv } from \"xanv\"\r\n\r\nconst uid = useId as any\r\nconst ustate = useState as any\r\nconst ueffect = useEffect as any\r\n\r\n\r\nclass Store<RS extends RowSchema, MS extends MetaSchema | undefined = undefined> {\r\n private _rows: MakeRowType<RS>[] = []\r\n private _meta: Map<keyof MakeMetaType<MS>, MakeMetaType<MS>[keyof MakeMetaType<MS>]> = new Map()\r\n private _hooks: Map<string, Function> = new Map()\r\n private _timer: any = null\r\n private _row_schema: RS\r\n private _meta_schema?: MS\r\n private _last_id = 0\r\n\r\n constructor(rowSchema: RS, metaSchema?: MS) {\r\n this._row_schema = {\r\n ...rowSchema,\r\n rid: xv.number(),\r\n vid: xv.number().default(() => Math.round((Math.random() + Math.random()) * 9999999999)),\r\n }\r\n this._meta_schema = metaSchema\r\n }\r\n\r\n private observe = () => {\r\n try {\r\n const hid = uid()\r\n const [, dispatch] = ustate(0)\r\n this._hooks.set(hid, () => dispatch(Math.random()))\r\n ueffect(() => () => {\r\n this._hooks.delete(hid)\r\n }, [])\r\n } catch (error) { }\r\n }\r\n\r\n private dispatch = () => {\r\n clearTimeout(this._timer)\r\n this._timer = setTimeout(() => {\r\n this._hooks.forEach((cb, key) => {\r\n try {\r\n cb()\r\n } catch (_err) {\r\n this._hooks.delete(key)\r\n }\r\n })\r\n }, 0)\r\n }\r\n\r\n rows(observe = true) {\r\n observe && this.observe()\r\n return this._rows\r\n }\r\n\r\n metas(observe = true) {\r\n observe && this.observe()\r\n return this._meta\r\n }\r\n\r\n // Row Methods\r\n create(row: Partial<MakeRowType<RS>>, observe?: boolean): MakeRowType<RS>\r\n create(row: Partial<MakeRowType<RS>>[], observe?: boolean): MakeRowType<RS>[]\r\n create(row: Partial<MakeRowType<RS>> | Partial<MakeRowType<RS>>[], observe = true): MakeRowType<RS> | MakeRowType<RS>[] {\r\n if (Array.isArray(row)) {\r\n const rows: MakeRowType<RS>[] = []\r\n for (const r of row) {\r\n rows.push(this.create(r, false))\r\n }\r\n observe && this.dispatch()\r\n return rows\r\n }\r\n\r\n // validate and create row\r\n let r: any = {} as MakeRowType<RS>\r\n for (let key in this._row_schema) {\r\n if (key === \"rid\" || key === \"vid\") continue;\r\n const schema = this._row_schema[key]\r\n r[key] = schema.parse(row[key])\r\n }\r\n\r\n this._last_id = this._last_id + 1;\r\n const _row: MakeRowType<RS> = {\r\n ...r,\r\n rid: this._last_id,\r\n vid: this._row_schema.vid.parse(undefined),\r\n }\r\n\r\n this._rows.push(_row)\r\n observe && this.dispatch()\r\n return _row\r\n }\r\n\r\n\r\n // update\r\n update(row: Partial<MakeRowType<RS>>, where?: WhereType<RS> | null, observe = true): MakeRowType<RS>[] | null {\r\n\r\n // validate row\r\n let r: any = {} as MakeRowType<RS>\r\n for (let key in row) {\r\n if (key === \"rid\" || key === 'vid') continue;\r\n const schema = this._row_schema[key]\r\n r[key] = schema.parse(row[key])\r\n }\r\n\r\n const rows = this.find(where)\r\n if (rows.length > 0) {\r\n for (let index = 0; index < rows.length; index++) {\r\n const _row = rows[index];\r\n const rid = _row.rid\r\n\r\n rows[index] = {\r\n ..._row,\r\n ...r,\r\n rid,\r\n vid: this._row_schema.vid.parse(undefined),\r\n }\r\n const rowIndex = this._rows.findIndex(r => r.rid === rid)\r\n this._rows[rowIndex] = rows[index]\r\n }\r\n observe && this.dispatch()\r\n }\r\n return this.find(where)\r\n }\r\n\r\n // delete\r\n delete(where?: WhereType<RS> | null, observe = true): number {\r\n const rows = this.find(where, false)\r\n\r\n let deletedCount = 0\r\n if (rows.length > 0) {\r\n this._rows = this._rows.filter(r => !rows.find(dr => dr.rid === r.rid))\r\n deletedCount = rows.length\r\n observe && this.dispatch()\r\n }\r\n return deletedCount\r\n }\r\n\r\n // find\r\n find(where?: WhereType<RS> | null, observe = true): MakeRowType<RS>[] {\r\n observe && this.observe()\r\n\r\n if (!where) {\r\n return this._rows\r\n }\r\n\r\n const rows: MakeRowType<RS>[] = []\r\n for (let key in where) {\r\n const wv = (where as any)[key]\r\n if (typeof wv === \"object\" && wv !== null) {\r\n // QueryValueType\r\n for (let row of this._rows) {\r\n let match = true\r\n const rvalue = (row as any)[key]\r\n if (wv.contain !== undefined) {\r\n if (typeof rvalue === \"string\" && typeof wv.contain === \"string\") {\r\n if (!rvalue.includes(wv.contain)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.startWith !== undefined) {\r\n if (typeof rvalue === \"string\" && typeof wv.startWith === \"string\") {\r\n if (!rvalue.startsWith(wv.startWith)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.endWith !== undefined) {\r\n if (typeof rvalue === \"string\" && typeof wv.endWith === \"string\") {\r\n if (!rvalue.endsWith(wv.endWith)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.equalWith !== undefined) {\r\n if (rvalue !== wv.equalWith) {\r\n match = false\r\n }\r\n }\r\n if (wv.notEqualWith !== undefined) {\r\n if (rvalue === wv.notEqualWith) {\r\n match = false\r\n }\r\n }\r\n if (wv.gt !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue > wv.gt)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.lt !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue < wv.lt)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.gte !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue >= wv.gte)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.lte !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue <= wv.lte)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (match) {\r\n rows.push(row)\r\n }\r\n }\r\n } else {\r\n // RowvType\r\n for (let row of this._rows) {\r\n if ((row as any)[key] === wv) {\r\n rows.push(row)\r\n }\r\n }\r\n }\r\n }\r\n return rows\r\n }\r\n\r\n findOne(where: WhereType<RS>, observe = true): MakeRowType<RS> | null {\r\n const rows = this.find(where, observe)\r\n return rows.length > 0 ? rows[0] : null\r\n }\r\n\r\n findById(rid: string, observe = true): MakeRowType<RS> | null {\r\n return this.findOne({ rid }, observe)\r\n }\r\n\r\n getIndex(where: WhereType<RS>, observe = true): number {\r\n observe && this.observe()\r\n const row = this.findOne(where, false)\r\n if (row) {\r\n return this._rows.findIndex(r => r.rid === row.rid)\r\n }\r\n return -1\r\n }\r\n\r\n move(fromIndex: number, toIndex: number, observe = true): boolean {\r\n if (fromIndex < 0 || fromIndex >= this._rows.length) return false\r\n if (toIndex < 0 || toIndex >= this._rows.length) return false\r\n const [movedRow] = this._rows.splice(fromIndex, 1)\r\n this._rows.splice(toIndex, 0, movedRow)\r\n observe && this.dispatch()\r\n return true\r\n }\r\n\r\n // Meta Methods\r\n setMeta<T extends keyof Infer<MS>>(key: T, value: Infer<MS>[T], observe = true) {\r\n this._meta.set(key, this._meta_schema ? (this._meta_schema[key] as any).parse(value) : value)\r\n observe && this.dispatch()\r\n }\r\n\r\n getMeta<T extends keyof Infer<MS>>(key: T, observe = true): Infer<MS>[T] | undefined {\r\n observe && this.observe()\r\n return this._meta.get(key) as Infer<MS>[T] | undefined\r\n }\r\n\r\n deleteMeta<T extends keyof Infer<MS>>(key: T, observe = true) {\r\n this._meta.delete(key)\r\n observe && this.dispatch()\r\n }\r\n\r\n clearMeta(observe = true) {\r\n this._meta.clear()\r\n observe && this.dispatch()\r\n }\r\n}\r\n\r\nexport default Store"],"names":[],"mappings":";;;;;;AAKA;AACA;AACA;AAGA;;;AAEW;AACA;;;;;AAiBF;;AAEA;AACA;AACG;;AAEL;;AACJ;;AAGG;AACA;;;AAGS;AACF;AAAC;AACC;AACF;AACJ;;AAEN;;AAzBG;;;AA4BA;;;;AAKA;;;AAOH;AACG;;AAEG;AACG;AACF;AACD;AACA;AACF;;;AAID;AACG;;;AAEA;AACF;;;AASD;AACA;AACA;;;AAKH;;;AAIG;AACG;;;AAEA;AACF;;AAGD;AACG;AACG;AACA;;AAQA;;AAEF;AACD;AACF;AACD;;;AAIH;;;AAIG;AACG;AACA;AACA;AACF;AACD;;;AAIH;AACG;;;AAIC;;AAGD;AACG;;;AAGG;;AAEG;AACA;;;;AAIO;AACH;AAAM;;AAEN;AACH;AACD;;;;AAIO;AACH;AAAM;;AAEN;AACH;AACD;;;;AAIO;AACH;AAAM;;AAEN;AACH;AACD;AACG;;AAEC;AACH;AACD;AACG;;AAEC;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;AACF;AACH;AACH;AAAM;;AAEJ;AACG;AACG;AACF;AACH;AACH;AACH;AACD;;AAGH;;AAEG;;AAGH;;;AAIA;AACG;;AAEA;AACG;AACF;;;AAIJ;;AACwD;;AACJ;AACjD;;AAEA;AACA;;;AAIH;AACG;AACA;;AAGH;AACG;;;AAIH;AACG;AACA;;;AAIA;AACA;;AAEL;;"}
1
+ {"version":3,"file":"Store.js","sources":["../src/Store.ts"],"sourcesContent":["\"use client\"\r\nimport { useEffect, useId, useState } from \"react\"\r\nimport { MakeMetaType, MakeRowType, MetaSchema, RowSchema, WhereType } from \"./types\"\r\nimport { Infer, xv } from \"xanv\"\r\n\r\nconst uid = useId as any\r\nconst ustate = useState as any\r\nconst ueffect = useEffect as any\r\n\r\n\r\nclass Store<RS extends RowSchema, MS extends MetaSchema | undefined = undefined> {\r\n private _rows: MakeRowType<RS>[] = []\r\n private _meta: Map<keyof MakeMetaType<MS>, MakeMetaType<MS>[keyof MakeMetaType<MS>]> = new Map()\r\n private _hooks: Map<string, Function> = new Map()\r\n private _timer: any = null\r\n private _row_schema: RS\r\n private _meta_schema?: MS\r\n private _last_id = 0\r\n\r\n constructor(rowSchema: RS, metaSchema?: MS) {\r\n this._row_schema = {\r\n ...rowSchema,\r\n rid: xv.number(),\r\n vid: xv.number().default(() => Math.round((Math.random() + Math.random()) * 9999999999)),\r\n }\r\n this._meta_schema = metaSchema\r\n }\r\n\r\n private observe = () => {\r\n try {\r\n const hid = uid()\r\n const [, dispatch] = ustate(0)\r\n this._hooks.set(hid, () => dispatch(Math.random()))\r\n ueffect(() => () => {\r\n this._hooks.delete(hid)\r\n }, [])\r\n } catch (error) { }\r\n }\r\n\r\n private dispatch = () => {\r\n clearTimeout(this._timer)\r\n this._timer = setTimeout(() => {\r\n this._hooks.forEach((cb, key) => {\r\n try {\r\n cb()\r\n } catch (_err) {\r\n this._hooks.delete(key)\r\n }\r\n })\r\n }, 0)\r\n }\r\n\r\n rows(observe = true) {\r\n observe && this.observe()\r\n return this._rows\r\n }\r\n\r\n metas(observe = true) {\r\n observe && this.observe()\r\n return this._meta\r\n }\r\n\r\n // Row Methods\r\n create(row: Partial<MakeRowType<RS>>, observe?: boolean): MakeRowType<RS>\r\n create(row: Partial<MakeRowType<RS>>[], observe?: boolean): MakeRowType<RS>[]\r\n create(row: Partial<MakeRowType<RS>> | Partial<MakeRowType<RS>>[], observe = true): MakeRowType<RS> | MakeRowType<RS>[] {\r\n if (Array.isArray(row)) {\r\n const rows: MakeRowType<RS>[] = []\r\n for (const r of row) {\r\n rows.push(this.create(r, false))\r\n }\r\n observe && this.dispatch()\r\n return rows\r\n }\r\n\r\n // validate and create row\r\n let r: any = {} as MakeRowType<RS>\r\n for (let key in this._row_schema) {\r\n if (key === \"rid\" || key === \"vid\") continue;\r\n const schema = this._row_schema[key]\r\n r[key] = schema.parse(row[key])\r\n }\r\n\r\n this._last_id = this._last_id + 1;\r\n const _row: MakeRowType<RS> = {\r\n ...r,\r\n rid: this._last_id,\r\n vid: this._row_schema.vid.parse(undefined),\r\n }\r\n\r\n this._rows.push(_row)\r\n observe && this.dispatch()\r\n return _row\r\n }\r\n\r\n\r\n // update\r\n update(row: Partial<MakeRowType<RS>>, where?: WhereType<RS> | null, observe = true): MakeRowType<RS>[] | null {\r\n\r\n // validate row\r\n let r: any = {} as MakeRowType<RS>\r\n for (let key in row) {\r\n if (key === \"rid\" || key === 'vid') continue;\r\n const schema = this._row_schema[key]\r\n r[key] = schema.parse(row[key])\r\n }\r\n\r\n const rows = this.find(where)\r\n if (rows.length > 0) {\r\n for (let index = 0; index < rows.length; index++) {\r\n const _row = rows[index];\r\n const rid = _row.rid\r\n\r\n rows[index] = {\r\n ..._row,\r\n ...r,\r\n rid,\r\n vid: this._row_schema.vid.parse(undefined),\r\n }\r\n const rowIndex = this._rows.findIndex(r => r.rid === rid)\r\n this._rows[rowIndex] = rows[index]\r\n }\r\n observe && this.dispatch()\r\n }\r\n return this.find(where)\r\n }\r\n\r\n // delete\r\n delete(where?: WhereType<RS> | null, observe = true): number {\r\n const rows = this.find(where, false)\r\n\r\n let deletedCount = 0\r\n if (rows.length > 0) {\r\n this._rows = this._rows.filter(r => !rows.find(dr => dr.rid === r.rid))\r\n deletedCount = rows.length\r\n observe && this.dispatch()\r\n }\r\n return deletedCount\r\n }\r\n\r\n // find\r\n find(where?: WhereType<RS> | null, observe = true): MakeRowType<RS>[] {\r\n observe && this.observe()\r\n\r\n if (!where) {\r\n return this._rows\r\n }\r\n\r\n const rows: MakeRowType<RS>[] = []\r\n for (let key in where) {\r\n const wv = (where as any)[key]\r\n if (typeof wv === \"object\" && wv !== null) {\r\n // QueryValueType\r\n for (let row of this._rows) {\r\n let match = true\r\n const rvalue = (row as any)[key]\r\n if (wv.contain !== undefined) {\r\n if (typeof rvalue === \"string\" && typeof wv.contain === \"string\") {\r\n if (!rvalue.includes(wv.contain)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.startWith !== undefined) {\r\n if (typeof rvalue === \"string\" && typeof wv.startWith === \"string\") {\r\n if (!rvalue.startsWith(wv.startWith)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.endWith !== undefined) {\r\n if (typeof rvalue === \"string\" && typeof wv.endWith === \"string\") {\r\n if (!rvalue.endsWith(wv.endWith)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.equalWith !== undefined) {\r\n if (rvalue !== wv.equalWith) {\r\n match = false\r\n }\r\n }\r\n if (wv.notEqualWith !== undefined) {\r\n if (rvalue === wv.notEqualWith) {\r\n match = false\r\n }\r\n }\r\n if (wv.gt !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue > wv.gt)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.lt !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue < wv.lt)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.gte !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue >= wv.gte)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (wv.lte !== undefined) {\r\n if (typeof rvalue === \"number\") {\r\n if (!(rvalue <= wv.lte)) {\r\n match = false\r\n }\r\n } else {\r\n match = false\r\n }\r\n }\r\n if (match) {\r\n rows.push(row)\r\n }\r\n }\r\n } else {\r\n // RowvType\r\n for (let row of this._rows) {\r\n if ((row as any)[key] === wv) {\r\n rows.push(row)\r\n }\r\n }\r\n }\r\n }\r\n return rows\r\n }\r\n\r\n findOne(where: WhereType<RS>, observe = true): MakeRowType<RS> | null {\r\n const rows = this.find(where, observe)\r\n return rows.length > 0 ? rows[0] : null\r\n }\r\n\r\n findById(rid: string, observe = true): MakeRowType<RS> | null {\r\n return this.findOne({ rid }, observe)\r\n }\r\n\r\n getIndex(where: WhereType<RS>, observe = true): number {\r\n observe && this.observe()\r\n const row = this.findOne(where, false)\r\n if (row) {\r\n return this._rows.findIndex(r => r.rid === row.rid)\r\n }\r\n return -1\r\n }\r\n\r\n move(fromIndex: number, toIndex: number, observe = true): boolean {\r\n if (fromIndex < 0 || toIndex < 0) return false\r\n const [movedRow] = this._rows.splice(fromIndex, 1)\r\n this._rows.splice(toIndex, 0, movedRow)\r\n observe && this.dispatch()\r\n return true\r\n }\r\n\r\n // Meta Methods\r\n setMeta<T extends keyof Infer<MS>>(key: T, value: Infer<MS>[T], observe = true) {\r\n this._meta.set(key, this._meta_schema ? (this._meta_schema[key] as any).parse(value) : value)\r\n observe && this.dispatch()\r\n }\r\n\r\n getMeta<T extends keyof Infer<MS>>(key: T, observe = true): Infer<MS>[T] | undefined {\r\n observe && this.observe()\r\n return this._meta.get(key) as Infer<MS>[T] | undefined\r\n }\r\n\r\n deleteMeta<T extends keyof Infer<MS>>(key: T, observe = true) {\r\n this._meta.delete(key)\r\n observe && this.dispatch()\r\n }\r\n\r\n clearMeta(observe = true) {\r\n this._meta.clear()\r\n observe && this.dispatch()\r\n }\r\n}\r\n\r\nexport default Store"],"names":[],"mappings":";;;;AAKA;AACA;AACA;AAGA;;;AAEW;AACA;;;;;AAiBF;;AAEA;AACA;AACG;;AAEL;;AACJ;;AAGG;AACA;;;AAGS;AACF;AAAC;AACC;AACF;AACJ;;AAEN;;AAzBG;;;AA4BA;;;;AAKA;;;AAOH;AACG;;AAEG;AACG;AACF;AACD;AACA;AACF;;;AAID;AACG;;;AAEA;AACF;;;AASD;AACA;AACA;;;AAKH;;;AAIG;AACG;;;AAEA;AACF;;AAGD;AACG;AACG;AACA;;AAQA;;AAEF;AACD;AACF;AACD;;;AAIH;;;AAIG;AACG;AACA;AACA;AACF;AACD;;;AAIH;AACG;;;AAIC;;AAGD;AACG;;;AAGG;;AAEG;AACA;;;;AAIO;AACH;AAAM;;AAEN;AACH;AACD;;;;AAIO;AACH;AAAM;;AAEN;AACH;AACD;;;;AAIO;AACH;AAAM;;AAEN;AACH;AACD;AACG;;AAEC;AACH;AACD;AACG;;AAEC;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;;;AAGI;AACH;AAAM;;AAEN;AACH;AACD;AACG;AACF;AACH;AACH;AAAM;;AAEJ;AACG;AACG;AACF;AACH;AACH;AACH;AACD;;AAGH;;AAEG;;AAGH;;;AAIA;AACG;;AAEA;AACG;AACF;;;AAIJ;AACG;AAAkC;AAClC;;AAEA;AACA;;;AAIH;AACG;AACA;;AAGH;AACG;;;AAIH;AACG;AACA;;;AAIA;AACA;;AAEL;;"}
package/index.cjs ADDED
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var Store = require('./Store.cjs');
7
+
8
+ const createStore = (rowSchema, metaSchema) => {
9
+ return new Store(rowSchema, metaSchema);
10
+ };
11
+
12
+ exports.Store = Store;
13
+ exports.default = createStore;
14
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["\"use client\"\r\nimport Store from \"./Store\"\r\nimport { MetaSchema, RowSchema } from \"./types\"\r\n\r\nconst createStore = <RS extends RowSchema, MS extends MetaSchema | undefined = undefined>(rowSchema: RS, metaSchema?: MS) => {\r\n return new Store(rowSchema, metaSchema)\r\n}\r\n\r\nexport * from \"./types\"\r\nexport { Store }\r\n\r\nexport default createStore"],"names":[],"mappings":";;;AAIA;AACI;AACJ;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["\"use client\"\r\nimport Store from \"./Store\"\r\nimport { MetaSchema, RowSchema } from \"./types\"\r\n\r\nconst createStore = <RS extends RowSchema, MS extends MetaSchema | undefined = undefined>(rowSchema: RS, metaSchema?: MS) => {\r\n return new Store(rowSchema, metaSchema)\r\n}\r\n\r\nexport * from \"./types\"\r\nexport { Store }\r\n\r\nexport default createStore"],"names":[],"mappings":";;;;;;;AAIA;AACI;AACJ;;;"}
package/index.js CHANGED
@@ -1,14 +1,9 @@
1
1
  "use client";
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var Store = require('./Store.js');
2
+ import Store from './Store.js';
7
3
 
8
4
  const createStore = (rowSchema, metaSchema) => {
9
5
  return new Store(rowSchema, metaSchema);
10
6
  };
11
7
 
12
- exports.Store = Store;
13
- exports.default = createStore;
8
+ export { Store, createStore as default };
14
9
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["\"use client\"\r\nimport Store from \"./Store\"\r\nimport { MetaSchema, RowSchema } from \"./types\"\r\n\r\nconst createStore = <RS extends RowSchema, MS extends MetaSchema | undefined = undefined>(rowSchema: RS, metaSchema?: MS) => {\r\n return new Store(rowSchema, metaSchema)\r\n}\r\n\r\nexport * from \"./types\"\r\nexport { Store }\r\n\r\nexport default createStore"],"names":[],"mappings":";;;;;;;AAIA;AACI;AACJ;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["\"use client\"\r\nimport Store from \"./Store\"\r\nimport { MetaSchema, RowSchema } from \"./types\"\r\n\r\nconst createStore = <RS extends RowSchema, MS extends MetaSchema | undefined = undefined>(rowSchema: RS, metaSchema?: MS) => {\r\n return new Store(rowSchema, metaSchema)\r\n}\r\n\r\nexport * from \"./types\"\r\nexport { Store }\r\n\r\nexport default createStore"],"names":[],"mappings":";;;AAIA;AACI;AACJ;;"}
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "react-rock",
3
- "version": "3.2.6",
3
+ "version": "3.2.7",
4
4
  "author": "Naxrul Ahmed",
5
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
- "module": "./index.mjs",
6
+ "main": "./index.cjs",
7
+ "module": "./index.js",
8
8
  "types": "./index.d.ts",
9
+ "type": "module",
9
10
  "keywords": [
10
11
  "react",
11
12
  "state management",
@@ -17,13 +18,6 @@
17
18
  "url": "https://github.com/devnax/react-rock/issues"
18
19
  },
19
20
  "homepage": "https://github.com/devnax/react-rock#readme",
20
- "exports": {
21
- ".": {
22
- "import": "./index.mjs",
23
- "require": "./index.js",
24
- "types": "./index.d.ts"
25
- }
26
- },
27
21
  "dependencies": {
28
22
  "xanv": "^1.1.11"
29
23
  }
package/index.mjs DELETED
@@ -1,9 +0,0 @@
1
- "use client";
2
- import Store from './Store.mjs';
3
-
4
- const createStore = (rowSchema, metaSchema) => {
5
- return new Store(rowSchema, metaSchema);
6
- };
7
-
8
- export { Store, createStore as default };
9
- //# sourceMappingURL=index.mjs.map