llama.cpp/examples/server/public/index.js

2 lines
24 KiB
JavaScript
Raw Normal View History

2023-06-27 02:45:22 +02:00
function t(){throw new Error("Cycle detected")}function e(){if(r>1){r--;return}let t,e=!1;while(void 0!==o){let i=o;o=void 0;_++;while(void 0!==i){const o=i.o;i.o=void 0;i.f&=-3;if(!(8&i.f)&&c(i))try{i.c()}catch(n){if(!e){t=n;e=!0}}i=o}}_=0;r--;if(e)throw t}function n(t){if(r>0)return t();r++;try{return t()}finally{e()}}let i,o,r=0,_=0,u=0;function s(t){if(void 0===i)return;let e=t.n;if(void 0===e||e.t!==i){e={i:0,S:t,p:i.s,n:void 0,t:i,e:void 0,x:void 0,r:e};if(void 0!==i.s)i.s.n=e;i.s=e;t.n=e;if(32&i.f)t.S(e);return e}else if(-1===e.i){e.i=0;if(void 0!==e.n){e.n.p=e.p;if(void 0!==e.p)e.p.n=e.n;e.p=i.s;e.n=void 0;i.s.n=e;i.s=e}return e}}function l(t){this.v=t;this.i=0;this.n=void 0;this.t=void 0}l.prototype.h=function(){return!0};l.prototype.S=function(t){if(this.t!==t&&void 0===t.e){t.x=this.t;if(void 0!==this.t)this.t.e=t;this.t=t}};l.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;if(void 0!==e){e.x=n;t.e=void 0}if(void 0!==n){n.e=e;t.x=void 0}if(t===this.t)this.t=n}};l.prototype.subscribe=function(t){const e=this;return b((function(){const n=e.value,i=32&this.f;this.f&=-33;try{t(n)}finally{this.f|=i}}))};l.prototype.valueOf=function(){return this.value};l.prototype.toString=function(){return this.value+""};l.prototype.toJSON=function(){return this.value};l.prototype.peek=function(){return this.v};Object.defineProperty(l.prototype,"value",{get(){const t=s(this);if(void 0!==t)t.i=this.i;return this.v},set(n){if(i instanceof d)!function(){throw new Error("Computed cannot have side-effects")}();if(n!==this.v){if(_>100)t();this.v=n;this.i++;u++;r++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N()}finally{e()}}}});function f(t){return new l(t)}function c(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function a(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n)e.r=n;e.S.n=e;e.i=-1;if(void 0===e.n){t.s=e;break}}}function h(t){let e,n=t.s;while(void 0!==n){const t=n.p;if(-1===n.i){n.S.U(n);if(void 0!==t)t.n=n.n;if(void 0!==n.n)n.n.p=t}else e=n;n.S.n=n.r;if(void 0!==n.r)n.r=void 0;n=t}t.s=e}function d(t){l.call(this,void 0);this.x=t;this.s=void 0;this.g=u-1;this.f=4}(d.prototype=new l).h=function(){this.f&=-3;if(1&this.f)return!1;if(32==(36&this.f))return!0;this.f&=-5;if(this.g===u)return!0;this.g=u;this.f|=1;if(this.i>0&&!c(this)){this.f&=-2;return!0}const t=i;try{a(this);i=this;const t=this.x();if(16&this.f||this.v!==t||0===this.i){this.v=t;this.f&=-17;this.i++}}catch(t){this.v=t;this.f|=16;this.i++}i=t;h(this);this.f&=-2;return!0};d.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t)}l.prototype.S.call(this,t)};d.prototype.U=function(t){if(void 0!==this.t){l.prototype.U.call(this,t);if(void 0===this.t){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t)}}};d.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N()}};d.prototype.peek=function(){if(!this.h())t();if(16&this.f)throw this.v;return this.v};Object.defineProperty(d.prototype,"value",{get(){if(1&this.f)t();const e=s(this);this.h();if(void 0!==e)e.i=this.i;if(16&this.f)throw this.v;return this.v}});function p(t){return new d(t)}function v(t){const n=t.u;t.u=void 0;if("function"==typeof n){r++;const o=i;i=void 0;try{n()}catch(e){t.f&=-2;t.f|=8;y(t);throw e}finally{i=o;e()}}}function y(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0;t.s=void 0;v(t)}function m(t){if(i!==this)throw new Error("Out-of-order effect");h(this);i=t;this.f&=-2;if(8&this.f)y(this);e()}function g(t){this.x=t;this.u=void 0;this.s=void 0;this.o=void 0;this.f=32}g.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const e=this.x();if("function"==typeof e)this.u=e}finally{t()}};g.prototype.S=function(){if(1&this.f)t();this.f|=1;this.f&=-9;v(this);a(this);r++;const e=i;i=this;return m.bind(this,e)};g.prototype.N=function(){if(!(2&this.f)){this.f|=2;this.o=o;o=this}};g.prototype.d=function(){this.f|=8;if(!(1&this.f))y(this)};function b(t){const e=new g(t);try{e.c()}catch(t){e.d();throw t}return e.d.bind(e)}va