memorio 0.2.3 → 0.2.4

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.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ declare var memorio: any
2
+
1
3
  /// <reference path="./types/memorio.d.ts" />
2
4
  /// <reference path="./types/observer.d.ts" />
3
5
  /// <reference path="./types/state.d.ts" />
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";(()=>{var u=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var f=(e,r)=>()=>(e&&(r=e(e=0)),r);var n=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var w=(e,r,l,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of P(r))!S.call(e,t)&&t!==l&&u(e,t,{get:()=>r[t],enumerable:!(s=O(r,t))||s.enumerable});return e};var E=e=>w(u({},"__esModule",{value:!0}),e);var g,b=f(()=>{g={name:"memorio",version:"0.2.3",description:"Memorio, State + Observer and Store for a easy life ",license:"MIT",deprecated:!1,preferGlobal:!0,target:"web",copyright:"Dario Passariello, BigLogic ca - a51.dev is a BigLogic project",homepage:"https://a51.gitbook.io/memorio",author:{name:"Dario Passariello",url:"https://dario.passariello.ca/",email:"dariopassariello@gmail.com"},support:{name:"Dario Passariello",url:"https://github.com/passariello/",email:"dariopassariello@gmail.com"},main:"index.js",contributors:[{name:"Dario Passariello",email:"dariopassarielloa@gmail.com"},{name:"Valeria Cala Scaglitta",email:"valeriacalascaglitta@gmail.com"}],globals:{memorio:{}},keywords:["biglogic","a51","memorio","state","store","observer","dario","passariello"],repository:{type:"git",url:"git+https://github.com/a51-dev/a51.memorio.git",help:"https://github.com/a51-dev/a51.memorio#readme"},bugs:{url:"https://github.com/a51-dev/a51.memorio/issues"},funding:[{type:"patreon",url:"https://www.patreon.com/passariello"}],typing:["types/*"],scripts:{build:"node ./esbuild.config.mjs",watch:"esbuild init.ts --bundle --outdir=dist --serve","-----------":"",tsc:"tsc -b .",eslint:"eslint .",updates:"npx npm-check-updates -u && npm i","----------":"","publish:npm":"npm run build && npm publish ./dist"},devDependencies:{"@eslint/js":"9.33.0","@types/jest":"^30.0.0","@types/node":"^24.3.0","@typescript-eslint/eslint-plugin":"8.39.1","@typescript-eslint/parser":"8.39.1",esbuild:"^0.25.9","esbuild-plugin-clean":"^1.0.1","esbuild-plugin-copy":"^2.1.1",eslint:"9.33.0","ts-loader":"^9.5.2","ts-node":"10.9.2",tslib:"^2.8.1",typescript:"5.9.2"}}});var I={};var m=f(()=>{"use strict";b();Object.defineProperty(global,"memorio",{value:{},writable:!1,configurable:!1,enumerable:!1});Object.defineProperty(global,"events",{value:{},writable:!0,configurable:!1,enumerable:!1});Object.defineProperty(memorio,"version",{writable:!1,configurable:!1,enumerable:!1,value:g.version})});var d=n(()=>{"use strict";Object.defineProperty(memorio,"dispatch",{writable:!1,configurable:!1,enumerable:!1,value:{set:(e,r={})=>{dispatchEvent(new CustomEvent(String(e),r))},listen:(e,r=null,l=!1)=>{observer.list?.[e]?.length>0&&observer.remove(e);let s=t=>r?setTimeout(()=>r(t),1):null;window.addEventListener(e,s),global.events[e]=s},remove:e=>{window.removeEventListener(e,global.events[e]),delete global.events[e]}}})});var y=n(()=>{"use strict";Object.defineProperty(memorio,"objPath",{writable:!1,configurable:!1,enumerable:!1,value:(e,r,l=".")=>r.concat(e).join(l)});var p=(e,r,l=[])=>{let s=t=>{let o=t.split(".");o.forEach((a,i)=>{let c=o.slice(0,i+1).join(".");global.memorio.dispatch.set(c,{detail:{name:c}})})};return new Proxy(e,{get(t,o){if(Object.isFrozen(t[o]))return t[o];try{let a=Reflect.get(t,o);return a&&typeof a=="object"&&["Array","Object"].includes(a.constructor.name)?p(a,r,l.concat(o)):a}catch(a){return console.error("Error: ",a),!1}},set(t,o,a){if(t[o]&&typeof t[o]=="object"&&Object.isFrozen(t[o])){console.error(`Error: state '${o}' is locked`);return}try{let i=global.memorio.objPath(o,l);return r({action:"set",path:i,target:t,newValue:a,previousValue:Reflect.get(t,o)}),s("state."+i),Reflect.set(t,o,a),t[o]&&typeof t[o]=="object"&&Reflect.defineProperty(t[o],"lock",{value(){Object.defineProperty(t,o,{writable:!1,enumerable:!1}),Object.freeze(t[o])}}),!0}catch(i){return console.error("Error in set trap:",i),!1}},deleteProperty(t,o){try{let a=global.memorio.objPath(o,l);return r({action:"delete",path:a,target:t}),Reflect.deleteProperty(t,o)}catch(a){return console.error("Error in deleteProperty trap:",a),!1}}})};global?.state?global.state=state:global.state=p({},()=>{});var v=new WeakSet;v.add(state);setInterval(()=>{if(!v.has(state)){alert("memorio State is compromised, check if you override it and please reload the page");for(let e=1;e<99999;e++)clearInterval(e);stop()}},1e3);Object.defineProperty(global,"state",{enumerable:!1,configurable:!1});Object.defineProperties(state,{list:{get(){let e=global.memorio.array.deepClone(state);return console.log(e)}},remove:{value(e){e in state?(delete state[e],console.debug(`State '${e}' deleted`)):console.error(`'${e}' not exist`)},writable:!1,configurable:!1},removeAll:{value(){state.forEach(e=>{delete state[e[0]]})},writable:!1,configurable:!1}})});var h=n(()=>{"use strict";global.observer||(global.observer=null);Object.defineProperty(global,"observer",{enumerable:!1});observer=(e,r=null,l=!0)=>{if((t=>t.split(".")[0]!=="state"?(console.error(`Observer Error: You need to declare 'state.' or 'store.'. The '${t}' string is incorrect!`),!1):!0)(e)){if(!e&&!r){console.error("Observer Error: You need to setup observer correctly, Some parameters are missed!");return}if(!e&&r){console.error("Observer Error: You need to declare what state need to be monitored as string like 'state.test'.");return}if(e&&!r){global.memorio.dispatch.listen(String(e),{detail:{name:String(e)}}),console.debug("called: ",e);return}if(e&&r){if(typeof e!="string"||typeof r!="function"){console.error("Observer Error: name of state need to be a 'string' like 'state.test' and the callback need to be a 'function'");return}global.memorio.dispatch.listen(e,r,l);return}}};Object.defineProperties(observer,{list:{get:()=>global.events},remove:{value:e=>{e&&(global.events[e]="")}},removeAll:{get:()=>{Object.entries(observer.list).forEach(e=>{global.events[e[0]]})}}});Object.freeze(observer)});var j=n(()=>{"use strict";Object.defineProperty(global,"store",{value:new Proxy({},{}),enumerable:!1,configurable:!1});Object.defineProperties(store,{get:{value(e){if(e)try{let r=localStorage.getItem(e);return r&&JSON.parse(r)}catch(r){console.error(`Error parsing store item '${e}':`,r)}}},set:{value(e,r){if(e)try{r==null?localStorage.setItem(e,JSON.stringify(null)):typeof r=="object"||typeof r=="number"||typeof r=="boolean"||typeof r=="string"?localStorage.setItem(e,JSON.stringify(r)):typeof r=="function"&&console.error("It's not secure to store functions.")}catch(l){console.error(`Error setting store item '${e}':`,l)}}},remove:{value(e){if(e&&localStorage.getItem(e))return localStorage.removeItem(e),!0}},delete:{value(e){store.remove(e)}},removeAll:{value(){return localStorage.clear(),!0}},clearAll:{value(){return store.removeAll(),!0}},quota:{value(){"storage"in navigator&&"estimate"in navigator.storage&&navigator.storage.estimate().then(({usage:e,quota:r})=>{e&&r&&console.debug(`Using ${e/1024} out of ${r/1024} Mb.`)}).catch(e=>{console.error("Error estimating quota:",e)})}},size:{value(){let e=0;for(let r in localStorage)if(localStorage.hasOwnProperty(r)){let l=localStorage.getItem(r);l&&(e+=l.length)}return e}}});Object.freeze(store)});m();d();y();h();j();})();
1
+ "use strict";(()=>{var f=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var n=(e,r)=>()=>(e&&(r=e(e=0)),r);var T=(e,r,s,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of P(r))!S.call(e,t)&&t!==s&&f(e,t,{get:()=>r[t],enumerable:!(l=O(r,t))||l.enumerable});return e};var c=e=>T(f({},"__esModule",{value:!0}),e);var g,b=n(()=>{g={name:"memorio",version:"0.2.4",type:"module",main:"index.js",types:"index.d.ts",typings:"./types/*",typeRoots:["../node_modules/@types"],description:"Memorio, State + Observer and Store for a easy life ",license:"MIT",deprecated:!1,preferGlobal:!0,target:"node",copyright:"Dario Passariello, BigLogic ca - a51.dev is a BigLogic project",homepage:"https://a51.gitbook.io/memorio",author:{name:"Dario Passariello",url:"https://dario.passariello.ca/",email:"dariopassariello@gmail.com"},support:{name:"Dario Passariello",url:"https://github.com/passariello/",email:"dariopassariello@gmail.com"},contributors:[{name:"Dario Passariello",email:"dariopassarielloa@gmail.com"},{name:"Valeria Cala Scaglitta",email:"valeriacalascaglitta@gmail.com"}],globals:{memorio:{}},keywords:["biglogic","a51","memorio","state","store","observer","dario","passariello"],repository:{type:"git",url:"git+https://github.com/a51-dev/a51.memorio.git",help:"https://github.com/a51-dev/a51.memorio#readme"},bugs:{url:"https://github.com/a51-dev/a51.memorio/issues"},funding:[{type:"patreon",url:"https://www.patreon.com/passariello"}],typing:["types/*"],scripts:{build:"node ./esbuild.config.mjs",watch:"esbuild init.ts --bundle --outdir=dist --serve","-----------":"",tsc:"tsc -b .",eslint:"eslint .",updates:"npx npm-check-updates -u && npm i","----------":"","publish:npm":"npm run build && npm publish ./dist"},devDependencies:{"@eslint/js":"9.33.0","@types/jest":"^30.0.0","@types/node":"^24.3.0",esbuild:"^0.25.9","esbuild-plugin-clean":"^1.0.1","esbuild-plugin-copy":"^2.1.1",eslint:"9.33.0","ts-loader":"^9.5.2","ts-node":"10.9.2",tslib:"^2.8.1",typescript:"5.9.2"}}});var E={};var m=n(()=>{"use strict";b();Object.defineProperty(globalThis,"memorio",{value:{},writable:!1,configurable:!1,enumerable:!1});Object.defineProperty(globalThis,"events",{value:{},writable:!0,configurable:!1,enumerable:!1});Object.defineProperty(memorio,"version",{writable:!1,configurable:!1,enumerable:!1,value:g.version})});var k={};var d=n(()=>{"use strict";Object.defineProperty(memorio,"dispatch",{writable:!1,configurable:!1,enumerable:!1,value:{set:(e,r={})=>{dispatchEvent(new CustomEvent(String(e),r))},listen:(e,r=null,s=!1)=>{observer.list?.[e]?.length>0&&observer.remove(e);let l=t=>r?setTimeout(()=>r(t),1):null;globalThis.addEventListener(e,l),globalThis.events[e]=l},remove:e=>{globalThis.removeEventListener(e,globalThis.events[e]),delete globalThis.events[e]}}})});var x={};var p,h,v=n(()=>{"use strict";Object.defineProperty(memorio,"objPath",{writable:!1,configurable:!1,enumerable:!1,value:(e,r,s=".")=>r.concat(e).join(s)});p=(e,r,s=[])=>{let l=t=>{let o=t.split(".");o.forEach((i,a)=>{let u=o.slice(0,a+1).join(".");globalThis.memorio.dispatch.set(u,{detail:{name:u}})})};return new Proxy(e,{get(t,o){if(Object.isFrozen(t[o]))return t[o];try{let i=Reflect.get(t,o);return i&&typeof i=="object"&&["Array","Object"].includes(i.constructor.name)?p(i,r,s.concat(o)):i}catch(i){return console.error("Error: ",i),!1}},set(t,o,i){if(t[o]&&typeof t[o]=="object"&&Object.isFrozen(t[o])){console.error(`Error: state '${o}' is locked`);return}try{let a=globalThis.memorio.objPath(o,s);return r({action:"set",path:a,target:t,newValue:i,previousValue:Reflect.get(t,o)}),l("state."+a),Reflect.set(t,o,i),t[o]&&typeof t[o]=="object"&&Reflect.defineProperty(t[o],"lock",{value(){Object.defineProperty(t,o,{writable:!1,enumerable:!1}),Object.freeze(t[o])}}),!0}catch(a){return console.error("Error in set trap:",a),!1}},deleteProperty(t,o){try{let i=globalThis.memorio.objPath(o,s);return r({action:"delete",path:i,target:t}),Reflect.deleteProperty(t,o)}catch(i){return console.error("Error in deleteProperty trap:",i),!1}}})};globalThis?.state?globalThis.state=state:globalThis.state=p({},()=>{});h=new WeakSet;h.add(state);setInterval(()=>{if(!h.has(state)){alert("memorio State is compromised, check if you override it and please reload the page");for(let e=1;e<99999;e++)clearInterval(e);stop()}},1e3);Object.defineProperty(globalThis,"state",{enumerable:!1,configurable:!1});Object.defineProperties(state,{list:{get(){let e=globalThis.memorio.array.deepClone(state);return console.log(e)}},remove:{value(e){e in state?(delete state[e],console.debug(`State '${e}' deleted`)):console.error(`'${e}' not exist`)},writable:!1,configurable:!1},removeAll:{value(){state.forEach(e=>{delete state[e[0]]})},writable:!1,configurable:!1}})});var I={};var y=n(()=>{"use strict";globalThis.observer||(globalThis.observer=null);Object.defineProperty(globalThis,"observer",{enumerable:!1});observer=(e,r=null,s=!0)=>{if((t=>t.split(".")[0]!=="state"?(console.error(`Observer Error: You need to declare 'state.' or 'store.'. The '${t}' string is incorrect!`),!1):!0)(e)){if(!e&&!r){console.error("Observer Error: You need to setup observer correctly, Some parameters are missed!");return}if(!e&&r){console.error("Observer Error: You need to declare what state need to be monitored as string like 'state.test'.");return}if(e&&!r){globalThis.memorio.dispatch.listen(String(e),{detail:{name:String(e)}}),console.debug("called: ",e);return}if(e&&r){if(typeof e!="string"||typeof r!="function"){console.error("Observer Error: name of state need to be a 'string' like 'state.test' and the callback need to be a 'function'");return}globalThis.memorio.dispatch.listen(e,r,s);return}}};Object.defineProperties(observer,{list:{get:()=>globalThis.events},remove:{value:e=>{e&&(globalThis.events[e]="")}},removeAll:{get:()=>{Object.entries(observer.list).forEach(e=>{globalThis.events[e[0]]})}}});Object.freeze(observer)});var $={};var j=n(()=>{"use strict";Object.defineProperty(globalThis,"store",{value:new Proxy({},{}),enumerable:!1,configurable:!1});Object.defineProperties(store,{get:{value(e){if(e)try{let r=localStorage.getItem(e);return r&&JSON.parse(r)}catch(r){console.error(`Error parsing store item '${e}':`,r)}}},set:{value(e,r){if(e)try{r==null?localStorage.setItem(e,JSON.stringify(null)):typeof r=="object"||typeof r=="number"||typeof r=="boolean"||typeof r=="string"?localStorage.setItem(e,JSON.stringify(r)):typeof r=="function"&&console.error("It's not secure to store functions.")}catch(s){console.error(`Error setting store item '${e}':`,s)}}},remove:{value(e){if(e&&localStorage.getItem(e))return localStorage.removeItem(e),!0}},delete:{value(e){store.remove(e)}},removeAll:{value(){return localStorage.clear(),!0}},clearAll:{value(){return store.removeAll(),!0}},quota:{value(){"storage"in navigator&&"estimate"in navigator.storage&&navigator.storage.estimate().then(({usage:e,quota:r})=>{e&&r&&console.debug(`Using ${e/1024} out of ${r/1024} Mb.`)}).catch(e=>{console.error("Error estimating quota:",e)})}},size:{value(){let e=0;for(let r in localStorage)if(localStorage.hasOwnProperty(r)){let s=localStorage.getItem(r);s&&(e+=s.length)}return e}}});Object.freeze(store)});m();d();v();y();j();})();
package/package.json CHANGED
@@ -1,11 +1,18 @@
1
1
  {
2
2
  "name": "memorio",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
+ "type": "module",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "typings": "./types/*",
8
+ "typeRoots": [
9
+ "../node_modules/@types"
10
+ ],
4
11
  "description": "Memorio, State + Observer and Store for a easy life ",
5
12
  "license": "MIT",
6
13
  "deprecated": false,
7
14
  "preferGlobal": true,
8
- "target": "web",
15
+ "target": "node",
9
16
  "copyright": "Dario Passariello, BigLogic ca - a51.dev is a BigLogic project",
10
17
  "homepage": "https://a51.gitbook.io/memorio",
11
18
  "author": {
@@ -18,7 +25,6 @@
18
25
  "url": "https://github.com/passariello/",
19
26
  "email": "dariopassariello@gmail.com"
20
27
  },
21
- "main": "index.js",
22
28
  "contributors": [
23
29
  {
24
30
  "name": "Dario Passariello",
@@ -73,8 +79,6 @@
73
79
  "@eslint/js": "9.33.0",
74
80
  "@types/jest": "^30.0.0",
75
81
  "@types/node": "^24.3.0",
76
- "@typescript-eslint/eslint-plugin": "8.39.1",
77
- "@typescript-eslint/parser": "8.39.1",
78
82
  "esbuild": "^0.25.9",
79
83
  "esbuild-plugin-clean": "^1.0.1",
80
84
  "esbuild-plugin-copy": "^2.1.1",
@@ -1,5 +1,4 @@
1
1
 
2
-
3
2
  declare module 'memorio' {
4
3
  const resource: { [key: string]: any }
5
4
  export = resource
@@ -19,10 +18,6 @@ declare var memorio: any
19
18
  type arguments = any
20
19
  declare var arguments: any
21
20
 
22
- /////////////////////////////////////////////
23
-
24
- interface Descr {
25
- name: string,
26
- active: boolean,
27
- subCommand: object,
28
- }
21
+ global.memorio = global.memorio
22
+ ? global.memorio
23
+ : globalThis.memorio