@tonyclaw/llm-inspector 1.6.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.
Files changed (286) hide show
  1. package/.output/nitro.json +17 -0
  2. package/.output/public/assets/alibaba-TTwafVwX.svg +1 -0
  3. package/.output/public/assets/index-B3RwBPLW.css +1 -0
  4. package/.output/public/assets/index-s4lwsWvq.js +97 -0
  5. package/.output/public/assets/main-Cp8AM0Pa.js +17 -0
  6. package/.output/public/assets/minimax-BPMzvuL-.jpeg +0 -0
  7. package/.output/public/assets/qwen-CONDcHqt.png +0 -0
  8. package/.output/public/assets/zhipuai-BPNAnxo-.svg +219 -0
  9. package/.output/server/_chunks/ssr-renderer.mjs +17 -0
  10. package/.output/server/_libs/@radix-ui/react-accessible-icon+[...].mjs +1 -0
  11. package/.output/server/_libs/@radix-ui/react-dismissable-layer+[...].mjs +210 -0
  12. package/.output/server/_libs/@radix-ui/react-navigation-menu+[...].mjs +1 -0
  13. package/.output/server/_libs/@radix-ui/react-one-time-password-field+[...].mjs +1 -0
  14. package/.output/server/_libs/@radix-ui/react-password-toggle-field+[...].mjs +1 -0
  15. package/.output/server/_libs/@radix-ui/react-use-callback-ref+[...].mjs +11 -0
  16. package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +69 -0
  17. package/.output/server/_libs/@radix-ui/react-use-effect-event+[...].mjs +1 -0
  18. package/.output/server/_libs/@radix-ui/react-use-escape-keydown+[...].mjs +17 -0
  19. package/.output/server/_libs/@radix-ui/react-use-is-hydrated+[...].mjs +1 -0
  20. package/.output/server/_libs/@radix-ui/react-use-layout-effect+[...].mjs +6 -0
  21. package/.output/server/_libs/@radix-ui/react-visually-hidden+[...].mjs +34 -0
  22. package/.output/server/_libs/ajv-formats.mjs +330 -0
  23. package/.output/server/_libs/ajv.mjs +11444 -0
  24. package/.output/server/_libs/aria-hidden.mjs +122 -0
  25. package/.output/server/_libs/atomically.mjs +152 -0
  26. package/.output/server/_libs/bail.mjs +8 -0
  27. package/.output/server/_libs/character-entities.mjs +2130 -0
  28. package/.output/server/_libs/class-variance-authority.mjs +44 -0
  29. package/.output/server/_libs/clsx.mjs +16 -0
  30. package/.output/server/_libs/comma-separated-tokens.mjs +10 -0
  31. package/.output/server/_libs/conf.mjs +635 -0
  32. package/.output/server/_libs/cookie-es.mjs +58 -0
  33. package/.output/server/_libs/core-util-is.mjs +75 -0
  34. package/.output/server/_libs/croner.mjs +1 -0
  35. package/.output/server/_libs/crossws.mjs +1 -0
  36. package/.output/server/_libs/debounce-fn.mjs +69 -0
  37. package/.output/server/_libs/decode-named-character-reference+[...].mjs +8 -0
  38. package/.output/server/_libs/detect-node-es.mjs +1 -0
  39. package/.output/server/_libs/devlop.mjs +8 -0
  40. package/.output/server/_libs/dot-prop.mjs +265 -0
  41. package/.output/server/_libs/env-paths.mjs +57 -0
  42. package/.output/server/_libs/estree-util-is-identifier-name.mjs +11 -0
  43. package/.output/server/_libs/extend.mjs +97 -0
  44. package/.output/server/_libs/fast-deep-equal.mjs +38 -0
  45. package/.output/server/_libs/fast-uri.mjs +812 -0
  46. package/.output/server/_libs/floating-ui__core.mjs +725 -0
  47. package/.output/server/_libs/floating-ui__dom.mjs +622 -0
  48. package/.output/server/_libs/floating-ui__react-dom.mjs +292 -0
  49. package/.output/server/_libs/floating-ui__utils.mjs +320 -0
  50. package/.output/server/_libs/get-nonce.mjs +9 -0
  51. package/.output/server/_libs/h3-v2.mjs +276 -0
  52. package/.output/server/_libs/h3.mjs +400 -0
  53. package/.output/server/_libs/hast-util-to-jsx-runtime.mjs +388 -0
  54. package/.output/server/_libs/hast-util-whitespace.mjs +10 -0
  55. package/.output/server/_libs/hookable.mjs +1 -0
  56. package/.output/server/_libs/html-url-attributes.mjs +26 -0
  57. package/.output/server/_libs/immediate.mjs +74 -0
  58. package/.output/server/_libs/inherits.mjs +50 -0
  59. package/.output/server/_libs/inline-style-parser.mjs +142 -0
  60. package/.output/server/_libs/is-plain-obj.mjs +10 -0
  61. package/.output/server/_libs/isarray.mjs +14 -0
  62. package/.output/server/_libs/isbot.mjs +20 -0
  63. package/.output/server/_libs/json-schema-traverse.mjs +180 -0
  64. package/.output/server/_libs/jszip.mjs +3049 -0
  65. package/.output/server/_libs/lie.mjs +273 -0
  66. package/.output/server/_libs/lucide-react.mjs +368 -0
  67. package/.output/server/_libs/mdast-util-from-markdown.mjs +717 -0
  68. package/.output/server/_libs/mdast-util-to-hast.mjs +710 -0
  69. package/.output/server/_libs/mdast-util-to-string.mjs +38 -0
  70. package/.output/server/_libs/micromark-core-commonmark.mjs +2259 -0
  71. package/.output/server/_libs/micromark-factory-destination.mjs +94 -0
  72. package/.output/server/_libs/micromark-factory-label.mjs +63 -0
  73. package/.output/server/_libs/micromark-factory-space.mjs +24 -0
  74. package/.output/server/_libs/micromark-factory-title.mjs +65 -0
  75. package/.output/server/_libs/micromark-factory-whitespace.mjs +22 -0
  76. package/.output/server/_libs/micromark-util-character.mjs +44 -0
  77. package/.output/server/_libs/micromark-util-chunked.mjs +36 -0
  78. package/.output/server/_libs/micromark-util-classify-character+[...].mjs +12 -0
  79. package/.output/server/_libs/micromark-util-combine-extensions+[...].mjs +41 -0
  80. package/.output/server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +19 -0
  81. package/.output/server/_libs/micromark-util-decode-string.mjs +21 -0
  82. package/.output/server/_libs/micromark-util-encode.mjs +1 -0
  83. package/.output/server/_libs/micromark-util-html-tag-name.mjs +69 -0
  84. package/.output/server/_libs/micromark-util-normalize-identifier+[...].mjs +6 -0
  85. package/.output/server/_libs/micromark-util-resolve-all.mjs +15 -0
  86. package/.output/server/_libs/micromark-util-sanitize-uri.mjs +41 -0
  87. package/.output/server/_libs/micromark-util-subtokenize.mjs +346 -0
  88. package/.output/server/_libs/micromark.mjs +906 -0
  89. package/.output/server/_libs/mimic-function.mjs +47 -0
  90. package/.output/server/_libs/ohash.mjs +1 -0
  91. package/.output/server/_libs/pako.mjs +4223 -0
  92. package/.output/server/_libs/process-nextick-args.mjs +48 -0
  93. package/.output/server/_libs/property-information.mjs +1209 -0
  94. package/.output/server/_libs/radix-ui.mjs +1 -0
  95. package/.output/server/_libs/radix-ui__number.mjs +6 -0
  96. package/.output/server/_libs/radix-ui__primitive.mjs +11 -0
  97. package/.output/server/_libs/radix-ui__react-accordion.mjs +1 -0
  98. package/.output/server/_libs/radix-ui__react-alert-dialog.mjs +1 -0
  99. package/.output/server/_libs/radix-ui__react-arrow.mjs +23 -0
  100. package/.output/server/_libs/radix-ui__react-aspect-ratio.mjs +1 -0
  101. package/.output/server/_libs/radix-ui__react-avatar.mjs +1 -0
  102. package/.output/server/_libs/radix-ui__react-checkbox.mjs +1 -0
  103. package/.output/server/_libs/radix-ui__react-collapsible.mjs +144 -0
  104. package/.output/server/_libs/radix-ui__react-collection.mjs +69 -0
  105. package/.output/server/_libs/radix-ui__react-compose-refs.mjs +39 -0
  106. package/.output/server/_libs/radix-ui__react-context-menu.mjs +1 -0
  107. package/.output/server/_libs/radix-ui__react-context.mjs +78 -0
  108. package/.output/server/_libs/radix-ui__react-dialog.mjs +325 -0
  109. package/.output/server/_libs/radix-ui__react-direction.mjs +9 -0
  110. package/.output/server/_libs/radix-ui__react-dropdown-menu.mjs +1 -0
  111. package/.output/server/_libs/radix-ui__react-focus-guards.mjs +29 -0
  112. package/.output/server/_libs/radix-ui__react-focus-scope.mjs +206 -0
  113. package/.output/server/_libs/radix-ui__react-form.mjs +1 -0
  114. package/.output/server/_libs/radix-ui__react-hover-card.mjs +1 -0
  115. package/.output/server/_libs/radix-ui__react-id.mjs +14 -0
  116. package/.output/server/_libs/radix-ui__react-label.mjs +1 -0
  117. package/.output/server/_libs/radix-ui__react-menu.mjs +1 -0
  118. package/.output/server/_libs/radix-ui__react-menubar.mjs +1 -0
  119. package/.output/server/_libs/radix-ui__react-popover.mjs +1 -0
  120. package/.output/server/_libs/radix-ui__react-popper.mjs +286 -0
  121. package/.output/server/_libs/radix-ui__react-portal.mjs +16 -0
  122. package/.output/server/_libs/radix-ui__react-presence.mjs +128 -0
  123. package/.output/server/_libs/radix-ui__react-primitive.mjs +42 -0
  124. package/.output/server/_libs/radix-ui__react-progress.mjs +1 -0
  125. package/.output/server/_libs/radix-ui__react-radio-group.mjs +1 -0
  126. package/.output/server/_libs/radix-ui__react-roving-focus.mjs +224 -0
  127. package/.output/server/_libs/radix-ui__react-scroll-area.mjs +721 -0
  128. package/.output/server/_libs/radix-ui__react-select.mjs +1163 -0
  129. package/.output/server/_libs/radix-ui__react-separator.mjs +28 -0
  130. package/.output/server/_libs/radix-ui__react-slider.mjs +1 -0
  131. package/.output/server/_libs/radix-ui__react-slot.mjs +99 -0
  132. package/.output/server/_libs/radix-ui__react-switch.mjs +1 -0
  133. package/.output/server/_libs/radix-ui__react-tabs.mjs +189 -0
  134. package/.output/server/_libs/radix-ui__react-toast.mjs +1 -0
  135. package/.output/server/_libs/radix-ui__react-toggle-group.mjs +1 -0
  136. package/.output/server/_libs/radix-ui__react-toggle.mjs +1 -0
  137. package/.output/server/_libs/radix-ui__react-toolbar.mjs +1 -0
  138. package/.output/server/_libs/radix-ui__react-tooltip.mjs +495 -0
  139. package/.output/server/_libs/radix-ui__react-use-previous.mjs +14 -0
  140. package/.output/server/_libs/radix-ui__react-use-size.mjs +39 -0
  141. package/.output/server/_libs/react-dom.mjs +9935 -0
  142. package/.output/server/_libs/react-markdown.mjs +147 -0
  143. package/.output/server/_libs/react-remove-scroll-bar.mjs +82 -0
  144. package/.output/server/_libs/react-remove-scroll.mjs +328 -0
  145. package/.output/server/_libs/react-style-singleton.mjs +69 -0
  146. package/.output/server/_libs/react.mjs +515 -0
  147. package/.output/server/_libs/readable-stream.mjs +1518 -0
  148. package/.output/server/_libs/remark-parse.mjs +19 -0
  149. package/.output/server/_libs/remark-rehype.mjs +21 -0
  150. package/.output/server/_libs/rou3.mjs +8 -0
  151. package/.output/server/_libs/safe-buffer.mjs +64 -0
  152. package/.output/server/_libs/semver.mjs +1984 -0
  153. package/.output/server/_libs/seroval-plugins.mjs +58 -0
  154. package/.output/server/_libs/seroval.mjs +1765 -0
  155. package/.output/server/_libs/setimmediate.mjs +1 -0
  156. package/.output/server/_libs/space-separated-tokens.mjs +6 -0
  157. package/.output/server/_libs/srvx.mjs +334 -0
  158. package/.output/server/_libs/stubborn-fs.mjs +91 -0
  159. package/.output/server/_libs/stubborn-utils.mjs +66 -0
  160. package/.output/server/_libs/style-to-js.mjs +72 -0
  161. package/.output/server/_libs/style-to-object.mjs +38 -0
  162. package/.output/server/_libs/tailwind-merge.mjs +3010 -0
  163. package/.output/server/_libs/tanstack__history.mjs +217 -0
  164. package/.output/server/_libs/tanstack__react-router.mjs +1480 -0
  165. package/.output/server/_libs/tanstack__react-store.mjs +1 -0
  166. package/.output/server/_libs/tanstack__react-virtual.mjs +44 -0
  167. package/.output/server/_libs/tanstack__router-core.mjs +4827 -0
  168. package/.output/server/_libs/tanstack__store.mjs +1 -0
  169. package/.output/server/_libs/tanstack__virtual-core.mjs +1225 -0
  170. package/.output/server/_libs/tiny-invariant.mjs +12 -0
  171. package/.output/server/_libs/tiny-warning.mjs +5 -0
  172. package/.output/server/_libs/trim-lines.mjs +41 -0
  173. package/.output/server/_libs/trough.mjs +85 -0
  174. package/.output/server/_libs/tslib.mjs +576 -0
  175. package/.output/server/_libs/ufo.mjs +54 -0
  176. package/.output/server/_libs/uint8array-extras.mjs +69 -0
  177. package/.output/server/_libs/unctx.mjs +1 -0
  178. package/.output/server/_libs/ungap__structured-clone.mjs +212 -0
  179. package/.output/server/_libs/unified.mjs +661 -0
  180. package/.output/server/_libs/unist-util-is.mjs +100 -0
  181. package/.output/server/_libs/unist-util-position.mjs +27 -0
  182. package/.output/server/_libs/unist-util-stringify-position.mjs +27 -0
  183. package/.output/server/_libs/unist-util-visit-parents.mjs +82 -0
  184. package/.output/server/_libs/unist-util-visit.mjs +24 -0
  185. package/.output/server/_libs/unstorage.mjs +1 -0
  186. package/.output/server/_libs/use-callback-ref.mjs +66 -0
  187. package/.output/server/_libs/use-sidecar.mjs +106 -0
  188. package/.output/server/_libs/use-sync-external-store.mjs +1 -0
  189. package/.output/server/_libs/util-deprecate.mjs +12 -0
  190. package/.output/server/_libs/vfile-message.mjs +138 -0
  191. package/.output/server/_libs/vfile.mjs +467 -0
  192. package/.output/server/_libs/when-exit.mjs +53 -0
  193. package/.output/server/_libs/zod.mjs +4460 -0
  194. package/.output/server/_ssr/index-ByCLZu7J.mjs +3061 -0
  195. package/.output/server/_ssr/index.mjs +1176 -0
  196. package/.output/server/_ssr/router-Bq_mxeNz.mjs +2872 -0
  197. package/.output/server/_ssr/start-HYkvq4Ni.mjs +4 -0
  198. package/.output/server/_tanstack-start-manifest_v-C4E0e9my.mjs +4 -0
  199. package/.output/server/index.mjs +393 -0
  200. package/README.md +196 -0
  201. package/package.json +91 -0
  202. package/src/assets/logos/alibaba.svg +1 -0
  203. package/src/assets/logos/anthropic.svg +1 -0
  204. package/src/assets/logos/deepseek.svg +1 -0
  205. package/src/assets/logos/minimax.jpeg +0 -0
  206. package/src/assets/logos/openai.svg +1 -0
  207. package/src/assets/logos/qwen.png +0 -0
  208. package/src/assets/logos/zhipuai.svg +219 -0
  209. package/src/cli.ts +68 -0
  210. package/src/components/ProxyViewer.tsx +325 -0
  211. package/src/components/ProxyViewerContainer.tsx +211 -0
  212. package/src/components/providers/ProviderCard.tsx +186 -0
  213. package/src/components/providers/ProviderForm.tsx +259 -0
  214. package/src/components/providers/ProviderLogo.tsx +111 -0
  215. package/src/components/providers/ProvidersPanel.tsx +259 -0
  216. package/src/components/providers/SettingsDialog.tsx +39 -0
  217. package/src/components/proxy-viewer/ConversationGroup.tsx +68 -0
  218. package/src/components/proxy-viewer/ConversationHeader.tsx +141 -0
  219. package/src/components/proxy-viewer/LogEntry.tsx +225 -0
  220. package/src/components/proxy-viewer/LogEntryHeader.tsx +250 -0
  221. package/src/components/proxy-viewer/ReplayDialog.tsx +208 -0
  222. package/src/components/proxy-viewer/ResponseView.tsx +161 -0
  223. package/src/components/proxy-viewer/StreamingChunkSequence.tsx +171 -0
  224. package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +139 -0
  225. package/src/components/proxy-viewer/formats/anthropic/ResponseView.tsx +64 -0
  226. package/src/components/proxy-viewer/formats/index.tsx +24 -0
  227. package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +80 -0
  228. package/src/components/proxy-viewer/index.ts +8 -0
  229. package/src/components/ui/badge.tsx +47 -0
  230. package/src/components/ui/button.tsx +47 -0
  231. package/src/components/ui/collapsible.tsx +21 -0
  232. package/src/components/ui/dialog.tsx +129 -0
  233. package/src/components/ui/json-viewer.tsx +464 -0
  234. package/src/components/ui/scroll-area.tsx +54 -0
  235. package/src/components/ui/select.tsx +178 -0
  236. package/src/components/ui/separator.tsx +28 -0
  237. package/src/components/ui/tabs.tsx +88 -0
  238. package/src/components/ui/tooltip.tsx +51 -0
  239. package/src/index.css +11 -0
  240. package/src/lib/export-logs.ts +51 -0
  241. package/src/lib/utils.ts +22 -0
  242. package/src/proxy/chunkStorage.ts +118 -0
  243. package/src/proxy/constants.ts +36 -0
  244. package/src/proxy/formats/anthropic/anthropicProvider.ts +75 -0
  245. package/src/proxy/formats/anthropic/handler.ts +74 -0
  246. package/src/proxy/formats/anthropic/index.ts +14 -0
  247. package/src/proxy/formats/anthropic/register.ts +4 -0
  248. package/src/proxy/formats/anthropic/schemas.ts +217 -0
  249. package/src/proxy/formats/anthropic/stream.ts +167 -0
  250. package/src/proxy/formats/handler.ts +46 -0
  251. package/src/proxy/formats/index.ts +12 -0
  252. package/src/proxy/formats/jsonSchema.ts +24 -0
  253. package/src/proxy/formats/openai/alibabaProvider.ts +38 -0
  254. package/src/proxy/formats/openai/handler.ts +70 -0
  255. package/src/proxy/formats/openai/index.ts +25 -0
  256. package/src/proxy/formats/openai/provider.ts +50 -0
  257. package/src/proxy/formats/openai/register.ts +4 -0
  258. package/src/proxy/formats/openai/schemas.ts +150 -0
  259. package/src/proxy/formats/openai/stream.ts +153 -0
  260. package/src/proxy/formats/protocol.ts +50 -0
  261. package/src/proxy/formats/providerRegistry.ts +51 -0
  262. package/src/proxy/formats/providers/index.ts +3 -0
  263. package/src/proxy/formats/registry.ts +61 -0
  264. package/src/proxy/handler.ts +389 -0
  265. package/src/proxy/logIndex.ts +187 -0
  266. package/src/proxy/logger.ts +99 -0
  267. package/src/proxy/providers.ts +234 -0
  268. package/src/proxy/schemas.ts +160 -0
  269. package/src/proxy/socketTracker.ts +158 -0
  270. package/src/proxy/store.ts +386 -0
  271. package/src/router.tsx +16 -0
  272. package/src/routes/__root.tsx +38 -0
  273. package/src/routes/api/config.paths.ts +14 -0
  274. package/src/routes/api/health.ts +11 -0
  275. package/src/routes/api/logs.$id.chunks.ts +36 -0
  276. package/src/routes/api/logs.$id.replay.ts +262 -0
  277. package/src/routes/api/logs.$id.ts +22 -0
  278. package/src/routes/api/logs.stream.ts +64 -0
  279. package/src/routes/api/logs.ts +30 -0
  280. package/src/routes/api/models.ts +10 -0
  281. package/src/routes/api/providers.$providerId.ts +45 -0
  282. package/src/routes/api/providers.ts +37 -0
  283. package/src/routes/api/sessions.ts +10 -0
  284. package/src/routes/index.tsx +6 -0
  285. package/src/routes/proxy/$.ts +15 -0
  286. package/styles/globals.css +121 -0
@@ -0,0 +1,6 @@
1
+ function stringify(values) {
2
+ return values.join(" ").trim();
3
+ }
4
+ export {
5
+ stringify as s
6
+ };
@@ -0,0 +1,334 @@
1
+ function lazyInherit(target, source, sourceKey) {
2
+ for (const key of [...Object.getOwnPropertyNames(source), ...Object.getOwnPropertySymbols(source)]) {
3
+ if (key === "constructor") continue;
4
+ const targetDesc = Object.getOwnPropertyDescriptor(target, key);
5
+ const desc = Object.getOwnPropertyDescriptor(source, key);
6
+ let modified = false;
7
+ if (desc.get) {
8
+ modified = true;
9
+ desc.get = targetDesc?.get || function() {
10
+ return this[sourceKey][key];
11
+ };
12
+ }
13
+ if (desc.set) {
14
+ modified = true;
15
+ desc.set = targetDesc?.set || function(value) {
16
+ this[sourceKey][key] = value;
17
+ };
18
+ }
19
+ if (!targetDesc?.value && typeof desc.value === "function") {
20
+ modified = true;
21
+ desc.value = function(...args) {
22
+ return this[sourceKey][key](...args);
23
+ };
24
+ }
25
+ if (modified) Object.defineProperty(target, key, desc);
26
+ }
27
+ }
28
+ const FastURL = /* @__PURE__ */ (() => {
29
+ const NativeURL = globalThis.URL;
30
+ const FastURL2 = class URL {
31
+ #url;
32
+ #href;
33
+ #protocol;
34
+ #host;
35
+ #pathname;
36
+ #search;
37
+ #searchParams;
38
+ #pos;
39
+ constructor(url) {
40
+ if (typeof url === "string") this.#href = url;
41
+ else {
42
+ this.#protocol = url.protocol;
43
+ this.#host = url.host;
44
+ this.#pathname = url.pathname;
45
+ this.#search = url.search;
46
+ }
47
+ }
48
+ static [Symbol.hasInstance](val) {
49
+ return val instanceof NativeURL;
50
+ }
51
+ get _url() {
52
+ if (this.#url) return this.#url;
53
+ this.#url = new NativeURL(this.href);
54
+ this.#href = void 0;
55
+ this.#protocol = void 0;
56
+ this.#host = void 0;
57
+ this.#pathname = void 0;
58
+ this.#search = void 0;
59
+ this.#searchParams = void 0;
60
+ this.#pos = void 0;
61
+ return this.#url;
62
+ }
63
+ get href() {
64
+ if (this.#url) return this.#url.href;
65
+ if (!this.#href) this.#href = `${this.#protocol || "http:"}//${this.#host || "localhost"}${this.#pathname || "/"}${this.#search || ""}`;
66
+ return this.#href;
67
+ }
68
+ #getPos() {
69
+ if (!this.#pos) {
70
+ const url = this.href;
71
+ const protoIndex = url.indexOf("://");
72
+ const pathnameIndex = protoIndex === -1 ? -1 : url.indexOf("/", protoIndex + 4);
73
+ this.#pos = [
74
+ protoIndex,
75
+ pathnameIndex,
76
+ pathnameIndex === -1 ? -1 : url.indexOf("?", pathnameIndex)
77
+ ];
78
+ }
79
+ return this.#pos;
80
+ }
81
+ get pathname() {
82
+ if (this.#url) return this.#url.pathname;
83
+ if (this.#pathname === void 0) {
84
+ const [, pathnameIndex, queryIndex] = this.#getPos();
85
+ if (pathnameIndex === -1) return this._url.pathname;
86
+ this.#pathname = this.href.slice(pathnameIndex, queryIndex === -1 ? void 0 : queryIndex);
87
+ }
88
+ return this.#pathname;
89
+ }
90
+ get search() {
91
+ if (this.#url) return this.#url.search;
92
+ if (this.#search === void 0) {
93
+ const [, pathnameIndex, queryIndex] = this.#getPos();
94
+ if (pathnameIndex === -1) return this._url.search;
95
+ const url = this.href;
96
+ this.#search = queryIndex === -1 || queryIndex === url.length - 1 ? "" : url.slice(queryIndex);
97
+ }
98
+ return this.#search;
99
+ }
100
+ get searchParams() {
101
+ if (this.#url) return this.#url.searchParams;
102
+ if (!this.#searchParams) this.#searchParams = new URLSearchParams(this.search);
103
+ return this.#searchParams;
104
+ }
105
+ get protocol() {
106
+ if (this.#url) return this.#url.protocol;
107
+ if (this.#protocol === void 0) {
108
+ const [protocolIndex] = this.#getPos();
109
+ if (protocolIndex === -1) return this._url.protocol;
110
+ this.#protocol = this.href.slice(0, protocolIndex + 1);
111
+ }
112
+ return this.#protocol;
113
+ }
114
+ toString() {
115
+ return this.href;
116
+ }
117
+ toJSON() {
118
+ return this.href;
119
+ }
120
+ };
121
+ lazyInherit(FastURL2.prototype, NativeURL.prototype, "_url");
122
+ Object.setPrototypeOf(FastURL2.prototype, NativeURL.prototype);
123
+ Object.setPrototypeOf(FastURL2, NativeURL);
124
+ return FastURL2;
125
+ })();
126
+ function resolvePortAndHost(opts) {
127
+ const _port = opts.port ?? globalThis.process?.env.PORT ?? 3e3;
128
+ const port = typeof _port === "number" ? _port : Number.parseInt(_port, 10);
129
+ if (port < 0 || port > 65535) throw new RangeError(`Port must be between 0 and 65535 (got "${port}").`);
130
+ return {
131
+ port,
132
+ hostname: opts.hostname ?? globalThis.process?.env.HOST
133
+ };
134
+ }
135
+ function fmtURL(host, port, secure) {
136
+ if (!host || !port) return;
137
+ if (host.includes(":")) host = `[${host}]`;
138
+ return `http${secure ? "s" : ""}://${host}:${port}/`;
139
+ }
140
+ function printListening(opts, url) {
141
+ if (!url || (opts.silent ?? globalThis.process?.env?.TEST)) return;
142
+ let additionalInfo = "";
143
+ try {
144
+ const _url = new URL(url);
145
+ if (_url.hostname === "[::]" || _url.hostname === "0.0.0.0") {
146
+ _url.hostname = "localhost";
147
+ url = _url.href;
148
+ additionalInfo = " (all interfaces)";
149
+ }
150
+ } catch {
151
+ }
152
+ let listeningOn = `➜ Listening on:`;
153
+ if (globalThis.process.stdout?.isTTY) {
154
+ listeningOn = `\x1B[32m${listeningOn}\x1B[0m`;
155
+ url = `\x1B[36m${url}\x1B[0m`;
156
+ additionalInfo = `\x1B[2m${additionalInfo}\x1B[0m`;
157
+ }
158
+ console.log(`${listeningOn} ${url}${additionalInfo}`);
159
+ }
160
+ function resolveTLSOptions(opts) {
161
+ if (!opts.tls || opts.protocol === "http") return;
162
+ const cert = resolveCertOrKey(opts.tls.cert);
163
+ const key = resolveCertOrKey(opts.tls.key);
164
+ if (!cert && !key) {
165
+ if (opts.protocol === "https") throw new TypeError("TLS `cert` and `key` must be provided for `https` protocol.");
166
+ return;
167
+ }
168
+ if (!cert || !key) throw new TypeError("TLS `cert` and `key` must be provided together.");
169
+ return {
170
+ cert,
171
+ key,
172
+ passphrase: opts.tls.passphrase
173
+ };
174
+ }
175
+ function resolveCertOrKey(value) {
176
+ if (!value) return;
177
+ if (typeof value !== "string") throw new TypeError("TLS certificate and key must be strings in PEM format or file paths.");
178
+ if (value.startsWith("-----BEGIN ")) return value;
179
+ const { readFileSync } = process.getBuiltinModule("node:fs");
180
+ return readFileSync(value, "utf8");
181
+ }
182
+ function createWaitUntil() {
183
+ const promises = /* @__PURE__ */ new Set();
184
+ return {
185
+ waitUntil: (promise) => {
186
+ if (typeof promise?.then !== "function") return;
187
+ promises.add(Promise.resolve(promise).catch(console.error).finally(() => {
188
+ promises.delete(promise);
189
+ }));
190
+ },
191
+ wait: () => {
192
+ return Promise.all(promises);
193
+ }
194
+ };
195
+ }
196
+ const noColor = /* @__PURE__ */ (() => {
197
+ const env = globalThis.process?.env ?? {};
198
+ return env.NO_COLOR === "1" || env.TERM === "dumb";
199
+ })();
200
+ const _c = (c, r = 39) => (t) => noColor ? t : `\x1B[${c}m${t}\x1B[${r}m`;
201
+ const bold = /* @__PURE__ */ _c(1, 22);
202
+ const red = /* @__PURE__ */ _c(31);
203
+ const green = /* @__PURE__ */ _c(32);
204
+ const gray = /* @__PURE__ */ _c(90);
205
+ function wrapFetch(server) {
206
+ const fetchHandler = server.options.fetch;
207
+ const middleware = server.options.middleware || [];
208
+ return middleware.length === 0 ? fetchHandler : (request) => callMiddleware(request, fetchHandler, middleware, 0);
209
+ }
210
+ function callMiddleware(request, fetchHandler, middleware, index) {
211
+ if (index === middleware.length) return fetchHandler(request);
212
+ return middleware[index](request, () => callMiddleware(request, fetchHandler, middleware, index + 1));
213
+ }
214
+ const gracefulShutdownPlugin = (server) => {
215
+ const config = server.options?.gracefulShutdown;
216
+ if (!globalThis.process?.on || config === false || config === void 0 && (process.env.CI || process.env.TEST)) return;
217
+ const gracefulTimeout = config === true || !config?.gracefulTimeout ? Number.parseInt(process.env.SERVER_SHUTDOWN_TIMEOUT || "") || 5 : config.gracefulTimeout;
218
+ let isClosing = false;
219
+ let isClosed = false;
220
+ const w = server.options.silent ? () => {
221
+ } : process.stderr.write.bind(process.stderr);
222
+ const forceClose = async () => {
223
+ if (isClosed) return;
224
+ w(red("\x1B[2K\rForcibly closing connections...\n"));
225
+ isClosed = true;
226
+ await server.close(true);
227
+ };
228
+ const shutdown = async () => {
229
+ if (isClosing || isClosed) return;
230
+ setTimeout(() => {
231
+ globalThis.process.once("SIGINT", forceClose);
232
+ }, 100);
233
+ isClosing = true;
234
+ const closePromise = server.close();
235
+ for (let remaining = gracefulTimeout; remaining > 0; remaining--) {
236
+ w(gray(`\rStopping server gracefully (${remaining}s)... Press ${bold("Ctrl+C")} again to force close.`));
237
+ if (await Promise.race([closePromise.then(() => true), new Promise((r) => setTimeout(() => r(false), 1e3))])) {
238
+ w("\x1B[2K\r" + green("Server closed successfully.\n"));
239
+ isClosed = true;
240
+ return;
241
+ }
242
+ }
243
+ w("\x1B[2K\rGraceful shutdown timed out.\n");
244
+ await forceClose();
245
+ };
246
+ for (const sig of ["SIGINT", "SIGTERM"]) globalThis.process.on(sig, shutdown);
247
+ };
248
+ const FastResponse = Response;
249
+ function serve(options) {
250
+ return new BunServer(options);
251
+ }
252
+ var BunServer = class {
253
+ runtime = "bun";
254
+ options;
255
+ bun = {};
256
+ serveOptions;
257
+ fetch;
258
+ waitUntil;
259
+ #wait;
260
+ constructor(options) {
261
+ this.options = {
262
+ ...options,
263
+ middleware: [...options.middleware || []]
264
+ };
265
+ for (const plugin of options.plugins || []) plugin(this);
266
+ gracefulShutdownPlugin(this);
267
+ const fetchHandler = wrapFetch(this);
268
+ const loader = globalThis.__srvxLoader__;
269
+ if (loader) {
270
+ this.fetch = fetchHandler;
271
+ loader(fetchHandler);
272
+ return;
273
+ }
274
+ this.#wait = createWaitUntil();
275
+ this.waitUntil = this.#wait.waitUntil;
276
+ this.fetch = (request, server) => {
277
+ Object.defineProperties(request, {
278
+ waitUntil: { value: this.#wait?.waitUntil },
279
+ runtime: {
280
+ enumerable: true,
281
+ value: {
282
+ name: "bun",
283
+ bun: { server }
284
+ }
285
+ },
286
+ ip: {
287
+ enumerable: true,
288
+ get() {
289
+ return server?.requestIP(request)?.address;
290
+ }
291
+ }
292
+ });
293
+ return fetchHandler(request);
294
+ };
295
+ const tls = resolveTLSOptions(this.options);
296
+ this.serveOptions = {
297
+ ...resolvePortAndHost(this.options),
298
+ reusePort: this.options.reusePort,
299
+ error: this.options.error,
300
+ ...this.options.bun,
301
+ tls: {
302
+ cert: tls?.cert,
303
+ key: tls?.key,
304
+ passphrase: tls?.passphrase,
305
+ ...this.options.bun?.tls
306
+ },
307
+ fetch: this.fetch
308
+ };
309
+ if (!options.manual) this.serve();
310
+ }
311
+ serve() {
312
+ if (!this.bun.server) this.bun.server = Bun.serve(this.serveOptions);
313
+ printListening(this.options, this.url);
314
+ return Promise.resolve(this);
315
+ }
316
+ get url() {
317
+ const server = this.bun?.server;
318
+ if (!server) return;
319
+ const address = server.address;
320
+ if (address) return fmtURL(address.address, address.port, server.protocol === "https");
321
+ return server.url.href;
322
+ }
323
+ ready() {
324
+ return Promise.resolve(this);
325
+ }
326
+ async close(closeAll) {
327
+ await Promise.all([this.#wait?.wait(), Promise.resolve(this.bun?.server?.stop(closeAll))]);
328
+ }
329
+ };
330
+ export {
331
+ FastURL as F,
332
+ FastResponse as a,
333
+ serve as s
334
+ };
@@ -0,0 +1,91 @@
1
+ import fs from "node:fs";
2
+ import { promisify } from "node:util";
3
+ import { r as retryifySync, a as retryifyAsync, b as attemptifySync, c as attemptifyAsync } from "./stubborn-utils.mjs";
4
+ import process from "node:process";
5
+ const Handlers = {
6
+ /* API */
7
+ isChangeErrorOk: (error) => {
8
+ if (!Handlers.isNodeError(error))
9
+ return false;
10
+ const { code } = error;
11
+ if (code === "ENOSYS")
12
+ return true;
13
+ if (!IS_USER_ROOT && (code === "EINVAL" || code === "EPERM"))
14
+ return true;
15
+ return false;
16
+ },
17
+ isNodeError: (error) => {
18
+ return error instanceof Error;
19
+ },
20
+ isRetriableError: (error) => {
21
+ if (!Handlers.isNodeError(error))
22
+ return false;
23
+ const { code } = error;
24
+ if (code === "EMFILE" || code === "ENFILE" || code === "EAGAIN" || code === "EBUSY" || code === "EACCESS" || code === "EACCES" || code === "EACCS" || code === "EPERM")
25
+ return true;
26
+ return false;
27
+ },
28
+ onChangeError: (error) => {
29
+ if (!Handlers.isNodeError(error))
30
+ throw error;
31
+ if (Handlers.isChangeErrorOk(error))
32
+ return;
33
+ throw error;
34
+ }
35
+ };
36
+ const ATTEMPTIFY_CHANGE_ERROR_OPTIONS = {
37
+ onError: Handlers.onChangeError
38
+ };
39
+ const ATTEMPTIFY_NOOP_OPTIONS = {
40
+ onError: () => void 0
41
+ };
42
+ const IS_USER_ROOT = process.getuid ? !process.getuid() : false;
43
+ const RETRYIFY_OPTIONS = {
44
+ isRetriable: Handlers.isRetriableError
45
+ };
46
+ const FS = {
47
+ attempt: {
48
+ /* ASYNC */
49
+ chmod: attemptifyAsync(promisify(fs.chmod), ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
50
+ chown: attemptifyAsync(promisify(fs.chown), ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
51
+ close: attemptifyAsync(promisify(fs.close), ATTEMPTIFY_NOOP_OPTIONS),
52
+ fsync: attemptifyAsync(promisify(fs.fsync), ATTEMPTIFY_NOOP_OPTIONS),
53
+ mkdir: attemptifyAsync(promisify(fs.mkdir), ATTEMPTIFY_NOOP_OPTIONS),
54
+ realpath: attemptifyAsync(promisify(fs.realpath), ATTEMPTIFY_NOOP_OPTIONS),
55
+ stat: attemptifyAsync(promisify(fs.stat), ATTEMPTIFY_NOOP_OPTIONS),
56
+ unlink: attemptifyAsync(promisify(fs.unlink), ATTEMPTIFY_NOOP_OPTIONS),
57
+ /* SYNC */
58
+ chmodSync: attemptifySync(fs.chmodSync, ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
59
+ chownSync: attemptifySync(fs.chownSync, ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
60
+ closeSync: attemptifySync(fs.closeSync, ATTEMPTIFY_NOOP_OPTIONS),
61
+ existsSync: attemptifySync(fs.existsSync, ATTEMPTIFY_NOOP_OPTIONS),
62
+ fsyncSync: attemptifySync(fs.fsync, ATTEMPTIFY_NOOP_OPTIONS),
63
+ mkdirSync: attemptifySync(fs.mkdirSync, ATTEMPTIFY_NOOP_OPTIONS),
64
+ realpathSync: attemptifySync(fs.realpathSync, ATTEMPTIFY_NOOP_OPTIONS),
65
+ statSync: attemptifySync(fs.statSync, ATTEMPTIFY_NOOP_OPTIONS),
66
+ unlinkSync: attemptifySync(fs.unlinkSync, ATTEMPTIFY_NOOP_OPTIONS)
67
+ },
68
+ retry: {
69
+ /* ASYNC */
70
+ close: retryifyAsync(promisify(fs.close), RETRYIFY_OPTIONS),
71
+ fsync: retryifyAsync(promisify(fs.fsync), RETRYIFY_OPTIONS),
72
+ open: retryifyAsync(promisify(fs.open), RETRYIFY_OPTIONS),
73
+ readFile: retryifyAsync(promisify(fs.readFile), RETRYIFY_OPTIONS),
74
+ rename: retryifyAsync(promisify(fs.rename), RETRYIFY_OPTIONS),
75
+ stat: retryifyAsync(promisify(fs.stat), RETRYIFY_OPTIONS),
76
+ write: retryifyAsync(promisify(fs.write), RETRYIFY_OPTIONS),
77
+ writeFile: retryifyAsync(promisify(fs.writeFile), RETRYIFY_OPTIONS),
78
+ /* SYNC */
79
+ closeSync: retryifySync(fs.closeSync, RETRYIFY_OPTIONS),
80
+ fsyncSync: retryifySync(fs.fsyncSync, RETRYIFY_OPTIONS),
81
+ openSync: retryifySync(fs.openSync, RETRYIFY_OPTIONS),
82
+ readFileSync: retryifySync(fs.readFileSync, RETRYIFY_OPTIONS),
83
+ renameSync: retryifySync(fs.renameSync, RETRYIFY_OPTIONS),
84
+ statSync: retryifySync(fs.statSync, RETRYIFY_OPTIONS),
85
+ writeSync: retryifySync(fs.writeSync, RETRYIFY_OPTIONS),
86
+ writeFileSync: retryifySync(fs.writeFileSync, RETRYIFY_OPTIONS)
87
+ }
88
+ };
89
+ export {
90
+ FS as F
91
+ };
@@ -0,0 +1,66 @@
1
+ const attemptifyAsync = (fn, options) => {
2
+ const { onError } = options;
3
+ return function attemptified(...args) {
4
+ return fn.apply(void 0, args).catch(onError);
5
+ };
6
+ };
7
+ const attemptifySync = (fn, options) => {
8
+ const { onError } = options;
9
+ return function attemptified(...args) {
10
+ try {
11
+ return fn.apply(void 0, args);
12
+ } catch (error) {
13
+ return onError(error);
14
+ }
15
+ };
16
+ };
17
+ const RETRY_INTERVAL = 250;
18
+ const retryifyAsync = (fn, options) => {
19
+ const { isRetriable } = options;
20
+ return function retryified(options2) {
21
+ const { timeout } = options2;
22
+ const interval = options2.interval ?? RETRY_INTERVAL;
23
+ const timestamp = Date.now() + timeout;
24
+ return function attempt(...args) {
25
+ return fn.apply(void 0, args).catch((error) => {
26
+ if (!isRetriable(error))
27
+ throw error;
28
+ if (Date.now() >= timestamp)
29
+ throw error;
30
+ const delay = Math.round(interval * Math.random());
31
+ if (delay > 0) {
32
+ const delayPromise = new Promise((resolve) => setTimeout(resolve, delay));
33
+ return delayPromise.then(() => attempt.apply(void 0, args));
34
+ } else {
35
+ return attempt.apply(void 0, args);
36
+ }
37
+ });
38
+ };
39
+ };
40
+ };
41
+ const retryifySync = (fn, options) => {
42
+ const { isRetriable } = options;
43
+ return function retryified(options2) {
44
+ const { timeout } = options2;
45
+ const timestamp = Date.now() + timeout;
46
+ return function attempt(...args) {
47
+ while (true) {
48
+ try {
49
+ return fn.apply(void 0, args);
50
+ } catch (error) {
51
+ if (!isRetriable(error))
52
+ throw error;
53
+ if (Date.now() >= timestamp)
54
+ throw error;
55
+ continue;
56
+ }
57
+ }
58
+ };
59
+ };
60
+ };
61
+ export {
62
+ retryifyAsync as a,
63
+ attemptifySync as b,
64
+ attemptifyAsync as c,
65
+ retryifySync as r
66
+ };
@@ -0,0 +1,72 @@
1
+ import { g as getDefaultExportFromCjs } from "./react.mjs";
2
+ import { r as requireCjs$1 } from "./style-to-object.mjs";
3
+ var utilities = {};
4
+ var hasRequiredUtilities;
5
+ function requireUtilities() {
6
+ if (hasRequiredUtilities) return utilities;
7
+ hasRequiredUtilities = 1;
8
+ Object.defineProperty(utilities, "__esModule", { value: true });
9
+ utilities.camelCase = void 0;
10
+ var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9_-]+$/;
11
+ var HYPHEN_REGEX = /-([a-z])/g;
12
+ var NO_HYPHEN_REGEX = /^[^-]+$/;
13
+ var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/;
14
+ var MS_VENDOR_PREFIX_REGEX = /^-(ms)-/;
15
+ var skipCamelCase = function(property) {
16
+ return !property || NO_HYPHEN_REGEX.test(property) || CUSTOM_PROPERTY_REGEX.test(property);
17
+ };
18
+ var capitalize = function(match, character) {
19
+ return character.toUpperCase();
20
+ };
21
+ var trimHyphen = function(match, prefix) {
22
+ return "".concat(prefix, "-");
23
+ };
24
+ var camelCase = function(property, options) {
25
+ if (options === void 0) {
26
+ options = {};
27
+ }
28
+ if (skipCamelCase(property)) {
29
+ return property;
30
+ }
31
+ property = property.toLowerCase();
32
+ if (options.reactCompat) {
33
+ property = property.replace(MS_VENDOR_PREFIX_REGEX, trimHyphen);
34
+ } else {
35
+ property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen);
36
+ }
37
+ return property.replace(HYPHEN_REGEX, capitalize);
38
+ };
39
+ utilities.camelCase = camelCase;
40
+ return utilities;
41
+ }
42
+ var cjs;
43
+ var hasRequiredCjs;
44
+ function requireCjs() {
45
+ if (hasRequiredCjs) return cjs;
46
+ hasRequiredCjs = 1;
47
+ var __importDefault = cjs && cjs.__importDefault || function(mod) {
48
+ return mod && mod.__esModule ? mod : { "default": mod };
49
+ };
50
+ var style_to_object_1 = __importDefault(/* @__PURE__ */ requireCjs$1());
51
+ var utilities_1 = /* @__PURE__ */ requireUtilities();
52
+ function StyleToJS(style, options) {
53
+ var output = {};
54
+ if (!style || typeof style !== "string") {
55
+ return output;
56
+ }
57
+ (0, style_to_object_1.default)(style, function(property, value) {
58
+ if (property && value) {
59
+ output[(0, utilities_1.camelCase)(property, options)] = value;
60
+ }
61
+ });
62
+ return output;
63
+ }
64
+ StyleToJS.default = StyleToJS;
65
+ cjs = StyleToJS;
66
+ return cjs;
67
+ }
68
+ var cjsExports = /* @__PURE__ */ requireCjs();
69
+ const styleToJs = /* @__PURE__ */ getDefaultExportFromCjs(cjsExports);
70
+ export {
71
+ styleToJs as s
72
+ };
@@ -0,0 +1,38 @@
1
+ import { r as requireCjs$1 } from "./inline-style-parser.mjs";
2
+ var cjs = {};
3
+ var hasRequiredCjs;
4
+ function requireCjs() {
5
+ if (hasRequiredCjs) return cjs;
6
+ hasRequiredCjs = 1;
7
+ var __importDefault = cjs && cjs.__importDefault || function(mod) {
8
+ return mod && mod.__esModule ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(cjs, "__esModule", { value: true });
11
+ cjs.default = StyleToObject;
12
+ const inline_style_parser_1 = __importDefault(/* @__PURE__ */ requireCjs$1());
13
+ function StyleToObject(style, iterator) {
14
+ let styleObject = null;
15
+ if (!style || typeof style !== "string") {
16
+ return styleObject;
17
+ }
18
+ const declarations = (0, inline_style_parser_1.default)(style);
19
+ const hasIterator = typeof iterator === "function";
20
+ declarations.forEach((declaration) => {
21
+ if (declaration.type !== "declaration") {
22
+ return;
23
+ }
24
+ const { property, value } = declaration;
25
+ if (hasIterator) {
26
+ iterator(property, value, declaration);
27
+ } else if (value) {
28
+ styleObject = styleObject || {};
29
+ styleObject[property] = value;
30
+ }
31
+ });
32
+ return styleObject;
33
+ }
34
+ return cjs;
35
+ }
36
+ export {
37
+ requireCjs as r
38
+ };