youiyoux 0.1.2 → 0.1.4

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 (212) hide show
  1. package/README.md +10 -0
  2. package/dist/chunks/{chunk-S7UV34H5.js → chunk-42YJX3W5.js} +1 -3
  3. package/dist/chunks/{chunk-FUB7B3VK.js → chunk-4BBYLTZX.js} +10 -10
  4. package/dist/chunks/chunk-52KOKYY6.js +8710 -0
  5. package/dist/chunks/chunk-FJZFCAL5.js +129 -0
  6. package/dist/chunks/chunk-FVVL5JCY.js +24 -0
  7. package/dist/chunks/{chunk-UHPK62Q5.js → chunk-M5XZWCPS.js} +240 -60
  8. package/dist/chunks/{chunk-ZLRFD5JI.js → chunk-NYDJYMID.js} +263 -16
  9. package/dist/chunks/{src-7ENJHYG4.js → chunk-RDTHHRZN.js} +319 -165
  10. package/dist/chunks/{chunk-E4HNK7VF.js → chunk-WNTS7ZO4.js} +1 -1
  11. package/dist/chunks/chunk-XAEMVEYX.js +188 -0
  12. package/dist/chunks/{chunk-CLNMVQZJ.js → chunk-YFCMTTXS.js} +708 -494
  13. package/dist/chunks/chunk-YJ7WMBTT.js +13761 -0
  14. package/dist/chunks/src-5IP4NGKT.js +115 -0
  15. package/dist/chunks/src-6CJR547Y.js +124 -0
  16. package/dist/chunks/{src-WQWYJ6IQ.js → src-BPETAFLW.js} +175 -76
  17. package/dist/chunks/{src-B742AYFC.js → src-LLV7IY6W.js} +55 -16
  18. package/dist/chunks/src-RHNZELGE.js +306 -0
  19. package/dist/chunks/{src-4KFNL3MY.js → src-SFKFERZ2.js} +18 -8
  20. package/dist/chunks/{src-VEHGMKYV.js → src-VL2ZYO6X.js} +4 -4
  21. package/dist/hub/assets/Badge-CUJUit4d.js +1 -0
  22. package/dist/hub/assets/CandidatePanel-CnbK4S0j.js +1 -0
  23. package/dist/hub/assets/CatalogScreen-B5OVL-AR.js +1 -0
  24. package/dist/hub/assets/ChangesScreen-GwGqJwxN.js +1 -0
  25. package/dist/hub/assets/CheatSheet-BLSOq-xa.js +1 -0
  26. package/dist/hub/assets/CodeBlock-CsiGFgvI.js +1 -0
  27. package/dist/hub/assets/CommandPalette-CAWQfdXJ.js +1 -0
  28. package/dist/hub/assets/CopyButton-DE8drl4P.js +1 -0
  29. package/dist/hub/assets/Disclosure-B1kTgPgk.js +1 -0
  30. package/dist/hub/assets/DiscoverScreen-Tl_Z6mgY.js +2 -0
  31. package/dist/hub/assets/DraftEditor-yIDapXTs.js +5 -0
  32. package/dist/hub/assets/Field-LwrJXoOs.js +1 -0
  33. package/dist/hub/assets/GapsScreen-DXZAlm6v.js +1 -0
  34. package/dist/hub/assets/HomeScreen-CEpiVhOa.js +1 -0
  35. package/dist/hub/assets/InventoryScreen-CEG3Pmw_.js +1 -0
  36. package/dist/hub/assets/KindIcon-BJ6bz-ny.js +1 -0
  37. package/dist/hub/assets/LibraryScreen-IaVnxrX9.js +1 -0
  38. package/dist/hub/assets/LicenceBadge-CLCUMMHE.js +1 -0
  39. package/dist/hub/assets/Opened-DJyf4Hnj.js +1 -0
  40. package/dist/hub/assets/Preview-C069zVMP.js +1 -0
  41. package/dist/hub/assets/RuleDetail-B4g2-TRe.js +3 -0
  42. package/dist/hub/assets/RulesScreen-CAaXIWjO.js +3 -0
  43. package/dist/hub/assets/ScreenImage-DcI7_G3O.js +1 -0
  44. package/dist/hub/assets/ScreensScreen-DwczCjZD.js +1 -0
  45. package/dist/hub/assets/SearchField-DaCpNAj6.js +1 -0
  46. package/dist/hub/assets/Section-BTnvUq_W.js +1 -0
  47. package/dist/hub/assets/Segmented-Dzi1x49S.js +1 -0
  48. package/dist/hub/assets/ServiceDown-Bv-BPXro.js +1 -0
  49. package/dist/hub/assets/SpecimenCapture-DlsjshVE.js +1 -0
  50. package/dist/hub/assets/Specimens-C-lHp7sr.js +2 -0
  51. package/dist/hub/assets/StackScreen-DkmELsqR.js +1 -0
  52. package/dist/hub/assets/StubScreens-Bt7lWLVK.js +1 -0
  53. package/dist/hub/assets/StyleScreen-tq1tbRBo.js +1 -0
  54. package/dist/hub/assets/Swatch-KDz4qxdM.js +1 -0
  55. package/dist/hub/assets/Tabs-1QQDS0I6.js +1 -0
  56. package/dist/hub/assets/TokenDetail-DvCw6GqC.js +1 -0
  57. package/dist/hub/assets/TokenValue-CsPRc2ai.js +1 -0
  58. package/dist/hub/assets/TokensScreen-DoENV8Xy.js +1 -0
  59. package/dist/hub/assets/arrow-right-DcbNDzqs.js +1 -0
  60. package/dist/hub/assets/bot-B3gC9oUR.js +1 -0
  61. package/dist/hub/assets/button-6mvMVtpb.js +1 -0
  62. package/dist/hub/assets/button.demo-DuU0DQbv.js +1 -0
  63. package/dist/hub/assets/card.demo-CufAxMAA.js +1 -0
  64. package/dist/hub/assets/chevron-down-CzN07vMi.js +1 -0
  65. package/dist/hub/assets/circle-alert-DT2LC4yf.js +1 -0
  66. package/dist/hub/assets/circle-check-DkwBMT62.js +1 -0
  67. package/dist/hub/assets/client-D7whEyep.js +1 -0
  68. package/dist/hub/assets/clsx-DB0hHKMi.js +1 -0
  69. package/dist/hub/assets/compass-BkKOZPYe.js +1 -0
  70. package/dist/hub/assets/contrast-BkNHUAPa.js +1 -0
  71. package/dist/hub/assets/createLucideIcon-CGDJWtKO.js +1 -0
  72. package/dist/hub/assets/discover-XjJEViwk.js +1 -0
  73. package/dist/hub/assets/dist-BYQYaPBV.js +1 -0
  74. package/dist/hub/assets/dist-Bk4srtDn.js +41 -0
  75. package/dist/hub/assets/dist-BogNzeK9.js +1 -0
  76. package/dist/hub/assets/dist-D0z7Bvsy.js +1 -0
  77. package/dist/hub/assets/download-BQI-Si9R.js +1 -0
  78. package/dist/hub/assets/engine-CMmt9yEz.js +1 -0
  79. package/dist/hub/assets/esm-NPpg23M8.js +1 -0
  80. package/dist/hub/assets/family-tiles-CyTdy_cP.js +1 -0
  81. package/dist/hub/assets/format-DxAYNTN_.js +1 -0
  82. package/dist/hub/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  83. package/dist/hub/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  84. package/dist/hub/assets/geist-latin-core-vkBVTr4s.woff2 +0 -0
  85. package/dist/hub/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  86. package/dist/hub/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  87. package/dist/hub/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
  88. package/dist/hub/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
  89. package/dist/hub/assets/geist-mono-latin-core-DccGGzmg.woff2 +0 -0
  90. package/dist/hub/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
  91. package/dist/hub/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
  92. package/dist/hub/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
  93. package/dist/hub/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
  94. package/dist/hub/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  95. package/dist/hub/assets/git-pull-request-arrow-RqUUIRCU.js +1 -0
  96. package/dist/hub/assets/input.demo-238gqWpz.js +1 -0
  97. package/dist/hub/assets/inventory-BI8QBdar.js +1 -0
  98. package/dist/hub/assets/inventory-source-lZYzcA8O.js +1 -0
  99. package/dist/hub/assets/jsx-runtime-D6zNwnaE.js +9 -0
  100. package/dist/hub/assets/layers-DfzdK_wG.js +1 -0
  101. package/dist/hub/assets/layout-grid-xFY9L9Oc.js +1 -0
  102. package/dist/hub/assets/library-W5R8GwvG.js +1 -0
  103. package/dist/hub/assets/main-7snyIdoi.css +2 -0
  104. package/dist/hub/assets/main-B9CIkk5m.js +2 -0
  105. package/dist/hub/assets/minus-BDifFhOo.js +1 -0
  106. package/dist/hub/assets/monitor-X_lELkcU.js +1 -0
  107. package/dist/hub/assets/mouse-pointer-click-CVJ6hWg8.js +1 -0
  108. package/dist/hub/assets/paintbrush-DOkEgSTO.js +1 -0
  109. package/dist/hub/assets/plural-BbGQPQKA.js +1 -0
  110. package/dist/hub/assets/preview-BA8CPsKb.css +2 -0
  111. package/dist/hub/assets/preview-DUm13vr1.js +3 -0
  112. package/dist/hub/assets/protocol-caP6umNL.js +1 -0
  113. package/dist/hub/assets/react-DB-4Zxce.js +1 -0
  114. package/dist/hub/assets/shield-check-0ka0kQct.js +1 -0
  115. package/dist/hub/assets/trash-B7aEfJps.js +1 -0
  116. package/dist/hub/assets/triangle-alert-Dkdi9eDR.js +1 -0
  117. package/dist/hub/assets/try-live-zX3CSd3P.js +1 -0
  118. package/dist/hub/assets/utils-BoaXfs8y.js +1 -0
  119. package/dist/hub/assets/values-DzxR_TlI.js +1 -0
  120. package/dist/hub/assets/worker-Bh-wSp42.js +1 -0
  121. package/dist/hub/assets/workflow-jpV8wh-U.js +1 -0
  122. package/dist/hub/assets/x-MLbFVa4v.js +1 -0
  123. package/dist/hub/favicon.svg +1 -0
  124. package/dist/hub/index.html +35 -0
  125. package/dist/hub/kit/candidates.json +1 -0
  126. package/dist/hub/kit/chunks/chunk-2NYFUOIV.js +14 -0
  127. package/dist/hub/kit/chunks/chunk-DCANE7XH.js +1 -0
  128. package/dist/hub/kit/chunks/chunk-FTGHCY4I.js +14 -0
  129. package/dist/hub/kit/chunks/chunk-IBF3UTJF.js +33 -0
  130. package/dist/hub/kit/chunks/chunk-LLXY4VSH.js +1 -0
  131. package/dist/hub/kit/chunks/chunk-PUPZMW4P.js +14 -0
  132. package/dist/hub/kit/chunks/chunk-PWLNZQET.js +1 -0
  133. package/dist/hub/kit/chunks/chunk-ULXWVOKJ.js +1 -0
  134. package/dist/hub/kit/chunks/chunk-WM4BGGMK.js +1 -0
  135. package/dist/hub/kit/chunks/chunk-ZQUNRK72.js +1 -0
  136. package/dist/hub/kit/class-variance-authority.js +1 -0
  137. package/dist/hub/kit/clsx.js +1 -0
  138. package/dist/hub/kit/fonts/geist-cyrillic-ext-wght-normal.woff2 +0 -0
  139. package/dist/hub/kit/fonts/geist-cyrillic-wght-normal.woff2 +0 -0
  140. package/dist/hub/kit/fonts/geist-latin-ext-wght-normal.woff2 +0 -0
  141. package/dist/hub/kit/fonts/geist-latin-wght-normal.woff2 +0 -0
  142. package/dist/hub/kit/fonts/geist-vietnamese-wght-normal.woff2 +0 -0
  143. package/dist/hub/kit/frame.css.src +73 -0
  144. package/dist/hub/kit/frame.js +2 -0
  145. package/dist/hub/kit/lucide-react.js +1878 -0
  146. package/dist/hub/kit/preview.html +13 -0
  147. package/dist/hub/kit/radix-ui-react-dialog.js +41 -0
  148. package/dist/hub/kit/radix-ui-react-label.js +1 -0
  149. package/dist/hub/kit/radix-ui-react-separator.js +1 -0
  150. package/dist/hub/kit/radix-ui-react-slot.js +1 -0
  151. package/dist/hub/kit/radix-ui-react-switch.js +1 -0
  152. package/dist/hub/kit/radix-ui-react-tabs.js +1 -0
  153. package/dist/hub/kit/react-dom-client.js +1 -0
  154. package/dist/hub/kit/react-dom.js +1 -0
  155. package/dist/hub/kit/react-jsx-runtime.js +1 -0
  156. package/dist/hub/kit/react.js +1 -0
  157. package/dist/hub/kit/tailwind-merge.js +1 -0
  158. package/dist/hub/kit/tailwindcss/index.css +950 -0
  159. package/dist/hub/kit/tailwindcss/preflight.css +398 -0
  160. package/dist/hub/kit/tailwindcss/theme.css +510 -0
  161. package/dist/hub/kit/tailwindcss/utilities.css +1 -0
  162. package/dist/hub-demo/frame/button.demo.js +1 -0
  163. package/dist/hub-demo/frame/card.demo.js +1 -0
  164. package/dist/hub-demo/frame/demos.js +6 -0
  165. package/dist/hub-demo/frame/frame.css +770 -0
  166. package/dist/hub-demo/frame/input.demo.js +1 -0
  167. package/dist/hub-demo/preview/components/button.demo.tsx +47 -0
  168. package/dist/hub-demo/preview/components/button.tsx +31 -0
  169. package/dist/hub-demo/preview/components/card.demo.tsx +26 -0
  170. package/dist/hub-demo/preview/components/card.tsx +20 -0
  171. package/dist/hub-demo/preview/components/input.demo.tsx +39 -0
  172. package/dist/hub-demo/preview/components/input.tsx +19 -0
  173. package/dist/hub-demo/preview/components/utils.ts +5 -0
  174. package/dist/hub-demo/preview/system.css +161 -0
  175. package/dist/hub-demo/public/data/demo-app.usage.bedd9c82fe.json +1 -0
  176. package/dist/hub-demo/public/data/demo.catalog.a605de2281.json +1 -0
  177. package/dist/hub-demo/public/data/gaps.129a93538d.json +1 -0
  178. package/dist/hub-demo/public/data/inventory.165a4f6408.json +1 -0
  179. package/dist/hub-demo/public/data/inventory.console.badge.ad0238784e.json +1 -0
  180. package/dist/hub-demo/public/data/inventory.console.button.3249daff35.json +1 -0
  181. package/dist/hub-demo/public/data/inventory.console.card.9ea88708ac.json +1 -0
  182. package/dist/hub-demo/public/data/inventory.console.dialog.8b6574d93a.json +1 -0
  183. package/dist/hub-demo/public/data/inventory.console.input.bdffb756a7.json +1 -0
  184. package/dist/hub-demo/public/data/inventory.console.link-as-button.1ce7faa1f3.json +1 -0
  185. package/dist/hub-demo/public/data/inventory.console.tabs.813e694c44.json +1 -0
  186. package/dist/hub-demo/public/data/inventory.extras.e5d06c6ff4.json +1 -0
  187. package/dist/hub-demo/public/data/inventory.site.badge.047a68f644.json +1 -0
  188. package/dist/hub-demo/public/data/inventory.site.button.720938384e.json +1 -0
  189. package/dist/hub-demo/public/data/inventory.site.card.d8df5f6873.json +1 -0
  190. package/dist/hub-demo/public/data/inventory.site.link-as-button.9c1f8a55bf.json +1 -0
  191. package/dist/hub-demo/public/data/inventory.site.tabs.59bd0200b9.json +1 -0
  192. package/dist/hub-demo/public/data/manifest.json +39 -0
  193. package/dist/hub-demo/public/data/specimens.console.dark.046471907d.css +786 -0
  194. package/dist/hub-demo/public/data/specimens.console.light.aaffa2d213.css +786 -0
  195. package/dist/hub-demo/public/data/specimens.site.dark.94a6706908.css +92 -0
  196. package/dist/hub-demo/public/data/specimens.site.light.3ddbc8d28d.css +92 -0
  197. package/dist/hub-demo/public/previews/button.dark.webp +0 -0
  198. package/dist/hub-demo/public/previews/button.light.webp +0 -0
  199. package/dist/hub-demo/public/previews/card.dark.webp +0 -0
  200. package/dist/hub-demo/public/previews/card.light.webp +0 -0
  201. package/dist/hub-demo/public/previews/input.dark.webp +0 -0
  202. package/dist/hub-demo/public/previews/input.light.webp +0 -0
  203. package/dist/hub-previews.js +173 -0
  204. package/dist/hub-server.js +6329 -0
  205. package/dist/hub-snapshot.js +573 -0
  206. package/dist/schema/youi.gaps.schema.json +235 -0
  207. package/dist/schema/youi.request.schema.json +229 -0
  208. package/dist/tailwind-worker.js +3 -3
  209. package/dist/youi.js +10 -8
  210. package/dist/youiyoux.js +10 -8
  211. package/package.json +4 -4
  212. package/dist/chunks/chunk-3ZHGONNA.js +0 -21797
@@ -1,4 +1,4 @@
1
- import { createRequire as __youiRequire } from "node:module"; const require = __youiRequire(import.meta.url);
1
+ import { createRequire as __youiRequire } from "node:module"; import { dirname as __youiDir } from "node:path"; import { fileURLToPath as __youiPath } from "node:url"; const require = __youiRequire(import.meta.url); const __youiDirname = __youiDir(__youiPath(import.meta.url));
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -0,0 +1,188 @@
1
+ import { createRequire as __youiRequire } from "node:module"; import { dirname as __youiDir } from "node:path"; import { fileURLToPath as __youiPath } from "node:url"; const require = __youiRequire(import.meta.url); const __youiDirname = __youiDir(__youiPath(import.meta.url));
2
+
3
+ // src/hub-packages.js
4
+ var PACKAGES = {
5
+ core: () => import("./src-RHNZELGE.js"),
6
+ scanner: () => import("./src-LLV7IY6W.js"),
7
+ discover: () => import("./src-SFKFERZ2.js"),
8
+ tokens: () => import("./src-5IP4NGKT.js")
9
+ };
10
+ var loadPackage = (name) => PACKAGES[name]();
11
+
12
+ // ../../apps/web/scripts/query-server.ts
13
+ import { existsSync } from "node:fs";
14
+ import { join, resolve } from "node:path";
15
+ var QUERY_PATH = "/__youi/query";
16
+ var MAX_LIMIT = 100;
17
+ var LOCAL_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
18
+ var send = (res, status, body) => {
19
+ res.statusCode = status;
20
+ res.setHeader("Content-Type", "application/json");
21
+ res.setHeader("Cache-Control", "no-store");
22
+ res.end(JSON.stringify(body));
23
+ };
24
+ function hostName(host) {
25
+ if (!host) return null;
26
+ const match = /^(\[[^\]]*\]|[^:]+)(?::\d+)?$/.exec(host.trim().toLowerCase());
27
+ return match ? match[1] : null;
28
+ }
29
+ function isLocalHost(host) {
30
+ const name = hostName(host);
31
+ return name !== null && LOCAL_HOSTS.has(name);
32
+ }
33
+ var NotFound = class extends Error {
34
+ };
35
+ var list = (value) => {
36
+ const items = value?.split(",").map((v) => v.trim()).filter(Boolean);
37
+ return items?.length ? items : void 0;
38
+ };
39
+ function page(params) {
40
+ const number = (name, fallback) => {
41
+ const n = Number(params.get(name) ?? fallback);
42
+ return Number.isSafeInteger(n) && n >= 0 ? n : fallback;
43
+ };
44
+ return { limit: Math.min(MAX_LIMIT, number("limit", 20)), offset: Math.min(2147483647, number("offset", 0)) };
45
+ }
46
+ function queryMiddleware(options = {}, base = "/", load = () => loadPackage("discover")) {
47
+ let discover = null;
48
+ const loaded = () => discover ??= load();
49
+ const env = options.env ?? process.env;
50
+ async function answer(kind, params) {
51
+ const d = await loaded();
52
+ const cache = resolve(options.cache ?? d.discoverCacheDir(void 0, env));
53
+ const path = options.index ?? d.discoverIndexPath(void 0, env);
54
+ const { limit, offset } = page(params);
55
+ if (kind === "discover") {
56
+ if (!existsSync(join(cache, d.INDEX_FILE))) throw new NotFound("no Discover index: run youiyoux discover sync");
57
+ const store2 = await d.readCatalog(cache, path, env);
58
+ const need = params.get("q")?.trim();
59
+ const all = params.get("all") === "1";
60
+ const role2 = params.get("role") ?? void 0;
61
+ const licences = list(params.get("licence"));
62
+ const sources = list(params.get("source"));
63
+ const styles = list(params.get("style"))?.filter((s) => s === "headless" || s === "styled");
64
+ const known = licences?.length === 1 && (licences[0] === "known" || licences[0] === "unknown") ? licences[0] === "known" : void 0;
65
+ if (need) {
66
+ const licence = known !== void 0 ? { licenseKnown: known } : licences ? { licenses: licences.filter((l) => l !== "unknown"), allowUnknownLicense: licences.includes("unknown") } : {};
67
+ const result = await d.searchCatalog(store2, need, { ...role2 ? { role: role2 } : {}, constraints: { ...licence, ...sources ? { registries: sources } : {}, ...styles?.length ? { styles } : {} }, all, limit, offset, facets: true });
68
+ return { kind, limit, ...result, offset };
69
+ }
70
+ const concept = role2 ? d.conceptForRole(role2) : void 0;
71
+ const scope = { all, ...role2 ? { roles: [concept?.id ?? role2] } : {}, ...sources ? { registries: sources } : {}, ...styles?.length ? { styles } : {} };
72
+ const held = known === true ? Object.keys((await store2.discoverFacets({ ...scope, scopes: all ? ["chosen", "all"] : ["chosen"] })).licence).filter((l) => l !== "unknown") : [];
73
+ if (known === true && held.length === 0) return { kind, limit, offset, total: 0, hits: [], facets: { role: {}, source: {}, licence: {}, style: {} }, indexBuiltAt: "", note: "" };
74
+ const named = known === true ? held : known === false ? ["unknown"] : licences;
75
+ return { kind, limit, ...await d.browseCatalog(store2, { ...scope, ...named ? { licences: named } : {} }, { limit, offset }) };
76
+ }
77
+ if (!env.DATABASE_URL && !existsSync(path)) throw new NotFound("no local index yet: run youiyoux inventory, youiyoux scan or youiyoux index rebuild");
78
+ const store = await d.sharedStore(path, env, { readOnly: true });
79
+ if (kind === "history") {
80
+ const project = params.get("project") ?? void 0;
81
+ const rows = await store.history({ ...project ? { project } : {}, limit: limit + 1, offset });
82
+ return { kind, limit, offset, more: rows.length > limit, rows: rows.slice(0, limit) };
83
+ }
84
+ const run = params.get("run") ?? void 0;
85
+ const role = params.get("role") ?? void 0;
86
+ if (kind === "families") return { kind, limit, offset, ...await store.families({ ...run ? { run } : {}, ...role ? { role } : {}, limit, offset }) };
87
+ if (kind === "looks") {
88
+ const family = params.get("family") ?? void 0;
89
+ return { kind, limit, offset, ...await store.looks({ ...run ? { run } : {}, ...family ? { family } : {}, ...role ? { role } : {}, limit, offset }) };
90
+ }
91
+ throw new NotFound(`unknown kind "${kind}": discover, families, looks or history`);
92
+ }
93
+ return async (req, res, next) => {
94
+ const url = new URL((req.url ?? "/").replace(base, "/"), "http://hub.local");
95
+ if (url.pathname !== QUERY_PATH || req.method !== "GET") return next();
96
+ if (!isLocalHost(req.headers.host)) return send(res, 403, { error: "the index answers this machine only (Host must be localhost)" });
97
+ try {
98
+ send(res, 200, await answer(url.searchParams.get("kind") ?? "", url.searchParams));
99
+ } catch (error) {
100
+ if (error instanceof NotFound) return send(res, 404, { error: error.message });
101
+ send(res, 500, { error: error instanceof Error ? error.message.split("\n")[0] : String(error) });
102
+ }
103
+ };
104
+ }
105
+
106
+ // ../../apps/web/scripts/try-server.ts
107
+ import { existsSync as existsSync2, readFileSync, statSync } from "node:fs";
108
+ import { join as join2, resolve as resolve2 } from "node:path";
109
+ var TRY_PATH = "/__youi/try";
110
+ var TRY_INDEX = "try.json";
111
+ var MAX_SIBLINGS = 6;
112
+ function tryProject(rootFromSnapshot, tsconfig, looks, lookSpecimen, kinds, lookOf) {
113
+ const specimens = {};
114
+ const ordered = [...looks].sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.column - b.column);
115
+ for (const look of ordered) {
116
+ const id = lookSpecimen[look.id];
117
+ if (!id || specimens[id] || kinds[id]?.kind !== "component" || look.recipe?.kind !== "component") continue;
118
+ const chain = JSON.stringify(look.recipe.wrappers);
119
+ const around = look.recipe.wrappers.length === 0 ? [] : ordered.filter((l) => l.file === look.file && l.role === look.role && l.recipe?.kind === "component" && JSON.stringify(l.recipe.wrappers) === chain);
120
+ const at = around.indexOf(look);
121
+ const start = Math.max(0, Math.min(at - Math.floor(MAX_SIBLINGS / 2), around.length - MAX_SIBLINGS));
122
+ const siblings = around.length > 1 ? around.slice(start, start + MAX_SIBLINGS).map((l) => lookOf(l.recipe, l.role)) : [];
123
+ specimens[id] = { look: lookOf(look.recipe, look.role), siblings };
124
+ }
125
+ return { root: rootFromSnapshot, tsconfig, specimens };
126
+ }
127
+ function readTryIndex(snapshot) {
128
+ const file = join2(snapshot, TRY_INDEX);
129
+ if (!existsSync2(file)) return null;
130
+ try {
131
+ return JSON.parse(readFileSync(file, "utf8"));
132
+ } catch {
133
+ return null;
134
+ }
135
+ }
136
+ function reader(snapshot) {
137
+ const file = join2(snapshot, TRY_INDEX);
138
+ let cached = null;
139
+ return () => {
140
+ if (!existsSync2(file)) return null;
141
+ const mtime = statSync(file).mtimeMs;
142
+ if (cached?.mtime !== mtime) cached = { mtime, index: readTryIndex(snapshot) };
143
+ return cached.index;
144
+ };
145
+ }
146
+ function tryMiddleware(snapshot, base = "/", load = () => loadPackage("scanner")) {
147
+ const index = reader(snapshot);
148
+ let scanner = null;
149
+ const loaded = () => scanner ??= load().then((module) => ({ module, cache: new module.BrowserBundleCache() }));
150
+ return async (req, res, next) => {
151
+ const url = new URL((req.url ?? "/").replace(base, "/"), "http://hub.local");
152
+ if (!url.pathname.startsWith(TRY_PATH) || req.method !== "GET") return next();
153
+ try {
154
+ const script = /^\/__youi\/try\/([0-9a-f]{16})\.js$/.exec(url.pathname);
155
+ if (script) {
156
+ const code = scanner ? (await scanner).cache.code(script[1]) : null;
157
+ if (code === null) return send(res, 404, { error: "no such bundle" });
158
+ res.setHeader("Content-Type", "text/javascript; charset=utf-8");
159
+ res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
160
+ res.end(code);
161
+ return;
162
+ }
163
+ if (url.pathname !== TRY_PATH) return send(res, 404, { error: "not found" });
164
+ const project = url.searchParams.get("project") ?? "";
165
+ const specimen = url.searchParams.get("specimen") ?? "";
166
+ const entry = Object.hasOwn(index()?.projects ?? {}, project) ? index().projects[project] : null;
167
+ const look = entry && Object.hasOwn(entry.specimens, specimen) ? entry.specimens[specimen] : null;
168
+ if (!entry || !look) return send(res, 404, { error: "This look cannot be tried here: the hub has no record of it." });
169
+ const root = resolve2(snapshot, entry.root);
170
+ const { module, cache } = await loaded();
171
+ const result = await cache.get(`${project}\0${specimen}\0${root}`, () => module.bundleForBrowser(root, entry.tsconfig, look.look, look.siblings));
172
+ if ("error" in result) return send(res, "busy" in result ? 503 : 422, { error: result.error });
173
+ send(res, 200, { script: `${base}${TRY_PATH.slice(1)}/${result.hash}.js` });
174
+ } catch (error) {
175
+ send(res, 500, { error: error instanceof Error ? error.message.split("\n")[0] : String(error) });
176
+ }
177
+ };
178
+ }
179
+
180
+ export {
181
+ loadPackage,
182
+ send,
183
+ isLocalHost,
184
+ queryMiddleware,
185
+ tryProject,
186
+ readTryIndex,
187
+ tryMiddleware
188
+ };