@symbo.ls/utils 3.14.651 → 3.14.656

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @symbo.ls/utils
2
2
 
3
+ ## 3.14.656
4
+
5
+ ### Patch Changes
6
+
7
+ - Auto-generated cross-repo patch release.
8
+ - Updated dependencies
9
+ - @symbo.ls/fetch@3.14.656
10
+
3
11
  ## 3.14.651
4
12
 
5
13
  ### Patch Changes
@@ -1,10 +1,10 @@
1
- "use strict";var D=Object.create;var g=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},$=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of I(t))!F.call(e,r)&&r!==n&&g(e,r,{get:()=>t[r],enumerable:!(o=T(t,r))||o.enumerable});return e};var m=(e,t,n)=>(n=e!=null?D(L(e)):{},$(t||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),J=e=>$(g({},"__esModule",{value:!0}),e);var Ot={};M(Ot,{call:()=>ut,defineSetter:()=>rt,error:()=>O,get:()=>U,getChildren:()=>Z,getContext:()=>ot,getDB:()=>at,getPath:()=>K,getQuery:()=>ht,getRef:()=>Y,getRoot:()=>tt,getRootContext:()=>nt,getRootData:()=>et,getRootState:()=>q,isMethod:()=>vt,keys:()=>j,log:()=>st,lookdown:()=>z,lookdownAll:()=>G,lookup:()=>B,nextElement:()=>ct,parse:()=>Q,parseDeep:()=>v,previousElement:()=>lt,remove:()=>H,setActiveRootState:()=>X,setNodeStyles:()=>C,setProps:()=>W,spotByPath:()=>V,variables:()=>ft,verbose:()=>N,warn:()=>it});module.exports=J(Ot);var S=require("./triggerEvent.js"),d=require("./keys.js"),f=require("./types.js"),E=require("./object.js"),P=require("./env.js"),A=require("./array.js"),b=require("./cache.js");const h="production";function V(e){const t=this,{__ref:n}=t,o=[].concat(e);let r=n.root[o[0]];if(!o||!o.length)return console.log(o,"on",t.key,"is undefined");for(;r.key===o[0]&&(o.shift(),!!o.length);)if(r=r[o[0]],!r)return;return r}function B(e){const t=this;let{parent:n}=t;if((0,f.isFunction)(e))return n.state&&e(n,n.state,n.context)?n:n.parent?n.lookup(e):void 0;if(t[e])return t[e];for(;n.param!==e;){if(n[e])return n[e];if(n=n.parent,!n)return}return n}function z(e){const t=this,{__ref:n}=t,o=n?.__children;if(o)for(let r=0;r<o.length;r++){const s=o[r],i=t[s];if(s===e)return i;if((0,f.isFunction)(e)){const l=e(i,i.state,i.context);if(i.state&&l)return i}const c=i?.lookdown?.(e);if(c)return c}}function G(e,t=[]){const n=this,{__ref:o}=n,r=o?.__children;if(r){for(let s=0;s<r.length;s++){const i=r[s],c=n[i];if(i===e)t.push(c);else if((0,f.isFunction)(e)){const l=e(c,c.state,c.context);c.state&&l&&t.push(c)}c?.lookdownAll?.(e,t)}return t.length?t:void 0}}function C(e={}){const t=this;if(t.node?.style){for(const n in e){const o=e[n],r=t[n];if((0,f.isObject)(o)&&r)C.call(r,o);else if(o!=null){const s=n.replace(/[A-Z]/g,c=>"-"+c.toLowerCase()),i=String(o).replace(/\s*!important\s*$/,"");t.node.style.setProperty(s,i,"important")}}return t}}function H(e){const t=this;if((0,S.triggerEventOn)("beforeRemove",t,e)===!1)return t;(0,f.isFunction)(t.node.remove)?t.node.remove():(0,P.isProduction)()||(console.warn("This item cant be removed"),t.log()),delete t.parent[t.key],t.parent.__ref&&(t.parent.__ref.__children=(0,A.removeValueFromArray)(t.parent.__ref.__children,t.key)),(0,S.triggerEventOn)("remove",t,e)}function U(e){return this[e]}function W(e,t){const n=this;if(e)return n.update(e,t),n}function Y(e){return e?this.__ref&&this.__ref[e]:this.__ref}function Z(){return this.getRef("__children").map(t=>this[t])}function K(){return this.getRef().path}let w=null;const X=e=>{w=e||null},k=()=>w||null;function q(e){let t=null;const n=o=>o.__element&&o.root?.isRootState;if(!this)t=k();else if(n(this))t=this.root;else if(this.__ref&&this.__ref.path){const o=this.state&&n(this.state),r=(0,f.isFunction)(this.state)&&this.parent.state&&n(this.parent.state);(o||r)&&(t=this.state.root||this.parent.state.root)}return t||(t=k()),e?t?.[e]:t}function tt(e){const t=this.getRootState()?.__element;return t&&Object.keys(t).length>0&&e?t[e]:t}function et(e){return this.getRoot("data")&&Object.keys(this.getRoot("data")).length>0&&e?this.getRoot("data")[e]:this.getRoot("data")}function nt(e){const t=this.getRoot()?.context;return e?t[e]:t}function ot(e){const t=this.context;return e?t[e]:t}const rt=(e,t,n,o)=>Object.defineProperty(e,t,{get:n,set:o});function j(){const e=this,t=[];for(const n in e)!Object.prototype.hasOwnProperty.call(e,n)||d.DOMQ_PROPERTIES.has(n)&&!d.PARSED_DOMQ_PROPERTIES.has(n)||t.push(n);return t}function Q(e=[]){const t=this,n={},o=j.call(t),r=o.includes("children"),s=e.length?new Set(e):null;for(let i=0;i<o.length;i++){const c=o[i];if(s&&s.has(c)||!Object.prototype.hasOwnProperty.call(t,c)||r&&c==="content")continue;const l=t[c];if(c==="state"){if(t.__ref&&!t.__ref.__hasRootState)continue;const u=(0,f.isFunction)(l&&l.parse)?l.parse():l;n[c]=(0,f.isFunction)(u)?u:JSON.parse(JSON.stringify(u||{}))}else if(c==="scope"){if(t.__ref&&!t.__ref.__hasRootScope)continue;n[c]=JSON.parse(JSON.stringify(l||{}))}else if(c==="props"){const{__element:u,update:a,...p}=t[c];n[c]=p}else(0,f.isDefined)(l)&&Object.prototype.hasOwnProperty.call(t,c)&&(n[c]=l)}return n}function v(e=[],t=new WeakSet){const n=this;if(t.has(n))return;t.add(n);const o=Q.call(n,e),r=e.length?new Set(e):null;for(const s in o){if(r&&r.has(s)||!Object.prototype.hasOwnProperty.call(n,s))continue;const i=o[s];Array.isArray(i)?o[s]=i.map(c=>(0,f.isObjectLike)(c)?v.call(c,e,t):c):(0,f.isObjectLike)(i)&&(o[s]=v.call(i,e,t))}return o}function N(...e){if(h!=="test"&&h!=="development")return;const t=this,{__ref:n}=t;return console.groupCollapsed(t.key),e.length?e.forEach(o=>console.log(`%c${o}:
2
- `,"font-weight: bold",t[o])):(console.log(n.path),t.keys().forEach(r=>console.log(`%c${r}:`,"font-weight: bold",t[r]))),console.log(t),console.groupEnd(t.key),t}function st(...e){(h==="test"||h==="development")&&console.log(...e)}function it(...e){(h==="test"||h==="development")&&console.warn(...e)}function O(...e){if(h==="test"||h==="development"){if(e[e.length-1]?.debugger)debugger;throw e[e.length-1]?.verbose&&N.call(this),new Error(...e)}}function ct(){const e=this,{key:t,parent:n}=e,{__children:o}=n.__ref,r=o.indexOf(t),s=o[r+1];return n[s]}function lt(e){const t=e||this,{key:n,parent:o}=t,{__children:r}=o.__ref;if(!r)return;const s=r.indexOf(n);return o[r[s-1]]}function ft(e={}){const t=this;t.data||(t.data={}),t.data.varCaches||(t.data.varCaches={});const n=t.data.varCaches,o={};let r;for(const s in e)e[s]!==n[s]&&(r=!0,o[s]=e[s]);return{changed:s=>{if(!r)return;const i=s(o,(0,E.deepClone)(n));for(const c in o)n[c]=o[c];return i},timeout:(s,i)=>{if(!r)return;const c=setTimeout(()=>{s(o),clearTimeout(c)},i)}}}function ut(e,...t){const n=this.context,o=n.utils?.[e]||n.functions?.[e]||n.methods?.[e]||n.snippets?.[e];if(o)try{const r=o.call(this,...t);return r&&typeof r.then=="function"&&r.catch(s=>{O.call(this,s)}),r}catch(r){if(O.call(this,r),n?.strictMode)throw r}}async function at(){const e=this,t=e.context?.fetch;if(!t)return null;if(typeof t.select=="function"){if(!t.__authInitialized&&t.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t,e.context)}return t}if(t.__resolved){if(!t.__resolved.__authInitialized&&t.__resolved.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t.__resolved,e.context)}return t.__resolved}if(t.__resolving)return t.__resolving;const n=import("@symbo.ls/fetch").then(({resolveDb:r})=>r(t));t.__resolving=n;const o=await n;if(t.__resolved=o,e.context.fetch=o,delete t.__resolving,o?.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(o,e.context)}return o}function ht(e){const t=this,n=e||b.OPTIONS.useStateQuery||t.context?.useStateQuery;if(!n)return null;const o={};if(y(t,o),n===!0)return o;const r=St[n];return r?r(o):o}const y=(e,t)=>{const n=e.__ref;if(!n)return;const o=n.__state;o&&typeof o=="string"&&pt(t,o);const r=n.__children;if(r)for(let c=0;c<r.length;c++){const l=e[r[c]];l&&l.__ref&&y(l,t)}const s=n.contentElementKey||"content",i=e[s];i&&i.__ref&&y(i,t)},pt=(e,t)=>{const o=t.replaceAll("../","").replaceAll("~/","").split("/");let r=e;for(let s=0;s<o.length;s++){const i=o[s];s===o.length-1?r[i]||(r[i]=!0):(r[i]===!0&&(r[i]={}),r[i]||(r[i]={}),r=r[i])}},R=(e,t=0)=>{const n=" ".repeat(t),o=Object.entries(e);return o.length?o.map(([s,i])=>i===!0?`${n}${s}`:`${n}${s} {
3
- ${R(i,t+1)}
1
+ "use strict";var D=Object.create;var g=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},w=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of I(t))!F.call(e,r)&&r!==n&&g(e,r,{get:()=>t[r],enumerable:!(o=T(t,r))||o.enumerable});return e};var m=(e,t,n)=>(n=e!=null?D(L(e)):{},w(t||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),J=e=>w(g({},"__esModule",{value:!0}),e);var vt={};M(vt,{call:()=>ut,defineSetter:()=>rt,error:()=>O,get:()=>U,getChildren:()=>Z,getContext:()=>ot,getDB:()=>at,getPath:()=>K,getQuery:()=>ht,getRef:()=>Y,getRoot:()=>tt,getRootContext:()=>nt,getRootData:()=>et,getRootState:()=>q,isMethod:()=>St,keys:()=>j,log:()=>st,lookdown:()=>z,lookdownAll:()=>G,lookup:()=>B,nextElement:()=>ct,parse:()=>Q,parseDeep:()=>v,previousElement:()=>lt,remove:()=>H,setActiveRootState:()=>X,setNodeStyles:()=>C,setProps:()=>W,spotByPath:()=>V,variables:()=>ft,verbose:()=>N,warn:()=>it});module.exports=J(vt);var S=require("./triggerEvent.js"),d=require("./keys.js"),f=require("./types.js"),E=require("./object.js"),P=require("./env.js"),A=require("./array.js"),b=require("./cache.js");const h="production";function V(e){const t=this,{__ref:n}=t,o=[].concat(e);let r=n.root[o[0]];if(!o||!o.length)return console.log(o,"on",t.key,"is undefined");for(;r.key===o[0]&&(o.shift(),!!o.length);)if(r=r[o[0]],!r)return;return r}function B(e){const t=this;let{parent:n}=t;if((0,f.isFunction)(e))return n.state&&e(n,n.state,n.context)?n:n.parent?n.lookup(e):void 0;if(t[e])return t[e];for(;n.param!==e;){if(n[e])return n[e];if(n=n.parent,!n)return}return n}function z(e){const t=this,{__ref:n}=t,o=n?.__children;if(o)for(let r=0;r<o.length;r++){const s=o[r],i=t[s];if(s===e)return i;if((0,f.isFunction)(e)){const l=e(i,i.state,i.context);if(i.state&&l)return i}const c=i?.lookdown?.(e);if(c)return c}}function G(e,t=[]){const n=this,{__ref:o}=n,r=o?.__children;if(r){for(let s=0;s<r.length;s++){const i=r[s],c=n[i];if(i===e)t.push(c);else if((0,f.isFunction)(e)){const l=e(c,c.state,c.context);c.state&&l&&t.push(c)}c?.lookdownAll?.(e,t)}return t.length?t:void 0}}function C(e={}){const t=this;if(t.node?.style){for(const n in e){const o=e[n],r=t[n];if((0,f.isObject)(o)&&r)C.call(r,o);else if(o!=null){const s=n.replace(/[A-Z]/g,c=>"-"+c.toLowerCase()),i=String(o).replace(/\s*!important\s*$/,"");t.node.style.setProperty(s,i,"important")}}return t}}function H(e){const t=this;if((0,S.triggerEventOn)("beforeRemove",t,e)===!1)return t;(0,f.isFunction)(t.node.remove)?t.node.remove():(0,P.isProduction)()||(console.warn("This item cant be removed"),t.log()),delete t.parent[t.key],t.parent.__ref&&(t.parent.__ref.__children=(0,A.removeValueFromArray)(t.parent.__ref.__children,t.key)),(0,S.triggerEventOn)("remove",t,e)}function U(e){return this[e]}function W(e,t){const n=this;if(e)return n.update(e,t),n}function Y(e){return e?this.__ref&&this.__ref[e]:this.__ref}function Z(){return this.getRef("__children").map(t=>this[t])}function K(){return this.getRef().path}let R=null;const X=e=>{R=e||null},$=()=>R||null;function q(e){let t=null;const n=o=>o.__element&&o.root?.isRootState;if(!this)t=$();else if(n(this))t=this.root;else if(this.__ref&&this.__ref.path){const o=this.state&&n(this.state),r=(0,f.isFunction)(this.state)&&this.parent.state&&n(this.parent.state);(o||r)&&(t=this.state.root||this.parent.state.root)}return t||(t=$()),e?t?.[e]:t}function tt(e){const t=this.getRootState()?.__element;return t&&Object.keys(t).length>0&&e?t[e]:t}function et(e){return this.getRoot("data")&&Object.keys(this.getRoot("data")).length>0&&e?this.getRoot("data")[e]:this.getRoot("data")}function nt(e){const t=this.getRoot()?.context;return e?t[e]:t}function ot(e){const t=this.context;return e?t[e]:t}const rt=(e,t,n,o)=>Object.defineProperty(e,t,{get:n,set:o});function j(){const e=this,t=[];for(const n in e)!Object.prototype.hasOwnProperty.call(e,n)||d.DOMQ_PROPERTIES.has(n)&&!d.PARSED_DOMQ_PROPERTIES.has(n)||t.push(n);return t}function Q(e=[]){const t=this,n={},o=j.call(t),r=o.includes("children"),s=e.length?new Set(e):null;for(let i=0;i<o.length;i++){const c=o[i];if(s&&s.has(c)||!Object.prototype.hasOwnProperty.call(t,c)||r&&c==="content")continue;const l=t[c];if(c==="state"){if(t.__ref&&!t.__ref.__hasRootState)continue;const u=(0,f.isFunction)(l&&l.parse)?l.parse():l;n[c]=(0,f.isFunction)(u)?u:JSON.parse(JSON.stringify(u||{}))}else if(c==="scope"){if(t.__ref&&!t.__ref.__hasRootScope)continue;n[c]=JSON.parse(JSON.stringify(l||{}))}else if(c==="props"){const{__element:u,update:a,...p}=t[c];n[c]=p}else(0,f.isDefined)(l)&&Object.prototype.hasOwnProperty.call(t,c)&&(n[c]=l)}return n}function v(e=[],t=new WeakSet){const n=this;if(t.has(n))return;t.add(n);const o=Q.call(n,e),r=e.length?new Set(e):null;for(const s in o){if(r&&r.has(s)||!Object.prototype.hasOwnProperty.call(n,s))continue;const i=o[s];Array.isArray(i)?o[s]=i.map(c=>(0,f.isObjectLike)(c)?v.call(c,e,t):c):(0,f.isObjectLike)(i)&&(o[s]=v.call(i,e,t))}return o}function N(...e){if(h!=="test"&&h!=="development")return;const t=this,{__ref:n}=t;return console.groupCollapsed(t.key),e.length?e.forEach(o=>console.log(`%c${o}:
2
+ `,"font-weight: bold",t[o])):(console.log(n.path),t.keys().forEach(r=>console.log(`%c${r}:`,"font-weight: bold",t[r]))),console.log(t),console.groupEnd(t.key),t}function st(...e){(h==="test"||h==="development")&&console.log(...e)}function it(...e){(h==="test"||h==="development")&&console.warn(...e)}function O(...e){if(h==="test"||h==="development"){if(e[e.length-1]?.debugger)debugger;throw e[e.length-1]?.verbose&&N.call(this),new Error(...e)}}function ct(){const e=this,{key:t,parent:n}=e,{__children:o}=n.__ref,r=o.indexOf(t),s=o[r+1];return n[s]}function lt(e){const t=e||this,{key:n,parent:o}=t,{__children:r}=o.__ref;if(!r)return;const s=r.indexOf(n);return o[r[s-1]]}function ft(e={}){const t=this;t.data||(t.data={}),t.data.varCaches||(t.data.varCaches={});const n=t.data.varCaches,o={};let r;for(const s in e)e[s]!==n[s]&&(r=!0,o[s]=e[s]);return{changed:s=>{if(!r)return;const i=s(o,(0,E.deepClone)(n));for(const c in o)n[c]=o[c];return i},timeout:(s,i)=>{if(!r)return;const c=setTimeout(()=>{s(o),clearTimeout(c)},i)}}}function ut(e,...t){const n=this.context,o=n.utils?.[e]||n.functions?.[e]||n.methods?.[e]||n.snippets?.[e];if(o)try{const r=o.call(this,...t);return r&&typeof r.then=="function"&&r.catch(s=>{O.call(this,s)}),r}catch(r){if(O.call(this,r),n?.strictMode)throw r}}async function at(){const e=this,t=e.context?.fetch;if(!t)return null;if(typeof t.select=="function"){if(!t.__authInitialized&&t.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t,e.context)}return t}if(t.__resolved){if(!t.__resolved.__authInitialized&&t.__resolved.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t.__resolved,e.context)}return t.__resolved}if(t.__resolving)return t.__resolving;const n=import("@symbo.ls/fetch").then(({resolveDb:r})=>r(t));t.__resolving=n;const o=await n;if(t.__resolved=o,e.context.fetch=o,delete t.__resolving,o?.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(o,e.context)}return o}function ht(e){const t=this,n=e||b.OPTIONS.useStateQuery||t.context?.useStateQuery;if(!n)return null;const o={};if(y(t,o),n===!0)return o;const r=yt[n];return r?r(o):o}const y=(e,t)=>{const n=e.__ref;if(!n)return;const o=n.__state;o&&typeof o=="string"&&pt(t,o);const r=n.__children;if(r)for(let c=0;c<r.length;c++){const l=e[r[c]];l&&l.__ref&&y(l,t)}const s=n.contentElementKey||"content",i=e[s];i&&i.__ref&&y(i,t)},pt=(e,t)=>{const o=t.replaceAll("../","").replaceAll("~/","").split("/");let r=e;for(let s=0;s<o.length;s++){const i=o[s];s===o.length-1?r[i]||(r[i]=!0):(r[i]===!0&&(r[i]={}),r[i]||(r[i]={}),r=r[i])}},k=(e,t=0)=>{const n=" ".repeat(t),o=Object.entries(e);return o.length?o.map(([s,i])=>i===!0?`${n}${s}`:`${n}${s} {
3
+ ${k(i,t+1)}
4
4
  ${n}}`).join(`
5
5
  `):""},dt=e=>`{
6
- ${R(e,1)}
6
+ ${k(e,1)}
7
7
  }`,_t=e=>{const t={fields:{},include:[]},n=(o,r)=>{const s=[];for(const i in o)if(o[i]===!0)s.push(i);else{const c=r?`${r}.${i}`:i;t.include.push(c),n(o[i],c)}s.length&&(t.fields[r||"_root"]=s)};return n(e,""),t},gt=e=>{const t=s=>{const i=[],c=[];for(const l in s)if(s[l]===!0)i.push(l);else{const u=t(s[l]),a=[];u.select&&a.push(`$select=${u.select}`),u.expand&&a.push(`$expand=${u.expand}`),c.push(a.length?`${l}(${a.join(";")})`:l)}return{select:i.length?i.join(","):"",expand:c.length?c.join(","):""}},{select:n,expand:o}=t(e),r=[];return n&&r.push(`$select=${n}`),o&&r.push(`$expand=${o}`),r.join("&")},mt=(e,t)=>{const n=[],o=[],r=new Set,s=(a,p,x)=>{r.add(p),x&&o.push(`LEFT JOIN ${p} ON ${p}.${x}_id = ${x}.id`);for(const _ in a)a[_]===!0?n.push(`${p}.${_}`):s(a[_],_,p)},i=Object.keys(e);i.length===1&&e[i[0]]!==!0?s(e[i[0]],i[0],null):s(e,"_root",null);const c=[...r][0]||"_root",l=n.length?n.join(", "):"*",u=o.length?`
8
8
  `+o.join(`
9
9
  `):"";return`SELECT ${l}
10
- FROM ${c}${u}`},xt=e=>{const t=[],n=(o,r)=>{for(const s in o){const i=r?`${r}/${s}`:s;o[s]===!0?t.push(i):n(o[s],i)}};return n(e,""),t},yt=e=>{const t=o=>{const r=[];for(const s in o)o[s]===!0?r.push(s):r.push(`${s}(${t(o[s])})`);return r.join(", ")},n=Object.keys(e);return n.length===1&&e[n[0]]!==!0?{from:n[0],select:t(e[n[0]])}:{from:null,select:t(e)}},St={graphql:dt,"json-api":_t,odata:gt,sql:mt,supabase:yt,paths:xt};function vt(e,t){return!!(d.METHODS.has(e)||t?.context?.methods?.[e])}
10
+ FROM ${c}${u}`},xt=e=>{const t=[],n=(o,r)=>{for(const s in o){const i=r?`${r}/${s}`:s;o[s]===!0?t.push(i):n(o[s],i)}};return n(e,""),t},yt={graphql:dt,"json-api":_t,odata:gt,sql:mt,paths:xt};function St(e,t){return!!(d.METHODS.has(e)||t?.context?.methods?.[e])}
@@ -1,10 +1,10 @@
1
- import{triggerEventOn as m}from"./triggerEvent.js";import{DOMQ_PROPERTIES as w,METHODS as k,PARSED_DOMQ_PROPERTIES as R}from"./keys.js";import{isDefined as E,isFunction as p,isObject as P,isObjectLike as x}from"./types.js";import{deepClone as A}from"./object.js";import{isProduction as b}from"./env.js";import{removeValueFromArray as C}from"./array.js";import{OPTIONS as j}from"./cache.js";const a="production";function X(e){const t=this,{__ref:n}=t,o=[].concat(e);let r=n.root[o[0]];if(!o||!o.length)return console.log(o,"on",t.key,"is undefined");for(;r.key===o[0]&&(o.shift(),!!o.length);)if(r=r[o[0]],!r)return;return r}function q(e){const t=this;let{parent:n}=t;if(p(e))return n.state&&e(n,n.state,n.context)?n:n.parent?n.lookup(e):void 0;if(t[e])return t[e];for(;n.param!==e;){if(n[e])return n[e];if(n=n.parent,!n)return}return n}function tt(e){const t=this,{__ref:n}=t,o=n?.__children;if(o)for(let r=0;r<o.length;r++){const s=o[r],i=t[s];if(s===e)return i;if(p(e)){const l=e(i,i.state,i.context);if(i.state&&l)return i}const c=i?.lookdown?.(e);if(c)return c}}function et(e,t=[]){const n=this,{__ref:o}=n,r=o?.__children;if(r){for(let s=0;s<r.length;s++){const i=r[s],c=n[i];if(i===e)t.push(c);else if(p(e)){const l=e(c,c.state,c.context);c.state&&l&&t.push(c)}c?.lookdownAll?.(e,t)}return t.length?t:void 0}}function Q(e={}){const t=this;if(t.node?.style){for(const n in e){const o=e[n],r=t[n];if(P(o)&&r)Q.call(r,o);else if(o!=null){const s=n.replace(/[A-Z]/g,c=>"-"+c.toLowerCase()),i=String(o).replace(/\s*!important\s*$/,"");t.node.style.setProperty(s,i,"important")}}return t}}function nt(e){const t=this;if(m("beforeRemove",t,e)===!1)return t;p(t.node.remove)?t.node.remove():b()||(console.warn("This item cant be removed"),t.log()),delete t.parent[t.key],t.parent.__ref&&(t.parent.__ref.__children=C(t.parent.__ref.__children,t.key)),m("remove",t,e)}function ot(e){return this[e]}function rt(e,t){const n=this;if(e)return n.update(e,t),n}function st(e){return e?this.__ref&&this.__ref[e]:this.__ref}function it(){return this.getRef("__children").map(t=>this[t])}function ct(){return this.getRef().path}let y=null;const lt=e=>{y=e||null},S=()=>y||null;function ft(e){let t=null;const n=o=>o.__element&&o.root?.isRootState;if(!this)t=S();else if(n(this))t=this.root;else if(this.__ref&&this.__ref.path){const o=this.state&&n(this.state),r=p(this.state)&&this.parent.state&&n(this.parent.state);(o||r)&&(t=this.state.root||this.parent.state.root)}return t||(t=S()),e?t?.[e]:t}function ut(e){const t=this.getRootState()?.__element;return t&&Object.keys(t).length>0&&e?t[e]:t}function at(e){return this.getRoot("data")&&Object.keys(this.getRoot("data")).length>0&&e?this.getRoot("data")[e]:this.getRoot("data")}function ht(e){const t=this.getRoot()?.context;return e?t[e]:t}function pt(e){const t=this.context;return e?t[e]:t}const dt=(e,t,n,o)=>Object.defineProperty(e,t,{get:n,set:o});function N(){const e=this,t=[];for(const n in e)!Object.prototype.hasOwnProperty.call(e,n)||w.has(n)&&!R.has(n)||t.push(n);return t}function D(e=[]){const t=this,n={},o=N.call(t),r=o.includes("children"),s=e.length?new Set(e):null;for(let i=0;i<o.length;i++){const c=o[i];if(s&&s.has(c)||!Object.prototype.hasOwnProperty.call(t,c)||r&&c==="content")continue;const l=t[c];if(c==="state"){if(t.__ref&&!t.__ref.__hasRootState)continue;const f=p(l&&l.parse)?l.parse():l;n[c]=p(f)?f:JSON.parse(JSON.stringify(f||{}))}else if(c==="scope"){if(t.__ref&&!t.__ref.__hasRootScope)continue;n[c]=JSON.parse(JSON.stringify(l||{}))}else if(c==="props"){const{__element:f,update:u,...h}=t[c];n[c]=h}else E(l)&&Object.prototype.hasOwnProperty.call(t,c)&&(n[c]=l)}return n}function v(e=[],t=new WeakSet){const n=this;if(t.has(n))return;t.add(n);const o=D.call(n,e),r=e.length?new Set(e):null;for(const s in o){if(r&&r.has(s)||!Object.prototype.hasOwnProperty.call(n,s))continue;const i=o[s];Array.isArray(i)?o[s]=i.map(c=>x(c)?v.call(c,e,t):c):x(i)&&(o[s]=v.call(i,e,t))}return o}function T(...e){if(a!=="test"&&a!=="development")return;const t=this,{__ref:n}=t;return console.groupCollapsed(t.key),e.length?e.forEach(o=>console.log(`%c${o}:
2
- `,"font-weight: bold",t[o])):(console.log(n.path),t.keys().forEach(r=>console.log(`%c${r}:`,"font-weight: bold",t[r]))),console.log(t),console.groupEnd(t.key),t}function _t(...e){(a==="test"||a==="development")&&console.log(...e)}function gt(...e){(a==="test"||a==="development")&&console.warn(...e)}function O(...e){if(a==="test"||a==="development"){if(e[e.length-1]?.debugger)debugger;throw e[e.length-1]?.verbose&&T.call(this),new Error(...e)}}function mt(){const e=this,{key:t,parent:n}=e,{__children:o}=n.__ref,r=o.indexOf(t),s=o[r+1];return n[s]}function xt(e){const t=e||this,{key:n,parent:o}=t,{__children:r}=o.__ref;if(!r)return;const s=r.indexOf(n);return o[r[s-1]]}function yt(e={}){const t=this;t.data||(t.data={}),t.data.varCaches||(t.data.varCaches={});const n=t.data.varCaches,o={};let r;for(const s in e)e[s]!==n[s]&&(r=!0,o[s]=e[s]);return{changed:s=>{if(!r)return;const i=s(o,A(n));for(const c in o)n[c]=o[c];return i},timeout:(s,i)=>{if(!r)return;const c=setTimeout(()=>{s(o),clearTimeout(c)},i)}}}function St(e,...t){const n=this.context,o=n.utils?.[e]||n.functions?.[e]||n.methods?.[e]||n.snippets?.[e];if(o)try{const r=o.call(this,...t);return r&&typeof r.then=="function"&&r.catch(s=>{O.call(this,s)}),r}catch(r){if(O.call(this,r),n?.strictMode)throw r}}async function vt(){const e=this,t=e.context?.fetch;if(!t)return null;if(typeof t.select=="function"){if(!t.__authInitialized&&t.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t,e.context)}return t}if(t.__resolved){if(!t.__resolved.__authInitialized&&t.__resolved.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t.__resolved,e.context)}return t.__resolved}if(t.__resolving)return t.__resolving;const n=import("@symbo.ls/fetch").then(({resolveDb:r})=>r(t));t.__resolving=n;const o=await n;if(t.__resolved=o,e.context.fetch=o,delete t.__resolving,o?.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(o,e.context)}return o}function Ot(e){const t=this,n=e||j.useStateQuery||t.context?.useStateQuery;if(!n)return null;const o={};if(g(t,o),n===!0)return o;const r=z[n];return r?r(o):o}const g=(e,t)=>{const n=e.__ref;if(!n)return;const o=n.__state;o&&typeof o=="string"&&I(t,o);const r=n.__children;if(r)for(let c=0;c<r.length;c++){const l=e[r[c]];l&&l.__ref&&g(l,t)}const s=n.contentElementKey||"content",i=e[s];i&&i.__ref&&g(i,t)},I=(e,t)=>{const o=t.replaceAll("../","").replaceAll("~/","").split("/");let r=e;for(let s=0;s<o.length;s++){const i=o[s];s===o.length-1?r[i]||(r[i]=!0):(r[i]===!0&&(r[i]={}),r[i]||(r[i]={}),r=r[i])}},$=(e,t=0)=>{const n=" ".repeat(t),o=Object.entries(e);return o.length?o.map(([s,i])=>i===!0?`${n}${s}`:`${n}${s} {
3
- ${$(i,t+1)}
1
+ import{triggerEventOn as m}from"./triggerEvent.js";import{DOMQ_PROPERTIES as R,METHODS as $,PARSED_DOMQ_PROPERTIES as k}from"./keys.js";import{isDefined as E,isFunction as p,isObject as P,isObjectLike as x}from"./types.js";import{deepClone as A}from"./object.js";import{isProduction as b}from"./env.js";import{removeValueFromArray as C}from"./array.js";import{OPTIONS as j}from"./cache.js";const a="production";function K(e){const t=this,{__ref:n}=t,o=[].concat(e);let r=n.root[o[0]];if(!o||!o.length)return console.log(o,"on",t.key,"is undefined");for(;r.key===o[0]&&(o.shift(),!!o.length);)if(r=r[o[0]],!r)return;return r}function X(e){const t=this;let{parent:n}=t;if(p(e))return n.state&&e(n,n.state,n.context)?n:n.parent?n.lookup(e):void 0;if(t[e])return t[e];for(;n.param!==e;){if(n[e])return n[e];if(n=n.parent,!n)return}return n}function q(e){const t=this,{__ref:n}=t,o=n?.__children;if(o)for(let r=0;r<o.length;r++){const s=o[r],i=t[s];if(s===e)return i;if(p(e)){const l=e(i,i.state,i.context);if(i.state&&l)return i}const c=i?.lookdown?.(e);if(c)return c}}function tt(e,t=[]){const n=this,{__ref:o}=n,r=o?.__children;if(r){for(let s=0;s<r.length;s++){const i=r[s],c=n[i];if(i===e)t.push(c);else if(p(e)){const l=e(c,c.state,c.context);c.state&&l&&t.push(c)}c?.lookdownAll?.(e,t)}return t.length?t:void 0}}function Q(e={}){const t=this;if(t.node?.style){for(const n in e){const o=e[n],r=t[n];if(P(o)&&r)Q.call(r,o);else if(o!=null){const s=n.replace(/[A-Z]/g,c=>"-"+c.toLowerCase()),i=String(o).replace(/\s*!important\s*$/,"");t.node.style.setProperty(s,i,"important")}}return t}}function et(e){const t=this;if(m("beforeRemove",t,e)===!1)return t;p(t.node.remove)?t.node.remove():b()||(console.warn("This item cant be removed"),t.log()),delete t.parent[t.key],t.parent.__ref&&(t.parent.__ref.__children=C(t.parent.__ref.__children,t.key)),m("remove",t,e)}function nt(e){return this[e]}function ot(e,t){const n=this;if(e)return n.update(e,t),n}function rt(e){return e?this.__ref&&this.__ref[e]:this.__ref}function st(){return this.getRef("__children").map(t=>this[t])}function it(){return this.getRef().path}let y=null;const ct=e=>{y=e||null},S=()=>y||null;function lt(e){let t=null;const n=o=>o.__element&&o.root?.isRootState;if(!this)t=S();else if(n(this))t=this.root;else if(this.__ref&&this.__ref.path){const o=this.state&&n(this.state),r=p(this.state)&&this.parent.state&&n(this.parent.state);(o||r)&&(t=this.state.root||this.parent.state.root)}return t||(t=S()),e?t?.[e]:t}function ft(e){const t=this.getRootState()?.__element;return t&&Object.keys(t).length>0&&e?t[e]:t}function ut(e){return this.getRoot("data")&&Object.keys(this.getRoot("data")).length>0&&e?this.getRoot("data")[e]:this.getRoot("data")}function at(e){const t=this.getRoot()?.context;return e?t[e]:t}function ht(e){const t=this.context;return e?t[e]:t}const pt=(e,t,n,o)=>Object.defineProperty(e,t,{get:n,set:o});function N(){const e=this,t=[];for(const n in e)!Object.prototype.hasOwnProperty.call(e,n)||R.has(n)&&!k.has(n)||t.push(n);return t}function D(e=[]){const t=this,n={},o=N.call(t),r=o.includes("children"),s=e.length?new Set(e):null;for(let i=0;i<o.length;i++){const c=o[i];if(s&&s.has(c)||!Object.prototype.hasOwnProperty.call(t,c)||r&&c==="content")continue;const l=t[c];if(c==="state"){if(t.__ref&&!t.__ref.__hasRootState)continue;const f=p(l&&l.parse)?l.parse():l;n[c]=p(f)?f:JSON.parse(JSON.stringify(f||{}))}else if(c==="scope"){if(t.__ref&&!t.__ref.__hasRootScope)continue;n[c]=JSON.parse(JSON.stringify(l||{}))}else if(c==="props"){const{__element:f,update:u,...h}=t[c];n[c]=h}else E(l)&&Object.prototype.hasOwnProperty.call(t,c)&&(n[c]=l)}return n}function v(e=[],t=new WeakSet){const n=this;if(t.has(n))return;t.add(n);const o=D.call(n,e),r=e.length?new Set(e):null;for(const s in o){if(r&&r.has(s)||!Object.prototype.hasOwnProperty.call(n,s))continue;const i=o[s];Array.isArray(i)?o[s]=i.map(c=>x(c)?v.call(c,e,t):c):x(i)&&(o[s]=v.call(i,e,t))}return o}function T(...e){if(a!=="test"&&a!=="development")return;const t=this,{__ref:n}=t;return console.groupCollapsed(t.key),e.length?e.forEach(o=>console.log(`%c${o}:
2
+ `,"font-weight: bold",t[o])):(console.log(n.path),t.keys().forEach(r=>console.log(`%c${r}:`,"font-weight: bold",t[r]))),console.log(t),console.groupEnd(t.key),t}function dt(...e){(a==="test"||a==="development")&&console.log(...e)}function _t(...e){(a==="test"||a==="development")&&console.warn(...e)}function O(...e){if(a==="test"||a==="development"){if(e[e.length-1]?.debugger)debugger;throw e[e.length-1]?.verbose&&T.call(this),new Error(...e)}}function gt(){const e=this,{key:t,parent:n}=e,{__children:o}=n.__ref,r=o.indexOf(t),s=o[r+1];return n[s]}function mt(e){const t=e||this,{key:n,parent:o}=t,{__children:r}=o.__ref;if(!r)return;const s=r.indexOf(n);return o[r[s-1]]}function xt(e={}){const t=this;t.data||(t.data={}),t.data.varCaches||(t.data.varCaches={});const n=t.data.varCaches,o={};let r;for(const s in e)e[s]!==n[s]&&(r=!0,o[s]=e[s]);return{changed:s=>{if(!r)return;const i=s(o,A(n));for(const c in o)n[c]=o[c];return i},timeout:(s,i)=>{if(!r)return;const c=setTimeout(()=>{s(o),clearTimeout(c)},i)}}}function yt(e,...t){const n=this.context,o=n.utils?.[e]||n.functions?.[e]||n.methods?.[e]||n.snippets?.[e];if(o)try{const r=o.call(this,...t);return r&&typeof r.then=="function"&&r.catch(s=>{O.call(this,s)}),r}catch(r){if(O.call(this,r),n?.strictMode)throw r}}async function St(){const e=this,t=e.context?.fetch;if(!t)return null;if(typeof t.select=="function"){if(!t.__authInitialized&&t.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t,e.context)}return t}if(t.__resolved){if(!t.__resolved.__authInitialized&&t.__resolved.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t.__resolved,e.context)}return t.__resolved}if(t.__resolving)return t.__resolving;const n=import("@symbo.ls/fetch").then(({resolveDb:r})=>r(t));t.__resolving=n;const o=await n;if(t.__resolved=o,e.context.fetch=o,delete t.__resolving,o?.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(o,e.context)}return o}function vt(e){const t=this,n=e||j.useStateQuery||t.context?.useStateQuery;if(!n)return null;const o={};if(g(t,o),n===!0)return o;const r=B[n];return r?r(o):o}const g=(e,t)=>{const n=e.__ref;if(!n)return;const o=n.__state;o&&typeof o=="string"&&I(t,o);const r=n.__children;if(r)for(let c=0;c<r.length;c++){const l=e[r[c]];l&&l.__ref&&g(l,t)}const s=n.contentElementKey||"content",i=e[s];i&&i.__ref&&g(i,t)},I=(e,t)=>{const o=t.replaceAll("../","").replaceAll("~/","").split("/");let r=e;for(let s=0;s<o.length;s++){const i=o[s];s===o.length-1?r[i]||(r[i]=!0):(r[i]===!0&&(r[i]={}),r[i]||(r[i]={}),r=r[i])}},w=(e,t=0)=>{const n=" ".repeat(t),o=Object.entries(e);return o.length?o.map(([s,i])=>i===!0?`${n}${s}`:`${n}${s} {
3
+ ${w(i,t+1)}
4
4
  ${n}}`).join(`
5
5
  `):""},L=e=>`{
6
- ${$(e,1)}
6
+ ${w(e,1)}
7
7
  }`,F=e=>{const t={fields:{},include:[]},n=(o,r)=>{const s=[];for(const i in o)if(o[i]===!0)s.push(i);else{const c=r?`${r}.${i}`:i;t.include.push(c),n(o[i],c)}s.length&&(t.fields[r||"_root"]=s)};return n(e,""),t},M=e=>{const t=s=>{const i=[],c=[];for(const l in s)if(s[l]===!0)i.push(l);else{const f=t(s[l]),u=[];f.select&&u.push(`$select=${f.select}`),f.expand&&u.push(`$expand=${f.expand}`),c.push(u.length?`${l}(${u.join(";")})`:l)}return{select:i.length?i.join(","):"",expand:c.length?c.join(","):""}},{select:n,expand:o}=t(e),r=[];return n&&r.push(`$select=${n}`),o&&r.push(`$expand=${o}`),r.join("&")},J=(e,t)=>{const n=[],o=[],r=new Set,s=(u,h,_)=>{r.add(h),_&&o.push(`LEFT JOIN ${h} ON ${h}.${_}_id = ${_}.id`);for(const d in u)u[d]===!0?n.push(`${h}.${d}`):s(u[d],d,h)},i=Object.keys(e);i.length===1&&e[i[0]]!==!0?s(e[i[0]],i[0],null):s(e,"_root",null);const c=[...r][0]||"_root",l=n.length?n.join(", "):"*",f=o.length?`
8
8
  `+o.join(`
9
9
  `):"";return`SELECT ${l}
10
- FROM ${c}${f}`},V=e=>{const t=[],n=(o,r)=>{for(const s in o){const i=r?`${r}/${s}`:s;o[s]===!0?t.push(i):n(o[s],i)}};return n(e,""),t},B=e=>{const t=o=>{const r=[];for(const s in o)o[s]===!0?r.push(s):r.push(`${s}(${t(o[s])})`);return r.join(", ")},n=Object.keys(e);return n.length===1&&e[n[0]]!==!0?{from:n[0],select:t(e[n[0]])}:{from:null,select:t(e)}},z={graphql:L,"json-api":F,odata:M,sql:J,supabase:B,paths:V};function $t(e,t){return!!(k.has(e)||t?.context?.methods?.[e])}export{St as call,dt as defineSetter,O as error,ot as get,it as getChildren,pt as getContext,vt as getDB,ct as getPath,Ot as getQuery,st as getRef,ut as getRoot,ht as getRootContext,at as getRootData,ft as getRootState,$t as isMethod,N as keys,_t as log,tt as lookdown,et as lookdownAll,q as lookup,mt as nextElement,D as parse,v as parseDeep,xt as previousElement,nt as remove,lt as setActiveRootState,Q as setNodeStyles,rt as setProps,X as spotByPath,yt as variables,T as verbose,gt as warn};
10
+ FROM ${c}${f}`},V=e=>{const t=[],n=(o,r)=>{for(const s in o){const i=r?`${r}/${s}`:s;o[s]===!0?t.push(i):n(o[s],i)}};return n(e,""),t},B={graphql:L,"json-api":F,odata:M,sql:J,paths:V};function Ot(e,t){return!!($.has(e)||t?.context?.methods?.[e])}export{yt as call,pt as defineSetter,O as error,nt as get,st as getChildren,ht as getContext,St as getDB,it as getPath,vt as getQuery,rt as getRef,ft as getRoot,at as getRootContext,ut as getRootData,lt as getRootState,Ot as isMethod,N as keys,dt as log,q as lookdown,tt as lookdownAll,X as lookup,gt as nextElement,D as parse,v as parseDeep,mt as previousElement,et as remove,ct as setActiveRootState,Q as setNodeStyles,ot as setProps,K as spotByPath,xt as variables,T as verbose,_t as warn};
package/methods.js CHANGED
@@ -475,8 +475,8 @@ export async function getDB () {
475
475
  element.context.fetch = resolved
476
476
  delete db.__resolving
477
477
  // resolveDb returns null when the config has no `adapter` field or the
478
- // adapter's setup() bails (e.g. cross-realm Supabase createClient
479
- // returns a client without `.auth` — see workspace
478
+ // adapter's setup() bails (e.g. a cross-realm client factory returns a
479
+ // client without `.auth` — see workspace
480
480
  // attachDbAdapters.js:resolveDbAdapters for the consumer-side
481
481
  // pre-resolve that bypasses this path). Without `?.`, the next line
482
482
  // throws `Cannot read properties of null (reading 'getSession')` and
@@ -659,31 +659,11 @@ const formatPaths = query => {
659
659
  return paths
660
660
  }
661
661
 
662
- const formatSupabase = query => {
663
- const build = obj => {
664
- const parts = []
665
- for (const key in obj) {
666
- if (obj[key] === true) {
667
- parts.push(key)
668
- } else {
669
- parts.push(`${key}(${build(obj[key])})`)
670
- }
671
- }
672
- return parts.join(', ')
673
- }
674
- const roots = Object.keys(query)
675
- if (roots.length === 1 && query[roots[0]] !== true) {
676
- return { from: roots[0], select: build(query[roots[0]]) }
677
- }
678
- return { from: null, select: build(query) }
679
- }
680
-
681
662
  const QUERY_FORMATTERS = {
682
663
  graphql: formatGraphQL,
683
664
  'json-api': formatJsonApi,
684
665
  odata: formatOData,
685
666
  sql: formatSQL,
686
- supabase: formatSupabase,
687
667
  paths: formatPaths
688
668
  }
689
669
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "3.14.651",
3
+ "version": "3.14.656",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
49
49
  "peerDependencies": {
50
- "@symbo.ls/fetch": "^3.14.599"
50
+ "@symbo.ls/fetch": "^3.14.656"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "@symbo.ls/fetch": {