@yourrealm/sdk 0.0.0-alpha.1378.ce03c8dc

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 (230) hide show
  1. package/LICENSE-EXCEPTION +26 -0
  2. package/README.md +34 -0
  3. package/dist/chunk-3R6KEFOI.js +22 -0
  4. package/dist/chunk-67BDAMYX.js +376 -0
  5. package/dist/chunk-AITGS27R.js +139 -0
  6. package/dist/chunk-CMAEHQ4F.js +6 -0
  7. package/dist/chunk-MLKGABMK.js +9 -0
  8. package/dist/chunk-O3UIK34B.js +1430 -0
  9. package/dist/chunk-VHTUSZUX.js +176 -0
  10. package/dist/cli.js +9006 -0
  11. package/dist/docker.js +54 -0
  12. package/dist/index.js +1053 -0
  13. package/dist/ingress.js +436 -0
  14. package/dist/jsx-runtime.js +2 -0
  15. package/dist/preact.js +22 -0
  16. package/dist/service-url.js +11 -0
  17. package/dist/services.js +213 -0
  18. package/dist/test.js +5069 -0
  19. package/dist/ui.js +254 -0
  20. package/dist/worker-protocol.js +89 -0
  21. package/package.json +112 -0
  22. package/src/app-icon.ts +74 -0
  23. package/src/apply.ts +52 -0
  24. package/src/bundle-ui.ts +211 -0
  25. package/src/bundle.ts +546 -0
  26. package/src/cli/build-dev-landing.ts +84 -0
  27. package/src/cli/build-install-panel.ts +90 -0
  28. package/src/cli/build-runtime.ts +133 -0
  29. package/src/cli/build.ts +63 -0
  30. package/src/cli/dev.ts +107 -0
  31. package/src/cli/down.ts +60 -0
  32. package/src/cli/main.ts +56 -0
  33. package/src/cli/test.ts +61 -0
  34. package/src/cli/validate.ts +37 -0
  35. package/src/compile.ts +100 -0
  36. package/src/create-app.ts +982 -0
  37. package/src/deep-merge.ts +33 -0
  38. package/src/dev/fixture.ts +48 -0
  39. package/src/dev/install-handler.ts +383 -0
  40. package/src/dev/server.ts +968 -0
  41. package/src/dev/stack.ts +108 -0
  42. package/src/dev/state.ts +159 -0
  43. package/src/docker.ts +96 -0
  44. package/src/errors.ts +61 -0
  45. package/src/factory.ts +481 -0
  46. package/src/garage.ts +56 -0
  47. package/src/generator/hash.ts +6 -0
  48. package/src/generator/resolve-refs.ts +207 -0
  49. package/src/grants-builder.ts +100 -0
  50. package/src/grants.ts +260 -0
  51. package/src/home-api.ts +172 -0
  52. package/src/home-cookie.ts +10 -0
  53. package/src/home-registry.ts +120 -0
  54. package/src/home.ts +187 -0
  55. package/src/host-registry.ts +143 -0
  56. package/src/http-header.ts +20 -0
  57. package/src/identifiers.ts +49 -0
  58. package/src/index.ts +66 -0
  59. package/src/info.ts +64 -0
  60. package/src/ini.ts +50 -0
  61. package/src/json.ts +14 -0
  62. package/src/jsx-runtime/index.ts +5 -0
  63. package/src/keys.ts +29 -0
  64. package/src/mysql.ts +56 -0
  65. package/src/pack-build.ts +108 -0
  66. package/src/pack.ts +115 -0
  67. package/src/peer-registry.ts +121 -0
  68. package/src/peer-world.ts +117 -0
  69. package/src/permission-meta.ts +116 -0
  70. package/src/permissions.ts +108 -0
  71. package/src/pkg-root.ts +34 -0
  72. package/src/postgres.ts +79 -0
  73. package/src/preact/index.ts +27 -0
  74. package/src/redis.ts +43 -0
  75. package/src/ref.ts +271 -0
  76. package/src/remote-registry.ts +33 -0
  77. package/src/required-host-kinds.ts +110 -0
  78. package/src/resolve-context.ts +111 -0
  79. package/src/resolve.ts +471 -0
  80. package/src/runtime/docker/compose/compose-schema.ts +118 -0
  81. package/src/runtime/docker/compose/convert-to-docker-compose.ts +278 -0
  82. package/src/runtime/docker/compose/default-hardening.ts +21 -0
  83. package/src/runtime/docker/compose/effects.ts +107 -0
  84. package/src/runtime/docker/compose/index.ts +17 -0
  85. package/src/runtime/docker/compose/labels.ts +39 -0
  86. package/src/runtime/docker/compose/types.ts +78 -0
  87. package/src/runtime/docker/home-proxy-server/index.ts +177 -0
  88. package/src/runtime/docker/home-proxy-server/protocol.ts +53 -0
  89. package/src/runtime/docker/ingress/build-config.ts +819 -0
  90. package/src/runtime/docker/ingress/index.ts +16 -0
  91. package/src/runtime/docker/ingress/types.ts +182 -0
  92. package/src/runtime/docker/log-frames.ts +121 -0
  93. package/src/runtime/docker/logs-server/index.ts +366 -0
  94. package/src/runtime/docker/spawn-server/context-key.ts +82 -0
  95. package/src/runtime/docker/spawn-server/index.ts +492 -0
  96. package/src/runtime/docker/spawn-server/protocol.ts +70 -0
  97. package/src/runtime/docker/spawn-server/spec.ts +122 -0
  98. package/src/runtime/docker/stats-server/disks.ts +161 -0
  99. package/src/runtime/docker/stats-server/index.ts +322 -0
  100. package/src/runtime/home-client/index.ts +71 -0
  101. package/src/runtime/log-line.ts +24 -0
  102. package/src/runtime/logs-client/index.ts +175 -0
  103. package/src/runtime/spawn-client/index.ts +93 -0
  104. package/src/runtime/spawn-client/kaniko.ts +79 -0
  105. package/src/runtime/stats-client/index.ts +65 -0
  106. package/src/runtime/stats-sample.ts +95 -0
  107. package/src/safe-json.ts +37 -0
  108. package/src/sandbox.ts +1209 -0
  109. package/src/schema/build-apps.ts +38 -0
  110. package/src/schema/home.ts +217 -0
  111. package/src/schema/host.ts +792 -0
  112. package/src/schema/inputs.ts +26 -0
  113. package/src/schema/nodes.ts +75 -0
  114. package/src/schema/peer.ts +400 -0
  115. package/src/schema/public-domain.ts +116 -0
  116. package/src/schema/remote.ts +74 -0
  117. package/src/security.ts +594 -0
  118. package/src/serialize.ts +21 -0
  119. package/src/service-definition.ts +284 -0
  120. package/src/service-url.ts +64 -0
  121. package/src/service.ts +39 -0
  122. package/src/services/index.ts +5 -0
  123. package/src/shared.ts +65 -0
  124. package/src/speculative-silo.ts +96 -0
  125. package/src/stable-secret.ts +14 -0
  126. package/src/surfaces.ts +264 -0
  127. package/src/tailwind-bin.ts +56 -0
  128. package/src/test/boot.ts +192 -0
  129. package/src/test/compile.ts +501 -0
  130. package/src/test/describe.ts +117 -0
  131. package/src/test/index.ts +11 -0
  132. package/src/test/ingress-fixture.ts +37 -0
  133. package/src/test/types.ts +318 -0
  134. package/src/trusted-headers.ts +79 -0
  135. package/src/types.ts +126 -0
  136. package/src/ui/components/aside.tsx +96 -0
  137. package/src/ui/components/badge.tsx +42 -0
  138. package/src/ui/components/button.tsx +59 -0
  139. package/src/ui/components/card.tsx +106 -0
  140. package/src/ui/components/checkbox.tsx +37 -0
  141. package/src/ui/components/code-block.tsx +29 -0
  142. package/src/ui/components/combobox.tsx +119 -0
  143. package/src/ui/components/config-field.tsx +284 -0
  144. package/src/ui/components/dialog.tsx +137 -0
  145. package/src/ui/components/domain-editor.tsx +317 -0
  146. package/src/ui/components/domain-list.ts +205 -0
  147. package/src/ui/components/dropdown-menu.tsx +73 -0
  148. package/src/ui/components/empty-state.tsx +51 -0
  149. package/src/ui/components/highlight.ts +59 -0
  150. package/src/ui/components/icons.tsx +101 -0
  151. package/src/ui/components/image-posture.tsx +85 -0
  152. package/src/ui/components/input.tsx +28 -0
  153. package/src/ui/components/label.tsx +16 -0
  154. package/src/ui/components/line-chart.tsx +113 -0
  155. package/src/ui/components/page.tsx +39 -0
  156. package/src/ui/components/permission-row.tsx +262 -0
  157. package/src/ui/components/permission-section.tsx +51 -0
  158. package/src/ui/components/pie-chart.tsx +245 -0
  159. package/src/ui/components/schema-block.tsx +60 -0
  160. package/src/ui/components/separator.tsx +42 -0
  161. package/src/ui/components/sheet.tsx +130 -0
  162. package/src/ui/components/sidebar.tsx +650 -0
  163. package/src/ui/components/silo-picker.tsx +510 -0
  164. package/src/ui/components/skeleton.tsx +13 -0
  165. package/src/ui/components/sonner.tsx +33 -0
  166. package/src/ui/components/switch.tsx +58 -0
  167. package/src/ui/components/table-view.ts +219 -0
  168. package/src/ui/components/table.tsx +506 -0
  169. package/src/ui/components/tabs.tsx +59 -0
  170. package/src/ui/components/timeago.tsx +84 -0
  171. package/src/ui/components/tooltip.tsx +56 -0
  172. package/src/ui/components.json +21 -0
  173. package/src/ui/dev/dev-shell.tsx +145 -0
  174. package/src/ui/home/home-grid.tsx +177 -0
  175. package/src/ui/hooks/use-mobile.ts +19 -0
  176. package/src/ui/index.ts +189 -0
  177. package/src/ui/install/adapter.ts +193 -0
  178. package/src/ui/install/deploy-targets-picker.tsx +185 -0
  179. package/src/ui/install/install-app-panel.tsx +912 -0
  180. package/src/ui/install/install-error.tsx +62 -0
  181. package/src/ui/install/perms-inactive.ts +50 -0
  182. package/src/ui/install/required-fields.ts +37 -0
  183. package/src/ui/install/tabs-form.tsx +557 -0
  184. package/src/ui/tokens.css +279 -0
  185. package/src/ui/utils.ts +78 -0
  186. package/src/ui-error.ts +139 -0
  187. package/src/ui-runtime/dev-landing-entry.tsx +258 -0
  188. package/src/ui-runtime/index.ts +83 -0
  189. package/src/ui-runtime/install-entry.tsx +119 -0
  190. package/src/ui-runtime/mount.ts +367 -0
  191. package/src/ui-runtime/runtime.css +56 -0
  192. package/src/ui-surface.ts +451 -0
  193. package/src/valkey.ts +43 -0
  194. package/src/worker/extract-tar.ts +125 -0
  195. package/src/worker/identity.ts +183 -0
  196. package/src/worker/index.ts +16 -0
  197. package/src/worker/public-ip.ts +92 -0
  198. package/src/worker/queue.ts +54 -0
  199. package/src/worker/reconcile.ts +127 -0
  200. package/src/worker/start-worker.ts +227 -0
  201. package/src/worker/ui-proxy.ts +335 -0
  202. package/src/worker/uplink.ts +523 -0
  203. package/src/worker/validate.ts +34 -0
  204. package/src/worker/verify-relay.ts +102 -0
  205. package/src/worker-protocol/app-dirs.ts +94 -0
  206. package/src/worker-protocol/home-proxy-paths.ts +76 -0
  207. package/src/worker-protocol/index.ts +55 -0
  208. package/src/worker-protocol/ingress.ts +166 -0
  209. package/src/worker-protocol/logs-socket-path.ts +50 -0
  210. package/src/worker-protocol/networks.ts +39 -0
  211. package/src/worker-protocol/node-version.ts +70 -0
  212. package/src/worker-protocol/silo-paths.ts +114 -0
  213. package/src/worker-protocol/spawn-paths.ts +165 -0
  214. package/src/worker-protocol/stats-socket-path.ts +40 -0
  215. package/src/worker-protocol/update-files.ts +77 -0
  216. package/src/worker-protocol/uplink/constants.ts +86 -0
  217. package/src/worker-protocol/uplink/errors.ts +61 -0
  218. package/src/worker-protocol/uplink/frame.ts +114 -0
  219. package/src/worker-protocol/uplink/identity.ts +40 -0
  220. package/src/worker-protocol/uplink/index.ts +63 -0
  221. package/src/worker-protocol/uplink/methods.ts +462 -0
  222. package/src/worker-protocol/uplink/mux.ts +646 -0
  223. package/src/worker-protocol/uplink/protocol.ts +11 -0
  224. package/src/worker-protocol/uplink/rpc.ts +309 -0
  225. package/src/worker-protocol/uplink/session.ts +540 -0
  226. package/src/worker-protocol/uplink/test-support.ts +188 -0
  227. package/src/worker-protocol/worker-mount.ts +27 -0
  228. package/src/worker-protocol/worker-state.ts +190 -0
  229. package/src/xml.ts +49 -0
  230. package/src/yaml.ts +15 -0
package/dist/ui.js ADDED
@@ -0,0 +1,254 @@
1
+ import "./chunk-MLKGABMK.js";
2
+
3
+ // src/ui-surface.ts
4
+ function loader(def) {
5
+ return def;
6
+ }
7
+ function action(def) {
8
+ return def;
9
+ }
10
+ function page(def) {
11
+ return def;
12
+ }
13
+ function widget(def) {
14
+ return def;
15
+ }
16
+
17
+ // src/ui-error.ts
18
+ var TRANSIENT_UI_ERROR_CODES = /* @__PURE__ */ new Set(["CONTAINER_STARTING"]);
19
+ var UiError = class extends Error {
20
+ code;
21
+ constructor(code, message) {
22
+ super(message);
23
+ this.name = "UiError";
24
+ this.code = code;
25
+ }
26
+ };
27
+ function isUiError(value) {
28
+ return value instanceof UiError;
29
+ }
30
+ function isTransientUiError(err) {
31
+ return isUiError(err) && TRANSIENT_UI_ERROR_CODES.has(err.code);
32
+ }
33
+
34
+ // src/ui/index.ts
35
+ var stub = (() => {
36
+ throw new Error(
37
+ "@yourrealm/sdk/ui has no runtime in this environment. Render functions are bundled by realm-sdk and execute inside the Home iframe."
38
+ );
39
+ });
40
+ var h = stub;
41
+ var Fragment = stub;
42
+ var Badge = stub;
43
+ var Button = stub;
44
+ var buttonVariants = stub;
45
+ var Card = stub;
46
+ var CardAction = stub;
47
+ var CardContent = stub;
48
+ var CardDescription = stub;
49
+ var CardFooter = stub;
50
+ var CardHeader = stub;
51
+ var CardTitle = stub;
52
+ var Checkbox = stub;
53
+ var Combobox = stub;
54
+ var EmptyState = stub;
55
+ var Dialog = stub;
56
+ var DialogClose = stub;
57
+ var DialogContent = stub;
58
+ var DialogDescription = stub;
59
+ var DialogFooter = stub;
60
+ var DialogHeader = stub;
61
+ var DialogOverlay = stub;
62
+ var DialogTitle = stub;
63
+ var DialogTrigger = stub;
64
+ var Input = stub;
65
+ var Label = stub;
66
+ var LineChart = stub;
67
+ var AreaChart = stub;
68
+ var Page = stub;
69
+ var PieChart = stub;
70
+ var Separator = stub;
71
+ var Sheet = stub;
72
+ var SheetClose = stub;
73
+ var SheetContent = stub;
74
+ var SheetDescription = stub;
75
+ var SheetFooter = stub;
76
+ var SheetHeader = stub;
77
+ var SheetTitle = stub;
78
+ var SheetTrigger = stub;
79
+ var Skeleton = stub;
80
+ var Switch = stub;
81
+ var Table = stub;
82
+ var TableBody = stub;
83
+ var TableCell = stub;
84
+ var TableHead = stub;
85
+ var TableHeader = stub;
86
+ var TableRow = stub;
87
+ var TablePagination = stub;
88
+ var useTableView = stub;
89
+ var TimeAgo = stub;
90
+ var timeago = stub;
91
+ var Tooltip = stub;
92
+ var TooltipContent = stub;
93
+ var TooltipProvider = stub;
94
+ var TooltipTrigger = stub;
95
+ var ArrowsClockwiseIcon = stub;
96
+ var ArrowSquareOutIcon = stub;
97
+ var CheckBoldIcon = stub;
98
+ var CheckCircleIcon = stub;
99
+ var CheckIcon = stub;
100
+ var ClipboardIcon = stub;
101
+ var ClockIcon = stub;
102
+ var CloudArrowDownIcon = stub;
103
+ var CubeIcon = stub;
104
+ var DownloadSimpleIcon = stub;
105
+ var EnvelopeIcon = stub;
106
+ var EyeIcon = stub;
107
+ var FadersIcon = stub;
108
+ var FolderOpenIcon = stub;
109
+ var FolderSimpleIcon = stub;
110
+ var GearIcon = stub;
111
+ var GiftIcon = stub;
112
+ var GithubLogoIcon = stub;
113
+ var GlobeIcon = stub;
114
+ var GraphicsCardIcon = stub;
115
+ var HandshakeIcon = stub;
116
+ var HardDrivesIcon = stub;
117
+ var HouseIcon = stub;
118
+ var InfoIcon = stub;
119
+ var KeyIcon = stub;
120
+ var LightbulbIcon = stub;
121
+ var ListChecksIcon = stub;
122
+ var LockIcon = stub;
123
+ var MagnifyingGlassIcon = stub;
124
+ var PackageIcon = stub;
125
+ var PlugIcon = stub;
126
+ var PlusIcon = stub;
127
+ var PulseIcon = stub;
128
+ var QuestionIcon = stub;
129
+ var RocketLaunchIcon = stub;
130
+ var ShareNetworkIcon = stub;
131
+ var ShieldIcon = stub;
132
+ var SidebarIcon = stub;
133
+ var SignOutIcon = stub;
134
+ var StackIcon = stub;
135
+ var StarIcon = stub;
136
+ var TerminalWindowIcon = stub;
137
+ var TrashIcon = stub;
138
+ var UserIcon = stub;
139
+ var WarningIcon = stub;
140
+ var WarningOctagonIcon = stub;
141
+ var XBoldIcon = stub;
142
+ var XIcon = stub;
143
+ export {
144
+ AreaChart,
145
+ ArrowSquareOutIcon,
146
+ ArrowsClockwiseIcon,
147
+ Badge,
148
+ Button,
149
+ Card,
150
+ CardAction,
151
+ CardContent,
152
+ CardDescription,
153
+ CardFooter,
154
+ CardHeader,
155
+ CardTitle,
156
+ CheckBoldIcon,
157
+ CheckCircleIcon,
158
+ CheckIcon,
159
+ Checkbox,
160
+ ClipboardIcon,
161
+ ClockIcon,
162
+ CloudArrowDownIcon,
163
+ Combobox,
164
+ CubeIcon,
165
+ Dialog,
166
+ DialogClose,
167
+ DialogContent,
168
+ DialogDescription,
169
+ DialogFooter,
170
+ DialogHeader,
171
+ DialogOverlay,
172
+ DialogTitle,
173
+ DialogTrigger,
174
+ DownloadSimpleIcon,
175
+ EmptyState,
176
+ EnvelopeIcon,
177
+ EyeIcon,
178
+ FadersIcon,
179
+ FolderOpenIcon,
180
+ FolderSimpleIcon,
181
+ Fragment,
182
+ GearIcon,
183
+ GiftIcon,
184
+ GithubLogoIcon,
185
+ GlobeIcon,
186
+ GraphicsCardIcon,
187
+ HandshakeIcon,
188
+ HardDrivesIcon,
189
+ HouseIcon,
190
+ InfoIcon,
191
+ Input,
192
+ KeyIcon,
193
+ Label,
194
+ LightbulbIcon,
195
+ LineChart,
196
+ ListChecksIcon,
197
+ LockIcon,
198
+ MagnifyingGlassIcon,
199
+ PackageIcon,
200
+ Page,
201
+ PieChart,
202
+ PlugIcon,
203
+ PlusIcon,
204
+ PulseIcon,
205
+ QuestionIcon,
206
+ RocketLaunchIcon,
207
+ Separator,
208
+ ShareNetworkIcon,
209
+ Sheet,
210
+ SheetClose,
211
+ SheetContent,
212
+ SheetDescription,
213
+ SheetFooter,
214
+ SheetHeader,
215
+ SheetTitle,
216
+ SheetTrigger,
217
+ ShieldIcon,
218
+ SidebarIcon,
219
+ SignOutIcon,
220
+ Skeleton,
221
+ StackIcon,
222
+ StarIcon,
223
+ Switch,
224
+ Table,
225
+ TableBody,
226
+ TableCell,
227
+ TableHead,
228
+ TableHeader,
229
+ TablePagination,
230
+ TableRow,
231
+ TerminalWindowIcon,
232
+ TimeAgo,
233
+ Tooltip,
234
+ TooltipContent,
235
+ TooltipProvider,
236
+ TooltipTrigger,
237
+ TrashIcon,
238
+ UiError,
239
+ UserIcon,
240
+ WarningIcon,
241
+ WarningOctagonIcon,
242
+ XBoldIcon,
243
+ XIcon,
244
+ action,
245
+ buttonVariants,
246
+ h,
247
+ isTransientUiError,
248
+ isUiError,
249
+ loader,
250
+ page,
251
+ timeago,
252
+ useTableView,
253
+ widget
254
+ };
@@ -0,0 +1,89 @@
1
+ import {
2
+ PLATFORM_INGRESS_PORTS,
3
+ REALM_APP_DIR_GID,
4
+ REALM_SILO_DIR,
5
+ dependsOnEdgeSchema,
6
+ ingressInputSchema,
7
+ isManagedSiloPath,
8
+ isPreparedAppDir,
9
+ managedSiloPath,
10
+ nodeVersionSchema,
11
+ readNodeVersion,
12
+ readUpdateFiles,
13
+ scopeBindSource,
14
+ shortNodeVersion,
15
+ siloReclaimCommand,
16
+ siloSetupCommand,
17
+ siloWidenCommand,
18
+ wireServiceSchema,
19
+ workerAppSchema,
20
+ workerStateSchema
21
+ } from "./chunk-67BDAMYX.js";
22
+ import {
23
+ MANAGEMENT_NET,
24
+ REALM_HOME_PROXY_CONTAINER_PATH,
25
+ REALM_HOME_PROXY_DIR,
26
+ REALM_LOGS_DIR,
27
+ REALM_LOGS_MOUNT,
28
+ REALM_LOGS_SOCKET,
29
+ REALM_SPAWN_DIR,
30
+ REALM_STATS_DIR,
31
+ REALM_STATS_MOUNT,
32
+ REALM_STATS_SOCKET,
33
+ SILO_NET_PREFIX,
34
+ UNTRUSTED_NET,
35
+ homeProxyAppDir,
36
+ homeProxyMount,
37
+ homeProxySocketPath,
38
+ isSiloNetwork,
39
+ siloNetwork,
40
+ spawnArtifactsPath,
41
+ spawnMounts,
42
+ spawnScratchPath,
43
+ spawnSocketDir,
44
+ spawnSocketPath
45
+ } from "./chunk-VHTUSZUX.js";
46
+ import "./chunk-MLKGABMK.js";
47
+ export {
48
+ MANAGEMENT_NET,
49
+ PLATFORM_INGRESS_PORTS,
50
+ REALM_APP_DIR_GID,
51
+ REALM_HOME_PROXY_CONTAINER_PATH,
52
+ REALM_HOME_PROXY_DIR,
53
+ REALM_LOGS_DIR,
54
+ REALM_LOGS_MOUNT,
55
+ REALM_LOGS_SOCKET,
56
+ REALM_SILO_DIR,
57
+ REALM_SPAWN_DIR,
58
+ REALM_STATS_DIR,
59
+ REALM_STATS_MOUNT,
60
+ REALM_STATS_SOCKET,
61
+ SILO_NET_PREFIX,
62
+ UNTRUSTED_NET,
63
+ dependsOnEdgeSchema,
64
+ homeProxyAppDir,
65
+ homeProxyMount,
66
+ homeProxySocketPath,
67
+ ingressInputSchema,
68
+ isManagedSiloPath,
69
+ isPreparedAppDir,
70
+ isSiloNetwork,
71
+ managedSiloPath,
72
+ nodeVersionSchema,
73
+ readNodeVersion,
74
+ readUpdateFiles,
75
+ scopeBindSource,
76
+ shortNodeVersion,
77
+ siloNetwork,
78
+ siloReclaimCommand,
79
+ siloSetupCommand,
80
+ siloWidenCommand,
81
+ spawnArtifactsPath,
82
+ spawnMounts,
83
+ spawnScratchPath,
84
+ spawnSocketDir,
85
+ spawnSocketPath,
86
+ wireServiceSchema,
87
+ workerAppSchema,
88
+ workerStateSchema
89
+ };
package/package.json ADDED
@@ -0,0 +1,112 @@
1
+ {
2
+ "name": "@yourrealm/sdk",
3
+ "version": "0.0.0-alpha.1378.ce03c8dc",
4
+ "description": "The Realm SDK: createApp, the r.* permission factories, the ui surface, the realm-sdk CLI and test harness.",
5
+ "license": "AGPL-3.0-only WITH Classpath-exception-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/benjick/holden.git",
9
+ "directory": "packages/sdk"
10
+ },
11
+ "bin": {
12
+ "realm-sdk": "./dist/cli.js"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "src",
17
+ "!src/**/*.test.ts",
18
+ "!src/**/*.test.tsx",
19
+ "!src/**/__snapshots__",
20
+ "LICENSE-EXCEPTION",
21
+ "README.md"
22
+ ],
23
+ "type": "module",
24
+ "sideEffects": false,
25
+ "exports": {
26
+ ".": {
27
+ "types": "./src/index.ts",
28
+ "default": "./dist/index.js"
29
+ },
30
+ "./docker": {
31
+ "types": "./src/docker.ts",
32
+ "default": "./dist/docker.js"
33
+ },
34
+ "./services": {
35
+ "types": "./src/services/index.ts",
36
+ "default": "./dist/services.js"
37
+ },
38
+ "./ui": {
39
+ "types": "./src/ui/index.ts",
40
+ "default": "./dist/ui.js"
41
+ },
42
+ "./preact": {
43
+ "types": "./src/preact/index.ts",
44
+ "default": "./dist/preact.js"
45
+ },
46
+ "./jsx-runtime": {
47
+ "types": "./src/jsx-runtime/index.ts",
48
+ "default": "./dist/jsx-runtime.js"
49
+ },
50
+ "./service-url": {
51
+ "types": "./src/service-url.ts",
52
+ "default": "./dist/service-url.js"
53
+ },
54
+ "./runtime/docker/ingress": {
55
+ "types": "./src/runtime/docker/ingress/index.ts",
56
+ "default": "./dist/ingress.js"
57
+ },
58
+ "./worker-protocol": {
59
+ "types": "./src/worker-protocol/index.ts",
60
+ "default": "./dist/worker-protocol.js"
61
+ },
62
+ "./test": {
63
+ "types": "./src/test/index.ts",
64
+ "default": "./dist/test.js"
65
+ },
66
+ "./ui/tokens.css": "./src/ui/tokens.css"
67
+ },
68
+ "publishConfig": {
69
+ "access": "public"
70
+ },
71
+ "dependencies": {
72
+ "@ark-ui/react": "^5.36.1",
73
+ "@jitl/quickjs-wasmfile-release-asyncify": "^0.32.0",
74
+ "@playwright/test": "1.58.0",
75
+ "@preact/signals": "^2.5.0",
76
+ "@tailwindcss/cli": "^4.2.2",
77
+ "@tanstack/react-query": "^5.62.0",
78
+ "class-variance-authority": "^0.7.1",
79
+ "clsx": "^2.1.1",
80
+ "esbuild": "^0.27.4",
81
+ "next-themes": "^0.4.6",
82
+ "playwright-core": "1.58.0",
83
+ "preact": "^10.27.2",
84
+ "preact-render-to-string": "^6.6.7",
85
+ "quickjs-emscripten-core": "^0.32.0",
86
+ "react": "npm:@preact/compat@^18.3.2",
87
+ "react-dom": "npm:@preact/compat@^18.3.2",
88
+ "react-icons": "^5.5.0",
89
+ "shiki": "^4.0.2",
90
+ "sonner": "^2.0.7",
91
+ "tailwind-merge": "^3.5.0",
92
+ "tailwindcss": "^4.2.2",
93
+ "typescript": "^5",
94
+ "yaml": "^2.8.3",
95
+ "zod": "^4.3.6"
96
+ },
97
+ "devDependencies": {
98
+ "@std/assert": "npm:@jsr/std__assert@^1",
99
+ "@std/path": "npm:@jsr/std__path@^1",
100
+ "@std/tar": "npm:@jsr/std__tar@^0.1",
101
+ "@std/testing": "npm:@jsr/std__testing@^1",
102
+ "@local/docker": "0.1.0",
103
+ "@local/logger": "0.1.0",
104
+ "@yourrealm/noise": "0.1.0"
105
+ },
106
+ "scripts": {
107
+ "typecheck": "deno check",
108
+ "test": "deno test --allow-all src/ integration/",
109
+ "test:integration": "deno test --allow-all integration-docker/",
110
+ "build:npm": "deno run -A build.ts"
111
+ }
112
+ }
@@ -0,0 +1,74 @@
1
+ // App icons — the tagged string an author writes as `router.icon`, and the
2
+ // one https URL it is fetched from. Pure string logic, no host globals at
3
+ // module load, so it rides both the default entry (authors get the type) and
4
+ // the `@yourrealm/sdk/compile` barrel (Home gets the schema and the resolver).
5
+
6
+ import { z } from "zod";
7
+
8
+ /**
9
+ * A routed service's icon: a key in one of the two icon packs, or an https
10
+ * URL to an svg/png/webp/jpeg. A bare key is not accepted — the pack is
11
+ * always named, so the source of every icon is explicit.
12
+ */
13
+ export type AppIcon =
14
+ | `dashboard-icons:${string}` // homarr-labs/dashboard-icons
15
+ | `selfhst:${string}` // selfhst/icons
16
+ | `https://${string}`;
17
+
18
+ /** Pack prefix → the GitHub repo jsDelivr serves the svg out of. */
19
+ const PACK_REPOS: Record<string, string> = {
20
+ "dashboard-icons": "homarr-labs/dashboard-icons",
21
+ selfhst: "selfhst/icons",
22
+ };
23
+
24
+ // A pack key is a filename in that repo's `svg/` directory. Lowercase, and
25
+ // no slash, so a key can't walk out of the directory or carry a query.
26
+ const PACK_KEY_RE = /^[a-z0-9][a-z0-9._-]*$/;
27
+
28
+ // Rejects whitespace and the quoting/markup characters that would let a URL
29
+ // break out of the attribute or JSON it ends up in.
30
+ const URL_UNSAFE_RE = /[\s"'<>\\`]/;
31
+
32
+ const FORM_MESSAGE = 'icon must be "dashboard-icons:<key>", "selfhst:<key>" or an https:// URL';
33
+
34
+ /**
35
+ * The single place a spec is read. Both `iconSourceUrl` and `appIconSchema`
36
+ * go through it, so what validates and what resolves cannot drift.
37
+ */
38
+ function parseIcon(spec: string): { url: string } | { error: string } {
39
+ for (const [prefix, repo] of Object.entries(PACK_REPOS)) {
40
+ if (!spec.startsWith(`${prefix}:`)) continue;
41
+ const key = spec.slice(prefix.length + 1);
42
+ if (!PACK_KEY_RE.test(key)) {
43
+ return {
44
+ error: `${prefix} key must be lowercase and match ${PACK_KEY_RE.source}`,
45
+ };
46
+ }
47
+ return { url: `https://cdn.jsdelivr.net/gh/${repo}/svg/${key}.svg` };
48
+ }
49
+ if (spec.startsWith("https://")) {
50
+ const rest = spec.slice("https://".length);
51
+ if (rest === "") return { error: "https icon URL must have a host" };
52
+ if (URL_UNSAFE_RE.test(rest))
53
+ return { error: "https icon URL must not contain whitespace or quotes" };
54
+ return { url: spec };
55
+ }
56
+ return { error: FORM_MESSAGE };
57
+ }
58
+
59
+ /** The https URL an icon spec is fetched from. Throws on a malformed spec. */
60
+ export function iconSourceUrl(spec: AppIcon): string {
61
+ const parsed = parseIcon(spec);
62
+ if ("error" in parsed) throw new Error(parsed.error);
63
+ return parsed.url;
64
+ }
65
+
66
+ /**
67
+ * Runtime guard for the same three forms the `AppIcon` type describes, so a
68
+ * realm.ts that dodges the type (a cast, a computed string) still fails at
69
+ * resolve rather than reaching Home's icon cache.
70
+ */
71
+ export const appIconSchema = z.string().superRefine((spec, ctx) => {
72
+ const parsed = parseIcon(spec);
73
+ if ("error" in parsed) ctx.addIssue({ code: "custom", message: parsed.error });
74
+ }) as unknown as z.ZodType<AppIcon>;
package/src/apply.ts ADDED
@@ -0,0 +1,52 @@
1
+ import type { Deferred, Ref } from "./ref.ts";
2
+ import { deferredRef } from "./ref.ts";
3
+
4
+ /**
5
+ * Recursively swap every `Ref<string>` in `T` for `string`. Applied to
6
+ * the input of an `apply()` callback so the user sees resolved strings
7
+ * wherever a sync ref sat in the original value. Deferred refs are
8
+ * forbidden inside `apply()`'s input by the wire schema, so they don't
9
+ * appear here.
10
+ */
11
+ export type Resolved<T> =
12
+ T extends Ref<string>
13
+ ? string
14
+ : T extends string | number | boolean | bigint | null | undefined
15
+ ? T
16
+ : T extends readonly (infer U)[]
17
+ ? readonly Resolved<U>[]
18
+ : T extends object
19
+ ? { [K in keyof T]: Resolved<T[K]> }
20
+ : T;
21
+
22
+ type DeferredFn = (input: unknown) => string;
23
+
24
+ function registry(): DeferredFn[] {
25
+ const g = globalThis as Record<string, unknown>;
26
+ let fns = g.__realm_deferred_fns as DeferredFn[] | undefined;
27
+ if (!fns) {
28
+ fns = [];
29
+ g.__realm_deferred_fns = fns;
30
+ }
31
+ return fns;
32
+ }
33
+
34
+ /**
35
+ * Apply `fn` to the resolved version of `input`. The bundle registers
36
+ * `fn` at registration order and returns a `Deferred<string>` carrying
37
+ * the id + raw input. The Home walker resolves every sync ref inside
38
+ * `input`, then re-runs the bundle in a second sandbox call to invoke
39
+ * `fn` with resolved values and splice the returned string into the
40
+ * final state.
41
+ *
42
+ * The return type `Deferred<string>` is deliberately distinct from
43
+ * `Ref<string>` — `interpolate` only accepts the latter, so passing an
44
+ * `apply()` result into a template is a type error. Move affix logic
45
+ * into the callback instead: `apply(input, s => \`prefix-${s}\`)`.
46
+ */
47
+ export function apply<T>(input: T, fn: (resolved: Resolved<T>) => string): Deferred<string> {
48
+ const fns = registry();
49
+ const id = fns.length;
50
+ fns.push(fn as DeferredFn);
51
+ return deferredRef({ kind: "deferred", id, input });
52
+ }