likec4 1.49.0 → 1.51.0
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/__app__/src/likec4.js +33 -62
- package/__app__/src/main.js +2 -56
- package/__app__/src/routes/index.js +81 -16
- package/__app__/src/routes/single.js +43 -23
- package/__app__/src/style.css +1 -1
- package/__app__/src/vendors.js +17891 -17752
- package/config/schema.json +16 -0
- package/dist/THIRD-PARTY-LICENSES.md +192 -62
- package/dist/_chunks/LikeC4.mjs +1 -0
- package/dist/_chunks/filesystem.mjs +1230 -0
- package/dist/_chunks/index.d.mts +11 -12
- package/dist/_chunks/index2.d.mts +173 -84
- package/dist/_chunks/libs/@chevrotain/cst-dts-gen.mjs +30 -0
- package/dist/_chunks/libs/@chevrotain/regexp-to-ast.mjs +8 -8
- package/dist/_chunks/libs/@chevrotain/types.d.mts +1 -0
- package/dist/_chunks/libs/@chevrotain/utils.mjs +1 -1
- package/dist/_chunks/libs/@hono/mcp.mjs +8 -8
- package/dist/_chunks/libs/@hono/node-server.mjs +1 -1
- package/dist/_chunks/libs/@logtape/logtape.mjs +3 -3
- package/dist/_chunks/libs/@lume/kiwi.mjs +1 -1
- package/dist/_chunks/libs/@modelcontextprotocol/sdk.d.mts +114 -14
- package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +7 -7
- package/dist/_chunks/libs/@msgpack/msgpack.mjs +1 -1
- package/dist/_chunks/libs/@nanostores/react.d.mts +61 -1
- package/dist/_chunks/libs/@nanostores/react.mjs +1 -1
- package/dist/_chunks/libs/@smithy/is-array-buffer.mjs +1 -0
- package/dist/_chunks/libs/@smithy/util-base64.mjs +1 -1
- package/dist/_chunks/libs/ajv.mjs +1 -1
- package/dist/_chunks/libs/ansi-align.mjs +2 -0
- package/dist/_chunks/libs/ansi-regex.mjs +1 -0
- package/dist/_chunks/libs/ansi-styles.mjs +1 -0
- package/dist/_chunks/libs/atomically.mjs +1 -1
- package/dist/_chunks/libs/birpc.mjs +1 -1
- package/dist/_chunks/libs/boxen.d.mts +1 -0
- package/dist/_chunks/libs/boxen.mjs +22 -0
- package/dist/_chunks/libs/chevrotain-allstar.mjs +2 -2
- package/dist/_chunks/libs/chevrotain.mjs +35 -35
- package/dist/_chunks/libs/conf.mjs +1 -1
- package/dist/_chunks/libs/defu.mjs +1 -1
- package/dist/_chunks/libs/esm-env.mjs +1 -1
- package/dist/_chunks/libs/eventemitter3.mjs +1 -1
- package/dist/_chunks/libs/fast-equals.mjs +1 -1
- package/dist/_chunks/libs/find-up-simple.mjs +1 -1
- package/dist/_chunks/libs/get-port.mjs +1 -1
- package/dist/_chunks/libs/is-docker.mjs +1 -1
- package/dist/_chunks/libs/is-error-instance.mjs +1 -1
- package/dist/_chunks/libs/is-inside-container.mjs +1 -1
- package/dist/_chunks/libs/is-plain-obj.mjs +1 -1
- package/dist/_chunks/libs/isexe.mjs +1 -1
- package/dist/_chunks/libs/json5.mjs +10 -10
- package/dist/_chunks/libs/khroma.mjs +1 -1
- package/dist/_chunks/libs/ky.mjs +2 -2
- package/dist/_chunks/libs/langium.d.mts +5 -4
- package/dist/_chunks/libs/langium.mjs +20 -19
- package/dist/_chunks/libs/merge-error-cause.mjs +2 -2
- package/dist/_chunks/libs/p-limit.mjs +1 -1
- package/dist/_chunks/libs/p-queue.mjs +1 -1
- package/dist/_chunks/libs/package-manager-detector.mjs +1 -1
- package/dist/_chunks/libs/package-up.mjs +1 -1
- package/dist/_chunks/libs/pako.mjs +1 -0
- package/dist/_chunks/libs/parse-ms.mjs +1 -1
- package/dist/_chunks/libs/pathe.mjs +1 -1
- package/dist/_chunks/libs/picomatch.mjs +1 -1
- package/dist/_chunks/libs/pretty-ms.mjs +1 -1
- package/dist/_chunks/libs/remeda.mjs +2 -1
- package/dist/_chunks/libs/safe-stringify.mjs +1 -1
- package/dist/_chunks/libs/strip-indent.mjs +1 -1
- package/dist/_chunks/libs/tinyrainbow.mjs +1 -1
- package/dist/_chunks/libs/ts-graphviz.mjs +3 -3
- package/dist/_chunks/libs/ufo.mjs +1 -1
- package/dist/_chunks/libs/vscode-languageserver.mjs +1 -0
- package/dist/_chunks/libs/which.mjs +1 -1
- package/dist/_chunks/libs/word-wrap.mjs +2 -2
- package/dist/_chunks/rolldown-runtime.mjs +1 -1
- package/dist/_chunks/sequence.mjs +1 -0
- package/dist/_chunks/src.mjs +15 -0
- package/dist/_chunks/src2.mjs +499 -0
- package/dist/cli/index.mjs +84 -231
- package/dist/config/index.mjs +1 -1
- package/dist/index.d.mts +810 -4
- package/dist/index.mjs +1 -1
- package/dist/model/index.mjs +1 -1
- package/dist/vite-plugin/index.d.mts +3 -0
- package/dist/vite-plugin/index.mjs +1 -1
- package/dist/vite-plugin/internal.d.mts +1 -2
- package/dist/vite-plugin/internal.mjs +1 -1
- package/package.json +28 -29
- package/react/index.d.mts +2 -2
- package/react/index.mjs +52 -76
- package/vite-plugin-modules.d.ts +5 -0
- package/dist/_chunks/GraphvizBinaryAdapter.mjs +0 -72
- package/dist/_chunks/filenames.mjs +0 -14
- package/dist/_chunks/libs/@chevrotain/gast.mjs +0 -1
- package/dist/_chunks/libs/@logtape/logtape.d.mts +0 -741
- package/dist/_chunks/libs/nanostores.d.mts +0 -63
- package/dist/_chunks/libs/nanostores.mjs +0 -1
- package/dist/_chunks/node.mjs +0 -481
- package/dist/_chunks/plugin.mjs +0 -322
- package/dist/_chunks/sequence-view.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"crypto";import{createServer as t}from"http";import{Http2ServerRequest as n}from"http2";import{Readable as r}from"stream";var i=class extends Error{constructor(e,t){super(e,t),this.name=`RequestError`}},a=e=>e instanceof i?e:new i(e.message,{cause:e}),o=global.Request,s=class extends o{constructor(e,t){typeof e==`object`&&d in e&&(e=e[d]()),t?.body?.getReader!==void 0&&(t.duplex??=`half`),super(e,t)}},c=e=>{let t=[],n=e.rawHeaders;for(let e=0;e<n.length;e+=2){let{[e]:r,[e+1]:i}=n;r.charCodeAt(0)!==58&&t.push([r,i])}return new Headers(t)},l=Symbol(`wrapBodyStream`),u=(e,t,n,i,a)=>{let o={method:e,headers:n,signal:a.signal};if(e===`TRACE`){o.method=`GET`;let e=new s(t,o);return Object.defineProperty(e,`method`,{get(){return`TRACE`}}),e}if(!(e===`GET`||e===`HEAD`))if(`rawBody`in i&&i.rawBody instanceof Buffer)o.body=new ReadableStream({start(e){e.enqueue(i.rawBody),e.close()}});else if(i[l]){let e;o.body=new ReadableStream({async pull(t){try{e||=r.toWeb(i).getReader();let{done:n,value:a}=await e.read();n?t.close():t.enqueue(a)}catch(e){t.error(e)}}})}else o.body=r.toWeb(i);return new s(t,o)},d=Symbol(`getRequestCache`),f=Symbol(`requestCache`),p=Symbol(`incomingKey`),m=Symbol(`urlKey`),h=Symbol(`headersKey`),g=Symbol(`abortControllerKey`),_={get method(){return this[p].method||`GET`},get url(){return this[m]},get headers(){return this[h]||=c(this[p])},[Symbol(`getAbortController`)](){return this[d](),this[g]},[d](){return this[g]||=new AbortController,this[f]||=u(this.method,this[m],this.headers,this[p],this[g])}};[`body`,`bodyUsed`,`cache`,`credentials`,`destination`,`integrity`,`mode`,`redirect`,`referrer`,`referrerPolicy`,`signal`,`keepalive`].forEach(e=>{Object.defineProperty(_,e,{get(){return this[d]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(_,e,{value:function(){return this[d]()[e]()}})}),Object.setPrototypeOf(_,s.prototype);var v=(e,t)=>{let r=Object.create(_);r[p]=e;let a=e.url||``;if(a[0]!==`/`&&(a.startsWith(`http://`)||a.startsWith(`https://`))){if(e instanceof n)throw new i(`Absolute URL for :path is not allowed in HTTP/2`);try{r[m]=new URL(a).href}catch(e){throw new i(`Invalid absolute URL`,{cause:e})}return r}let o=(e instanceof n?e.authority:e.headers.host)||t;if(!o)throw new i(`Missing host header`);let s;if(e instanceof n){if(s=e.scheme,!(s===`http`||s===`https`))throw new i(`Unsupported scheme`)}else s=e.socket&&e.socket.encrypted?`https`:`http`;let c=new URL(`${s}://${o}${a}`);if(c.hostname.length!==o.length&&c.hostname!==o.replace(/:\d+$/,``))throw new i(`Invalid host header`);return r[m]=c.href,r},y=Symbol(`responseCache`),b=Symbol(`getResponseCache`),x=Symbol(`cache`),S=global.Response,C=class e{#e;#t;[b](){return delete this[x],this[y]||=new S(this.#e,this.#t)}constructor(t,n){let r;if(this.#e=t,n instanceof e){let e=n[y];if(e){this.#t=e,this[b]();return}else this.#t=n.#t,r=new Headers(n.#t.headers)}else this.#t=n;(typeof t==`string`||t?.getReader!==void 0||t instanceof Blob||t instanceof Uint8Array)&&(r||=n?.headers||{"content-type":`text/plain; charset=UTF-8`},this[x]=[n?.status||200,t,r])}get headers(){let e=this[x];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2])),e[2]):this[b]().headers}get status(){return this[x]?.[0]??this[b]().status}get ok(){let e=this.status;return e>=200&&e<300}};[`body`,`bodyUsed`,`redirected`,`statusText`,`trailers`,`type`,`url`].forEach(e=>{Object.defineProperty(C.prototype,e,{get(){return this[b]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(C.prototype,e,{value:function(){return this[b]()[e]()}})}),Object.setPrototypeOf(C,S),Object.setPrototypeOf(C.prototype,S.prototype);async function w(e){return Promise.race([e,Promise.resolve().then(()=>Promise.resolve(void 0))])}function T(e,t,n){let r=t=>{e.cancel(t).catch(()=>{})};return t.on(`close`,r),t.on(`error`,r),(n??e.read()).then(o,i),e.closed.finally(()=>{t.off(`close`,r),t.off(`error`,r)});function i(e){e&&t.destroy(e)}function a(){e.read().then(o,i)}function o({done:n,value:r}){try{if(n)t.end();else if(!t.write(r))t.once(`drain`,a);else return e.read().then(o,i)}catch(e){i(e)}}}function E(e,t){if(e.locked)throw TypeError(`ReadableStream is locked.`);return t.destroyed?void 0:T(e.getReader(),t)}var D=e=>{let t={};e instanceof Headers||(e=new Headers(e??void 0));let n=[];for(let[r,i]of e)r===`set-cookie`?n.push(i):t[r]=i;return n.length>0&&(t[`set-cookie`]=n),t[`content-type`]??=`text/plain; charset=UTF-8`,t},O=`x-hono-already-sent`;global.crypto===void 0&&(global.crypto=e);var k=Symbol(`outgoingEnded`),A=()=>new Response(null,{status:400}),j=e=>new Response(null,{status:e instanceof Error&&(e.name===`TimeoutError`||e.constructor.name===`TimeoutError`)?504:500}),M=(e,t)=>{let n=e instanceof Error?e:Error(`unknown error`,{cause:e});n.code===`ERR_STREAM_PREMATURE_CLOSE`?console.info(`The user aborted a request.`):(console.error(e),t.headersSent||t.writeHead(500,{"Content-Type":`text/plain`}),t.end(`Error: ${n.message}`),t.destroy(n))},N=e=>{`flushHeaders`in e&&e.writable&&e.flushHeaders()},P=async(e,t)=>{let[n,r,i]=e[x];i instanceof Headers&&(i=D(i)),typeof r==`string`?i[`Content-Length`]=Buffer.byteLength(r):r instanceof Uint8Array?i[`Content-Length`]=r.byteLength:r instanceof Blob&&(i[`Content-Length`]=r.size),t.writeHead(n,i),typeof r==`string`||r instanceof Uint8Array?t.end(r):r instanceof Blob?t.end(new Uint8Array(await r.arrayBuffer())):(N(t),await E(r,t)?.catch(e=>M(e,t))),t[k]?.()},F=e=>typeof e.then==`function`,I=async(e,t,n={})=>{if(F(e))if(n.errorHandler)try{e=await e}catch(t){let r=await n.errorHandler(t);if(!r)return;e=r}else e=await e.catch(j);if(x in e)return P(e,t);let r=D(e.headers);if(e.body){let n=e.body.getReader(),i=[],a=!1,o;if(r[`transfer-encoding`]!==`chunked`){let e=2;for(let t=0;t<e;t++){o||=n.read();let r=await w(o).catch(e=>{console.error(e),a=!0});if(!r){if(t===1){await new Promise(e=>setTimeout(e)),e=3;continue}break}if(o=void 0,r.value&&i.push(r.value),r.done){a=!0;break}}a&&!(`content-length`in r)&&(r[`content-length`]=i.reduce((e,t)=>e+t.length,0))}t.writeHead(e.status,r),i.forEach(e=>{t.write(e)}),a?t.end():(i.length===0&&N(t),await T(n,t,o))}else r[O]||(t.writeHead(e.status,r),t.end());t[k]?.()},L=(e,t={})=>{let r=t.autoCleanupIncoming??!0;return t.overrideGlobalObjects!==!1&&global.Request!==s&&(Object.defineProperty(global,`Request`,{value:s}),Object.defineProperty(global,`Response`,{value:C})),async(i,o)=>{let s,c;try{c=v(i,t.hostname);let a=!r||i.method===`GET`||i.method===`HEAD`;if(a||(i[l]=!0,i.on(`end`,()=>{a=!0}),i instanceof n&&(o[k]=()=>{a||setTimeout(()=>{a||setTimeout(()=>{i.destroy(),o.destroy()})})})),o.on(`close`,()=>{c[g]&&(i.errored?c[g].abort(i.errored.toString()):o.writableFinished||c[g].abort(`Client connection prematurely closed.`)),a||setTimeout(()=>{a||setTimeout(()=>{i.destroy()})})}),s=e(c,{incoming:i,outgoing:o}),x in s)return P(s,o)}catch(e){if(s)return M(e,o);if(t.errorHandler){if(s=await t.errorHandler(c?e:a(e)),!s)return}else s=c?j(e):A()}try{return await I(s,o,t)}catch(e){return M(e,o)}}},R=e=>{let n=e.fetch,r=L(n,{hostname:e.hostname,overrideGlobalObjects:e.overrideGlobalObjects,autoCleanupIncoming:e.autoCleanupIncoming});return(e.createServer||t)(e.serverOptions||{},r)},z=(e,t)=>{let n=R(e);return n.listen(e?.port??3e3,e.hostname,()=>{let e=n.address();t&&t(e)}),n};export{z as t};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{r as
|
|
2
|
-
`;break;case`t`:a+=` `;break;case`r`:a+=`\r`;break;case`b`:a+=`\b`;break;case`f`:a+=`\f`;break;case`v`:a+=`\v`;break;case`0`:a+=`\0`;break;case`\\`:a+=`\\`;break;case`"`:a+=`"`;break;case`'`:a+=`'`;break;case`u`:if(r+4<n){let n=e.slice(r+1,r+5),i=Number.parseInt(n,16);Number.isNaN(i)?a+=t:(a+=String.fromCharCode(i),r+=4)}else a+=t;break;default:a+=t}r++}}else a+=e[r],r++;if(r>=n)return null;i=a,r++}else{let t=r;for(;r<n&&e[r]!==`]`&&e[r]!==`'`&&e[r]!==`"`;)r++;if(r>=n)return null;let a=e.slice(t,r);if(a.length===0)return null;let o=Number(a);i=Number.isNaN(o)?a:o}for(;r<n&&e[r]!==`]`;)r++;r<n&&r++}else{let t=r;for(;r<n&&e[r]!==`.`&&e[r]!==`[`&&e[r]!==`?`&&e[r]!==`]`;)r++;if(i=e.slice(t,r),i.length===0)return null}return r<n&&e[r]===`.`&&r++,{segment:i,nextIndex:r}}function
|
|
1
|
+
import{r as e}from"../../rolldown-runtime.mjs";import t from"node:util";function n(e){return typeof e==`function`?e:r(e)}function r(e){if(e==null)return()=>!1;if(e===`fatal`)return e=>e.level===`fatal`;if(e===`error`)return e=>e.level===`fatal`||e.level===`error`;if(e===`warning`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`;if(e===`info`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`;if(e===`debug`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`||e.level===`debug`;if(e===`trace`)return()=>!0;throw TypeError(`Invalid log level: ${e}.`)}const i=[`trace`,`debug`,`info`,`warning`,`error`,`fatal`];function a(e,t){let n=i.indexOf(e);if(n<0)throw TypeError(`Invalid log level: ${JSON.stringify(e)}.`);let r=i.indexOf(t);if(r<0)throw TypeError(`Invalid log level: ${JSON.stringify(t)}.`);return n-r}function o(e=[]){return c.getLogger(e)}const s=Symbol.for(`logtape.rootLogger`);var c=class e{parent;children;category;sinks;parentSinks=`inherit`;filters;lowestLevel=`trace`;contextLocalStorage;static getLogger(t=[]){let n=s in globalThis?globalThis[s]??null:null;return n??(n=new e(null,[]),globalThis[s]=n),typeof t==`string`?n.getChild(t):t.length===0?n:n.getChild(t)}constructor(e,t){this.parent=e,this.children={},this.category=t,this.sinks=[],this.filters=[]}getChild(t){let n=typeof t==`string`?t:t[0],r=this.children[n],i=r instanceof e?r:r?.deref();return i??(i=new e(this,[...this.category,n]),this.children[n]=`WeakRef`in globalThis?new WeakRef(i):i),typeof t==`string`||t.length===1?i:i.getChild(t.slice(1))}reset(){for(;this.sinks.length>0;)this.sinks.shift();for(this.parentSinks=`inherit`;this.filters.length>0;)this.filters.shift();this.lowestLevel=`trace`}resetDescendants(){for(let t of Object.values(this.children))(t instanceof e?t:t.deref())?.resetDescendants();this.reset()}with(e){return new l(this,{...e})}filter(e){for(let t of this.filters)if(!t(e))return!1;return this.filters.length<1?this.parent?.filter(e)??!0:!0}*getSinks(e){if(!(this.lowestLevel===null||a(e,this.lowestLevel)<0)){if(this.parent!=null&&this.parentSinks===`inherit`)for(let t of this.parent.getSinks(e))yield t;for(let e of this.sinks)yield e}}emit(e,t){let n=y(),r=`category`in e?e.category:this.category,i=n.length>0?[...n,...r]:r,o=Object.getOwnPropertyDescriptors(e);o.category={value:i,enumerable:!0,configurable:!0};let s=Object.defineProperties({},o);if(!(this.lowestLevel===null||a(s.level,this.lowestLevel)<0||!this.filter(s))){for(let e of this.getSinks(s.level))if(!t?.has(e))try{e(s)}catch(n){let r=new Set(t);r.add(e),u.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:e,error:n,record:s},r)}}}log(e,t,n,r){let i=b(),a,o=typeof n==`function`?{category:this.category,level:e,timestamp:Date.now(),get message(){return g(t,this.properties)},rawMessage:t,get properties(){return a??={...i,...n()},a}}:{category:this.category,level:e,timestamp:Date.now(),message:g(t,{...i,...n}),rawMessage:t,properties:{...i,...n}};this.emit(o,r)}logLazily(e,t,n={}){let r=b(),i,a;function o(){if((a==null||i==null)&&(a=t((e,...t)=>(i=e,_(e,t))),i==null))throw TypeError(`No log record was made.`);return[a,i]}this.emit({category:this.category,level:e,get message(){return o()[0]},get rawMessage(){return o()[1]},timestamp:Date.now(),properties:{...r,...n}})}logTemplate(e,t,n,r={}){let i=b();this.emit({category:this.category,level:e,message:_(t,n),rawMessage:t,timestamp:Date.now(),properties:{...i,...r}})}trace(e,...t){typeof e==`string`?this.log(`trace`,e,t[0]??{}):typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){typeof e==`string`?this.log(`debug`,e,t[0]??{}):typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){typeof e==`string`?this.log(`info`,e,t[0]??{}):typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){typeof e==`string`?this.log(`warning`,e,t[0]??{}):typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){this.warn(e,...t)}error(e,...t){typeof e==`string`?this.log(`error`,e,t[0]??{}):typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){typeof e==`string`?this.log(`fatal`,e,t[0]??{}):typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},l=class e{logger;properties;constructor(e,t){this.logger=e,this.properties=t}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(e){return this.logger.getChild(e).with(this.properties)}with(t){return new e(this.logger,{...this.properties,...t})}log(e,t,n,r){this.logger.log(e,t,typeof n==`function`?()=>({...this.properties,...n()}):{...this.properties,...n},r)}logLazily(e,t){this.logger.logLazily(e,t,this.properties)}logTemplate(e,t,n){this.logger.logTemplate(e,t,n,this.properties)}emit(e){let t={...e,properties:{...this.properties,...e.properties}};this.logger.emit(t)}trace(e,...t){typeof e==`string`?this.log(`trace`,e,t[0]??{}):typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){typeof e==`string`?this.log(`debug`,e,t[0]??{}):typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){typeof e==`string`?this.log(`info`,e,t[0]??{}):typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){typeof e==`string`?this.log(`warning`,e,t[0]??{}):typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){this.warn(e,...t)}error(e,...t){typeof e==`string`?this.log(`error`,e,t[0]??{}):typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){typeof e==`string`?this.log(`fatal`,e,t[0]??{}):typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}};const u=c.getLogger([`logtape`,`meta`]);function d(e){return e.includes(`.`)||e.includes(`[`)||e.includes(`?.`)}function f(e,t){if(!(t===`__proto__`||t===`prototype`||t===`constructor`)&&(typeof e==`object`||typeof e==`function`)&&e!==null)return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function p(e,t){let n=e.length,r=t;if(r>=n)return null;let i;if(e[r]===`[`){if(r++,r>=n)return null;if(e[r]===`"`||e[r]===`'`){let t=e[r];r++;let a=``;for(;r<n&&e[r]!==t;)if(e[r]===`\\`){if(r++,r<n){let t=e[r];switch(t){case`n`:a+=`
|
|
2
|
+
`;break;case`t`:a+=` `;break;case`r`:a+=`\r`;break;case`b`:a+=`\b`;break;case`f`:a+=`\f`;break;case`v`:a+=`\v`;break;case`0`:a+=`\0`;break;case`\\`:a+=`\\`;break;case`"`:a+=`"`;break;case`'`:a+=`'`;break;case`u`:if(r+4<n){let n=e.slice(r+1,r+5),i=Number.parseInt(n,16);Number.isNaN(i)?a+=t:(a+=String.fromCharCode(i),r+=4)}else a+=t;break;default:a+=t}r++}}else a+=e[r],r++;if(r>=n)return null;i=a,r++}else{let t=r;for(;r<n&&e[r]!==`]`&&e[r]!==`'`&&e[r]!==`"`;)r++;if(r>=n)return null;let a=e.slice(t,r);if(a.length===0)return null;let o=Number(a);i=Number.isNaN(o)?a:o}for(;r<n&&e[r]!==`]`;)r++;r<n&&r++}else{let t=r;for(;r<n&&e[r]!==`.`&&e[r]!==`[`&&e[r]!==`?`&&e[r]!==`]`;)r++;if(i=e.slice(t,r),i.length===0)return null}return r<n&&e[r]===`.`&&r++,{segment:i,nextIndex:r}}function m(e,t){if(typeof t==`string`)return f(e,t);if(Array.isArray(e)&&t>=0&&t<e.length)return e[t]}function h(e,t){if(e==null||t.length===0||t.endsWith(`.`))return;let n=e,r=0,i=t.length;for(;r<i;){if(t.slice(r,r+2)===`?.`){if(r+=2,n==null)return}else if(n==null)return;let e=p(t,r);if(e===null)return;let{segment:i,nextIndex:a}=e;if(r=a,n=m(n,i),n===void 0)return}return n}function g(e,t){let n=e.length;if(n===0)return[``];if(!e.includes(`{`))return[e];let r=[],i=0;for(let a=0;a<n;a++){let o=e[a];if(o===`{`){if((a+1<n?e[a+1]:``)===`{`){a++;continue}let o=e.indexOf(`}`,a+1);if(o===-1)continue;let s=e.slice(i,a);r.push(s.replace(/{{/g,`{`).replace(/}}/g,`}`));let c=e.slice(a+1,o),l,u=c.trim();u===`*`?l=c in t?t[c]:`*`in t?t[`*`]:t:(l=c===u||c in t?t[c]:t[u],l===void 0&&d(u)&&(l=h(t,u))),r.push(l),a=o,i=a+1}else o===`}`&&a+1<n&&e[a+1]===`}`&&a++}let a=e.slice(i);return r.push(a.replace(/{{/g,`{`).replace(/}}/g,`}`)),r}function _(e,t){let n=[];for(let r=0;r<e.length;r++)n.push(e[r]),r<t.length&&n.push(t[r]);return n}const v=Symbol.for(`logtape.categoryPrefix`);function y(){let e=c.getLogger().contextLocalStorage?.getStore();if(e==null)return[];let t=e[v];return Array.isArray(t)?t:[]}function b(){let e=c.getLogger().contextLocalStorage?.getStore();if(e==null)return{};let t={};for(let n of Object.keys(e))t[n]=e[n];return t}var x=e({inspect:()=>S});function S(e,n){return t.inspect(e,n)}const C={trace:`TRC`,debug:`DBG`,info:`INF`,warning:`WRN`,error:`ERR`,fatal:`FTL`},w=typeof document<`u`||typeof navigator<`u`&&navigator.product===`ReactNative`?e=>JSON.stringify(e):`Deno`in globalThis&&`inspect`in globalThis.Deno&&typeof globalThis.Deno.inspect==`function`?(e,t)=>globalThis.Deno.inspect(e,{strAbbreviateSize:1/0,iterableLimit:1/0,...t}):x!=null&&`inspect`in x&&typeof S==`function`?(e,t)=>S(e,{maxArrayLength:1/0,maxStringLength:1/0,...t}):e=>JSON.stringify(e);function T(e){return e<10?`0${e}`:`${e}`}function E(e){return e<10?`00${e}`:e<100?`0${e}`:`${e}`}const D={"date-time-timezone":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())} ${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())} +00:00`},"date-time-tz":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())} ${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())} +00`},"date-time":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())} ${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())}`},"time-timezone":e=>{let t=new Date(e);return`${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())} +00:00`},"time-tz":e=>{let t=new Date(e);return`${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())} +00`},time:e=>{let t=new Date(e);return`${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())}`},date:e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())}`},rfc3339:e=>new Date(e).toISOString(),none:()=>null},O={ABBR:C,abbr:{trace:`trc`,debug:`dbg`,info:`inf`,warning:`wrn`,error:`err`,fatal:`ftl`},FULL:{trace:`TRACE`,debug:`DEBUG`,info:`INFO`,warning:`WARNING`,error:`ERROR`,fatal:`FATAL`},full:{trace:`trace`,debug:`debug`,info:`info`,warning:`warning`,error:`error`,fatal:`fatal`},L:{trace:`T`,debug:`D`,info:`I`,warning:`W`,error:`E`,fatal:`F`},l:{trace:`t`,debug:`d`,info:`i`,warning:`w`,error:`e`,fatal:`f`}};function k(e={}){let t=(()=>{let t=e.timestamp;return t==null?D[`date-time-timezone`]:t===`disabled`?D.none:typeof t==`string`&&t in D?D[t]:t})(),n=e.category??`·`,r=e.value?t=>e.value(t,w):w,i=(()=>{let t=e.level;return t==null||t===`ABBR`?e=>O.ABBR[e]:t===`abbr`?e=>O.abbr[e]:t===`FULL`?e=>O.FULL[e]:t===`full`?e=>O.full[e]:t===`L`?e=>O.L[e]:t===`l`?e=>O.l[e]:t})(),a=e.format??(({timestamp:e,level:t,category:n,message:r})=>`${e?`${e} `:``}[${t}] ${n}: ${r}`);return e=>{let o=e.message,s=o.length,c;if(s===1)c=o[0];else if(s<=6){c=``;for(let e=0;e<s;e++)c+=e%2==0?o[e]:r(o[e])}else{let e=Array(s);for(let t=0;t<s;t++)e[t]=t%2==0?o[t]:r(o[t]);c=e.join(``)}return`${a({timestamp:t(e.timestamp),level:i(e.level),category:typeof n==`function`?n(e.category):e.category.join(n),message:c,record:e})}\n`}}k();const A=`\x1B[0m`,j={black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`},M={bold:`\x1B[1m`,dim:`\x1B[2m`,italic:`\x1B[3m`,underline:`\x1B[4m`,strikethrough:`\x1B[9m`},N={trace:null,debug:`blue`,info:`green`,warning:`yellow`,error:`red`,fatal:`magenta`};function P(e={}){let t=e.format,n=e.timestampStyle===void 0?`dim`:e.timestampStyle,r=e.timestampColor??null,i=`${n==null?``:M[n]}${r==null?``:j[r]}`,a=n==null&&r==null?``:A,o=e.levelStyle===void 0?`bold`:e.levelStyle,s=e.levelColors??N,c=e.categoryStyle===void 0?`dim`:e.categoryStyle,l=e.categoryColor??null,u=`${c==null?``:M[c]}${l==null?``:j[l]}`,d=c==null&&l==null?``:A;return k({timestamp:`date-time-tz`,value(e,t){return t(e,{colors:!0})},...e,format({timestamp:e,level:n,category:r,message:c,record:l}){let f=s[l.level];return e=`${i}${e}${a}`,n=`${o==null?``:M[o]}${f==null?``:j[f]}${n}${o==null&&f==null?``:A}`,t==null?`${e} ${n} ${u}${r}:${d} ${c}`:t({timestamp:e,level:n,category:`${u}${r}${d}`,message:c,record:l})}})}P();function F(e={}){if(!e.categorySeparator&&!e.message&&!e.properties)return e=>{if(e.message.length===3)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0]+JSON.stringify(e.message[1])+e.message[2],logger:e.category.join(`.`),properties:e.properties})+`
|
|
3
3
|
`;if(e.message.length===1)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0],logger:e.category.join(`.`),properties:e.properties})+`
|
|
4
4
|
`;let t=e.message[0];for(let n=1;n<e.message.length;n++)t+=n&1?JSON.stringify(e.message[n]):e.message[n];return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:t,logger:e.category.join(`.`),properties:e.properties})+`
|
|
5
5
|
`};let t=e.message===`template`,n=e.properties??`nest:properties`,r;if(typeof e.categorySeparator==`function`)r=e.categorySeparator;else{let t=e.categorySeparator??`.`;r=e=>e.join(t)}let i;if(n===`flatten`)i=e=>e;else if(n.startsWith(`prepend:`)){let e=n.substring(8);if(e===``)throw TypeError(`Invalid properties option: ${JSON.stringify(n)}. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`);i=t=>{let n={};for(let r in t)n[`${e}${r}`]=t[r];return n}}else if(n.startsWith(`nest:`)){let e=n.substring(5);i=t=>({[e]:t})}else throw TypeError(`Invalid properties option: ${JSON.stringify(n)}. It must be "flatten", "prepend:<prefix>", or "nest:<key>".`);let a;return a=t?e=>{if(typeof e.rawMessage==`string`)return e.rawMessage;let t=``;for(let n=0;n<e.rawMessage.length;n++)t+=n%2<1?e.rawMessage[n]:`{}`;return t}:e=>{let t=e.message.length;if(t===1)return e.message[0];let n=``;for(let r=0;r<t;r++)n+=r%2<1?e.message[r]:JSON.stringify(e.message[r]);return n},e=>JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:a(e),logger:r(e.category),...i(e.properties)})+`
|
|
6
|
-
`}
|
|
6
|
+
`}F();const I={trace:`background-color: gray; color: white;`,debug:`background-color: gray; color: white;`,info:`background-color: white; color: black;`,warning:`background-color: orange; color: black;`,error:`background-color: red; color: white;`,fatal:`background-color: maroon; color: white;`};function L(e){let t=``,n=[];for(let r=0;r<e.message.length;r++)r%2==0?t+=e.message[r]:(t+=`%o`,n.push(e.message[r]));let r=new Date(e.timestamp);return[`%c${`${r.getUTCHours().toString().padStart(2,`0`)}:${r.getUTCMinutes().toString().padStart(2,`0`)}:${r.getUTCSeconds().toString().padStart(2,`0`)}.${r.getUTCMilliseconds().toString().padStart(3,`0`)}`} %c${C[e.level]}%c %c${e.category.join(`·`)} %c${t}`,`color: gray;`,I[e.level],`background-color: default;`,`color: gray;`,`color: default;`,...n]}function R(e={}){let t=e.formatter??L,n={trace:`debug`,debug:`debug`,info:`info`,warning:`warn`,error:`error`,fatal:`error`,...e.levelMap??{}},r=e.console??globalThis.console,i=e=>{let i=t(e),a=n[e.level];if(a===void 0)throw TypeError(`Invalid log level: ${e.level}.`);if(typeof i==`string`){let e=i.replace(/\r?\n$/,``);r[a](e)}else r[a](...i)};if(!e.nonBlocking)return i;let a=e.nonBlocking===!0?{}:e.nonBlocking,o=a.bufferSize??100,s=a.flushInterval??100,c=[],l=null,u=!1,d=!1,f=o*2;function p(){if(c.length===0)return;let e=c.splice(0);for(let t of e)try{i(t)}catch{}}function m(){d||(d=!0,setTimeout(()=>{d=!1,p()},0))}function h(){l!==null||u||(l=setInterval(()=>{p()},s))}let g=e=>{u||(c.length>=f&&c.shift(),c.push(e),c.length>=o?m():l===null&&h())};return g[Symbol.dispose]=()=>{u=!0,l!==null&&(clearInterval(l),l=null),p()},g}let z=null;const B=new Set,V=new Set,H=new Set;function U(e){return e.category.length===0||e.category.length===1&&e.category[0]===`logtape`||e.category.length===2&&e.category[0]===`logtape`&&e.category[1]===`meta`}function W(e){if(z!=null&&!e.reset)throw new X(`Already configured; if you want to reset, turn on the reset flag.`);if(H.size>0)throw new X(`Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().`);K();try{G(e,!1)}catch(e){throw e instanceof X&&K(),e}}function G(e,t){z=e;let r=!1,i=new Set;for(let t of e.loggers){U(t)&&(r=!0);let a=Array.isArray(t.category)?JSON.stringify(t.category):JSON.stringify([t.category]);if(i.has(a))throw new X(`Duplicate logger configuration for category: ${a}. Each category can only be configured once.`);i.add(a);let o=c.getLogger(t.category);for(let n of t.sinks??[]){let t=e.sinks[n];if(!t)throw new X(`Sink not found: ${n}.`);o.sinks.push(t)}o.parentSinks=t.parentSinks??`inherit`,t.lowestLevel!==void 0&&(o.lowestLevel=t.lowestLevel);for(let r of t.filters??[]){let t=e.filters?.[r];if(t===void 0)throw new X(`Filter not found: ${r}.`);o.filters.push(n(t))}B.add(o)}c.getLogger().contextLocalStorage=e.contextLocalStorage;for(let n of Object.values(e.sinks)){if(Symbol.asyncDispose in n)if(t)H.add(n);else throw new X(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&V.add(n)}for(let n of Object.values(e.filters??{}))if(!(n==null||typeof n==`string`)){if(Symbol.asyncDispose in n)if(t)H.add(n);else throw new X(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&V.add(n)}if(typeof globalThis.EdgeRuntime!=`string`&&`process`in globalThis&&!(`Deno`in globalThis)){let e=globalThis.process,n=e?.on;typeof n==`function`&&n.call(e,`exit`,t?J:Y)}else addEventListener(`unload`,t?J:Y);let a=c.getLogger([`logtape`,`meta`]);r||a.sinks.push(R()),a.info(`LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category {metaLoggerCategory}. The meta logger purposes to log internal errors such as sink exceptions. If you are seeing this message, the meta logger is automatically configured. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than {dismissLevel}. See also <https://logtape.org/manual/categories#meta-logger>.`,{metaLoggerCategory:[`logtape`,`meta`],dismissLevel:`info`})}function K(){Y(),q()}function q(){let e=c.getLogger([]);e.resetDescendants(),delete e.contextLocalStorage,B.clear(),z=null}async function J(){Y();let e=[];for(let t of H)e.push(t[Symbol.asyncDispose]()),H.delete(t);await Promise.all(e)}function Y(){for(let e of V)e[Symbol.dispose]();V.clear()}var X=class extends Error{constructor(e){super(e),this.name=`ConfigureError`}};export{o as a,k as i,R as n,P as r,W as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function createMap(){return new IndexedMap}var IndexedMap=class e{index={};array=[];size(){return this.array.length}empty(){return this.array.length===0}itemAt(e){return this.array[e]}contains(e){return this.index[e.id()]!==void 0}find(e){let t=this.index[e.id()];return t===void 0?void 0:this.array[t]}setDefault(e,t){let r=this.index[e.id()];if(r===void 0){let r=new Pair(e,t());return this.index[e.id()]=this.array.length,this.array.push(r),r}else return this.array[r]}insert(e,t){let r=new Pair(e,t),i=this.index[e.id()];return i===void 0?(this.index[e.id()]=this.array.length,this.array.push(r)):this.array[i]=r,r}erase(e){let t=this.index[e.id()];if(t===void 0)return;this.index[e.id()]=void 0;let n=this.array[t],r=this.array.pop();return n!==r&&(this.array[t]=r,this.index[r.first.id()]=t),n}copy(){let t=new e;for(let e=0;e<this.array.length;e++){let n=this.array[e].copy();t.array[e]=n,t.index[n.first.id()]=e}return t}},Pair=class e{first;second;constructor(e,t){this.first=e,this.second=t}copy(){return new e(this.first,this.second)}},Variable=class{constructor(e=``){this._name=e}id(){return this._id}name(){return this._name}setName(e){this._name=e}context(){return this._context}setContext(e){this._context=e}value(){return this._value}setValue(e){this._value=e}plus(e){return new Expression(this,e)}minus(e){return new Expression(this,typeof e==`number`?-e:[-1,e])}multiply(e){return new Expression([e,this])}divide(e){return new Expression([1/e,this])}toJSON(){return{name:this._name,value:this._value}}toString(){return this._context+`[`+this._name+`:`+this._value+`]`}_name;_value=0;_context=null;_id=VarId++};let VarId=0;var Expression=class e{constructor(){let e=parseArgs(arguments);this._terms=e.terms,this._constant=e.constant}terms(){return this._terms}constant(){return this._constant}value(){let e=this._constant;for(let t=0,n=this._terms.size();t<n;t++){let n=this._terms.itemAt(t);e+=n.first.value()*n.second}return e}plus(t){return new e(this,t)}minus(t){return new e(this,typeof t==`number`?-t:[-1,t])}multiply(t){return new e([t,this])}divide(t){return new e([1/t,this])}isConstant(){return this._terms.size()==0}toString(){let e=this._terms.array.map(function(e){return e.second+`*`+e.first.toString()}).join(` + `);return!this.isConstant()&&this._constant!==0&&(e+=` + `),e+=this._constant,e}_terms;_constant};function parseArgs(t){let n=0,i=()=>0,o=createMap();for(let e=0,s=t.length;e<s;++e){let s=t[e];if(typeof s==`number`)n+=s;else if(s instanceof Variable)o.setDefault(s,i).second+=1;else if(s instanceof Expression){n+=s.constant();let e=s.terms();for(let t=0,n=e.size();t<n;t++){let n=e.itemAt(t);o.setDefault(n.first,i).second+=n.second}}else if(s instanceof Array){if(s.length!==2)throw Error(`array must have length 2`);let e=s[0],t=s[1];if(typeof e!=`number`)throw Error(`array item 0 must be a number`);if(t instanceof Variable)o.setDefault(t,i).second+=e;else if(t instanceof Expression){n+=t.constant()*e;let r=t.terms();for(let t=0,n=r.size();t<n;t++){let n=r.itemAt(t);o.setDefault(n.first,i).second+=n.second*e}}else throw Error(`array item 1 must be a variable or expression`)}else throw Error(`invalid Expression argument: `+s)}return{terms:o,constant:n}}var Strength=class e{static create(e,t,n,r=1){let i=0;return i+=Math.max(0,Math.min(1e3,e*r))*1e6,i+=Math.max(0,Math.min(1e3,t*r))*1e3,i+=Math.max(0,Math.min(1e3,n*r)),i}static required=e.create(1e3,1e3,1e3);static strong=e.create(1,0,0);static medium=e.create(0,1,0);static weak=e.create(0,0,1);static clip(t){return Math.max(0,Math.min(e.required,t))}},Operator;(function(e){e[e.Le=0]=`Le`,e[e.Ge=1]=`Ge`,e[e.Eq=2]=`Eq`})(Operator||={});var Constraint=class{constructor(e,t,n,r=Strength.required){this._operator=t,this._strength=Strength.clip(r),n===void 0&&e instanceof Expression?this._expression=e:this._expression=e.minus(n)}id(){return this._id}expression(){return this._expression}op(){return this._operator}strength(){return this._strength}toString(){return this._expression.toString()+` `+[`<=`,`>=`,`=`][this._operator]+` 0 (`+this._strength.toString()+`)`}_expression;_operator;_strength;_id=CnId++};let CnId=0;var Solver=class{maxIterations=1e3;constructor(){}createConstraint(e,t,n,r=Strength.required){let i=new Constraint(e,t,n,r);return this.addConstraint(i),i}addConstraint(e){if(this._cnMap.find(e)!==void 0)throw Error(`duplicate constraint`);let t=this._createRow(e),n=t.row,r=t.tag,i=this._chooseSubject(n,r);if(i.type()===SymbolType.Invalid&&n.allDummies())if(nearZero(n.constant()))i=r.marker;else throw Error(`unsatisfiable constraint`);if(i.type()===SymbolType.Invalid){if(!this._addWithArtificialVariable(n))throw Error(`unsatisfiable constraint`)}else n.solveFor(i),this._substitute(i,n),this._rowMap.insert(i,n);this._cnMap.insert(e,r),this._optimize(this._objective)}removeConstraint(e){let t=this._cnMap.erase(e);if(t===void 0)throw Error(`unknown constraint`);this._removeConstraintEffects(e,t.second);let n=t.second.marker,r=this._rowMap.erase(n);if(r===void 0){let e=this._getMarkerLeavingSymbol(n);if(e.type()===SymbolType.Invalid)throw Error(`failed to find leaving row`);r=this._rowMap.erase(e),r.second.solveForEx(e,n),this._substitute(n,r.second)}this._optimize(this._objective)}hasConstraint(e){return this._cnMap.contains(e)}getConstraints(){return this._cnMap.array.map(({first:e})=>e)}addEditVariable(e,t){if(this._editMap.find(e)!==void 0)throw Error(`duplicate edit variable`);if(t=Strength.clip(t),t===Strength.required)throw Error(`bad required strength`);let n=new Constraint(new Expression(e),Operator.Eq,void 0,t);this.addConstraint(n);let r={tag:this._cnMap.find(n).second,constraint:n,constant:0};this._editMap.insert(e,r)}removeEditVariable(e){let t=this._editMap.erase(e);if(t===void 0)throw Error(`unknown edit variable`);this.removeConstraint(t.second.constraint)}hasEditVariable(e){return this._editMap.contains(e)}suggestValue(e,t){let n=this._editMap.find(e);if(n===void 0)throw Error(`unknown edit variable`);let r=this._rowMap,i=n.second,a=t-i.constant;i.constant=t;let o=i.tag.marker,s=r.find(o);if(s!==void 0){s.second.add(-a)<0&&this._infeasibleRows.push(o),this._dualOptimize();return}let c=i.tag.other;if(s=r.find(c),s!==void 0){s.second.add(a)<0&&this._infeasibleRows.push(c),this._dualOptimize();return}for(let e=0,t=r.size();e<t;++e){let t=r.itemAt(e),n=t.second,i=n.coefficientFor(o);i!==0&&n.add(a*i)<0&&t.first.type()!==SymbolType.External&&this._infeasibleRows.push(t.first)}this._dualOptimize()}updateVariables(){let e=this._varMap,t=this._rowMap;for(let n=0,r=e.size();n<r;++n){let r=e.itemAt(n),i=t.find(r.second);i===void 0?r.first.setValue(0):r.first.setValue(i.second.constant())}}_getVarSymbol(e){let t=()=>this._makeSymbol(SymbolType.External);return this._varMap.setDefault(e,t).second}_createRow(e){let t=e.expression(),n=new Row(t.constant()),r=t.terms();for(let e=0,t=r.size();e<t;++e){let t=r.itemAt(e);if(!nearZero(t.second)){let e=this._getVarSymbol(t.first),r=this._rowMap.find(e);r===void 0?n.insertSymbol(e,t.second):n.insertRow(r.second,t.second)}}let i=this._objective,a=e.strength(),o={marker:INVALID_SYMBOL,other:INVALID_SYMBOL};switch(e.op()){case Operator.Le:case Operator.Ge:{let t=e.op()===Operator.Le?1:-1,r=this._makeSymbol(SymbolType.Slack);if(o.marker=r,n.insertSymbol(r,t),a<Strength.required){let e=this._makeSymbol(SymbolType.Error);o.other=e,n.insertSymbol(e,-t),i.insertSymbol(e,a)}break}case Operator.Eq:if(a<Strength.required){let e=this._makeSymbol(SymbolType.Error),t=this._makeSymbol(SymbolType.Error);o.marker=e,o.other=t,n.insertSymbol(e,-1),n.insertSymbol(t,1),i.insertSymbol(e,a),i.insertSymbol(t,a)}else{let e=this._makeSymbol(SymbolType.Dummy);o.marker=e,n.insertSymbol(e)}break}return n.constant()<0&&n.reverseSign(),{row:n,tag:o}}_chooseSubject(e,t){let n=e.cells();for(let e=0,t=n.size();e<t;++e){let t=n.itemAt(e);if(t.first.type()===SymbolType.External)return t.first}let r=t.marker.type();return(r===SymbolType.Slack||r===SymbolType.Error)&&e.coefficientFor(t.marker)<0?t.marker:(r=t.other.type(),(r===SymbolType.Slack||r===SymbolType.Error)&&e.coefficientFor(t.other)<0?t.other:INVALID_SYMBOL)}_addWithArtificialVariable(e){let t=this._makeSymbol(SymbolType.Slack);this._rowMap.insert(t,e.copy()),this._artificial=e.copy(),this._optimize(this._artificial);let n=nearZero(this._artificial.constant());this._artificial=null;let r=this._rowMap.erase(t);if(r!==void 0){let e=r.second;if(e.isConstant())return n;let i=this._anyPivotableSymbol(e);if(i.type()===SymbolType.Invalid)return!1;e.solveForEx(t,i),this._substitute(i,e),this._rowMap.insert(i,e)}let i=this._rowMap;for(let e=0,n=i.size();e<n;++e)i.itemAt(e).second.removeSymbol(t);return this._objective.removeSymbol(t),n}_substitute(e,t){let n=this._rowMap;for(let r=0,i=n.size();r<i;++r){let i=n.itemAt(r);i.second.substitute(e,t),i.second.constant()<0&&i.first.type()!==SymbolType.External&&this._infeasibleRows.push(i.first)}this._objective.substitute(e,t),this._artificial&&this._artificial.substitute(e,t)}_optimize(e){let t=0;for(;t<this.maxIterations;){let n=this._getEnteringSymbol(e);if(n.type()===SymbolType.Invalid)return;let r=this._getLeavingSymbol(n);if(r.type()===SymbolType.Invalid)throw Error(`the objective is unbounded`);let i=this._rowMap.erase(r).second;i.solveForEx(r,n),this._substitute(n,i),this._rowMap.insert(n,i),t++}throw Error(`solver iterations exceeded`)}_dualOptimize(){let e=this._rowMap,t=this._infeasibleRows;for(;t.length!==0;){let n=t.pop(),r=e.find(n);if(r!==void 0&&r.second.constant()<0){let t=this._getDualEnteringSymbol(r.second);if(t.type()===SymbolType.Invalid)throw Error(`dual optimize failed`);let i=r.second;e.erase(n),i.solveForEx(n,t),this._substitute(t,i),e.insert(t,i)}}}_getEnteringSymbol(e){let t=e.cells();for(let e=0,n=t.size();e<n;++e){let n=t.itemAt(e),r=n.first;if(n.second<0&&r.type()!==SymbolType.Dummy)return r}return INVALID_SYMBOL}_getDualEnteringSymbol(e){let t=Number.MAX_VALUE,n=INVALID_SYMBOL,r=e.cells();for(let e=0,i=r.size();e<i;++e){let i=r.itemAt(e),a=i.first,o=i.second;if(o>0&&a.type()!==SymbolType.Dummy){let e=this._objective.coefficientFor(a)/o;e<t&&(t=e,n=a)}}return n}_getLeavingSymbol(e){let t=Number.MAX_VALUE,n=INVALID_SYMBOL,r=this._rowMap;for(let i=0,a=r.size();i<a;++i){let a=r.itemAt(i),o=a.first;if(o.type()!==SymbolType.External){let r=a.second,i=r.coefficientFor(e);if(i<0){let e=-r.constant()/i;e<t&&(t=e,n=o)}}}return n}_getMarkerLeavingSymbol(e){let t=Number.MAX_VALUE,n=t,r=t,i=INVALID_SYMBOL,a=i,o=i,s=i,c=this._rowMap;for(let t=0,i=c.size();t<i;++t){let i=c.itemAt(t),l=i.second,u=l.coefficientFor(e);if(u===0)continue;let d=i.first;if(d.type()===SymbolType.External)s=d;else if(u<0){let e=-l.constant()/u;e<n&&(n=e,a=d)}else{let e=l.constant()/u;e<r&&(r=e,o=d)}}return a===i?o===i?s:o:a}_removeConstraintEffects(e,t){t.marker.type()===SymbolType.Error&&this._removeMarkerEffects(t.marker,e.strength()),t.other.type()===SymbolType.Error&&this._removeMarkerEffects(t.other,e.strength())}_removeMarkerEffects(e,t){let n=this._rowMap.find(e);n===void 0?this._objective.insertSymbol(e,-t):this._objective.insertRow(n.second,-t)}_anyPivotableSymbol(e){let t=e.cells();for(let e=0,n=t.size();e<n;++e){let n=t.itemAt(e),r=n.first.type();if(r===SymbolType.Slack||r===SymbolType.Error)return n.first}return INVALID_SYMBOL}_makeSymbol(e){return new Symbol(e,this._idTick++)}_cnMap=createCnMap();_rowMap=createRowMap();_varMap=createVarMap();_editMap=createEditMap();_infeasibleRows=[];_objective=new Row;_artificial=null;_idTick=0};function nearZero(e){let t=1e-8;return e<0?-e<t:e<t}function createCnMap(){return createMap()}function createRowMap(){return createMap()}function createVarMap(){return createMap()}function createEditMap(){return createMap()}var SymbolType;(function(e){e[e.Invalid=0]=`Invalid`,e[e.External=1]=`External`,e[e.Slack=2]=`Slack`,e[e.Error=3]=`Error`,e[e.Dummy=4]=`Dummy`})(SymbolType||={});var Symbol=class{constructor(e,t){this._id=t,this._type=e}id(){return this._id}type(){return this._type}_id;_type};let INVALID_SYMBOL=new Symbol(SymbolType.Invalid,-1);var Row=class t{constructor(e=0){this._constant=e}cells(){return this._cellMap}constant(){return this._constant}isConstant(){return this._cellMap.empty()}allDummies(){let e=this._cellMap;for(let t=0,n=e.size();t<n;++t)if(e.itemAt(t).first.type()!==SymbolType.Dummy)return!1;return!0}copy(){let e=new t(this._constant);return e._cellMap=this._cellMap.copy(),e}add(e){return this._constant+=e}insertSymbol(e,t=1){let n=this._cellMap.setDefault(e,()=>0);nearZero(n.second+=t)&&this._cellMap.erase(e)}insertRow(e,t=1){this._constant+=e._constant*t;let n=e._cellMap;for(let e=0,r=n.size();e<r;++e){let r=n.itemAt(e);this.insertSymbol(r.first,r.second*t)}}removeSymbol(e){this._cellMap.erase(e)}reverseSign(){this._constant=-this._constant;let e=this._cellMap;for(let t=0,n=e.size();t<n;++t){let n=e.itemAt(t);n.second=-n.second}}solveFor(e){let t=this._cellMap,n=-1/t.erase(e).second;this._constant*=n;for(let e=0,r=t.size();e<r;++e)t.itemAt(e).second*=n}solveForEx(e,t){this.insertSymbol(e,-1),this.solveFor(t)}coefficientFor(e){let t=this._cellMap.find(e);return t===void 0?0:t.second}substitute(e,t){let n=this._cellMap.erase(e);n!==void 0&&this.insertRow(t,n.second)}_cellMap=createMap();_constant};export{Variable as a,Strength as i,Constraint as n,Operator as r,Solver as t};
|
|
1
|
+
function e(){return new t}var t=class e{index={};array=[];size(){return this.array.length}empty(){return this.array.length===0}itemAt(e){return this.array[e]}contains(e){return this.index[e.id()]!==void 0}find(e){let t=this.index[e.id()];return t===void 0?void 0:this.array[t]}setDefault(e,t){let r=this.index[e.id()];if(r===void 0){let r=new n(e,t());return this.index[e.id()]=this.array.length,this.array.push(r),r}else return this.array[r]}insert(e,t){let r=new n(e,t),i=this.index[e.id()];return i===void 0?(this.index[e.id()]=this.array.length,this.array.push(r)):this.array[i]=r,r}erase(e){let t=this.index[e.id()];if(t===void 0)return;this.index[e.id()]=void 0;let n=this.array[t],r=this.array.pop();return n!==r&&(this.array[t]=r,this.index[r.first.id()]=t),n}copy(){let t=new e;for(let e=0;e<this.array.length;e++){let n=this.array[e].copy();t.array[e]=n,t.index[n.first.id()]=e}return t}},n=class e{first;second;constructor(e,t){this.first=e,this.second=t}copy(){return new e(this.first,this.second)}},r=class{constructor(e=``){this._name=e}id(){return this._id}name(){return this._name}setName(e){this._name=e}context(){return this._context}setContext(e){this._context=e}value(){return this._value}setValue(e){this._value=e}plus(e){return new a(this,e)}minus(e){return new a(this,typeof e==`number`?-e:[-1,e])}multiply(e){return new a([e,this])}divide(e){return new a([1/e,this])}toJSON(){return{name:this._name,value:this._value}}toString(){return this._context+`[`+this._name+`:`+this._value+`]`}_name;_value=0;_context=null;_id=i++};let i=0;var a=class e{constructor(){let e=o(arguments);this._terms=e.terms,this._constant=e.constant}terms(){return this._terms}constant(){return this._constant}value(){let e=this._constant;for(let t=0,n=this._terms.size();t<n;t++){let n=this._terms.itemAt(t);e+=n.first.value()*n.second}return e}plus(t){return new e(this,t)}minus(t){return new e(this,typeof t==`number`?-t:[-1,t])}multiply(t){return new e([t,this])}divide(t){return new e([1/t,this])}isConstant(){return this._terms.size()==0}toString(){let e=this._terms.array.map(function(e){return e.second+`*`+e.first.toString()}).join(` + `);return!this.isConstant()&&this._constant!==0&&(e+=` + `),e+=this._constant,e}_terms;_constant};function o(t){let n=0,i=()=>0,o=e();for(let e=0,s=t.length;e<s;++e){let s=t[e];if(typeof s==`number`)n+=s;else if(s instanceof r)o.setDefault(s,i).second+=1;else if(s instanceof a){n+=s.constant();let e=s.terms();for(let t=0,n=e.size();t<n;t++){let n=e.itemAt(t);o.setDefault(n.first,i).second+=n.second}}else if(s instanceof Array){if(s.length!==2)throw Error(`array must have length 2`);let e=s[0],t=s[1];if(typeof e!=`number`)throw Error(`array item 0 must be a number`);if(t instanceof r)o.setDefault(t,i).second+=e;else if(t instanceof a){n+=t.constant()*e;let r=t.terms();for(let t=0,n=r.size();t<n;t++){let n=r.itemAt(t);o.setDefault(n.first,i).second+=n.second*e}}else throw Error(`array item 1 must be a variable or expression`)}else throw Error(`invalid Expression argument: `+s)}return{terms:o,constant:n}}var s=class e{static create(e,t,n,r=1){let i=0;return i+=Math.max(0,Math.min(1e3,e*r))*1e6,i+=Math.max(0,Math.min(1e3,t*r))*1e3,i+=Math.max(0,Math.min(1e3,n*r)),i}static required=e.create(1e3,1e3,1e3);static strong=e.create(1,0,0);static medium=e.create(0,1,0);static weak=e.create(0,0,1);static clip(t){return Math.max(0,Math.min(e.required,t))}},c;(function(e){e[e.Le=0]=`Le`,e[e.Ge=1]=`Ge`,e[e.Eq=2]=`Eq`})(c||={});var l=class{constructor(e,t,n,r=s.required){this._operator=t,this._strength=s.clip(r),n===void 0&&e instanceof a?this._expression=e:this._expression=e.minus(n)}id(){return this._id}expression(){return this._expression}op(){return this._operator}strength(){return this._strength}toString(){return this._expression.toString()+` `+[`<=`,`>=`,`=`][this._operator]+` 0 (`+this._strength.toString()+`)`}_expression;_operator;_strength;_id=u++};let u=0;var d=class{maxIterations=1e3;constructor(){}createConstraint(e,t,n,r=s.required){let i=new l(e,t,n,r);return this.addConstraint(i),i}addConstraint(e){if(this._cnMap.find(e)!==void 0)throw Error(`duplicate constraint`);let t=this._createRow(e),n=t.row,r=t.tag,i=this._chooseSubject(n,r);if(i.type()===_.Invalid&&n.allDummies())if(f(n.constant()))i=r.marker;else throw Error(`unsatisfiable constraint`);if(i.type()===_.Invalid){if(!this._addWithArtificialVariable(n))throw Error(`unsatisfiable constraint`)}else n.solveFor(i),this._substitute(i,n),this._rowMap.insert(i,n);this._cnMap.insert(e,r),this._optimize(this._objective)}removeConstraint(e){let t=this._cnMap.erase(e);if(t===void 0)throw Error(`unknown constraint`);this._removeConstraintEffects(e,t.second);let n=t.second.marker,r=this._rowMap.erase(n);if(r===void 0){let e=this._getMarkerLeavingSymbol(n);if(e.type()===_.Invalid)throw Error(`failed to find leaving row`);r=this._rowMap.erase(e),r.second.solveForEx(e,n),this._substitute(n,r.second)}this._optimize(this._objective)}hasConstraint(e){return this._cnMap.contains(e)}getConstraints(){return this._cnMap.array.map(({first:e})=>e)}addEditVariable(e,t){if(this._editMap.find(e)!==void 0)throw Error(`duplicate edit variable`);if(t=s.clip(t),t===s.required)throw Error(`bad required strength`);let n=new l(new a(e),c.Eq,void 0,t);this.addConstraint(n);let r={tag:this._cnMap.find(n).second,constraint:n,constant:0};this._editMap.insert(e,r)}removeEditVariable(e){let t=this._editMap.erase(e);if(t===void 0)throw Error(`unknown edit variable`);this.removeConstraint(t.second.constraint)}hasEditVariable(e){return this._editMap.contains(e)}suggestValue(e,t){let n=this._editMap.find(e);if(n===void 0)throw Error(`unknown edit variable`);let r=this._rowMap,i=n.second,a=t-i.constant;i.constant=t;let o=i.tag.marker,s=r.find(o);if(s!==void 0){s.second.add(-a)<0&&this._infeasibleRows.push(o),this._dualOptimize();return}let c=i.tag.other;if(s=r.find(c),s!==void 0){s.second.add(a)<0&&this._infeasibleRows.push(c),this._dualOptimize();return}for(let e=0,t=r.size();e<t;++e){let t=r.itemAt(e),n=t.second,i=n.coefficientFor(o);i!==0&&n.add(a*i)<0&&t.first.type()!==_.External&&this._infeasibleRows.push(t.first)}this._dualOptimize()}updateVariables(){let e=this._varMap,t=this._rowMap;for(let n=0,r=e.size();n<r;++n){let r=e.itemAt(n),i=t.find(r.second);i===void 0?r.first.setValue(0):r.first.setValue(i.second.constant())}}_getVarSymbol(e){let t=()=>this._makeSymbol(_.External);return this._varMap.setDefault(e,t).second}_createRow(e){let t=e.expression(),n=new b(t.constant()),r=t.terms();for(let e=0,t=r.size();e<t;++e){let t=r.itemAt(e);if(!f(t.second)){let e=this._getVarSymbol(t.first),r=this._rowMap.find(e);r===void 0?n.insertSymbol(e,t.second):n.insertRow(r.second,t.second)}}let i=this._objective,a=e.strength(),o={marker:y,other:y};switch(e.op()){case c.Le:case c.Ge:{let t=e.op()===c.Le?1:-1,r=this._makeSymbol(_.Slack);if(o.marker=r,n.insertSymbol(r,t),a<s.required){let e=this._makeSymbol(_.Error);o.other=e,n.insertSymbol(e,-t),i.insertSymbol(e,a)}break}case c.Eq:if(a<s.required){let e=this._makeSymbol(_.Error),t=this._makeSymbol(_.Error);o.marker=e,o.other=t,n.insertSymbol(e,-1),n.insertSymbol(t,1),i.insertSymbol(e,a),i.insertSymbol(t,a)}else{let e=this._makeSymbol(_.Dummy);o.marker=e,n.insertSymbol(e)}break}return n.constant()<0&&n.reverseSign(),{row:n,tag:o}}_chooseSubject(e,t){let n=e.cells();for(let e=0,t=n.size();e<t;++e){let t=n.itemAt(e);if(t.first.type()===_.External)return t.first}let r=t.marker.type();return(r===_.Slack||r===_.Error)&&e.coefficientFor(t.marker)<0?t.marker:(r=t.other.type(),(r===_.Slack||r===_.Error)&&e.coefficientFor(t.other)<0?t.other:y)}_addWithArtificialVariable(e){let t=this._makeSymbol(_.Slack);this._rowMap.insert(t,e.copy()),this._artificial=e.copy(),this._optimize(this._artificial);let n=f(this._artificial.constant());this._artificial=null;let r=this._rowMap.erase(t);if(r!==void 0){let e=r.second;if(e.isConstant())return n;let i=this._anyPivotableSymbol(e);if(i.type()===_.Invalid)return!1;e.solveForEx(t,i),this._substitute(i,e),this._rowMap.insert(i,e)}let i=this._rowMap;for(let e=0,n=i.size();e<n;++e)i.itemAt(e).second.removeSymbol(t);return this._objective.removeSymbol(t),n}_substitute(e,t){let n=this._rowMap;for(let r=0,i=n.size();r<i;++r){let i=n.itemAt(r);i.second.substitute(e,t),i.second.constant()<0&&i.first.type()!==_.External&&this._infeasibleRows.push(i.first)}this._objective.substitute(e,t),this._artificial&&this._artificial.substitute(e,t)}_optimize(e){let t=0;for(;t<this.maxIterations;){let n=this._getEnteringSymbol(e);if(n.type()===_.Invalid)return;let r=this._getLeavingSymbol(n);if(r.type()===_.Invalid)throw Error(`the objective is unbounded`);let i=this._rowMap.erase(r).second;i.solveForEx(r,n),this._substitute(n,i),this._rowMap.insert(n,i),t++}throw Error(`solver iterations exceeded`)}_dualOptimize(){let e=this._rowMap,t=this._infeasibleRows;for(;t.length!==0;){let n=t.pop(),r=e.find(n);if(r!==void 0&&r.second.constant()<0){let t=this._getDualEnteringSymbol(r.second);if(t.type()===_.Invalid)throw Error(`dual optimize failed`);let i=r.second;e.erase(n),i.solveForEx(n,t),this._substitute(t,i),e.insert(t,i)}}}_getEnteringSymbol(e){let t=e.cells();for(let e=0,n=t.size();e<n;++e){let n=t.itemAt(e),r=n.first;if(n.second<0&&r.type()!==_.Dummy)return r}return y}_getDualEnteringSymbol(e){let t=Number.MAX_VALUE,n=y,r=e.cells();for(let e=0,i=r.size();e<i;++e){let i=r.itemAt(e),a=i.first,o=i.second;if(o>0&&a.type()!==_.Dummy){let e=this._objective.coefficientFor(a)/o;e<t&&(t=e,n=a)}}return n}_getLeavingSymbol(e){let t=Number.MAX_VALUE,n=y,r=this._rowMap;for(let i=0,a=r.size();i<a;++i){let a=r.itemAt(i),o=a.first;if(o.type()!==_.External){let r=a.second,i=r.coefficientFor(e);if(i<0){let e=-r.constant()/i;e<t&&(t=e,n=o)}}}return n}_getMarkerLeavingSymbol(e){let t=Number.MAX_VALUE,n=t,r=t,i=y,a=i,o=i,s=i,c=this._rowMap;for(let t=0,i=c.size();t<i;++t){let i=c.itemAt(t),l=i.second,u=l.coefficientFor(e);if(u===0)continue;let d=i.first;if(d.type()===_.External)s=d;else if(u<0){let e=-l.constant()/u;e<n&&(n=e,a=d)}else{let e=l.constant()/u;e<r&&(r=e,o=d)}}return a===i?o===i?s:o:a}_removeConstraintEffects(e,t){t.marker.type()===_.Error&&this._removeMarkerEffects(t.marker,e.strength()),t.other.type()===_.Error&&this._removeMarkerEffects(t.other,e.strength())}_removeMarkerEffects(e,t){let n=this._rowMap.find(e);n===void 0?this._objective.insertSymbol(e,-t):this._objective.insertRow(n.second,-t)}_anyPivotableSymbol(e){let t=e.cells();for(let e=0,n=t.size();e<n;++e){let n=t.itemAt(e),r=n.first.type();if(r===_.Slack||r===_.Error)return n.first}return y}_makeSymbol(e){return new v(e,this._idTick++)}_cnMap=p();_rowMap=m();_varMap=h();_editMap=g();_infeasibleRows=[];_objective=new b;_artificial=null;_idTick=0};function f(e){let t=1e-8;return e<0?-e<t:e<t}function p(){return e()}function m(){return e()}function h(){return e()}function g(){return e()}var _;(function(e){e[e.Invalid=0]=`Invalid`,e[e.External=1]=`External`,e[e.Slack=2]=`Slack`,e[e.Error=3]=`Error`,e[e.Dummy=4]=`Dummy`})(_||={});var v=class{constructor(e,t){this._id=t,this._type=e}id(){return this._id}type(){return this._type}_id;_type};let y=new v(_.Invalid,-1);var b=class t{constructor(e=0){this._constant=e}cells(){return this._cellMap}constant(){return this._constant}isConstant(){return this._cellMap.empty()}allDummies(){let e=this._cellMap;for(let t=0,n=e.size();t<n;++t)if(e.itemAt(t).first.type()!==_.Dummy)return!1;return!0}copy(){let e=new t(this._constant);return e._cellMap=this._cellMap.copy(),e}add(e){return this._constant+=e}insertSymbol(e,t=1){let n=this._cellMap.setDefault(e,()=>0);f(n.second+=t)&&this._cellMap.erase(e)}insertRow(e,t=1){this._constant+=e._constant*t;let n=e._cellMap;for(let e=0,r=n.size();e<r;++e){let r=n.itemAt(e);this.insertSymbol(r.first,r.second*t)}}removeSymbol(e){this._cellMap.erase(e)}reverseSign(){this._constant=-this._constant;let e=this._cellMap;for(let t=0,n=e.size();t<n;++t){let n=e.itemAt(t);n.second=-n.second}}solveFor(e){let t=this._cellMap,n=-1/t.erase(e).second;this._constant*=n;for(let e=0,r=t.size();e<r;++e)t.itemAt(e).second*=n}solveForEx(e,t){this.insertSymbol(e,-1),this.solveFor(t)}coefficientFor(e){let t=this._cellMap.find(e);return t===void 0?0:t.second}substitute(e,t){let n=this._cellMap.erase(e);n!==void 0&&this.insertRow(t,n.second)}_cellMap=e();_constant};export{r as a,s as i,l as n,c as r,d as t};
|
|
@@ -416,6 +416,13 @@ interface $ZodNullInternals extends $ZodTypeInternals<null, null> {
|
|
|
416
416
|
values: PrimitiveSet;
|
|
417
417
|
isst: $ZodIssueInvalidType;
|
|
418
418
|
}
|
|
419
|
+
interface $ZodAnyDef extends $ZodTypeDef {
|
|
420
|
+
type: "any";
|
|
421
|
+
}
|
|
422
|
+
interface $ZodAnyInternals extends $ZodTypeInternals<any, any> {
|
|
423
|
+
def: $ZodAnyDef;
|
|
424
|
+
isst: never;
|
|
425
|
+
}
|
|
419
426
|
interface $ZodUnknownDef extends $ZodTypeDef {
|
|
420
427
|
type: "unknown";
|
|
421
428
|
}
|
|
@@ -1391,6 +1398,8 @@ interface ZodBoolean extends _ZodBoolean<$ZodBooleanInternals<boolean>> {}
|
|
|
1391
1398
|
declare const ZodBoolean: $constructor<ZodBoolean>;
|
|
1392
1399
|
interface ZodNull extends _ZodType<$ZodNullInternals> {}
|
|
1393
1400
|
declare const ZodNull: $constructor<ZodNull>;
|
|
1401
|
+
interface ZodAny extends _ZodType<$ZodAnyInternals> {}
|
|
1402
|
+
declare const ZodAny: $constructor<ZodAny>;
|
|
1394
1403
|
interface ZodUnknown extends _ZodType<$ZodUnknownInternals> {}
|
|
1395
1404
|
declare const ZodUnknown: $constructor<ZodUnknown>;
|
|
1396
1405
|
interface ZodArray$1<T extends SomeType = $ZodType> extends _ZodType<$ZodArrayInternals<T>>, $ZodArray<T> {
|
|
@@ -2307,7 +2316,7 @@ declare enum ZodFirstPartyTypeKind {
|
|
|
2307
2316
|
ZodReadonly = "ZodReadonly"
|
|
2308
2317
|
}
|
|
2309
2318
|
//#endregion
|
|
2310
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
2319
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.d.ts
|
|
2311
2320
|
type AnySchema = ZodTypeAny | $ZodType;
|
|
2312
2321
|
type AnyObjectSchema = AnyZodObject | $ZodObject | AnySchema;
|
|
2313
2322
|
type ZodRawShapeCompat = Record<string, AnySchema>;
|
|
@@ -2318,7 +2327,7 @@ type SchemaOutput<S> = S extends ZodTypeAny ? TypeOf<S> : S extends $ZodType ? o
|
|
|
2318
2327
|
*/
|
|
2319
2328
|
type ShapeOutput<Shape extends ZodRawShapeCompat> = { [K in keyof Shape]: SchemaOutput<Shape[K]> };
|
|
2320
2329
|
//#endregion
|
|
2321
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
2330
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/types.d.ts
|
|
2322
2331
|
/**
|
|
2323
2332
|
* Information about a validated access token, provided to request handlers.
|
|
2324
2333
|
*/
|
|
@@ -2351,7 +2360,7 @@ interface AuthInfo {
|
|
|
2351
2360
|
extra?: Record<string, unknown>;
|
|
2352
2361
|
}
|
|
2353
2362
|
//#endregion
|
|
2354
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
2363
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/types.d.ts
|
|
2355
2364
|
/**
|
|
2356
2365
|
* Task creation parameters, used to ask that the server create a task to represent a request.
|
|
2357
2366
|
*/
|
|
@@ -5965,6 +5974,10 @@ interface RequestInfo {
|
|
|
5965
5974
|
* The headers of the request.
|
|
5966
5975
|
*/
|
|
5967
5976
|
headers: IsomorphicHeaders;
|
|
5977
|
+
/**
|
|
5978
|
+
* The full URL of the request.
|
|
5979
|
+
*/
|
|
5980
|
+
url?: URL;
|
|
5968
5981
|
}
|
|
5969
5982
|
/**
|
|
5970
5983
|
* Extra information about a message.
|
|
@@ -6045,7 +6058,7 @@ type ServerRequest = Infer<typeof ServerRequestSchema>;
|
|
|
6045
6058
|
type ServerNotification = Infer<typeof ServerNotificationSchema>;
|
|
6046
6059
|
type ServerResult = Infer<typeof ServerResultSchema>;
|
|
6047
6060
|
//#endregion
|
|
6048
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
6061
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.d.ts
|
|
6049
6062
|
/**
|
|
6050
6063
|
* Options for sending a JSON-RPC message.
|
|
6051
6064
|
*/
|
|
@@ -6119,7 +6132,7 @@ interface Transport {
|
|
|
6119
6132
|
setProtocolVersion?: (version: string) => void;
|
|
6120
6133
|
}
|
|
6121
6134
|
//#endregion
|
|
6122
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
6135
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.d.ts
|
|
6123
6136
|
/**
|
|
6124
6137
|
* Extended handler extra with task store for task creation.
|
|
6125
6138
|
* @experimental
|
|
@@ -6335,7 +6348,7 @@ interface TaskStore {
|
|
|
6335
6348
|
}>;
|
|
6336
6349
|
}
|
|
6337
6350
|
//#endregion
|
|
6338
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
6351
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/responseMessage.d.ts
|
|
6339
6352
|
/**
|
|
6340
6353
|
* Base message type
|
|
6341
6354
|
*/
|
|
@@ -6377,7 +6390,7 @@ interface ErrorMessage extends BaseResponseMessage {
|
|
|
6377
6390
|
*/
|
|
6378
6391
|
type ResponseMessage<T extends Result$1> = TaskStatusMessage | TaskCreatedMessage | ResultMessage<T> | ErrorMessage;
|
|
6379
6392
|
//#endregion
|
|
6380
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
6393
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.d.ts
|
|
6381
6394
|
/**
|
|
6382
6395
|
* Callback for progress notifications.
|
|
6383
6396
|
*/
|
|
@@ -7843,7 +7856,7 @@ declare enum TypeName {
|
|
|
7843
7856
|
String = "string"
|
|
7844
7857
|
}
|
|
7845
7858
|
//#endregion
|
|
7846
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
7859
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/types.d.ts
|
|
7847
7860
|
/**
|
|
7848
7861
|
* JSON Schema type definition (JSON Schema Draft 2020-12)
|
|
7849
7862
|
*
|
|
@@ -7908,7 +7921,7 @@ interface jsonSchemaValidator {
|
|
|
7908
7921
|
getValidator<T>(schema: JsonSchemaType): JsonSchemaValidator<T>;
|
|
7909
7922
|
}
|
|
7910
7923
|
//#endregion
|
|
7911
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
7924
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.d.ts
|
|
7912
7925
|
/**
|
|
7913
7926
|
* Experimental task features for low-level MCP servers.
|
|
7914
7927
|
*
|
|
@@ -7939,6 +7952,93 @@ declare class ExperimentalServerTasks<RequestT extends Request = Request, Notifi
|
|
|
7939
7952
|
* @experimental
|
|
7940
7953
|
*/
|
|
7941
7954
|
requestStream<T extends AnySchema>(request: ServerRequest | RequestT, resultSchema: T, options?: RequestOptions): AsyncGenerator<ResponseMessage<SchemaOutput<T>>, void, void>;
|
|
7955
|
+
/**
|
|
7956
|
+
* Sends a sampling request and returns an AsyncGenerator that yields response messages.
|
|
7957
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
7958
|
+
*
|
|
7959
|
+
* For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages
|
|
7960
|
+
* before the final result.
|
|
7961
|
+
*
|
|
7962
|
+
* @example
|
|
7963
|
+
* ```typescript
|
|
7964
|
+
* const stream = server.experimental.tasks.createMessageStream({
|
|
7965
|
+
* messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
|
|
7966
|
+
* maxTokens: 100
|
|
7967
|
+
* }, {
|
|
7968
|
+
* onprogress: (progress) => {
|
|
7969
|
+
* // Handle streaming tokens via progress notifications
|
|
7970
|
+
* console.log('Progress:', progress.message);
|
|
7971
|
+
* }
|
|
7972
|
+
* });
|
|
7973
|
+
*
|
|
7974
|
+
* for await (const message of stream) {
|
|
7975
|
+
* switch (message.type) {
|
|
7976
|
+
* case 'taskCreated':
|
|
7977
|
+
* console.log('Task created:', message.task.taskId);
|
|
7978
|
+
* break;
|
|
7979
|
+
* case 'taskStatus':
|
|
7980
|
+
* console.log('Task status:', message.task.status);
|
|
7981
|
+
* break;
|
|
7982
|
+
* case 'result':
|
|
7983
|
+
* console.log('Final result:', message.result);
|
|
7984
|
+
* break;
|
|
7985
|
+
* case 'error':
|
|
7986
|
+
* console.error('Error:', message.error);
|
|
7987
|
+
* break;
|
|
7988
|
+
* }
|
|
7989
|
+
* }
|
|
7990
|
+
* ```
|
|
7991
|
+
*
|
|
7992
|
+
* @param params - The sampling request parameters
|
|
7993
|
+
* @param options - Optional request options (timeout, signal, task creation params, onprogress, etc.)
|
|
7994
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
7995
|
+
*
|
|
7996
|
+
* @experimental
|
|
7997
|
+
*/
|
|
7998
|
+
createMessageStream(params: CreateMessageRequestParams, options?: RequestOptions): AsyncGenerator<ResponseMessage<CreateMessageResult>, void, void>;
|
|
7999
|
+
/**
|
|
8000
|
+
* Sends an elicitation request and returns an AsyncGenerator that yields response messages.
|
|
8001
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
8002
|
+
*
|
|
8003
|
+
* For task-augmented requests (especially URL-based elicitation), yields 'taskCreated'
|
|
8004
|
+
* and 'taskStatus' messages before the final result.
|
|
8005
|
+
*
|
|
8006
|
+
* @example
|
|
8007
|
+
* ```typescript
|
|
8008
|
+
* const stream = server.experimental.tasks.elicitInputStream({
|
|
8009
|
+
* mode: 'url',
|
|
8010
|
+
* message: 'Please authenticate',
|
|
8011
|
+
* elicitationId: 'auth-123',
|
|
8012
|
+
* url: 'https://example.com/auth'
|
|
8013
|
+
* }, {
|
|
8014
|
+
* task: { ttl: 300000 } // Task-augmented for long-running auth flow
|
|
8015
|
+
* });
|
|
8016
|
+
*
|
|
8017
|
+
* for await (const message of stream) {
|
|
8018
|
+
* switch (message.type) {
|
|
8019
|
+
* case 'taskCreated':
|
|
8020
|
+
* console.log('Task created:', message.task.taskId);
|
|
8021
|
+
* break;
|
|
8022
|
+
* case 'taskStatus':
|
|
8023
|
+
* console.log('Task status:', message.task.status);
|
|
8024
|
+
* break;
|
|
8025
|
+
* case 'result':
|
|
8026
|
+
* console.log('User action:', message.result.action);
|
|
8027
|
+
* break;
|
|
8028
|
+
* case 'error':
|
|
8029
|
+
* console.error('Error:', message.error);
|
|
8030
|
+
* break;
|
|
8031
|
+
* }
|
|
8032
|
+
* }
|
|
8033
|
+
* ```
|
|
8034
|
+
*
|
|
8035
|
+
* @param params - The elicitation request parameters
|
|
8036
|
+
* @param options - Optional request options (timeout, signal, task creation params, etc.)
|
|
8037
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
8038
|
+
*
|
|
8039
|
+
* @experimental
|
|
8040
|
+
*/
|
|
8041
|
+
elicitInputStream(params: ElicitRequestFormParams | ElicitRequestURLParams, options?: RequestOptions): AsyncGenerator<ResponseMessage<ElicitResult>, void, void>;
|
|
7942
8042
|
/**
|
|
7943
8043
|
* Gets the current status of a task.
|
|
7944
8044
|
*
|
|
@@ -7981,7 +8081,7 @@ declare class ExperimentalServerTasks<RequestT extends Request = Request, Notifi
|
|
|
7981
8081
|
cancelTask(taskId: string, options?: RequestOptions): Promise<CancelTaskResult>;
|
|
7982
8082
|
}
|
|
7983
8083
|
//#endregion
|
|
7984
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
8084
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.d.ts
|
|
7985
8085
|
type ServerOptions = ProtocolOptions & {
|
|
7986
8086
|
/**
|
|
7987
8087
|
* Capabilities to advertise as being supported by this server.
|
|
@@ -8172,7 +8272,7 @@ declare class Server<RequestT extends Request = Request, NotificationT extends N
|
|
|
8172
8272
|
sendPromptListChanged(): Promise<void>;
|
|
8173
8273
|
}
|
|
8174
8274
|
//#endregion
|
|
8175
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
8275
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/uriTemplate.d.ts
|
|
8176
8276
|
type Variables = Record<string, string | string[]>;
|
|
8177
8277
|
declare class UriTemplate {
|
|
8178
8278
|
/**
|
|
@@ -8198,7 +8298,7 @@ declare class UriTemplate {
|
|
|
8198
8298
|
match(uri: string): Variables | null;
|
|
8199
8299
|
}
|
|
8200
8300
|
//#endregion
|
|
8201
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
8301
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.d.ts
|
|
8202
8302
|
/**
|
|
8203
8303
|
* Experimental task features for McpServer.
|
|
8204
8304
|
*
|
|
@@ -8266,7 +8366,7 @@ declare class ExperimentalMcpServerTasks {
|
|
|
8266
8366
|
}, handler: ToolTaskHandler<InputArgs>): RegisteredTool;
|
|
8267
8367
|
}
|
|
8268
8368
|
//#endregion
|
|
8269
|
-
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
8369
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.d.ts
|
|
8270
8370
|
/**
|
|
8271
8371
|
* High-level MCP server that provides a simpler API for working with resources, tools, and prompts.
|
|
8272
8372
|
* For advanced usage (like sending notifications or setting custom request handlers), use the underlying
|
|
@@ -8622,4 +8722,4 @@ type RegisteredPrompt = {
|
|
|
8622
8722
|
remove(): void;
|
|
8623
8723
|
};
|
|
8624
8724
|
//#endregion
|
|
8625
|
-
export {
|
|
8725
|
+
export { $strip as S, ZodUnion$1 as _, ZodBoolean as a, $partial as b, ZodEnum$1 as c, ZodObject$1 as d, ZodOptional$1 as f, ZodTransform as g, ZodString as h, ZodArray$1 as i, ZodInt as l, ZodRecord as m, ServerOptions as n, ZodCustom as o, ZodPipe as p, ZodAny as r, ZodDefault$1 as s, McpServer as t, ZodNumber as u, input$1 as v, $strict as x, output$1 as y };
|