likec4 1.56.0 → 1.58.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__/codegen/react.mjs +7 -8
- package/__app__/codegen/webcomponent.mjs +77 -736
- package/__app__/src/aichat/index.mjs +8 -0
- package/__app__/src/chunks/AIChat.mjs +959 -0
- package/__app__/src/chunks/DiagramActorProvider.mjs +7638 -0
- package/__app__/src/chunks/LikeC4Styles.mjs +1866 -0
- package/__app__/src/chunks/Markdown.mjs +146 -0
- package/__app__/src/chunks/NavigationPanel.mjs +61 -0
- package/__app__/src/chunks/ProjectsOverview.mjs +540 -0
- package/__app__/src/chunks/adhoc-editor.mjs +3386 -0
- package/__app__/src/chunks/es.mjs +439 -0
- package/__app__/src/chunks/hooks.mjs +145 -0
- package/__app__/src/chunks/libs/@dagrejs/dagre.mjs +1894 -0
- package/__app__/src/chunks/libs/@floating-ui.mjs +2218 -0
- package/__app__/src/chunks/libs/@mantine.mjs +12070 -0
- package/__app__/src/chunks/libs/@tabler/icons-react.mjs +252 -0
- package/__app__/src/chunks/libs/@tanstack-ai.mjs +1768 -0
- package/__app__/src/chunks/libs/@tanstack.mjs +2718 -0
- package/__app__/src/chunks/libs/@xstate/react.mjs +1982 -0
- package/__app__/src/chunks/libs/@xyflow/react.mjs +5256 -0
- package/__app__/src/chunks/libs/bezier-js.mjs +1003 -0
- package/__app__/src/chunks/libs/d3.mjs +2842 -0
- package/__app__/src/chunks/libs/fast-equals.mjs +268 -0
- package/__app__/src/chunks/libs/framer.mjs +5872 -0
- package/__app__/src/chunks/libs/remeda.mjs +642 -0
- package/__app__/src/chunks/libs/zod.mjs +3170 -0
- package/__app__/src/chunks/rolldown-runtime.mjs +23 -0
- package/__app__/src/chunks/styled-system.mjs +1040 -0
- package/__app__/src/fonts.css +1 -1
- package/__app__/src/main.mjs +14847 -1
- package/__app__/src/style.css +1 -1
- package/config/schema.json +14 -41
- package/dist/chunks/enableServer.mjs +1 -0
- package/dist/chunks/filenames.mjs +2 -2
- package/dist/chunks/index2.d.mts +2057 -722
- package/dist/chunks/libs/@chevrotain/gast.mjs +1 -1
- package/dist/chunks/libs/@logtape/logtape.mjs +4 -3
- package/dist/chunks/libs/@ts-graphviz/ast.mjs +3 -0
- package/dist/chunks/libs/@ts-graphviz/common.d.mts +9 -0
- package/dist/chunks/libs/@ts-graphviz/core.mjs +1 -0
- package/dist/chunks/libs/chevrotain-allstar.mjs +2 -2
- package/dist/chunks/libs/chevrotain.mjs +26 -26
- package/dist/chunks/libs/langium.d.mts +5 -5
- package/dist/chunks/libs/langium.mjs +10 -10
- package/dist/chunks/libs/merge-error-cause.mjs +1 -1
- package/dist/chunks/libs/pako.mjs +3 -1
- package/dist/chunks/libs/pretty-ms.mjs +1 -1
- package/dist/chunks/libs/remeda.mjs +1 -1
- package/dist/chunks/libs/ufo.mjs +1 -1
- package/dist/chunks/libs/unstorage.mjs +1 -1
- package/dist/chunks/libs/which.mjs +1 -1
- package/dist/chunks/libs/zod.d.mts +60 -25
- package/dist/chunks/libs/zod.mjs +65 -0
- package/dist/chunks/node.mjs +84 -56
- package/dist/chunks/sequence-view.mjs +1 -1
- package/dist/chunks/vite-plugin.mjs +593 -0
- package/dist/cli/index.mjs +184 -141
- package/dist/index.d.mts +2 -131
- package/dist/index.mjs +1 -1
- package/dist/model/index.d.mts +2 -2
- package/dist/vite-plugin/index.d.mts +53 -2
- package/dist/vite-plugin/index.mjs +1 -1
- package/dist/vite-plugin/internal/index.d.mts +327 -4
- package/dist/vite-plugin/internal/index.mjs +946 -1
- package/package.json +85 -72
- package/react/index.d.mts +174 -73
- package/react/index.mjs +42468 -38926
- package/vite-plugin-modules.d.ts +4 -0
- package/__app__/chunks/ColorSchemeToggle.mjs +0 -1
- package/__app__/chunks/DiagramActorProvider.mjs +0 -10
- package/__app__/chunks/Fallback.mjs +0 -1
- package/__app__/chunks/Header.mjs +0 -13
- package/__app__/chunks/IconRenderer.mjs +0 -1
- package/__app__/chunks/LikeC4Diagram.mjs +0 -19
- package/__app__/chunks/LikeC4ModelContext.mjs +0 -1
- package/__app__/chunks/LikeC4ModelContext2.mjs +0 -1
- package/__app__/chunks/LikeC4Styles.mjs +0 -48
- package/__app__/chunks/NavigationPanel.mjs +0 -1
- package/__app__/chunks/StaticLikeC4Diagram.mjs +0 -1
- package/__app__/chunks/ViewReact.mjs +0 -1
- package/__app__/chunks/__root.mjs +0 -1
- package/__app__/chunks/adhoc-editor.mjs +0 -1
- package/__app__/chunks/hooks.mjs +0 -1
- package/__app__/chunks/libs/@dagrejs/dagre.mjs +0 -1
- package/__app__/chunks/libs/@floating-ui/core.mjs +0 -1
- package/__app__/chunks/libs/@floating-ui/dom.mjs +0 -1
- package/__app__/chunks/libs/@floating-ui/react.mjs +0 -1
- package/__app__/chunks/libs/@mantine/core.mjs +0 -41
- package/__app__/chunks/libs/@mantine/hooks.mjs +0 -1
- package/__app__/chunks/libs/@nanostores/react.mjs +0 -1
- package/__app__/chunks/libs/@react-hookz/web.mjs +0 -1
- package/__app__/chunks/libs/@tabler/icons-react.mjs +0 -15
- package/__app__/chunks/libs/@tanstack/history.mjs +0 -1
- package/__app__/chunks/libs/@tanstack/react-router.mjs +0 -3
- package/__app__/chunks/libs/@tanstack/router-core.mjs +0 -1
- package/__app__/chunks/libs/@xstate/react.mjs +0 -1
- package/__app__/chunks/libs/@xstate/store.mjs +0 -1
- package/__app__/chunks/libs/@xyflow/react.mjs +0 -7
- package/__app__/chunks/libs/@zag-js/anatomy.mjs +0 -1
- package/__app__/chunks/libs/@zag-js/collection.mjs +0 -1
- package/__app__/chunks/libs/@zag-js/core.mjs +0 -1
- package/__app__/chunks/libs/@zag-js/react.mjs +0 -1
- package/__app__/chunks/libs/@zag-js/tree-view.mjs +0 -1
- package/__app__/chunks/libs/bezier-js.mjs +0 -1
- package/__app__/chunks/libs/d3-path.mjs +0 -1
- package/__app__/chunks/libs/d3-shape.mjs +0 -1
- package/__app__/chunks/libs/fast-equals.mjs +0 -1
- package/__app__/chunks/libs/framer-motion.mjs +0 -9
- package/__app__/chunks/libs/html-to-image.mjs +0 -2
- package/__app__/chunks/libs/motion-dom.mjs +0 -1
- package/__app__/chunks/libs/motion.mjs +0 -1
- package/__app__/chunks/libs/nanostores.mjs +0 -1
- package/__app__/chunks/libs/react-error-boundary.mjs +0 -1
- package/__app__/chunks/libs/react-resizable-panels.mjs +0 -1
- package/__app__/chunks/libs/remeda.mjs +0 -1
- package/__app__/chunks/libs/xstate.mjs +0 -1
- package/__app__/chunks/libs/zod.mjs +0 -39
- package/__app__/chunks/rolldown-runtime.mjs +0 -1
- package/__app__/chunks/safeCtx.mjs +0 -1
- package/__app__/chunks/searchParams.mjs +0 -1
- package/__app__/chunks/single-index.mjs +0 -1
- package/__app__/chunks/styled-system.mjs +0 -1
- package/__app__/chunks/styles.css.mjs +0 -1
- package/__app__/chunks/useLikeC4Project.mjs +0 -1
- package/__app__/chunks/useUpdateEffect.mjs +0 -1
- package/__app__/src/pages/AdHocViewEditor.mjs +0 -1
- package/__app__/src/pages/EmbedPage.mjs +0 -1
- package/__app__/src/pages/ExportPage.mjs +0 -1
- package/__app__/src/pages/ProjectsOverview.mjs +0 -1
- package/__app__/src/pages/ViewAsD2.mjs +0 -1
- package/__app__/src/pages/ViewAsDot.mjs +0 -1
- package/__app__/src/pages/ViewAsMmd.mjs +0 -1
- package/__app__/src/pages/ViewAsPuml.mjs +0 -1
- package/__app__/src/pages/ViewEditor.mjs +0 -1
- package/__app__/src/pages/ViewReact.mjs +0 -1
- package/__app__/src/routeTree.gen.mjs +0 -1
- package/__app__/src/routes/__root.mjs +0 -1
- package/__app__/src/routes/_single/adhoc.mjs +0 -1
- package/__app__/src/routes/_single/embed._viewId.mjs +0 -1
- package/__app__/src/routes/_single/export._viewId.mjs +0 -1
- package/__app__/src/routes/_single/route.mjs +0 -1
- package/__app__/src/routes/_single/single-index.mjs +0 -1
- package/__app__/src/routes/_single/view._viewId.d2.mjs +0 -1
- package/__app__/src/routes/_single/view._viewId.dot.mjs +0 -1
- package/__app__/src/routes/_single/view._viewId.index.mjs +0 -1
- package/__app__/src/routes/_single/view._viewId.mjs +0 -1
- package/__app__/src/routes/_single/view._viewId.mmd.mjs +0 -1
- package/__app__/src/routes/_single/view._viewId.puml.mjs +0 -1
- package/__app__/src/routes/_single/webcomponent._.mjs +0 -33
- package/__app__/src/routes/index.mjs +0 -1
- package/__app__/src/routes/project._projectId/-components.mjs +0 -1
- package/__app__/src/routes/project._projectId/adhoc.mjs +0 -1
- package/__app__/src/routes/project._projectId/embed._viewId.mjs +0 -1
- package/__app__/src/routes/project._projectId/export._viewId.mjs +0 -1
- package/__app__/src/routes/project._projectId/index.mjs +0 -1
- package/__app__/src/routes/project._projectId/route.mjs +0 -1
- package/__app__/src/routes/project._projectId/view._viewId.d2.mjs +0 -1
- package/__app__/src/routes/project._projectId/view._viewId.dot.mjs +0 -1
- package/__app__/src/routes/project._projectId/view._viewId.index.mjs +0 -1
- package/__app__/src/routes/project._projectId/view._viewId.mjs +0 -1
- package/__app__/src/routes/project._projectId/view._viewId.mmd.mjs +0 -1
- package/__app__/src/routes/project._projectId/view._viewId.puml.mjs +0 -1
- package/__app__/src/routes/projects.mjs +0 -1
- package/dist/chunks/libs/@chevrotain/utils.mjs +0 -1
- package/dist/chunks/libs/@hono/mcp.mjs +0 -45
- package/dist/chunks/libs/@hono/node-server.mjs +0 -1
- package/dist/chunks/libs/@logtape/logtape.d.mts +0 -1023
- package/dist/chunks/libs/@modelcontextprotocol/sdk.mjs +0 -12
- package/dist/chunks/libs/ajv.mjs +0 -1
- package/dist/chunks/libs/ansi-align.mjs +0 -2
- package/dist/chunks/libs/ansi-regex.mjs +0 -1
- package/dist/chunks/libs/ansi-styles.mjs +0 -1
- package/dist/chunks/libs/atomically.mjs +0 -1
- package/dist/chunks/libs/boxen.mjs +0 -22
- package/dist/chunks/libs/conf.mjs +0 -1
- package/dist/chunks/libs/defu.mjs +0 -1
- package/dist/chunks/libs/destr.mjs +0 -1
- package/dist/chunks/libs/find-up-simple.mjs +0 -1
- package/dist/chunks/libs/get-port.mjs +0 -1
- package/dist/chunks/libs/hono.mjs +0 -1
- package/dist/chunks/libs/is-docker.mjs +0 -1
- package/dist/chunks/libs/is-error-instance.mjs +0 -1
- package/dist/chunks/libs/is-inside-container.mjs +0 -1
- package/dist/chunks/libs/is-plain-obj.mjs +0 -1
- package/dist/chunks/libs/isexe.mjs +0 -1
- package/dist/chunks/libs/ky.mjs +0 -3
- package/dist/chunks/libs/p-debounce.mjs +0 -1
- package/dist/chunks/libs/p-limit.mjs +0 -1
- package/dist/chunks/libs/p-timeout.mjs +0 -1
- package/dist/chunks/libs/package-up.mjs +0 -1
- package/dist/chunks/libs/parse-ms.mjs +0 -1
- package/dist/chunks/libs/safe-stringify.mjs +0 -1
- package/dist/chunks/libs/strip-indent.mjs +0 -1
- package/dist/chunks/libs/tinyrainbow.mjs +0 -1
- package/dist/chunks/libs/ts-graphviz.d.mts +0 -12
- package/dist/chunks/libs/ts-graphviz.mjs +0 -4
- package/dist/chunks/libs/vscode-languageserver.mjs +0 -1
- package/dist/chunks/libs/word-wrap.mjs +0 -12
- package/dist/chunks/plugin.mjs +0 -400
- package/dist/vite-plugin/internal/chunks/libs/@nanostores/react.d.mts +0 -269
- package/dist/vite-plugin/internal/chunks/libs/@nanostores/react.mjs +0 -1
- package/dist/vite-plugin/internal/chunks/libs/birpc.mjs +0 -1
- package/dist/vite-plugin/internal/chunks/libs/fast-equals.mjs +0 -1
- package/dist/vite-plugin/internal/chunks/libs/nanostores.d.mts +0 -59
- package/dist/vite-plugin/internal/chunks/libs/nanostores.mjs +0 -1
- package/dist/vite-plugin/internal/chunks/libs/remeda.mjs +0 -1
- package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"../../rolldown-runtime.mjs";import e from"node:crypto";import{createServer as t}from"node:http";import{Http2ServerRequest as n,constants as r}from"node:http2";import{Readable as i}from"node:stream";var RequestError=class extends Error{constructor(e,t){super(e,t),this.name=`RequestError`}},toRequestError=e=>e instanceof RequestError?e:new RequestError(e.message,{cause:e}),a=global.Request,Request=class extends a{constructor(e,t){typeof e==`object`&&s in e&&(e=e[s]()),t?.body?.getReader!==void 0&&(t.duplex??=`half`),super(e,t)}},newHeadersFromIncoming=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)},o=Symbol(`wrapBodyStream`),newRequestFromIncoming=(e,t,n,r,a)=>{let s={method:e,headers:n,signal:a.signal};if(e===`TRACE`){s.method=`GET`;let e=new Request(t,s);return Object.defineProperty(e,`method`,{get(){return`TRACE`}}),e}if(!(e===`GET`||e===`HEAD`))if(`rawBody`in r&&r.rawBody instanceof Buffer)s.body=new ReadableStream({start(e){e.enqueue(r.rawBody),e.close()}});else if(r[o]){let e;s.body=new ReadableStream({async pull(t){try{e||=i.toWeb(r).getReader();let{done:n,value:a}=await e.read();n?t.close():t.enqueue(a)}catch(e){t.error(e)}}})}else s.body=i.toWeb(r);return new Request(t,s)},s=Symbol(`getRequestCache`),c=Symbol(`requestCache`),l=Symbol(`incomingKey`),u=Symbol(`urlKey`),d=Symbol(`headersKey`),f=Symbol(`abortControllerKey`),p={get method(){return this[l].method||`GET`},get url(){return this[u]},get headers(){return this[d]||=newHeadersFromIncoming(this[l])},[Symbol(`getAbortController`)](){return this[s](),this[f]},[s](){return this[f]||=new AbortController,this[c]||=newRequestFromIncoming(this.method,this[u],this.headers,this[l],this[f])}};[`body`,`bodyUsed`,`cache`,`credentials`,`destination`,`integrity`,`mode`,`redirect`,`referrer`,`referrerPolicy`,`signal`,`keepalive`].forEach(e=>{Object.defineProperty(p,e,{get(){return this[s]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(p,e,{value:function(){return this[s]()[e]()}})}),Object.setPrototypeOf(p,Request.prototype);var newRequest=(e,t)=>{let r=Object.create(p);r[l]=e;let i=e.url||``;if(i[0]!==`/`&&(i.startsWith(`http://`)||i.startsWith(`https://`))){if(e instanceof n)throw new RequestError(`Absolute URL for :path is not allowed in HTTP/2`);try{r[u]=new URL(i).href}catch(e){throw new RequestError(`Invalid absolute URL`,{cause:e})}return r}let a=(e instanceof n?e.authority:e.headers.host)||t;if(!a)throw new RequestError(`Missing host header`);let o;if(e instanceof n){if(o=e.scheme,!(o===`http`||o===`https`))throw new RequestError(`Unsupported scheme`)}else o=e.socket&&e.socket.encrypted?`https`:`http`;let s=new URL(`${o}://${a}${i}`);if(s.hostname.length!==a.length&&s.hostname!==a.replace(/:\d+$/,``))throw new RequestError(`Invalid host header`);return r[u]=s.href,r},m=Symbol(`responseCache`),h=Symbol(`getResponseCache`),g=Symbol(`cache`),_=global.Response,v=class _Response{#e;#t;[h](){return delete this[g],this[m]||=new _(this.#e,this.#t)}constructor(e,t){let n;if(this.#e=e,t instanceof _Response){let e=t[m];if(e){this.#t=e,this[h]();return}else this.#t=t.#t,n=new Headers(t.#t.headers)}else this.#t=t;(typeof e==`string`||e?.getReader!==void 0||e instanceof Blob||e instanceof Uint8Array)&&(this[g]=[t?.status||200,e,n||t?.headers])}get headers(){let e=this[g];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":`text/plain; charset=UTF-8`})),e[2]):this[h]().headers}get status(){return this[g]?.[0]??this[h]().status}get ok(){let e=this.status;return e>=200&&e<300}};[`body`,`bodyUsed`,`redirected`,`statusText`,`trailers`,`type`,`url`].forEach(e=>{Object.defineProperty(v.prototype,e,{get(){return this[h]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(v.prototype,e,{value:function(){return this[h]()[e]()}})}),Object.setPrototypeOf(v,_),Object.setPrototypeOf(v.prototype,_.prototype);async function readWithoutBlocking(e){return Promise.race([e,Promise.resolve().then(()=>Promise.resolve(void 0))])}function writeFromReadableStreamDefaultReader(e,t,n){let cancel=t=>{e.cancel(t).catch(()=>{})};return t.on(`close`,cancel),t.on(`error`,cancel),(n??e.read()).then(flow,handleStreamError),e.closed.finally(()=>{t.off(`close`,cancel),t.off(`error`,cancel)});function handleStreamError(e){e&&t.destroy(e)}function onDrain(){e.read().then(flow,handleStreamError)}function flow({done:n,value:r}){try{if(n)t.end();else if(!t.write(r))t.once(`drain`,onDrain);else return e.read().then(flow,handleStreamError)}catch(e){handleStreamError(e)}}}function writeFromReadableStream(e,t){if(e.locked)throw TypeError(`ReadableStream is locked.`);return t.destroyed?void 0:writeFromReadableStreamDefaultReader(e.getReader(),t)}var buildOutgoingHttpHeaders=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},y=`x-hono-already-sent`;global.crypto===void 0&&(global.crypto=e);var b=Symbol(`outgoingEnded`),x=Symbol(`incomingDraining`),S=500,C=64*1024*1024,drainIncoming=e=>{let t=e;if(e.destroyed||t[x])return;if(t[x]=!0,e instanceof n){try{e.stream?.close?.(r.NGHTTP2_NO_ERROR)}catch{}return}let i=0,cleanup=()=>{clearTimeout(a),e.off(`data`,onData),e.off(`end`,cleanup),e.off(`error`,cleanup)},forceClose=()=>{cleanup();let t=e.socket;t&&!t.destroyed&&t.destroySoon()},a=setTimeout(forceClose,S);a.unref?.();let onData=e=>{i+=e.length,i>C&&forceClose()};e.on(`data`,onData),e.on(`end`,cleanup),e.on(`error`,cleanup),e.resume()},handleRequestError=()=>new Response(null,{status:400}),handleFetchError=e=>new Response(null,{status:e instanceof Error&&(e.name===`TimeoutError`||e.constructor.name===`TimeoutError`)?504:500}),handleResponseError=(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))},flushHeaders=e=>{`flushHeaders`in e&&e.writable&&e.flushHeaders()},responseViaCache=async(e,t)=>{let[n,r,i]=e[g],a=!1;if(!i)i={"content-type":`text/plain; charset=UTF-8`};else if(i instanceof Headers)a=i.has(`content-length`),i=buildOutgoingHttpHeaders(i);else if(Array.isArray(i)){let e=new Headers(i);a=e.has(`content-length`),i=buildOutgoingHttpHeaders(e)}else for(let e in i)if(e.length===14&&e.toLowerCase()===`content-length`){a=!0;break}a||(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())):(flushHeaders(t),await writeFromReadableStream(r,t)?.catch(e=>handleResponseError(e,t))),t[b]?.()},isPromise=e=>typeof e.then==`function`,responseViaResponseObject=async(e,t,n={})=>{if(isPromise(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(handleFetchError);if(g in e)return responseViaCache(e,t);let r=buildOutgoingHttpHeaders(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 readWithoutBlocking(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&&flushHeaders(t),await writeFromReadableStreamDefaultReader(n,t,o))}else r[y]||(t.writeHead(e.status,r),t.end());t[b]?.()},getRequestListener=(e,t={})=>{let r=t.autoCleanupIncoming??!0;return t.overrideGlobalObjects!==!1&&global.Request!==Request&&(Object.defineProperty(global,`Request`,{value:Request}),Object.defineProperty(global,`Response`,{value:v})),async(i,a)=>{let s,c;try{c=newRequest(i,t.hostname);let l=!r||i.method===`GET`||i.method===`HEAD`;if(l||(i[o]=!0,i.on(`end`,()=>{l=!0}),i instanceof n&&(a[b]=()=>{l||setTimeout(()=>{l||setTimeout(()=>{drainIncoming(i)})})}),a.on(`finish`,()=>{l||drainIncoming(i)})),a.on(`close`,()=>{c[f]&&(i.errored?c[f].abort(i.errored.toString()):a.writableFinished||c[f].abort(`Client connection prematurely closed.`)),l||setTimeout(()=>{l||setTimeout(()=>{drainIncoming(i)})})}),s=e(c,{incoming:i,outgoing:a}),g in s)return responseViaCache(s,a)}catch(e){if(s)return handleResponseError(e,a);if(t.errorHandler){if(s=await t.errorHandler(c?e:toRequestError(e)),!s)return}else s=c?handleFetchError(e):handleRequestError()}try{return await responseViaResponseObject(s,a,t)}catch(e){return handleResponseError(e,a)}}},createAdaptorServer=e=>{let n=e.fetch,r=getRequestListener(n,{hostname:e.hostname,overrideGlobalObjects:e.overrideGlobalObjects,autoCleanupIncoming:e.autoCleanupIncoming});return(e.createServer||t)(e.serverOptions||{},r)},serve=(e,t)=>{let n=createAdaptorServer(e);return n.listen(e?.port??3e3,e.hostname,()=>{let e=n.address();t&&t(e)}),n};export{serve as t};
|