trellis 3.1.35 → 3.2.2

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 (287) hide show
  1. package/CHANGELOG.md +23 -5
  2. package/README.md +63 -156
  3. package/bin/trellis.mjs +2 -75
  4. package/dist/{better-sqlite-backend-ahx5p0br.js → better-sqlite-backend-2P4F6AOJ.js} +91 -29
  5. package/dist/boot-middleware-MHLHFCUC.js +9 -0
  6. package/dist/browser/index.d.ts +18 -0
  7. package/dist/browser/index.d.ts.map +1 -0
  8. package/dist/browser/index.js +95 -0
  9. package/dist/{index-53f3b8p8.js → chunk-2W3MHTMG.js} +552 -213
  10. package/dist/chunk-44FFQKQX.js +142 -0
  11. package/dist/chunk-4HYPLFJD.js +150 -0
  12. package/dist/chunk-4XIVMVHC.js +361 -0
  13. package/dist/{index-yp88he8n.js → chunk-6CTA6MCE.js} +88 -64
  14. package/dist/chunk-6GEZ6DN5.js +394 -0
  15. package/dist/chunk-7ZFRVCUE.js +211 -0
  16. package/dist/chunk-CAG4FULI.js +121 -0
  17. package/dist/chunk-FF36CQHZ.js +61 -0
  18. package/dist/{index-h32txmxe.js → chunk-FKQO5A3H.js} +6 -13
  19. package/dist/{index-nq520y6k.js → chunk-FWRS4CSC.js} +46 -32
  20. package/dist/chunk-GFZCJ4EH.js +108 -0
  21. package/dist/chunk-GLM4HGN4.js +55 -0
  22. package/dist/{index-4cdr7x2x.js → chunk-GU374KWZ.js} +182 -111
  23. package/dist/chunk-H6JB3PZ3.js +45 -0
  24. package/dist/chunk-IZX2PLIB.js +1240 -0
  25. package/dist/chunk-J2TXUFCZ.js +289 -0
  26. package/dist/chunk-J3WYZO3Q.js +211 -0
  27. package/dist/{index-xzym9w0m.js → chunk-JA7AIHRK.js} +12 -7
  28. package/dist/chunk-JHHEXEDM.js +162 -0
  29. package/dist/chunk-JUEMDWLU.js +233 -0
  30. package/dist/chunk-KFQGP6VL.js +33 -0
  31. package/dist/chunk-KIJITUZB.js +419 -0
  32. package/dist/{index-4wxa8xz4.js → chunk-KQ4A2D2P.js} +162 -23
  33. package/dist/chunk-KSU2GW22.js +958 -0
  34. package/dist/{index-rv1p47gp.js → chunk-L5N5PR2S.js} +3015 -2480
  35. package/dist/{index-h9e2efx4.js → chunk-LNUIGRDZ.js} +71 -55
  36. package/dist/{index-skhn0agf.js → chunk-MLC5BUYO.js} +19 -20
  37. package/dist/chunk-MPXUVGT3.js +104 -0
  38. package/dist/chunk-N6MYZT4O.js +68 -0
  39. package/dist/chunk-O2AV5WMN.js +48 -0
  40. package/dist/chunk-PZ4XYZ4J.js +143 -0
  41. package/dist/chunk-QB5ISE47.js +419 -0
  42. package/dist/chunk-RSWUFTO2.js +857 -0
  43. package/dist/chunk-S3XLFZ27.js +1095 -0
  44. package/dist/{index-w5wccer3.js → chunk-S6GBJ2ZB.js} +28 -12
  45. package/dist/{index-7pjz3tsy.js → chunk-SGMDTWJJ.js} +57 -15
  46. package/dist/chunk-SPSPV5BC.js +390 -0
  47. package/dist/chunk-TCKXSOBP.js +123 -0
  48. package/dist/chunk-UBGUDMUV.js +59 -0
  49. package/dist/{index-wt8rz4gn.js → chunk-UQISRW6T.js} +97 -26
  50. package/dist/chunk-USEINYUL.js +12 -0
  51. package/dist/{index-bmyt7k8n.js → chunk-UZRUP7QW.js} +12 -4
  52. package/dist/{index-xhcp6xrn.js → chunk-VBYUTRXX.js} +695 -514
  53. package/dist/{index-vkpkfwhq.js → chunk-VDAKEOML.js} +234 -194
  54. package/dist/chunk-WXSWA3MV.js +0 -0
  55. package/dist/{index-n9f2qyh5.js → chunk-X5FLTRUB.js} +55 -33
  56. package/dist/{index-h7zxhhhh.js → chunk-XMQ7G77X.js} +46 -38
  57. package/dist/{index-w7ng765c.js → chunk-YCM7ZYEZ.js} +102 -49
  58. package/dist/cli/deploy-cli.d.ts +18 -0
  59. package/dist/cli/deploy-cli.d.ts.map +1 -0
  60. package/dist/cli/errors.d.ts +6 -0
  61. package/dist/cli/errors.d.ts.map +1 -0
  62. package/dist/cli/examples.d.ts +23 -0
  63. package/dist/cli/examples.d.ts.map +1 -0
  64. package/dist/cli/index.d.ts +1 -1
  65. package/dist/cli/index.d.ts.map +1 -1
  66. package/dist/cli/index.js +2426 -6225
  67. package/dist/client/index.browser.d.ts +29 -0
  68. package/dist/client/index.browser.d.ts.map +1 -0
  69. package/dist/client/index.browser.js +64 -0
  70. package/dist/client/index.d.ts +6 -1
  71. package/dist/client/index.d.ts.map +1 -1
  72. package/dist/client/index.js +41 -21
  73. package/dist/client/live.d.ts +67 -0
  74. package/dist/client/live.d.ts.map +1 -0
  75. package/dist/client/reactive.d.ts +31 -0
  76. package/dist/client/reactive.d.ts.map +1 -0
  77. package/dist/client/sdk.browser.d.ts +104 -0
  78. package/dist/client/sdk.browser.d.ts.map +1 -0
  79. package/dist/client/sdk.browser.js +9 -0
  80. package/dist/client/sdk.d.ts +26 -2
  81. package/dist/client/sdk.d.ts.map +1 -1
  82. package/dist/client/sdk.js +9 -0
  83. package/dist/client/vcs-client.d.ts +129 -0
  84. package/dist/client/vcs-client.d.ts.map +1 -0
  85. package/dist/cms/index.js +171 -163
  86. package/dist/{config-8hczw0rs.js → config-PFTP67TR.js} +8 -9
  87. package/dist/core/computation/index.d.ts +5 -0
  88. package/dist/core/computation/index.d.ts.map +1 -0
  89. package/dist/core/computation/rollup.d.ts +18 -0
  90. package/dist/core/computation/rollup.d.ts.map +1 -0
  91. package/dist/core/index.d.ts +5 -0
  92. package/dist/core/index.d.ts.map +1 -1
  93. package/dist/core/index.js +171 -104
  94. package/dist/core/kernel/boot-middleware.d.ts +10 -0
  95. package/dist/core/kernel/boot-middleware.d.ts.map +1 -0
  96. package/dist/core/kernel/logic-middleware.d.ts +7 -1
  97. package/dist/core/kernel/logic-middleware.d.ts.map +1 -1
  98. package/dist/core/kernel/trellis-kernel.d.ts.map +1 -1
  99. package/dist/core/ontology/types.d.ts +5 -0
  100. package/dist/core/ontology/types.d.ts.map +1 -1
  101. package/dist/core/persist/better-sqlite-backend.d.ts +9 -2
  102. package/dist/core/persist/better-sqlite-backend.d.ts.map +1 -1
  103. package/dist/core/persist/factory.d.ts +6 -7
  104. package/dist/core/persist/factory.d.ts.map +1 -1
  105. package/dist/core/persist/factory.js +2 -3
  106. package/dist/core/persist/sqljs-backend.js +2 -3
  107. package/dist/db/index.d.ts +4 -1
  108. package/dist/db/index.d.ts.map +1 -1
  109. package/dist/db/index.js +67 -54
  110. package/dist/db/inspector.js +11 -19
  111. package/dist/db/trellis.css +1 -1
  112. package/dist/decisions/index.js +9 -10
  113. package/dist/deploy-LQ7GUGJ5.js +9 -0
  114. package/dist/deploy-YNVG5E4E.js +9 -0
  115. package/dist/deploy-cli-24BCHAXY.js +67 -0
  116. package/dist/deploy-cli-C35HTITO.js +67 -0
  117. package/dist/embeddings/auto-embed.d.ts +2 -2
  118. package/dist/embeddings/auto-embed.d.ts.map +1 -1
  119. package/dist/embeddings/index.js +20 -22
  120. package/dist/embeddings/search.d.ts +2 -1
  121. package/dist/embeddings/search.d.ts.map +1 -1
  122. package/dist/embeddings/store.d.ts +25 -4
  123. package/dist/embeddings/store.d.ts.map +1 -1
  124. package/dist/engine.d.ts +59 -19
  125. package/dist/engine.d.ts.map +1 -1
  126. package/dist/import-UZEKXU3B.js +10 -0
  127. package/dist/index.js +102 -93
  128. package/dist/launch-explorer-HZ4ZJA4X.js +95 -0
  129. package/dist/links/index.js +24 -26
  130. package/dist/mcp/server.d.ts.map +1 -1
  131. package/dist/plugins/agent-memory/index.js +316 -0
  132. package/dist/plugins/idea-garden/index.js +165 -0
  133. package/dist/plugins/plan-approval/index.js +579 -0
  134. package/dist/plugins/proactive-watcher/index.js +194 -0
  135. package/dist/{index-2r4jxwnb.js → query-XYLTJYSA.js} +14 -15
  136. package/dist/react/index.js +39 -70
  137. package/dist/react/realtime.js +11 -0
  138. package/dist/react/schema-hooks.js +87 -0
  139. package/dist/realtime/broadcast-channel-transport.d.ts +43 -0
  140. package/dist/realtime/broadcast-channel-transport.d.ts.map +1 -0
  141. package/dist/realtime/durable-object-relay-transport.d.ts +96 -0
  142. package/dist/realtime/durable-object-relay-transport.d.ts.map +1 -0
  143. package/dist/realtime/index.d.ts +44 -0
  144. package/dist/realtime/index.d.ts.map +1 -0
  145. package/dist/realtime/index.js +40 -0
  146. package/dist/realtime/memory-hub.d.ts +32 -0
  147. package/dist/realtime/memory-hub.d.ts.map +1 -0
  148. package/dist/realtime/persistent-channel.d.ts +105 -0
  149. package/dist/realtime/persistent-channel.d.ts.map +1 -0
  150. package/dist/realtime/presence.d.ts +73 -0
  151. package/dist/realtime/presence.d.ts.map +1 -0
  152. package/dist/realtime/relay-persistence.d.ts +37 -0
  153. package/dist/realtime/relay-persistence.d.ts.map +1 -0
  154. package/dist/realtime/relay-persistence.js +107 -0
  155. package/dist/realtime/relay-server.d.ts +103 -0
  156. package/dist/realtime/relay-server.d.ts.map +1 -0
  157. package/dist/realtime/room.d.ts +98 -0
  158. package/dist/realtime/room.d.ts.map +1 -0
  159. package/dist/realtime/text.d.ts +73 -0
  160. package/dist/realtime/text.d.ts.map +1 -0
  161. package/dist/realtime/types.d.ts +89 -0
  162. package/dist/realtime/types.d.ts.map +1 -0
  163. package/dist/realtime/websocket-relay-transport.d.ts +28 -0
  164. package/dist/realtime/websocket-relay-transport.d.ts.map +1 -0
  165. package/dist/realtime.bundle.js +1100 -0
  166. package/dist/{remote-manager-xvbg4230.js → remote-manager-ODE3T2KR.js} +25 -15
  167. package/dist/scaffold/seed.d.ts.map +1 -1
  168. package/dist/scaffold/write.d.ts +1 -1
  169. package/dist/scaffold/write.d.ts.map +1 -1
  170. package/dist/schema/define.d.ts +137 -0
  171. package/dist/schema/define.d.ts.map +1 -0
  172. package/dist/schema/entity-projection.d.ts +34 -0
  173. package/dist/schema/entity-projection.d.ts.map +1 -0
  174. package/dist/schema/eql.d.ts +46 -0
  175. package/dist/schema/eql.d.ts.map +1 -0
  176. package/dist/schema/index.d.ts +21 -0
  177. package/dist/schema/index.d.ts.map +1 -0
  178. package/dist/schema/index.js +46 -0
  179. package/dist/schema/kernel-resolve.d.ts +21 -0
  180. package/dist/schema/kernel-resolve.d.ts.map +1 -0
  181. package/dist/schema/mutations.d.ts +20 -0
  182. package/dist/schema/mutations.d.ts.map +1 -0
  183. package/dist/schema/resolve.d.ts +21 -0
  184. package/dist/schema/resolve.d.ts.map +1 -0
  185. package/dist/server/deploy-meta.d.ts +25 -0
  186. package/dist/server/deploy-meta.d.ts.map +1 -0
  187. package/dist/server/deploy.d.ts +7 -2
  188. package/dist/server/deploy.d.ts.map +1 -1
  189. package/dist/server/index.d.ts +7 -2
  190. package/dist/server/index.d.ts.map +1 -1
  191. package/dist/server/index.js +100 -58
  192. package/dist/server/node-adapter.js +5 -104
  193. package/dist/server/realtime.d.ts +14 -3
  194. package/dist/server/realtime.d.ts.map +1 -1
  195. package/dist/server/server.d.ts +8 -16
  196. package/dist/server/server.d.ts.map +1 -1
  197. package/dist/server/sprites.d.ts +18 -1
  198. package/dist/server/sprites.d.ts.map +1 -1
  199. package/dist/server/tenancy.d.ts +4 -0
  200. package/dist/server/tenancy.d.ts.map +1 -1
  201. package/dist/server/usage-meter.d.ts +53 -0
  202. package/dist/server/usage-meter.d.ts.map +1 -0
  203. package/dist/server-MB3OPSPI.js +18 -0
  204. package/dist/server-ZVWGLLRF.js +18 -0
  205. package/dist/sprites-KQGTGM6W.js +27 -0
  206. package/dist/{sprites-vc4qbrp1.js → sprites-RU3E4XQN.js} +6 -7
  207. package/dist/svelte/index.d.ts +17 -0
  208. package/dist/svelte/index.d.ts.map +1 -0
  209. package/dist/svelte/index.js +51 -0
  210. package/dist/svelte/schema-hooks.d.ts +45 -0
  211. package/dist/svelte/schema-hooks.d.ts.map +1 -0
  212. package/dist/svelte/schema-hooks.js +71 -0
  213. package/dist/svelte/stores.d.ts +78 -0
  214. package/dist/svelte/stores.d.ts.map +1 -0
  215. package/dist/sync/http-transport.d.ts +3 -3
  216. package/dist/sync/http-transport.d.ts.map +1 -1
  217. package/dist/sync/index.d.ts +15 -1
  218. package/dist/sync/index.d.ts.map +1 -1
  219. package/dist/sync/index.js +617 -0
  220. package/dist/sync/memory-room.d.ts +37 -0
  221. package/dist/sync/memory-room.d.ts.map +1 -0
  222. package/dist/sync/memory-transport.d.ts +3 -3
  223. package/dist/sync/memory-transport.d.ts.map +1 -1
  224. package/dist/sync/partykit-room.d.ts +40 -0
  225. package/dist/sync/partykit-room.d.ts.map +1 -0
  226. package/dist/sync/partykit-transport.d.ts +84 -0
  227. package/dist/sync/partykit-transport.d.ts.map +1 -0
  228. package/dist/sync/room-core.d.ts +53 -0
  229. package/dist/sync/room-core.d.ts.map +1 -0
  230. package/dist/sync/sync-engine.d.ts +40 -2
  231. package/dist/sync/sync-engine.d.ts.map +1 -1
  232. package/dist/sync/sync-room-server.d.ts +39 -0
  233. package/dist/sync/sync-room-server.d.ts.map +1 -0
  234. package/dist/sync/types.d.ts +70 -3
  235. package/dist/sync/types.d.ts.map +1 -1
  236. package/dist/sync/vcs-sync-peer.d.ts +63 -0
  237. package/dist/sync/vcs-sync-peer.d.ts.map +1 -0
  238. package/dist/sync/ws-transport.d.ts +2 -2
  239. package/dist/sync/ws-transport.d.ts.map +1 -1
  240. package/dist/tenancy-NBLLGCNJ.js +14 -0
  241. package/dist/tenancy-POMWQP6M.js +16 -0
  242. package/dist/ui/client.html +355 -67
  243. package/dist/ui/launch-explorer.d.ts +22 -0
  244. package/dist/ui/launch-explorer.d.ts.map +1 -0
  245. package/dist/ui/server.d.ts +1 -1
  246. package/dist/ui/server.d.ts.map +1 -1
  247. package/dist/vcs/blob-store.d.ts.map +1 -1
  248. package/dist/vcs/idb-op-log.d.ts +67 -0
  249. package/dist/vcs/idb-op-log.d.ts.map +1 -0
  250. package/dist/vcs/index.d.ts +1 -0
  251. package/dist/vcs/index.d.ts.map +1 -1
  252. package/dist/vcs/index.js +81 -72
  253. package/dist/vcs/issue.d.ts +22 -5
  254. package/dist/vcs/issue.d.ts.map +1 -1
  255. package/dist/vcs/lane-materialize.d.ts +5 -0
  256. package/dist/vcs/lane-materialize.d.ts.map +1 -1
  257. package/dist/vcs/op-log.d.ts +28 -2
  258. package/dist/vcs/op-log.d.ts.map +1 -1
  259. package/dist/vcs/ops.d.ts +10 -0
  260. package/dist/vcs/ops.d.ts.map +1 -1
  261. package/dist/vcs/types.d.ts +2 -0
  262. package/dist/vcs/types.d.ts.map +1 -1
  263. package/dist/{vm-config-6xhsj6b3.js → vm-config-JI4OXKDQ.js} +9 -10
  264. package/dist/vue/hooks.d.ts +64 -0
  265. package/dist/vue/hooks.d.ts.map +1 -0
  266. package/dist/vue/index.d.ts +19 -0
  267. package/dist/vue/index.d.ts.map +1 -0
  268. package/dist/vue/index.js +59 -0
  269. package/dist/vue/schema-hooks.d.ts +41 -0
  270. package/dist/vue/schema-hooks.d.ts.map +1 -0
  271. package/dist/vue/schema-hooks.js +64 -0
  272. package/package.json +130 -17
  273. package/dist/deploy-999q207z.js +0 -10
  274. package/dist/engine-y0724kjq.js +0 -8
  275. package/dist/import-s2b8e0ft.js +0 -11
  276. package/dist/index-a76rekgs.js +0 -67
  277. package/dist/index-c9h37r6h.js +0 -1
  278. package/dist/index-hr9qvv77.js +0 -860
  279. package/dist/index-k5b0xskw.js +0 -1
  280. package/dist/index-nzb3am4f.js +0 -80
  281. package/dist/index-wncptktd.js +0 -292
  282. package/dist/index-y6a4kj0p.js +0 -43
  283. package/dist/index-yhwjgfvj.js +0 -342
  284. package/dist/sdk-bepky0xs.js +0 -16
  285. package/dist/server-szdjx0nt.js +0 -13
  286. package/dist/sqlite-backend-0vsmc6qj.js +0 -8
  287. package/dist/tenancy-pjm32b4v.js +0 -14
@@ -0,0 +1,123 @@
1
+ import {
2
+ __esm
3
+ } from "./chunk-KFQGP6VL.js";
4
+
5
+ // src/server/node-adapter.ts
6
+ async function startNodeServer(opts) {
7
+ const http = await import("http");
8
+ const httpServer = http.createServer(
9
+ async (req, res) => {
10
+ try {
11
+ const fetchReq = await toFetchRequest(req);
12
+ const fetchRes = await opts.fetch(fetchReq);
13
+ await writeFetchResponse(res, fetchRes);
14
+ } catch (err) {
15
+ const msg = err instanceof Error ? err.message : String(err);
16
+ res.statusCode = 500;
17
+ res.setHeader("Content-Type", "application/json");
18
+ res.end(JSON.stringify({ error: "Internal Server Error", message: msg }));
19
+ }
20
+ }
21
+ );
22
+ let wss = null;
23
+ try {
24
+ const { WebSocketServer } = await import("ws");
25
+ wss = new WebSocketServer({ noServer: true });
26
+ httpServer.on("upgrade", (req, socket, head) => {
27
+ wss.handleUpgrade(req, socket, head, (ws) => {
28
+ wss.emit("connection", ws, req);
29
+ });
30
+ });
31
+ wss.on("connection", (ws) => {
32
+ Promise.resolve(opts.websocket.open(ws)).catch(() => {
33
+ });
34
+ ws.on("message", (raw) => {
35
+ const data = Array.isArray(raw) ? Buffer.concat(raw).toString() : raw instanceof ArrayBuffer ? Buffer.from(raw).toString() : raw.toString();
36
+ Promise.resolve(opts.websocket.message(ws, data)).catch(() => {
37
+ });
38
+ });
39
+ ws.on("close", () => opts.websocket.close(ws));
40
+ });
41
+ } catch {
42
+ httpServer.on("upgrade", (_req, socket) => {
43
+ socket.destroy();
44
+ });
45
+ }
46
+ await new Promise(
47
+ (resolve) => httpServer.listen(opts.port, opts.hostname, resolve)
48
+ );
49
+ const addr = httpServer.address();
50
+ const boundPort = typeof addr === "object" && addr ? addr.port : opts.port;
51
+ const boundHost = typeof addr === "object" && addr ? addr.address : opts.hostname;
52
+ return wrapNodeServer(httpServer, wss, boundPort, boundHost);
53
+ }
54
+ async function toFetchRequest(req) {
55
+ const host = req.headers.host ?? "localhost";
56
+ const protocol = req.socket?.encrypted ? "https" : "http";
57
+ const url = `${protocol}://${host}${req.url ?? "/"}`;
58
+ const method = req.method ?? "GET";
59
+ const headers = new Headers();
60
+ for (const [key, value] of Object.entries(req.headers)) {
61
+ if (Array.isArray(value)) {
62
+ for (const v of value) headers.append(key, v);
63
+ } else if (value != null) {
64
+ headers.set(key, value);
65
+ }
66
+ }
67
+ const hasBody = method !== "GET" && method !== "HEAD";
68
+ const body = hasBody ? new Uint8Array(await readBody(req)) : void 0;
69
+ return new Request(url, { method, headers, body });
70
+ }
71
+ function readBody(req) {
72
+ return new Promise((resolve, reject) => {
73
+ const chunks = [];
74
+ req.on("data", (c) => chunks.push(c));
75
+ req.on("end", () => resolve(Buffer.concat(chunks)));
76
+ req.on("error", reject);
77
+ });
78
+ }
79
+ async function writeFetchResponse(res, fetchRes) {
80
+ res.statusCode = fetchRes.status;
81
+ fetchRes.headers.forEach((value, key) => res.setHeader(key, value));
82
+ if (!fetchRes.body) {
83
+ res.end();
84
+ return;
85
+ }
86
+ const reader = fetchRes.body.getReader();
87
+ while (true) {
88
+ const { done, value } = await reader.read();
89
+ if (done) break;
90
+ res.write(value);
91
+ }
92
+ res.end();
93
+ }
94
+ function wrapNodeServer(httpServer, wss, port, hostname) {
95
+ return {
96
+ port,
97
+ hostname: hostname ?? "localhost",
98
+ stop(closeActiveConnections) {
99
+ return new Promise((resolve, reject) => {
100
+ const closeHttp = () => {
101
+ httpServer.close((err) => err ? reject(err) : resolve());
102
+ };
103
+ if (!wss) {
104
+ closeHttp();
105
+ return;
106
+ }
107
+ if (closeActiveConnections) {
108
+ for (const client of wss.clients) client.terminate();
109
+ }
110
+ wss.close(() => closeHttp());
111
+ });
112
+ }
113
+ };
114
+ }
115
+ var init_node_adapter = __esm({
116
+ "src/server/node-adapter.ts"() {
117
+ }
118
+ });
119
+
120
+ export {
121
+ startNodeServer,
122
+ init_node_adapter
123
+ };
@@ -0,0 +1,59 @@
1
+ // src/client/reactive.ts
2
+ var Signal = class {
3
+ _value;
4
+ _subs = /* @__PURE__ */ new Set();
5
+ constructor(initial) {
6
+ this._value = initial;
7
+ }
8
+ get value() {
9
+ return this._value;
10
+ }
11
+ set value(v) {
12
+ if (Object.is(this._value, v)) return;
13
+ this._value = v;
14
+ for (const fn of this._subs) {
15
+ try {
16
+ fn(v);
17
+ } catch {
18
+ }
19
+ }
20
+ }
21
+ /** Subscribe to changes. Immediately called with current value. */
22
+ subscribe(fn) {
23
+ this._subs.add(fn);
24
+ try {
25
+ fn(this._value);
26
+ } catch {
27
+ }
28
+ return () => {
29
+ this._subs.delete(fn);
30
+ };
31
+ }
32
+ /** Read without tracking. */
33
+ peek() {
34
+ return this._value;
35
+ }
36
+ /** Whether any subscriber is registered. */
37
+ hasSubscribers() {
38
+ return this._subs.size > 0;
39
+ }
40
+ };
41
+ var BatchSignal = class extends Signal {
42
+ _raf = null;
43
+ constructor(initial) {
44
+ super(initial);
45
+ }
46
+ set value(v) {
47
+ if (Object.is(this.peek(), v)) return;
48
+ if (this._raf !== null) cancelAnimationFrame(this._raf);
49
+ this._raf = requestAnimationFrame(() => {
50
+ this._raf = null;
51
+ super.value = v;
52
+ });
53
+ }
54
+ };
55
+
56
+ export {
57
+ Signal,
58
+ BatchSignal
59
+ };
@@ -1,30 +1,83 @@
1
- // @bun
2
1
  import {
2
+ assertSpriteCli,
3
3
  runSpriteCmd,
4
4
  runSpriteCopy
5
- } from "./index-y6a4kj0p.js";
5
+ } from "./chunk-FF36CQHZ.js";
6
6
  import {
7
7
  updateConfig
8
- } from "./index-xzym9w0m.js";
8
+ } from "./chunk-JA7AIHRK.js";
9
+ import {
10
+ __require
11
+ } from "./chunk-KFQGP6VL.js";
9
12
 
10
13
  // src/server/deploy.ts
11
14
  import { existsSync, writeFileSync, mkdirSync } from "fs";
12
15
  import { join, resolve } from "path";
16
+
17
+ // src/server/deploy-meta.ts
18
+ var DEPLOY_NAME_RE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
19
+ var MIN_LEN = 3;
20
+ var MAX_LEN = 32;
21
+ var DeployNameError = class extends Error {
22
+ constructor(message) {
23
+ super(message);
24
+ this.name = "DeployNameError";
25
+ }
26
+ };
27
+ function normalizeDeployName(name) {
28
+ return name.trim().toLowerCase();
29
+ }
30
+ function validateDeployName(name) {
31
+ const normalized = normalizeDeployName(name);
32
+ if (!normalized) {
33
+ throw new DeployNameError("Deploy name is required.");
34
+ }
35
+ if (normalized.length < MIN_LEN || normalized.length > MAX_LEN) {
36
+ throw new DeployNameError(
37
+ `Deploy name must be ${MIN_LEN}\u2013${MAX_LEN} characters (got ${normalized.length}).`
38
+ );
39
+ }
40
+ if (normalized.includes("--")) {
41
+ throw new DeployNameError(
42
+ "Deploy name cannot contain consecutive hyphens."
43
+ );
44
+ }
45
+ if (!DEPLOY_NAME_RE.test(normalized)) {
46
+ throw new DeployNameError(
47
+ "Deploy name must start with a letter and use only lowercase letters, numbers, and single hyphens (e.g. my-app)."
48
+ );
49
+ }
50
+ return normalized;
51
+ }
52
+ function buildDeployUrl(name) {
53
+ const slug = validateDeployName(name);
54
+ return `https://${slug}.sprites.app`;
55
+ }
56
+
57
+ // src/server/deploy.ts
13
58
  async function deploy(opts) {
14
- const { name, port = 3000, configDir = ".", onProgress = () => {} } = opts;
59
+ const { port = 3e3, configDir = ".", onProgress = () => {
60
+ } } = opts;
61
+ const name = validateDeployName(opts.name);
15
62
  const apiKey = opts.apiKey ?? generateSecret("spk_");
16
63
  const jwtSecret = opts.jwtSecret ?? generateSecret("jws_");
17
- const url = `https://${name}.sprites.app`;
64
+ const url = buildDeployUrl(name);
65
+ if (opts.stub) {
66
+ onProgress("Stub deploy \u2014 skipping Sprites provisioning");
67
+ onProgress("Writing .trellis-db.json...");
68
+ writeRemoteDeployConfig({ name, url, apiKey, configDir });
69
+ return { url, name, apiKey };
70
+ }
18
71
  onProgress("Checking Sprites CLI...");
19
- await runSpriteCmd(["--version"]).catch(() => {
20
- throw new Error("`sprite` CLI not found. Install it from https://docs.sprites.dev and authenticate.");
21
- });
72
+ await assertSpriteCli();
22
73
  onProgress("Writing server entrypoint...");
23
74
  const tmpDir = resolve(configDir, ".trellis-deploy");
24
- if (!existsSync(tmpDir))
25
- mkdirSync(tmpDir, { recursive: true });
75
+ if (!existsSync(tmpDir)) mkdirSync(tmpDir, { recursive: true });
26
76
  const entrypoint = join(tmpDir, "server-entry.ts");
27
- writeFileSync(entrypoint, generateServerEntrypoint({ port, apiKey, jwtSecret }));
77
+ writeFileSync(
78
+ entrypoint,
79
+ generateServerEntrypoint({ port, apiKey, jwtSecret })
80
+ );
28
81
  onProgress("Bundling server with Bun...");
29
82
  const bundlePath = join(tmpDir, "server.js");
30
83
  await runBun([
@@ -55,7 +108,8 @@ async function deploy(opts) {
55
108
  "bash",
56
109
  "-c",
57
110
  "which bun || curl -fsSL https://bun.sh/install | bash"
58
- ]).catch(() => {});
111
+ ]).catch(() => {
112
+ });
59
113
  onProgress("Starting server...");
60
114
  await runSpriteCmd([
61
115
  "exec",
@@ -64,7 +118,8 @@ async function deploy(opts) {
64
118
  "bash",
65
119
  "-c",
66
120
  "sprite sessions list 2>/dev/null | grep trellis-db | awk '{print $1}' | xargs -r sprite sessions kill"
67
- ]).catch(() => {});
121
+ ]).catch(() => {
122
+ });
68
123
  await runSpriteCmd([
69
124
  "exec",
70
125
  "--sprite",
@@ -78,15 +133,21 @@ async function deploy(opts) {
78
133
  `cd /home/sprite/trellis-db && ~/.bun/bin/bun run server.js`
79
134
  ]);
80
135
  onProgress("Writing .trellis-db.json...");
81
- updateConfig({
82
- mode: "remote",
83
- url,
84
- apiKey,
85
- spriteName: name,
86
- deployedAt: new Date().toISOString()
87
- }, configDir);
136
+ writeRemoteDeployConfig({ name, url, apiKey, configDir });
88
137
  return { url, name, apiKey };
89
138
  }
139
+ function writeRemoteDeployConfig(opts) {
140
+ updateConfig(
141
+ {
142
+ mode: "remote",
143
+ url: opts.url,
144
+ apiKey: opts.apiKey,
145
+ spriteName: opts.name,
146
+ deployedAt: (/* @__PURE__ */ new Date()).toISOString()
147
+ },
148
+ opts.configDir
149
+ );
150
+ }
90
151
  function generateSecret(prefix) {
91
152
  const bytes = new Uint8Array(24);
92
153
  crypto.getRandomValues(bytes);
@@ -94,11 +155,15 @@ function generateSecret(prefix) {
94
155
  return `${prefix}${b64}`;
95
156
  }
96
157
  async function runBun(args) {
97
- const proc = Bun.spawn(["bun", ...args], { stdout: "pipe", stderr: "pipe" });
98
- const exitCode = await proc.exited;
99
- if (exitCode !== 0) {
100
- const err = await new Response(proc.stderr).text();
101
- throw new Error(`bun ${args[0]} failed (exit ${exitCode}): ${err}`);
158
+ const { execFile } = __require("child_process");
159
+ const { promisify } = __require("util");
160
+ const execFileAsync = promisify(execFile);
161
+ try {
162
+ await execFileAsync("bun", args);
163
+ } catch (err) {
164
+ throw new Error(
165
+ `bun ${args[0]} failed (exit ${err.code ?? "?"}): ${err.stderr ?? err.message}`
166
+ );
102
167
  }
103
168
  }
104
169
  function generateServerEntrypoint(opts) {
@@ -129,4 +194,10 @@ console.log('URL: https://\${process.env.SPRITE_NAME ?? 'localhost'}.sprites.app
129
194
  `;
130
195
  }
131
196
 
132
- export { deploy };
197
+ export {
198
+ DeployNameError,
199
+ normalizeDeployName,
200
+ validateDeployName,
201
+ buildDeployUrl,
202
+ deploy
203
+ };
@@ -0,0 +1,12 @@
1
+ // src/schema/mutations.ts
2
+ function entityMutations(client, schema) {
3
+ return {
4
+ create: (attrs) => client.create(schema.type, attrs),
5
+ update: (id, attrs) => client.update(id, attrs),
6
+ remove: (id) => client.delete(id)
7
+ };
8
+ }
9
+
10
+ export {
11
+ entityMutations
12
+ };
@@ -1,4 +1,3 @@
1
- // @bun
2
1
  // src/server/vm-config.ts
3
2
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
4
3
  import { join } from "path";
@@ -43,7 +42,7 @@ function setActiveSprite(spriteName) {
43
42
  if (!config.sprites[spriteName]) {
44
43
  config.sprites[spriteName] = {
45
44
  name: spriteName,
46
- createdAt: new Date().toISOString(),
45
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
47
46
  url: `https://${spriteName}.sprites.app`,
48
47
  hasTrellis: false
49
48
  };
@@ -55,7 +54,7 @@ function trackSprite(spriteName, opts = {}) {
55
54
  const config = loadVmConfig();
56
55
  const existing = config.sprites[spriteName] ?? {
57
56
  name: spriteName,
58
- createdAt: new Date().toISOString(),
57
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
59
58
  url: `https://${spriteName}.sprites.app`,
60
59
  hasTrellis: false
61
60
  };
@@ -87,4 +86,13 @@ function getSprite(spriteName) {
87
86
  return config.sprites[spriteName] ?? null;
88
87
  }
89
88
 
90
- export { loadVmConfig, saveVmConfig, getActiveSprite, setActiveSprite, trackSprite, untrackSprite, isSpriteTracked, getSprite };
89
+ export {
90
+ loadVmConfig,
91
+ saveVmConfig,
92
+ getActiveSprite,
93
+ setActiveSprite,
94
+ trackSprite,
95
+ untrackSprite,
96
+ isSpriteTracked,
97
+ getSprite
98
+ };