@lifeart/gxt
Version:
<img align="right" width="95" height="95" alt="Philosopher’s stone, logo of PostCSS" src="./public/logo.png">
2 lines (1 loc) • 10.7 kB
JavaScript
function t(){return U++,U===Number.MAX_SAFE_INTEGER&&(U=1,Z=/* @__PURE__ */new WeakMap),U}function e(t,e){return Z.get(t)!==e&&(Z.set(t,e),!0)}function n(t){J=t}function i(){return Q=!0,()=>{Q=!1}}function o(t){t.length>1&&t.sort((t,e)=>t.id-e.id)}function r(){let n=null;T(!0);const i=Rt.size>1?Array.from(Rt).sort((t,e)=>t.id-e.id):Rt;for(const t of i){F(t,!1);const e=Ot.get(t.id);if(void 0!==e){Ot.delete(t.id),null===n&&(n=[]);for(const t of e)n.push(t);e.clear()}}if(null!==n){o(n);const i=t();for(const t of n)e(t,i)&&F(t,!1)}Rt.clear(),T(!1)}async function s(){let n=null;T(!0);const i=Rt.size>1?Array.from(Rt).sort((t,e)=>t.id-e.id):Rt;for(const t of i){await F(t,!0);const e=Ot.get(t.id);if(void 0!==e){Ot.delete(t.id),null===n&&(n=[]);for(const t of e)n.push(t);e.clear()}}if(null!==n){o(n);const i=t();for(const t of n)e(t,i)&&await F(t,!0)}Rt.clear(),T(!1)}function a(){if(ASYNC_COMPILE_TRANSFORMS&&z())return s();r()}function l(t){t.opsArrayPool&&Object.assign(st.opsArrayPool,t.opsArrayPool),t.destructorArrayPool&&Object.assign(st.destructorArrayPool,t.destructorArrayPool),t.idPool&&Object.assign(st.idPool,t.idPool)}function u(){return ct.acquire()}function c(t){ct.release(t)}function h(t){ut.add(t);const e=lt.get(t);if(void 0!==e){lt.delete(t);for(let t=0;t<e.length;t++)e[t]();c(e)}}function f(t,e=[]){ut.add(t);const n=lt.get(t);if(void 0===n)return;let i;lt.delete(t);for(let o=0;o<n.length;o++)i=n[o](),i&&e.push(i);c(n)}function d(t,...e){let n=lt.get(t);void 0===n&&(n=u(),lt.set(t,n));for(let i=0;i<e.length;i++)n.push(e[i])}function g(t,e){let n=lt.get(t);void 0===n&&(n=u(),lt.set(t,n));for(let i=0;i<e.length;i++)n.push(e[i])}function _(t){return ut.has(t)}function v(t){return ut.has(t)||ht.has(t)}function y(t){ht.add(t)}function p(){if(yt.length>0)return yt.pop();const t=vt++;return Mt=Math.max(Mt,vt-yt.length),t}function M(t,e,n){if(e[ot])return;const i=e[it],o=t[it];let r=gt.get(o);void 0===r?(r=/* @__PURE__ */new Set,r.add(i),gt.set(o,r)):r.add(i),dt.set(i,e),WITH_CONTEXT_API&&_t.set(i,o),e[ot]=!0,d(e,()=>{if(dt.get(i)===e){if(e[ot]=!1,WITH_CONTEXT_API){const t=_t.get(i);if(void 0!==t){const e=gt.get(t);e&&e.delete(i)}_t.delete(i)}gt.delete(i),dt.delete(i),function(t){if(yt.length>=pt){if(!(Mt>pt&&pt<st.idPool.max))return;pt=Math.min(Math.ceil(pt*st.idPool.growthFactor),st.idPool.max)}yt.push(t)}(i)}})}function S(t){return Array.isArray(t)}function m(t){return"function"==typeof t}function A(t){return null==t}function w(t){const e=typeof t;return"string"===e||"number"===e||"boolean"===e||"bigint"===e}function x(t){return t[tt]}function b(t){return t[nt].length?t[nt].slice(0):zt.get(t)??[]}function z(){return ASYNC_COMPILE_TRANSFORMS&&Ct}function P(){return Array.from(Et)}function C(){return Array.from(Nt)}function k(t){let e=Dt.get(t);return void 0===e&&(e=/* @__PURE__ */new Map,Dt.set(t,e)),e}function R(t,e,n){let i="function"==typeof n?.initializer;return{get(){const o=k(this);if(o.has(e))return o.get(e).value;{const r=Y(i?n.initializer?.call(this):n?.value,`${t.constructor.name}.${e}.`);return o.set(e,r),r.value}},set(n){const i=k(this);if(!i.has(e))return void i.set(e,Y(n,`${t.constructor.name}.${e}.`));const o=i.get(e);o.value!==n&&o.update(n)},enumerable:n?.enumerable??!0,configurable:n?.configurable??!0}}function O(){return Ft}function T(t){Ft=t}function N(t){let e=kt.get(t.id);return void 0===e&&(e=Tt.acquire(),kt.set(t.id,e)),e}function E(t,e){t.forEach(t=>{const n=function(t){let e=Ot.get(t.id);return void 0===e&&(e=/* @__PURE__ */new Set,Ot.set(t.id,e)),e}(t);n.add(e)})}function W(t,e,n,i){if(n){const t=i.indexOf(n);t>-1&&i.splice(t,1)}}function F(t,e=!0){const n=N(t),i=t.value;if(e)return async function(t,e,n){if(TRY_CATCH_ERROR_HANDLING){let t=null;try{for(let i=0;i<e.length;i++)t=e[i],Pt.has(t)?await t(n):t(n)}catch(i){W(0,0,t,e)}}else{let t=null;for(let i=0;i<e.length;i++)t=e[i],Pt.has(t)?await t(n):t(n)}}(0,n,i);!function(t,e,n){if(TRY_CATCH_ERROR_HANDLING){let t=null;try{for(let i=0;i<e.length;i++)t=e[i],t(n)}catch(i){W(0,0,t,e)}}else for(let o=0;o<e.length;o++)e[o](n)}(0,n,i)}function I(t,e,n){let i=Dt.get(t);if(void 0===i)i=/* @__PURE__ */new Map,Dt.set(t,i);else{const t=i.get(e);if(void 0!==t)return t}const o=new jt(()=>"function"==typeof n?n():t[e],`${t.constructor.name}.${e+""}`);return i.set(e,o),o}function D(t,e,n=!1){const i=function(t,e){let n=Dt.get(t);if(void 0===n)n=/* @__PURE__ */new Map,Dt.set(t,n);else{const t=n.get(e);if(void 0!==t)return t}const i=new $t(t[e],`${t.constructor.name}.${e+""}`);return n.set(e,i),i}(t,e);if(n)return i;try{Object.defineProperty(t,e,{get:()=>i.value,set(t){i.update(t)},enumerable:!0,configurable:!0})}catch(o){}return i}function $(t,e){return new Yt(t,void 0)}function j(t,e){function n(){return function(){if(!r||null===s||null===a)return!1;if(It===l)return!0;if(0===s.size)return!1;for(const t of s){const e=a.get(t.id);if(void 0===e||t._revision!==e)return!1}return!0}()?i:function(){const e=Wt,n=/* @__PURE__ */new Set;let o;q(n);try{o=t()}finally{q(e),null!==e&&n.forEach(t=>e.add(t))}n.size>0&&E(n,u),u.isConst=0===n.size,u.relatedCells=n;const c=/* @__PURE__ */new Map;return n.forEach(t=>c.set(t.id,t._revision)),s=n,a=c,l=It,i=o,r=!0,o}()}let i,o,r=!1,s=null,a=null,l=-1;const u=new Yt(()=>o(),void 0);return o=n,{[tt]:!0,get tag(){return u},invalidate(){r=!1,s=null,a=null},get value(){return null!==Wt&&null!==s&&s.size>0&&s.forEach(t=>Wt.add(t)),n()}}}function L(t){const e=t();return m(e)?L(e):"object"==typeof e&&null!==e&&x(e)?e.value:e}function Y(t,e){return new $t(t,e)}function H(){return Wt}function q(t){Wt=t}function V(t){void 0!==t&&t()}function G(t){const e=$(t);let n,i=!1;const o=$(()=>(V(n),n=void 0,e.value)),r=B(o,t=>{m(t)&&(n=t)});return()=>{i||(i=!0,V(n),e.destroy(),o.destroy(),r())}}function X(t,e){const n=O(),i=H();n||T(!0),q(null);try{ASYNC_COMPILE_TRANSFORMS?void 0!==e(t.value)&&function(t){ASYNC_COMPILE_TRANSFORMS&&(Pt.add(t),Ct=!0)}(e):e(t.value)}finally{q(i),n||T(!1)}}function B(t,e){X(t,e);const n=N(t);return n.push(e),()=>{const i=n.indexOf(e);i>-1&&n.splice(i,1),0===n.length&&(kt.delete(t.id),function(t){Tt.release(t)}(n),"destroy"in t&&t.destroy())}}let J,K=!1,Q=!1,U=0,Z=/* @__PURE__ */new WeakMap;const tt=/* @__PURE__ */Symbol(),et=/* @__PURE__ */Symbol(),nt=/* @__PURE__ */Symbol(),it=/* @__PURE__ */Symbol(),ot=/* @__PURE__ */Symbol(),rt={initial:50,max:500,growthFactor:1.5,shrinkThreshold:.25,minSize:10},st={opsArrayPool:{...rt,initial:100,max:1e3},destructorArrayPool:{...rt,initial:100,max:1e3},idPool:{...rt,initial:100,max:1e3}};class at{pool=[];currentMaxSize;config;createFn;resetFn;totalAllocated=0;highWaterMark=0;constructor(t,e,n=()=>{}){this.config=t,this.currentMaxSize=t.initial,this.createFn=e,this.resetFn=n}acquire(){return this.pool.length>0?this.pool.pop():(this.totalAllocated++,this.highWaterMark=Math.max(this.highWaterMark,this.totalAllocated),this.createFn())}release(t){if(this.pool.length>=this.currentMaxSize){if(!(this.highWaterMark>this.currentMaxSize&&this.currentMaxSize<this.config.max))return;this.currentMaxSize=Math.min(Math.ceil(this.currentMaxSize*this.config.growthFactor),this.config.max)}this.resetFn(t),this.pool.push(t)}maybeShrink(){if(this.pool.length/this.currentMaxSize>this.config.shrinkThreshold){const t=Math.max(Math.ceil(this.highWaterMark*this.config.growthFactor),this.config.minSize,this.config.initial);if(t<this.currentMaxSize)for(this.currentMaxSize=t;this.pool.length>this.currentMaxSize;)this.pool.pop()}this.highWaterMark=this.totalAllocated-this.pool.length}getStats(){return{poolSize:this.pool.length,currentMaxSize:this.currentMaxSize,totalAllocated:this.totalAllocated,highWaterMark:this.highWaterMark}}clear(){this.pool.length=0,this.totalAllocated=0,this.highWaterMark=0,this.currentMaxSize=this.config.initial}}const lt=/* @__PURE__ */new WeakMap,ut=/* @__PURE__ */new WeakSet,ct=new at(st.destructorArrayPool,()=>[],t=>{t.length=0}),ht=/* @__PURE__ */new WeakSet,ft=/*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({__proto__:null,associateDestroyableChild:function(t,e){d(t,()=>{f(e)})},destroy:f,destroySync:h,isDestroyed:_,isDestructionStarted:v,markAsDestroyed:y,registerDestructor:d,registerDestructorBatch:g},Symbol.toStringTag,{value:"Module"})),dt=/* @__PURE__ */new Map,gt=/* @__PURE__ */new Map,_t=/* @__PURE__ */new Map;let vt=1;const yt=[];let pt=st.idPool.initial,Mt=0;const St="template",mt="args",At="_debug_args",wt="$fw",xt="/tests.html"===location.pathname,bt=[],zt=/* @__PURE__ */new WeakMap,Pt=/* @__PURE__ */new WeakSet;let Ct=!1;const kt=/* @__PURE__ */new Map,Rt=/* @__PURE__ */new Set,Ot=/* @__PURE__ */new Map,Tt=new at(st.opsArrayPool,()=>[],t=>{t.length=0}),Nt=/* @__PURE__ */new Set,Et=/* @__PURE__ */new Set;var Wt=null;let Ft=!1,It=0;const Dt=/* @__PURE__ */new WeakMap;class $t{__value;id=Lt++;_revision=0;[Symbol.toPrimitive](){return this.value}_debugName;[tt]=!0;constructor(t,e){this.__value=t}get _value(){return this.__value}set _value(t){this.__value=t}get value(){return null!==Wt&&Wt.add(this),this._value}set value(t){this.update(t)}update(t){const e=this._value!==t;this._value=t,e&&(this._revision=++It),Rt.add(this),globalThis.__gxtExternalSchedule?globalThis.__gxtExternalSchedule():Q||K||(K=!0,ASYNC_COMPILE_TRANSFORMS&&z()?queueMicrotask(async()=>{try{await s(),void 0!==J&&(J(),J=void 0)}finally{K=!1}}):queueMicrotask(()=>{try{r(),void 0!==J&&(J(),J=void 0)}finally{K=!1}}))}}class jt extends $t{__isResolved=!1;__lazyValue;__fn;constructor(t,e){super(void 0,e),this.__fn=t}get _value(){return this.__isResolved||(this.__lazyValue=this.__fn(),this.__isResolved=!0),this.__lazyValue}set _value(t){this.__lazyValue=t,this.__isResolved=!0}}let Lt=0;class Yt{fn;isConst=!1;isDestroyed=!1;id=Lt++;[Symbol.toPrimitive](){return this.value}_debugName;relatedCells=null;[tt]=!0;constructor(t,e){this.fn=t}destroy(){this.isDestroyed=!0,kt.delete(this.id),null!==this.relatedCells&&(this.relatedCells.forEach(t=>{const e=Ot.get(t.id);void 0!==e&&(e.delete(this),0===e.size&&Ot.delete(t.id))}),this.relatedCells.clear())}get value(){if(this.isDestroyed)return;if(this.isConst||!Ft||null!==Wt)return this.fn();let t;try{return t=/* @__PURE__ */new Set,q(t),this.fn()}finally{E(t,this),this.isConst=0===t.size,this.relatedCells=t,q(null)}}}const Ht=X;export{mt as $,$t as A,X as B,it as C,B as D,m as E,I as F,ft as G,n as H,M as I,_ as J,p as K,Ht as L,Yt as M,w as N,A as O,_t as P,L as Q,nt as R,h as S,dt as T,v as U,f as V,xt as W,y as X,ot as Y,bt as Z,g as _,wt as a,St as b,et as c,j as d,Y as e,D as f,l as g,G as h,$ as i,H as j,O as k,q as l,a as m,R as n,Rt as o,Dt as p,x as q,d as r,T as s,i as t,gt as u,S as v,b as w,At as x,P as y,C as z};