@likec4/mcp 1.59.1 → 1.59.3

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.
Files changed (50) hide show
  1. package/README.md +102 -100
  2. package/dist/app/render-view-client.css +1 -0
  3. package/dist/app/render-view-client.js +745 -0
  4. package/dist/chunks/src.mjs +55 -341
  5. package/dist/cli.mjs +1 -5
  6. package/package.json +33 -24
  7. package/dist/chunks/libs/@chevrotain/cst-dts-gen.mjs +0 -1
  8. package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +0 -9
  9. package/dist/chunks/libs/@hono/mcp.mjs +0 -70
  10. package/dist/chunks/libs/@hono/node-server.mjs +0 -3
  11. package/dist/chunks/libs/@logtape/logtape.mjs +0 -5
  12. package/dist/chunks/libs/@modelcontextprotocol/sdk.mjs +0 -5
  13. package/dist/chunks/libs/@radix-ui/colors.mjs +0 -1
  14. package/dist/chunks/libs/@ts-graphviz/ast.mjs +0 -3
  15. package/dist/chunks/libs/@ts-graphviz/core.mjs +0 -1
  16. package/dist/chunks/libs/@ungap/structured-clone.mjs +0 -1
  17. package/dist/chunks/libs/character-entities.mjs +0 -2
  18. package/dist/chunks/libs/chevrotain-allstar.mjs +0 -2
  19. package/dist/chunks/libs/chevrotain.mjs +0 -58
  20. package/dist/chunks/libs/chokidar.mjs +0 -3
  21. package/dist/chunks/libs/chroma-js.mjs +0 -15
  22. package/dist/chunks/libs/eventemitter3.mjs +0 -1
  23. package/dist/chunks/libs/graphology-dag.mjs +0 -1
  24. package/dist/chunks/libs/graphology.mjs +0 -1
  25. package/dist/chunks/libs/hast-util-sanitize.mjs +0 -1
  26. package/dist/chunks/libs/hast-util-to-html.mjs +0 -9
  27. package/dist/chunks/libs/hono.mjs +0 -1
  28. package/dist/chunks/libs/immer.mjs +0 -1
  29. package/dist/chunks/libs/khroma.mjs +0 -1
  30. package/dist/chunks/libs/langium.mjs +0 -19
  31. package/dist/chunks/libs/markdown-table.mjs +0 -2
  32. package/dist/chunks/libs/mdast-util-find-and-replace.mjs +0 -1
  33. package/dist/chunks/libs/mdast-util-from-markdown.mjs +0 -3
  34. package/dist/chunks/libs/mdast-util-gfm.mjs +0 -15
  35. package/dist/chunks/libs/mdast-util-to-hast.mjs +0 -11
  36. package/dist/chunks/libs/merge-error-cause.mjs +0 -2
  37. package/dist/chunks/libs/micromark-extension-gfm.mjs +0 -1
  38. package/dist/chunks/libs/mnemonist.mjs +0 -1
  39. package/dist/chunks/libs/nano-spawn.mjs +0 -3
  40. package/dist/chunks/libs/p-queue.mjs +0 -1
  41. package/dist/chunks/libs/pathe.mjs +0 -1
  42. package/dist/chunks/libs/picomatch.mjs +0 -1
  43. package/dist/chunks/libs/pretty-ms.mjs +0 -1
  44. package/dist/chunks/libs/remark-github-blockquote-alert.mjs +0 -3
  45. package/dist/chunks/libs/remark-rehype.mjs +0 -1
  46. package/dist/chunks/libs/remeda.mjs +0 -1
  47. package/dist/chunks/libs/ufo.mjs +0 -1
  48. package/dist/chunks/libs/unified.mjs +0 -1
  49. package/dist/chunks/libs/unstorage.mjs +0 -1
  50. package/dist/chunks/rolldown-runtime.mjs +0 -1
@@ -1 +0,0 @@
1
- import"../rolldown-runtime.mjs";String.fromCharCode;const e=/^[\s\w\0+.-]{2,}:([/\\]{1,2})/,t=/^[\s\w\0+.-]{2,}:([/\\]{2})?/,n=/^([/\\]\s*){2,}[^/\\]/,r=/\/$|\/\?|\/#/,i=/^\.?\//;function isRelative(e){return[`./`,`../`].some(t=>e.startsWith(t))}function hasProtocol(r,i={}){return typeof i==`boolean`&&(i={acceptRelative:i}),i.strict?e.test(r):t.test(r)||(i.acceptRelative?n.test(r):!1)}function hasTrailingSlash(e=``,t){return t?r.test(e):e.endsWith(`/`)}function withoutTrailingSlash(e=``,t){if(!t)return(hasTrailingSlash(e)?e.slice(0,-1):e)||`/`;if(!hasTrailingSlash(e,!0))return e||`/`;let n=e,r=``,i=e.indexOf(`#`);i!==-1&&(n=e.slice(0,i),r=e.slice(i));let[a,...o]=n.split(`?`);return((a.endsWith(`/`)?a.slice(0,-1):a)||`/`)+(o.length>0?`?${o.join(`?`)}`:``)+r}function withTrailingSlash(e=``,t){if(!t)return e.endsWith(`/`)?e:e+`/`;if(hasTrailingSlash(e,!0))return e||`/`;let n=e,r=``,i=e.indexOf(`#`);if(i!==-1&&(n=e.slice(0,i),r=e.slice(i),!n))return r;let[a,...o]=n.split(`?`);return a+`/`+(o.length>0?`?${o.join(`?`)}`:``)+r}function hasLeadingSlash(e=``){return e.startsWith(`/`)}function withoutLeadingSlash(e=``){return(hasLeadingSlash(e)?e.slice(1):e)||`/`}function cleanDoubleSlashes(e=``){return e.split(`://`).map(e=>e.replace(/\/{2,}/g,`/`)).join(`://`)}function withoutBase(e,t){if(isEmptyURL(t))return e;let n=withoutTrailingSlash(t);if(!e.startsWith(n))return e;let r=e[n.length];return r&&r!==`/`&&r!==`?`?e:`/`+e.slice(n.length).replace(/^\/+/,``)}function isEmptyURL(e){return!e||e===`/`}function isNonEmptyURL(e){return e&&e!==`/`}function joinURL(e,...t){let n=e||``;for(let e of t.filter(e=>isNonEmptyURL(e)))if(n){let t=e.replace(i,``);n=withTrailingSlash(n)+t}else n=e;return n}function joinRelativeURL(...e){let t=/\/(?!\/)/,n=e.filter(Boolean),r=[],i=0;for(let e of n)if(!(!e||e===`/`)){for(let[n,a]of e.split(t).entries())if(!(!a||a===`.`)){if(a===`..`){if(r.length===1&&hasProtocol(r[0]))continue;r.pop(),i--;continue}if(n===1&&r[r.length-1]?.endsWith(`:/`)){r[r.length-1]+=`/`+a;continue}r.push(a),i++}}let a=r.join(`/`);return i>=0?n[0]?.startsWith(`/`)&&!a.startsWith(`/`)?a=`/`+a:n[0]?.startsWith(`./`)&&!a.startsWith(`./`)&&(a=`./`+a):a=`../`.repeat(-1*i)+a,n[n.length-1]?.endsWith(`/`)&&!a.endsWith(`/`)&&(a+=`/`),a}export{joinRelativeURL as a,withoutBase as c,isRelative as i,withoutLeadingSlash as l,hasLeadingSlash as n,joinURL as o,hasProtocol as r,withTrailingSlash as s,cleanDoubleSlashes as t,withoutTrailingSlash as u};
@@ -1 +0,0 @@
1
- import{a as e,r as t,t as n}from"../rolldown-runtime.mjs";import"./mdast-util-gfm.mjs";import{n as r}from"./mdast-util-from-markdown.mjs";import{r as i}from"./merge-error-cause.mjs";import a from"node:path";import o from"node:process";import{fileURLToPath as s}from"node:url";function bail(e){if(e)throw e}var c=n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function isArray(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function isPlainObject(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function setProperty(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function getProperty(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function extend(){var e,t,n,r,i,a,u=arguments[0],d=1,f=arguments.length,p=!1;for(typeof u==`boolean`&&(p=u,u=arguments[1]||{},d=2),(u==null||typeof u!=`object`&&typeof u!=`function`)&&(u={});d<f;++d)if(e=arguments[d],e!=null)for(t in e)n=l(u,t),r=l(e,t),u!==r&&(p&&r&&(s(r)||(i=o(r)))?(i?(i=!1,a=n&&o(n)?n:[]):a=n&&s(n)?n:{},c(u,{name:t,newValue:extend(p,a,r)})):r!==void 0&&c(u,{name:t,newValue:r}));return u}}));function trough(){let e=[],t={run,use};return t;function run(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);next(null,...t);function next(i,...a){let o=e[++n],s=-1;if(i){r(i);return}for(;++s<t.length;)(a[s]===null||a[s]===void 0)&&(a[s]=t[s]);t=a,o?wrap(o,next)(...a):r(null,...a)}}function use(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function wrap(e,t){let n;return wrapped;function wrapped(...t){let r=e.length>t.length,i;r&&t.push(done);try{i=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return done(t)}r||(i&&i.then&&typeof i.then==`function`?i.then(then,done):i instanceof Error?done(i):then(i))}function done(e,...r){n||(n=!0,t(e,...r))}function then(e){done(null,e)}}var VFileMessage=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let i=``,a={},o=!1;if(t&&(a=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?i=e:!a.cause&&e&&(o=!0,i=e.message,a.cause=e),!a.ruleId&&!a.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?a.ruleId=n:(a.source=n.slice(0,e),a.ruleId=n.slice(e+1))}if(!a.place&&a.ancestors&&a.ancestors){let e=a.ancestors[a.ancestors.length-1];e&&(a.place=e.position)}let s=a.place&&`start`in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file,this.message=i,this.line=s?s.line:void 0,this.name=r(a.place)||`1:1`,this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=o&&a.cause&&typeof a.cause.stack==`string`?a.cause.stack:``,this.actual,this.expected,this.note,this.url}};VFileMessage.prototype.file=``,VFileMessage.prototype.name=``,VFileMessage.prototype.reason=``,VFileMessage.prototype.message=``,VFileMessage.prototype.stack=``,VFileMessage.prototype.column=void 0,VFileMessage.prototype.line=void 0,VFileMessage.prototype.ancestors=void 0,VFileMessage.prototype.cause=void 0,VFileMessage.prototype.fatal=void 0,VFileMessage.prototype.place=void 0,VFileMessage.prototype.ruleId=void 0,VFileMessage.prototype.source=void 0;function isUrl(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}const l=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`];var VFile=class{constructor(e){let t;t=e?isUrl(e)?{path:e}:typeof e==`string`||isUint8Array$1(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:o.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<l.length;){let e=l[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)l.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?a.basename(this.path):void 0}set basename(e){assertNonEmpty(e,`basename`),assertPart(e,`basename`),this.path=a.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?a.dirname(this.path):void 0}set dirname(e){assertPath(this.basename,`dirname`),this.path=a.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?a.extname(this.path):void 0}set extname(e){if(assertPart(e,`extname`),assertPath(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=a.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){isUrl(e)&&(e=s(e)),assertNonEmpty(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?a.basename(this.path,this.extname):void 0}set stem(e){assertNonEmpty(e,`stem`),assertPart(e,`stem`),this.path=a.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new VFileMessage(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function assertPart(e,t){if(e&&e.includes(a.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+a.sep+"`")}function assertNonEmpty(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function assertPath(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function isUint8Array$1(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}t(isUint8Array$1,`isUint8Array`);var u=e(c(),1);const CallableInstance=(function(e){let t=this.constructor.prototype,n=t[e],apply=function(){return n.apply(apply,arguments)};return Object.setPrototypeOf(apply,t),apply}),d={}.hasOwnProperty,f=new class Processor extends CallableInstance{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=trough()}copy(){let e=new Processor,t=-1;for(;++t<this.attachers.length;){let n=this.attachers[t];e.use(...n)}return e.data((0,u.default)(!0,{},this.namespace)),e}data(e,t){return typeof e==`string`?arguments.length===2?(assertUnfrozen(`data`,this.frozen),this.namespace[e]=t,this):d.call(this.namespace,e)&&this.namespace[e]||void 0:e?(assertUnfrozen(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=vfile(e),n=this.parser||this.Parser;return assertParser(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),assertParser(`process`,this.parser||this.Parser),assertCompiler(`process`,this.compiler||this.Compiler),t?executor(void 0,t):new Promise(executor);function executor(r,i){let a=vfile(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return realDone(e);let i=t,a=n.stringify(i,r);looksLikeAValue(a)?r.value=a:r.result=a,realDone(e,r)});function realDone(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),assertParser(`processSync`,this.parser||this.Parser),assertCompiler(`processSync`,this.compiler||this.Compiler),this.process(e,realDone),assertDone(`processSync`,`process`,t),n;function realDone(e,r){t=!0,bail(e),n=r}}run(e,t,n){assertNode(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?executor(void 0,n):new Promise(executor);function executor(i,a){let o=vfile(t);r.run(e,o,realDone);function realDone(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,realDone),assertDone(`runSync`,`run`,n),r;function realDone(e,t){bail(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=vfile(t),r=this.compiler||this.Compiler;return assertCompiler(`stringify`,r),assertNode(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(assertUnfrozen(`use`,this.frozen),e!=null)if(typeof e==`function`)addPlugin(e,t);else if(typeof e==`object`)Array.isArray(e)?addList(e):addPreset(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function add(e){if(typeof e==`function`)addPlugin(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;addPlugin(t,n)}else addPreset(e);else throw TypeError("Expected usable value, not `"+e+"`")}function addPreset(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");addList(e.plugins),e.settings&&(r.settings=(0,u.default)(!0,r.settings,e.settings))}function addList(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];add(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function addPlugin(e,t){let r=-1,a=-1;for(;++r<n.length;)if(n[r][0]===e){a=r;break}if(a===-1)n.push([e,...t]);else if(t.length>0){let[r,...o]=t,s=n[a][1];i(s)&&i(r)&&(r=(0,u.default)(!0,s,r)),n[a]=[e,r,...o]}}}}().freeze();function assertParser(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function assertCompiler(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function assertUnfrozen(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function assertNode(e){if(!i(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function assertDone(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function vfile(e){return looksLikeAVFile(e)?e:new VFile(e)}function looksLikeAVFile(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function looksLikeAValue(e){return typeof e==`string`||isUint8Array(e)}function isUint8Array(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}export{f as t};
@@ -1 +0,0 @@
1
- import"../rolldown-runtime.mjs";const e=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,t=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,n=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function jsonParseTransform(e,t){if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t){warnKeyDropped(e);return}return t}function warnKeyDropped(e){console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`)}function destr(r,i={}){if(typeof r!=`string`)return r;if(r[0]===`"`&&r[r.length-1]===`"`&&r.indexOf(`\\`)===-1)return r.slice(1,-1);let a=r.trim();if(a.length<=9)switch(a.toLowerCase()){case`true`:return!0;case`false`:return!1;case`undefined`:return;case`null`:return null;case`nan`:return NaN;case`infinity`:return 1/0;case`-infinity`:return-1/0}if(!n.test(r)){if(i.strict)throw SyntaxError(`[destr] Invalid JSON`);return r}try{if(e.test(r)||t.test(r)){if(i.strict)throw Error(`[destr] Possible prototype pollution`);return JSON.parse(r,jsonParseTransform)}return JSON.parse(r)}catch(e){if(i.strict)throw e;return r}}function wrapToPromise(e){return!e||typeof e.then!=`function`?Promise.resolve(e):e}function asyncCall(e,...t){try{return wrapToPromise(e(...t))}catch(e){return Promise.reject(e)}}function isPrimitive(e){let t=typeof e;return e===null||t!==`object`&&t!==`function`}function isPureObject(e){let t=Object.getPrototypeOf(e);return!t||t.isPrototypeOf(Object)}function stringify(e){if(isPrimitive(e))return String(e);if(isPureObject(e)||Array.isArray(e))return JSON.stringify(e);if(typeof e.toJSON==`function`)return stringify(e.toJSON());throw Error(`[unstorage] Cannot stringify value!`)}const r=`base64:`;function serializeRaw(e){return typeof e==`string`?e:r+base64Encode(e)}function deserializeRaw(e){return typeof e!=`string`||!e.startsWith(r)?e:base64Decode(e.slice(7))}function base64Decode(e){return globalThis.Buffer?Buffer.from(e,`base64`):Uint8Array.from(globalThis.atob(e),e=>e.codePointAt(0))}function base64Encode(e){return globalThis.Buffer?Buffer.from(e).toString(`base64`):globalThis.btoa(String.fromCodePoint(...e))}const i=[`has`,`hasItem`,`get`,`getItem`,`getItemRaw`,`set`,`setItem`,`setItemRaw`,`del`,`remove`,`removeItem`,`getMeta`,`setMeta`,`removeMeta`,`getKeys`,`clear`,`mount`,`unmount`];function prefixStorage(e,t){if(t=normalizeBaseKey(t),!t)return e;let n={...e};for(let r of i)n[r]=(n=``,...i)=>e[r](t+n,...i);return n.getKeys=(n=``,...r)=>e.getKeys(t+n,...r).then(e=>e.map(e=>e.slice(t.length))),n.keys=n.getKeys,n.getItems=async(n,r)=>{let i=n.map(e=>typeof e==`string`?t+e:{...e,key:t+e.key});return(await e.getItems(i,r)).map(e=>({key:e.key.slice(t.length),value:e.value}))},n.setItems=async(n,r)=>{let i=n.map(e=>({key:t+e.key,value:e.value,options:e.options}));return e.setItems(i,r)},n}function normalizeKey(e){return e&&e.split(`?`)[0]?.replace(/[/\\]/g,`:`).replace(/:+/g,`:`).replace(/^:|:$/g,``)||``}function joinKeys(...e){return normalizeKey(e.join(`:`))}function normalizeBaseKey(e){return e=normalizeKey(e),e?e+`:`:``}function filterKeyByDepth(e,t){if(t===void 0)return!0;let n=0,r=e.indexOf(`:`);for(;r>-1;)n++,r=e.indexOf(`:`,r+1);return n<=t}function filterKeyByBase(e,t){return t?e.startsWith(t)&&e[e.length-1]!==`$`:e[e.length-1]!==`$`}function defineDriver(e){return e}const a=defineDriver(()=>{let e=new Map;return{name:`memory`,getInstance:()=>e,hasItem(t){return e.has(t)},getItem(t){return e.get(t)??null},getItemRaw(t){return e.get(t)??null},setItem(t,n){e.set(t,n)},setItemRaw(t,n){e.set(t,n)},removeItem(t){e.delete(t)},getKeys(){return[...e.keys()]},clear(){e.clear()},dispose(){e.clear()}}});function createStorage(e={}){let t={mounts:{"":e.driver||a()},mountpoints:[``],watching:!1,watchListeners:[],unwatch:{}},getMount=e=>{for(let n of t.mountpoints)if(e.startsWith(n))return{base:n,relativeKey:e.slice(n.length),driver:t.mounts[n]};return{base:``,relativeKey:e,driver:t.mounts[``]}},getMounts=(e,n)=>t.mountpoints.filter(t=>t.startsWith(e)||n&&e.startsWith(t)).map(n=>({relativeBase:e.length>n.length?e.slice(n.length):void 0,mountpoint:n,driver:t.mounts[n]})),onChange=(e,n)=>{if(t.watching){n=normalizeKey(n);for(let r of t.watchListeners)r(e,n)}},startWatch=async()=>{if(!t.watching){t.watching=!0;for(let e in t.mounts)t.unwatch[e]=await watch(t.mounts[e],onChange,e)}},stopWatch=async()=>{if(t.watching){for(let e in t.unwatch)await t.unwatch[e]();t.unwatch={},t.watching=!1}},runBatch=(e,t,n)=>{let r=new Map,getBatch=e=>{let t=r.get(e.base);return t||(t={driver:e.driver,base:e.base,items:[]},r.set(e.base,t)),t};for(let n of e){let e=typeof n==`string`,r=normalizeKey(e?n:n.key),i=e?void 0:n.value,a=e||!n.options?t:{...t,...n.options},o=getMount(r);getBatch(o).items.push({key:r,value:i,relativeKey:o.relativeKey,options:a})}return Promise.all([...r.values()].map(e=>n(e))).then(e=>e.flat())},n={hasItem(e,t={}){e=normalizeKey(e);let{relativeKey:n,driver:r}=getMount(e);return asyncCall(r.hasItem,n,t)},getItem(e,t={}){e=normalizeKey(e);let{relativeKey:n,driver:r}=getMount(e);return asyncCall(r.getItem,n,t).then(e=>destr(e))},getItems(e,t={}){return runBatch(e,t,e=>e.driver.getItems?asyncCall(e.driver.getItems,e.items.map(e=>({key:e.relativeKey,options:e.options})),t).then(t=>t.map(t=>({key:joinKeys(e.base,t.key),value:destr(t.value)}))):Promise.all(e.items.map(t=>asyncCall(e.driver.getItem,t.relativeKey,t.options).then(e=>({key:t.key,value:destr(e)})))))},getItemRaw(e,t={}){e=normalizeKey(e);let{relativeKey:n,driver:r}=getMount(e);return r.getItemRaw?asyncCall(r.getItemRaw,n,t):asyncCall(r.getItem,n,t).then(e=>deserializeRaw(e))},async setItem(e,t,r={}){if(t===void 0)return n.removeItem(e);e=normalizeKey(e);let{relativeKey:i,driver:a}=getMount(e);a.setItem&&(await asyncCall(a.setItem,i,stringify(t),r),a.watch||onChange(`update`,e))},async setItems(e,t){await runBatch(e,t,async e=>{if(e.driver.setItems)return asyncCall(e.driver.setItems,e.items.map(e=>({key:e.relativeKey,value:stringify(e.value),options:e.options})),t);e.driver.setItem&&await Promise.all(e.items.map(t=>asyncCall(e.driver.setItem,t.relativeKey,stringify(t.value),t.options)))})},async setItemRaw(e,t,r={}){if(t===void 0)return n.removeItem(e,r);e=normalizeKey(e);let{relativeKey:i,driver:a}=getMount(e);if(a.setItemRaw)await asyncCall(a.setItemRaw,i,t,r);else if(a.setItem)await asyncCall(a.setItem,i,serializeRaw(t),r);else return;a.watch||onChange(`update`,e)},async removeItem(e,t={}){typeof t==`boolean`&&(t={removeMeta:t}),e=normalizeKey(e);let{relativeKey:n,driver:r}=getMount(e);r.removeItem&&(await asyncCall(r.removeItem,n,t),(t.removeMeta||t.removeMata)&&await asyncCall(r.removeItem,n+`$`,t),r.watch||onChange(`remove`,e))},async getMeta(e,t={}){typeof t==`boolean`&&(t={nativeOnly:t}),e=normalizeKey(e);let{relativeKey:n,driver:r}=getMount(e),i=Object.create(null);if(r.getMeta&&Object.assign(i,await asyncCall(r.getMeta,n,t)),!t.nativeOnly){let e=await asyncCall(r.getItem,n+`$`,t).then(e=>destr(e));e&&typeof e==`object`&&(typeof e.atime==`string`&&(e.atime=new Date(e.atime)),typeof e.mtime==`string`&&(e.mtime=new Date(e.mtime)),Object.assign(i,e))}return i},setMeta(e,t,n={}){return this.setItem(e+`$`,t,n)},removeMeta(e,t={}){return this.removeItem(e+`$`,t)},async getKeys(e,t={}){e=normalizeBaseKey(e);let n=getMounts(e,!0),r=[],i=[],a=!0;for(let e of n){e.driver.flags?.maxDepth||(a=!1);let n=await asyncCall(e.driver.getKeys,e.relativeBase,t);for(let t of n){let n=e.mountpoint+normalizeKey(t);r.some(e=>n.startsWith(e))||i.push(n)}r=[e.mountpoint,...r.filter(t=>!t.startsWith(e.mountpoint))]}let o=t.maxDepth!==void 0&&!a;return i.filter(n=>(!o||filterKeyByDepth(n,t.maxDepth))&&filterKeyByBase(n,e))},async clear(e,t={}){e=normalizeBaseKey(e),await Promise.all(getMounts(e,!1).map(async e=>{if(e.driver.clear)return asyncCall(e.driver.clear,e.relativeBase,t);if(e.driver.removeItem){let n=await e.driver.getKeys(e.relativeBase||``,t);return Promise.all(n.map(n=>e.driver.removeItem(n,t)))}}))},async dispose(){await Promise.all(Object.values(t.mounts).map(e=>dispose(e)))},async watch(e){return await startWatch(),t.watchListeners.push(e),async()=>{t.watchListeners=t.watchListeners.filter(t=>t!==e),t.watchListeners.length===0&&await stopWatch()}},async unwatch(){t.watchListeners=[],await stopWatch()},mount(e,r){if(e=normalizeBaseKey(e),e&&t.mounts[e])throw Error(`already mounted at ${e}`);return e&&(t.mountpoints.push(e),t.mountpoints.sort((e,t)=>t.length-e.length)),t.mounts[e]=r,t.watching&&Promise.resolve(watch(r,onChange,e)).then(n=>{t.unwatch[e]=n}).catch(console.error),n},async unmount(e,n=!0){e=normalizeBaseKey(e),!(!e||!t.mounts[e])&&(t.watching&&e in t.unwatch&&(t.unwatch[e]?.(),delete t.unwatch[e]),n&&await dispose(t.mounts[e]),t.mountpoints=t.mountpoints.filter(t=>t!==e),delete t.mounts[e])},getMount(e=``){e=normalizeKey(e)+`:`;let t=getMount(e);return{driver:t.driver,base:t.base}},getMounts(e=``,t={}){return e=normalizeKey(e),getMounts(e,t.parents).map(e=>({driver:e.driver,base:e.mountpoint}))},keys:(e,t={})=>n.getKeys(e,t),get:(e,t={})=>n.getItem(e,t),set:(e,t,r={})=>n.setItem(e,t,r),has:(e,t={})=>n.hasItem(e,t),del:(e,t={})=>n.removeItem(e,t),remove:(e,t={})=>n.removeItem(e,t)};return n}function watch(e,t,n){return e.watch?e.watch((e,r)=>t(e,n+r)):()=>{}}async function dispose(e){typeof e.dispose==`function`&&await asyncCall(e.dispose)}export{prefixStorage as n,createStorage as t};
@@ -1 +0,0 @@
1
- var e=Object.create,t=Object.defineProperty,__name=(e,n)=>t(e,`name`,{value:n,configurable:!0}),n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,__commonJSMin=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),__exportAll=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},__copyProps=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},__reExport=(e,t,n)=>(__copyProps(e,t,`default`),n&&__copyProps(n,t,`default`)),__toESM=(n,r,a)=>(a=n==null?{}:e(i(n)),__copyProps(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));export{__toESM as a,__reExport as i,__exportAll as n,__name as r,__commonJSMin as t};