immu-js 0.1.0 → 0.1.1

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/dist/immu-js.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=new WeakMap;function h(n){let r=m.get(n);return r||(r={subscribers:[],version:0,dirtyProps:new Set},m.set(n,r)),r}let d=new Set,g=!1;function M(n,r){const t=h(n);t.version++,t.dirtyProps.add(r),d.add(n),g||(g=!0,queueMicrotask(k))}function k(){const n=d;d=new Set,g=!1;for(const r of n){const t=h(r),s=t.dirtyProps;t.dirtyProps=new Set;const f=s.has("*"),l=t.subscribers.filter(c=>f||c.prop===void 0||s.has(c.prop));for(const c of l)c.callback()}}const p=[];function b(){p.push(new Set)}function y(){return p.pop()??new Set}function v(n){p.length>0&&p[p.length-1].add(n)}function S(n){const r=new Set,t=[Object.prototype,Array.prototype,Function.prototype,String.prototype,Number.prototype,Boolean.prototype,Symbol.prototype,Date.prototype,RegExp.prototype,Map.prototype,Set.prototype,WeakMap.prototype,WeakSet.prototype,Promise.prototype,Error.prototype];let s=n;for(;s&&!t.includes(s);){for(const f of Reflect.ownKeys(s))f!=="constructor"&&r.add(f);s=Object.getPrototypeOf(s)}return Array.from(r)}function P(n){const r=new n,t=r,s=new Map,f=[],l=new Map,c=h(t),u=S(r);for(const e of u){if(typeof e=="symbol")continue;const o=e,i=r[o];typeof i!="function"&&(s.set(o,i),f.push(o))}for(const e of f)delete r[e],Object.defineProperty(t,e,{get(){return v(t),s.get(e)},set(o){s.set(e,o),M(t,e)},enumerable:!0,configurable:!0});return Object.defineProperty(t,"_version",{get(){return c.version},enumerable:!1,configurable:!1}),Object.defineProperty(t,"_subscribe",{value:(e,o)=>{const i={callback:e,prop:o};return c.subscribers.push(i),()=>{c.subscribers=c.subscribers.filter(a=>a!==i)}},enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(t,"_reset",{value:()=>{const e=new n,o=S(e);for(const i of o){if(typeof i=="symbol")continue;const a=i,w=e[a];typeof w!="function"&&(t[a]=w)}},enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(t,"_saveVersion",{value:(e="default")=>{const o=[];for(const[i,a]of s)o.push([i,structuredClone(a)]);l.set(e,o)},enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(t,"_loadVersion",{value:(e="default")=>{const o=l.get(e);if(!o)throw new Error(`No saved version found for label "${e}"`);for(const[i,a]of o)t[i]=structuredClone(a)},enumerable:!1,configurable:!1,writable:!1}),t}function _(n){let r,t=new Map,s,f=!1;function l(u){for(const[e,o]of u)if(e._version!==o)return!1;return!0}function c(u){for(const[e]of u)v(e)}return(...u)=>{const e=JSON.stringify(u);if(f&&e===r&&l(t))return c(t),s;b();const o=n(...u),i=y();t=new Map;for(const a of i)t.set(a,a._version);return r=e,s=o,f=!0,c(t),o}}function O(n){let r=new Map,t,s=!1;function f(c){for(const[u,e]of c)if(u._version!==e)return!1;return!0}function l(c){for(const[u]of c)v(u)}return{get value(){if(s&&f(r))return l(r),t;b();const c=n(),u=y();r=new Map;for(const e of u)r.set(e,e._version);return t=c,s=!0,l(r),c}}}function j(n,r){let t=!0,s=[],f=[],l;function c(){if(!t)return;if(r){const e=r();if(l&&A(l,e))return;l=e}for(const e of f)e();f=[],b(),n();const u=y();s=Array.from(u);for(const e of s){const o=e._subscribe(()=>{c()});f.push(o)}if(r){b(),r();const e=y();for(const o of Array.from(e))if(!s.includes(o)){const i=o._subscribe(()=>{c()});f.push(i)}}}return c(),()=>{t=!1;for(const u of f)u();f=[]}}function A(n,r){if(n.length!==r.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==r[t])return!1;return!0}exports._flush=k;exports.computed=O;exports.create=P;exports.memo=_;exports.run=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=new WeakMap;function v(n){let r=S.get(n);return r||(r={subscribers:[],version:0,dirtyProps:new Set},S.set(n,r)),r}let d=new Set,g=!1;function P(n,r){const t=v(n);t.version++,t.dirtyProps.add(r),d.add(n),g||(g=!0,queueMicrotask(k))}function k(){const n=d;d=new Set,g=!1;for(const r of n){const t=v(r),s=t.dirtyProps;t.dirtyProps=new Set;const f=s.has("*"),l=t.subscribers.filter(c=>f||c.prop===void 0||s.has(c.prop));for(const c of l)c.callback()}}const p=[];function b(){p.push(new Set)}function y(){return p.pop()??new Set}function w(n){p.length>0&&p[p.length-1].add(n)}function h(n){const r=new Set,t=[Object.prototype,Array.prototype,Function.prototype,String.prototype,Number.prototype,Boolean.prototype,Symbol.prototype,Date.prototype,RegExp.prototype,Map.prototype,Set.prototype,WeakMap.prototype,WeakSet.prototype,Promise.prototype,Error.prototype];let s=n;for(;s&&!t.includes(s);){for(const f of Reflect.ownKeys(s))f!=="constructor"&&r.add(f);s=Object.getPrototypeOf(s)}return Array.from(r)}function M(n){const r=new n,t=r,s=new Map,f=[],l=new Map,c=v(t),u=h(r);for(const e of u){if(typeof e=="symbol")continue;const o=e,i=r[o];typeof i!="function"&&(s.set(o,i),f.push(o))}for(const e of f)delete r[e],Object.defineProperty(t,e,{get(){return w(t),s.get(e)},set(o){s.set(e,o),P(t,e)},enumerable:!0,configurable:!0});return Object.defineProperty(t,"_version",{get(){return c.version},enumerable:!1,configurable:!1}),Object.defineProperty(t,"_subscribe",{value:(e,o)=>{const i={callback:e,prop:o};return c.subscribers.push(i),()=>{c.subscribers=c.subscribers.filter(a=>a!==i)}},enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(t,"_reset",{value:()=>{const e=new n,o=h(e);for(const i of o){if(typeof i=="symbol")continue;const a=i,m=e[a];typeof m!="function"&&(t[a]=m)}},enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(t,"_saveVersion",{value:(e="default")=>{const o=[];for(const[i,a]of s)o.push([i,structuredClone(a)]);l.set(e,o)},enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(t,"_loadVersion",{value:(e="default")=>{const o=l.get(e);if(!o)throw new Error(`No saved version found for label "${e}"`);for(const[i,a]of o)t[i]=structuredClone(a)},enumerable:!1,configurable:!1,writable:!1}),t}function _(n){let r,t=new Map,s,f=!1;function l(u){for(const[e,o]of u)if(e._version!==o)return!1;return!0}function c(u){for(const[e]of u)w(e)}return(...u)=>{const e=JSON.stringify(u);if(f&&e===r&&l(t))return c(t),s;b();const o=n(...u),i=y();t=new Map;for(const a of i)t.set(a,a._version);return r=e,s=o,f=!0,c(t),o}}function O(n){let r=new Map,t,s=!1;function f(c){for(const[u,e]of c)if(u._version!==e)return!1;return!0}function l(c){for(const[u]of c)w(u)}return{get value(){if(s&&f(r))return l(r),t;b();const c=n(),u=y();r=new Map;for(const e of u)r.set(e,e._version);return t=c,s=!0,l(r),c}}}function j(n,r){let t=!0,s=[],f=[],l;function c(){if(!t)return;if(r){const e=r();if(l&&A(l,e))return;l=e}for(const e of f)e();f=[],b(),n();const u=y();s=Array.from(u);for(const e of s){const o=e._subscribe(()=>{c()});f.push(o)}if(r){b(),r();const e=y();for(const o of Array.from(e))if(!s.includes(o)){const i=o._subscribe(()=>{c()});f.push(i)}}}return c(),()=>{t=!1;for(const u of f)u();f=[]}}function A(n,r){if(n.length!==r.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==r[t])return!1;return!0}exports._flush=k;exports.computed=O;exports.create=M;exports.getAllProps=h;exports.memo=_;exports.run=j;
package/dist/immu-js.js CHANGED
@@ -223,6 +223,7 @@ export {
223
223
  M as _flush,
224
224
  j as computed,
225
225
  _ as create,
226
+ S as getAllProps,
226
227
  O as memo,
227
228
  A as run
228
229
  };
package/dist/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export { memo } from "./memo";
5
5
  export { computed } from "./computed";
6
6
  export { run } from "./run";
7
7
  export { flush as _flush } from "./scheduler";
8
+ export { getAllProps } from "./utils";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "immu-js",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Independent immutable state library for JavaScript/TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/immu-js.cjs",