@selvajs/selva 4.21.0-beta.21 → 4.21.0-beta.23

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 (228) hide show
  1. package/build/adapter-node.js +1 -1
  2. package/build/client/_app/immutable/chunks/B58dPMPq.js +1 -0
  3. package/build/client/_app/immutable/chunks/B58dPMPq.js.br +1 -0
  4. package/build/client/_app/immutable/chunks/B58dPMPq.js.gz +0 -0
  5. package/build/client/_app/immutable/chunks/{C6zhj8Tc.js → DtmN00GS.js} +3 -3
  6. package/build/client/_app/immutable/chunks/DtmN00GS.js.br +0 -0
  7. package/build/client/_app/immutable/chunks/{C6zhj8Tc.js.gz → DtmN00GS.js.gz} +0 -0
  8. package/build/client/_app/immutable/entry/{app.C2KpbBu3.js → app.Dl3HM1mx.js} +2 -2
  9. package/build/client/_app/immutable/entry/app.Dl3HM1mx.js.br +0 -0
  10. package/build/client/_app/immutable/entry/app.Dl3HM1mx.js.gz +0 -0
  11. package/build/client/_app/immutable/nodes/21.BZJQikE5.js +1 -0
  12. package/build/client/_app/immutable/nodes/21.BZJQikE5.js.br +0 -0
  13. package/build/client/_app/immutable/nodes/21.BZJQikE5.js.gz +0 -0
  14. package/build/client/_app/version.json +1 -1
  15. package/build/client/_app/version.json.br +0 -0
  16. package/build/client/_app/version.json.gz +0 -0
  17. package/build/server/.vite/manifest.json +228 -187
  18. package/build/server/chunks/AppHeader.js +1 -1
  19. package/build/server/chunks/Callout.js +1 -1
  20. package/build/server/chunks/ConfirmDialog.js +1 -1
  21. package/build/server/chunks/DataTable.js +1 -1
  22. package/build/server/chunks/DefinitionCard.js +2 -2
  23. package/build/server/chunks/EmptyState.js +1 -1
  24. package/build/server/chunks/ErrorScreen.js +1 -1
  25. package/build/server/chunks/FilterableDropdown.js +1 -1
  26. package/build/server/chunks/PageContent.js +1 -1
  27. package/build/server/chunks/SectionHeader.js +1 -1
  28. package/build/server/chunks/SettingsMenu.js +1 -1
  29. package/build/server/chunks/SideNav.js +1 -1
  30. package/build/server/chunks/StatCard.js +1 -1
  31. package/build/server/chunks/UserAvatar.js +1 -1
  32. package/build/server/chunks/UserRowIdentity.js +1 -1
  33. package/build/server/chunks/activity.js +1 -1
  34. package/build/server/chunks/alert-dialog.js +1 -1
  35. package/build/server/chunks/arrow-left.js +1 -1
  36. package/build/server/chunks/arrow-right.js +1 -1
  37. package/build/server/chunks/{keepalive-DbmLH4v1.js → async-solve-Doflh4BJ.js} +5 -3
  38. package/build/server/chunks/async-solve-Doflh4BJ.js.map +1 -0
  39. package/build/server/chunks/asyncSolves.server.js +22 -0
  40. package/build/server/chunks/asyncSolves.server.js.map +1 -0
  41. package/build/server/chunks/auth-bootstrap.server.js +1 -1
  42. package/build/server/chunks/badge.js +1 -1
  43. package/build/server/chunks/boot.server.js +1 -1
  44. package/build/server/chunks/building-complex.js +1 -1
  45. package/build/server/chunks/button.js +1 -1
  46. package/build/server/chunks/capture.js +1 -1
  47. package/build/server/chunks/card-content.js +1 -1
  48. package/build/server/chunks/card-description.js +1 -1
  49. package/build/server/chunks/card-header.js +1 -1
  50. package/build/server/chunks/card-title.js +1 -1
  51. package/build/server/chunks/chevron-down.js +1 -1
  52. package/build/server/chunks/chevron-left.js +1 -1
  53. package/build/server/chunks/chevron-right.js +1 -1
  54. package/build/server/chunks/chevron-up.js +1 -1
  55. package/build/server/chunks/circle.js +1 -1
  56. package/build/server/chunks/computeRateLimit.server.js +1 -1
  57. package/build/server/chunks/copy.js +1 -1
  58. package/build/server/chunks/create-id.js +1 -1
  59. package/build/server/chunks/delete-with-blobs.js +1 -1
  60. package/build/server/chunks/dialog-description.js +1 -1
  61. package/build/server/chunks/dialog.js +1 -1
  62. package/build/server/chunks/dom-typeahead.svelte.js +1 -1
  63. package/build/server/chunks/dynamic-value-list.js +301 -0
  64. package/build/server/chunks/dynamic-value-list.js.map +1 -0
  65. package/build/server/chunks/engine.server.js +2 -1
  66. package/build/server/chunks/engine.server.js.map +1 -1
  67. package/build/server/chunks/events.js +1 -1
  68. package/build/server/chunks/external-link.js +1 -1
  69. package/build/server/chunks/folder-kanban.js +1 -1
  70. package/build/server/chunks/folder-open.js +1 -1
  71. package/build/server/chunks/folders.js +1 -1
  72. package/build/server/chunks/footerContext.svelte.js +1 -1
  73. package/build/server/chunks/gauge.js +1 -1
  74. package/build/server/chunks/handlers.js +1 -1
  75. package/build/server/chunks/index-server2.js +1 -1
  76. package/build/server/chunks/input-group.js +1 -1
  77. package/build/server/chunks/input.js +1 -1
  78. package/build/server/chunks/instance.js +4 -4
  79. package/build/server/chunks/instanceAdmins.server.js +1 -1
  80. package/build/server/chunks/internal.js +1 -1
  81. package/build/server/chunks/key-round.js +1 -1
  82. package/build/server/chunks/label.js +1 -1
  83. package/build/server/chunks/link-2.js +1 -1
  84. package/build/server/chunks/localeContext.svelte.js +1 -1
  85. package/build/server/chunks/mail.js +1 -1
  86. package/build/server/chunks/minus.js +1 -1
  87. package/build/server/chunks/package.js +2 -2
  88. package/build/server/chunks/package.js.map +1 -1
  89. package/build/server/chunks/permissions.server.js +1 -1
  90. package/build/server/chunks/plus.js +1 -1
  91. package/build/server/chunks/popper-layer-force-mount.js +1 -1
  92. package/build/server/chunks/providers.server.js +3 -28134
  93. package/build/server/chunks/providers.server.js.map +1 -1
  94. package/build/server/chunks/refresh-cw.js +1 -1
  95. package/build/server/chunks/registry.js +22 -0
  96. package/build/server/chunks/registry.js.map +1 -1
  97. package/build/server/chunks/rotate-ccw.js +1 -1
  98. package/build/server/chunks/roving-focus-group.js +1 -1
  99. package/build/server/chunks/scroll-lock.js +1 -1
  100. package/build/server/chunks/scroll-text.js +1 -1
  101. package/build/server/chunks/search.js +1 -1
  102. package/build/server/chunks/search2.js +1 -1
  103. package/build/server/chunks/select.js +1 -1
  104. package/build/server/chunks/separator.js +1 -1
  105. package/build/server/chunks/server-config-write.js +1 -1
  106. package/build/server/chunks/server.js +28298 -5
  107. package/build/server/chunks/server.js.map +1 -1
  108. package/build/server/chunks/server2.js +5 -107
  109. package/build/server/chunks/server2.js.map +1 -1
  110. package/build/server/chunks/server3.js +101 -3911
  111. package/build/server/chunks/server3.js.map +1 -1
  112. package/build/server/chunks/server4.js +3916 -41
  113. package/build/server/chunks/server4.js.map +1 -1
  114. package/build/server/chunks/server5.js +45 -0
  115. package/build/server/chunks/server5.js.map +1 -0
  116. package/build/server/chunks/settings.js +1 -1
  117. package/build/server/chunks/severity.js +1 -1
  118. package/build/server/chunks/shield-check.js +1 -1
  119. package/build/server/chunks/shield.js +1 -1
  120. package/build/server/chunks/signInMaxAge.server.js +1 -1
  121. package/build/server/chunks/solve.server.js +4 -3
  122. package/build/server/chunks/solve.server.js.map +1 -1
  123. package/build/server/chunks/star.js +1 -1
  124. package/build/server/chunks/state.js +1 -1
  125. package/build/server/chunks/sveltekit.js +1 -1
  126. package/build/server/chunks/tabs-trigger.js +1 -1
  127. package/build/server/chunks/textarea.js +1 -1
  128. package/build/server/chunks/toast-state.svelte.js +1 -1
  129. package/build/server/chunks/toggle-group-item.js +1 -1
  130. package/build/server/chunks/trash.js +1 -1
  131. package/build/server/chunks/user-plus.js +1 -1
  132. package/build/server/chunks/users.js +1 -1
  133. package/build/server/chunks/utils.js +1 -1
  134. package/build/server/chunks/x.js +1 -1
  135. package/build/server/entries/endpoints/.well-known/oauth-authorization-server/_server.ts.js +1 -1
  136. package/build/server/entries/endpoints/.well-known/oauth-protected-resource/_server.ts.js +1 -1
  137. package/build/server/entries/endpoints/.well-known/oauth-protected-resource/mcp/_server.ts.js +1 -1
  138. package/build/server/entries/endpoints/api/admin/compute/_server.ts.js +1 -1
  139. package/build/server/entries/endpoints/api/admin/compute/actions/_server.ts.js +1 -1
  140. package/build/server/entries/endpoints/api/admin/compute/status/_server.ts.js +1 -1
  141. package/build/server/entries/endpoints/api/admin/orgs/_id_/_server.ts.js +1 -1
  142. package/build/server/entries/endpoints/api/admin/orgs/_server.ts.js +1 -1
  143. package/build/server/entries/endpoints/api/admin/projects/_id_/_server.ts.js +1 -1
  144. package/build/server/entries/endpoints/api/admin/projects/_id_/grants/_grantId_/_server.ts.js +1 -1
  145. package/build/server/entries/endpoints/api/admin/projects/_id_/grants/_server.ts.js +1 -1
  146. package/build/server/entries/endpoints/api/admin/projects/_server.ts.js +1 -1
  147. package/build/server/entries/endpoints/api/admin/system/health/_server.ts.js +1 -1
  148. package/build/server/entries/endpoints/api/admin/system/update/_server.ts.js +1 -1
  149. package/build/server/entries/endpoints/api/admin/users/_id_/_server.ts.js +1 -1
  150. package/build/server/entries/endpoints/api/admin/users/_id_/disable/_server.ts.js +1 -1
  151. package/build/server/entries/endpoints/api/admin/users/_server.ts.js +1 -1
  152. package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js +1 -1
  153. package/build/server/entries/endpoints/api/v1/compute/_server.ts.js +8 -4
  154. package/build/server/entries/endpoints/api/v1/compute/_server.ts.js.map +1 -1
  155. package/build/server/entries/endpoints/api/v1/definitions/_guid_/solve/_server.ts.js +12 -3
  156. package/build/server/entries/endpoints/api/v1/definitions/_guid_/solve/_server.ts.js.map +1 -1
  157. package/build/server/entries/endpoints/api/v1/solves/_solveId_/_server.ts.js +32 -0
  158. package/build/server/entries/endpoints/api/v1/solves/_solveId_/_server.ts.js.map +1 -0
  159. package/build/server/entries/endpoints/auth/email/callback/_server.ts.js +1 -1
  160. package/build/server/entries/endpoints/auth/supabase/callback/_server.ts.js +1 -1
  161. package/build/server/entries/endpoints/auth/supabase/start/_server.ts.js +1 -1
  162. package/build/server/entries/endpoints/docs/api/openapi.yaml/_server.ts.js +1 -1
  163. package/build/server/entries/endpoints/mcp/_server.ts.js +244 -41
  164. package/build/server/entries/endpoints/mcp/_server.ts.js.map +1 -1
  165. package/build/server/entries/endpoints/oauth/register/_server.ts.js +1 -1
  166. package/build/server/entries/endpoints/oauth/token/_server.ts.js +1 -1
  167. package/build/server/entries/hooks.server.js +2 -1
  168. package/build/server/entries/hooks.server.js.map +1 -1
  169. package/build/server/entries/pages/_error.svelte.js +1 -1
  170. package/build/server/entries/pages/_layout.svelte.js +1 -1
  171. package/build/server/entries/pages/_page.svelte.js +1 -1
  172. package/build/server/entries/pages/accept-invite/_page.svelte.js +1 -1
  173. package/build/server/entries/pages/admin/_error.svelte.js +1 -1
  174. package/build/server/entries/pages/admin/_layout.svelte.js +2 -2
  175. package/build/server/entries/pages/admin/_page.svelte.js +2 -2
  176. package/build/server/entries/pages/admin/audit/_page.svelte.js +1 -1
  177. package/build/server/entries/pages/admin/compute/_page.svelte.js +2 -2
  178. package/build/server/entries/pages/admin/organizations/_page.svelte.js +1 -1
  179. package/build/server/entries/pages/admin/projects/_id_/_page.svelte.js +1 -1
  180. package/build/server/entries/pages/admin/projects/_page.svelte.js +1 -1
  181. package/build/server/entries/pages/admin/system/_page.server.ts.js +1 -1
  182. package/build/server/entries/pages/admin/system/_page.svelte.js +1 -1
  183. package/build/server/entries/pages/admin/users/_page.svelte.js +1 -1
  184. package/build/server/entries/pages/auth/email/sent/_page.svelte.js +1 -1
  185. package/build/server/entries/pages/auth/email/start/_page.svelte.js +1 -1
  186. package/build/server/entries/pages/docs/api/_page.svelte.js +1 -1
  187. package/build/server/entries/pages/library/_guid_/_page.server.ts.js +1 -1
  188. package/build/server/entries/pages/library/_guid_/_page.svelte.js +71 -305
  189. package/build/server/entries/pages/library/_guid_/_page.svelte.js.map +1 -1
  190. package/build/server/entries/pages/library/_layout.svelte.js +1 -1
  191. package/build/server/entries/pages/library/_page.svelte.js +1 -1
  192. package/build/server/entries/pages/login/_page.svelte.js +1 -1
  193. package/build/server/entries/pages/oauth/authorize/_page.server.ts.js +1 -1
  194. package/build/server/entries/pages/oauth/authorize/_page.svelte.js +1 -1
  195. package/build/server/entries/pages/projects/_layout.svelte.js +1 -1
  196. package/build/server/entries/pages/projects/_page.server.ts.js +1 -1
  197. package/build/server/entries/pages/projects/_page.svelte.js +1 -1
  198. package/build/server/entries/pages/setup/_page.server.ts.js +1 -1
  199. package/build/server/entries/pages/setup/_page.svelte.js +1 -1
  200. package/build/server/entries/pages/team/_layout.svelte.js +2 -2
  201. package/build/server/entries/pages/team/_page.svelte.js +1 -1
  202. package/build/server/entries/pages/team/activity/_page.svelte.js +1 -1
  203. package/build/server/entries/pages/team/compute/_page.svelte.js +2 -2
  204. package/build/server/entries/pages/team/members/_page.svelte.js +1 -1
  205. package/build/server/entries/pages/team/projects/_page.server.ts.js +1 -1
  206. package/build/server/entries/pages/team/projects/_page.svelte.js +1 -1
  207. package/build/server/entries/pages/team/reclaim/_page.svelte.js +1 -1
  208. package/build/server/entries/pages/team/settings/_page.svelte.js +1 -1
  209. package/build/server/entries/pages/team/shares/_page.svelte.js +1 -1
  210. package/build/server/entries/pages/team/tokens/_page.svelte.js +1 -1
  211. package/build/server/index.js +1 -1
  212. package/build/server/manifest-full.js +8 -1
  213. package/build/server/manifest.js +8 -1
  214. package/build/server/nodes/21.js +1 -1
  215. package/build/server/remote-entry.js +1 -1
  216. package/build/server/server.js +8 -1
  217. package/package.json +8 -8
  218. package/templates/.env.example +5 -3
  219. package/build/client/_app/immutable/chunks/C36Kxzt3.js +0 -1
  220. package/build/client/_app/immutable/chunks/C36Kxzt3.js.br +0 -1
  221. package/build/client/_app/immutable/chunks/C36Kxzt3.js.gz +0 -0
  222. package/build/client/_app/immutable/chunks/C6zhj8Tc.js.br +0 -0
  223. package/build/client/_app/immutable/entry/app.C2KpbBu3.js.br +0 -0
  224. package/build/client/_app/immutable/entry/app.C2KpbBu3.js.gz +0 -0
  225. package/build/client/_app/immutable/nodes/21.C3YDbmsU.js +0 -1
  226. package/build/client/_app/immutable/nodes/21.C3YDbmsU.js.br +0 -0
  227. package/build/client/_app/immutable/nodes/21.C3YDbmsU.js.gz +0 -0
  228. package/build/server/chunks/keepalive-DbmLH4v1.js.map +0 -1
@@ -1,19 +1,21 @@
1
- import { f as getLogger } from "../../../chunks/providers.server.js";
2
1
  import { n as env } from "../../../chunks/previous-key.js";
3
2
  import { H as apiScopeActionCovers } from "../../../chunks/access.js";
3
+ import { f as getLogger } from "../../../chunks/providers.server.js";
4
4
  import { n as ApiScopeActionSchema, o as parseApiScope } from "../../../chunks/types.js";
5
5
  import { i as inventoryWarningText, r as inventoryDiffToMarkdown } from "../../../chunks/inventory.js";
6
6
  import { r as GuidSchema } from "../../../chunks/schemas.js";
7
7
  import { q as ProjectVisibilitySchema } from "../../../chunks/api.js";
8
8
  import { r as getLayoutItems, t as getGroups } from "../../../chunks/traversal.js";
9
9
  import { n as schemaDiffToMarkdown } from "../../../chunks/diff.js";
10
+ import { t as buildFormModel } from "../../../chunks/dynamic-value-list.js";
10
11
  import { s as resourceMetadataUrl } from "../../../chunks/oauth.js";
11
- import { i as oauthServer } from "../../../chunks/server2.js";
12
+ import { i as oauthServer } from "../../../chunks/server3.js";
12
13
  import { t as publicUrl } from "../../../chunks/origin.js";
13
14
  import { t as buildOpenApiDocument } from "../../../chunks/openapi.js";
14
15
  import { t as MCP_FILES_PREFIX } from "../../../chunks/path.js";
15
16
  import { i as jsonBytes, r as fromJsonBytes, t as mcpStash } from "../../../chunks/stash-instance.js";
16
17
  import { z } from "zod";
18
+ import { existsSync } from "node:fs";
17
19
  import { readFile } from "node:fs/promises";
18
20
  import * as z$1 from "zod/v4";
19
21
  import process$1 from "node:process";
@@ -21106,6 +21108,12 @@ new URL("../dist/views/solve.html", import.meta.url);
21106
21108
  var CaptureUnavailableError = class extends Error {
21107
21109
  name = "CaptureUnavailableError";
21108
21110
  };
21111
+ var FALLBACK_PATHS = [
21112
+ "/usr/bin/chromium",
21113
+ "/usr/bin/chromium-browser",
21114
+ "/snap/bin/chromium",
21115
+ "/usr/bin/google-chrome"
21116
+ ];
21109
21117
  var CAPTURE_FILE = new URL("../dist/views/capture.html", import.meta.url);
21110
21118
  var ARGS = [
21111
21119
  "--use-angle=swiftshader",
@@ -21127,17 +21135,25 @@ async function launch(executablePath, timeout) {
21127
21135
  } catch {
21128
21136
  throw new CaptureUnavailableError("Rendering needs the `playwright-core` package on the server, which is not installed.");
21129
21137
  }
21130
- try {
21138
+ const candidates = executablePath ? [{ executablePath }] : [
21139
+ {},
21140
+ { channel: "chrome" },
21141
+ { channel: "msedge" },
21142
+ ...FALLBACK_PATHS.filter((p) => existsSync(p)).map((p) => ({ executablePath: p }))
21143
+ ];
21144
+ let first;
21145
+ for (const candidate of candidates) try {
21131
21146
  const launched = await chromium.launch({
21132
- executablePath,
21147
+ ...candidate,
21133
21148
  args: ARGS,
21134
21149
  timeout
21135
21150
  });
21136
21151
  launched.on("disconnected", () => browser = void 0);
21137
21152
  return launched;
21138
21153
  } catch (err) {
21139
- throw new CaptureUnavailableError(`No browser to render with: ${err instanceof Error ? err.message.split("\n")[0] : String(err)}. Install one on the server with \`npx playwright install --with-deps chromium\`, or point the server at an existing Chromium.`);
21154
+ first ??= err;
21140
21155
  }
21156
+ throw new CaptureUnavailableError(`No browser to render with: ${first instanceof Error ? first.message.split("\n")[0] : String(first)}. Install Chrome or Chromium on the server (\`npx playwright install --with-deps chromium\`, or the system package), or point the server at one.`);
21141
21157
  }
21142
21158
  /**
21143
21159
  * Draws a Rhino.Compute response in Selva's viewer, in a headless Chromium, and returns a PNG.
@@ -21179,19 +21195,23 @@ async function capture(response, options) {
21179
21195
  });
21180
21196
  await page.setContent(html, { waitUntil: "load" });
21181
21197
  const hdr = options.hdr ? await options.hdr() : void 0;
21182
- const { pngs, drawn } = await page.evaluate((req) => globalThis.selvaCapture(req), {
21198
+ const presets = options.views?.length ? options.views : [options.view ?? "default"];
21199
+ const result = await page.evaluate((req) => globalThis.selvaCapture(req), {
21183
21200
  response,
21184
- views: options.views?.length ? options.views : [options.view ?? "default"],
21201
+ cameras: options.cameras?.length ? options.cameras : presets.map((view) => ({ view })),
21185
21202
  grid: options.grid ?? true,
21186
21203
  look: options.look,
21187
21204
  background: options.background,
21188
21205
  camera: options.camera,
21189
- hdr
21206
+ hdr,
21207
+ hide: options.hide,
21208
+ cutaway: options.cutaway,
21209
+ frame: options.frame,
21210
+ sheet: options.sheet
21190
21211
  });
21191
21212
  return {
21192
- png: pngs[0] ?? "",
21193
- pngs,
21194
- drawn
21213
+ ...result,
21214
+ png: result.images[0]?.png ?? ""
21195
21215
  };
21196
21216
  } finally {
21197
21217
  options.signal?.removeEventListener("abort", closePage);
@@ -21254,7 +21274,7 @@ function conditionText(condition, labelOf) {
21254
21274
  if (action === "disable") return `disabled when ${joined}`;
21255
21275
  return `shown only when ${joined}`;
21256
21276
  }
21257
- function inputLine({ input, item, label }, labelOf) {
21277
+ function inputLine({ input, item, label }, labelOf, filledBy) {
21258
21278
  const parts = [`- "${label}" (id ${input.id}): ${input.paramType}`];
21259
21279
  if (input.inputStructure && input.inputStructure !== "item") parts.push(`, ${input.inputStructure} of them`);
21260
21280
  if (item?.widgetType === "number") {
@@ -21268,8 +21288,9 @@ function inputLine({ input, item, label }, labelOf) {
21268
21288
  if (item?.widgetType === "checkbox" && item.config?.displayAs === "button") parts.push(", a button: true runs it once");
21269
21289
  const options = optionsOf(item);
21270
21290
  if (item?.widgetType === "dynamicValueList") {
21271
- const defaults = Object.keys(options ?? {});
21272
- parts.push(", options computed by the solve from other inputs: selva_solve lists the current ones" + (defaults.length ? ` (defaults: ${defaults.map((k) => `"${k}"`).join(", ")})` : ""));
21291
+ const sources = filledBy(input.id);
21292
+ parts.push(", its options are computed in the solve" + (sources.length ? ` by ${sources.map((s) => `"${s}"`).join(", ")}` : "") + " and can change with other inputs; selva_solve lists them");
21293
+ if (options && Object.keys(options).length) parts.push(`; before a solve: ${Object.keys(options).map((k) => `"${k}"`).join(", ")}`);
21273
21294
  } else if (options) parts.push(`, one of: ${Object.keys(options).map((k) => `"${k}"`).join(", ")}`);
21274
21295
  if (input.default !== void 0) parts.push(`, default ${JSON.stringify(input.default)}`);
21275
21296
  const condition = conditionText(item?.visibilityCondition, labelOf);
@@ -21294,6 +21315,8 @@ function outputLine(schema, item, id) {
21294
21315
  function formText(schema) {
21295
21316
  const described = describeInputs(schema);
21296
21317
  const labelOf = (id) => described.find((d) => d.input.id === id)?.label ?? id;
21318
+ const filledBy = (id) => schema.outputs.filter((o) => o.type === "dynamicValueList" && o.targetInputId === id).map((o) => o.nickname);
21319
+ const line = (d) => inputLine(d, labelOf, filledBy);
21297
21320
  const lines = [];
21298
21321
  const placedInputs = /* @__PURE__ */ new Set();
21299
21322
  const placedOutputs = /* @__PURE__ */ new Set();
@@ -21304,7 +21327,7 @@ function formText(schema) {
21304
21327
  const d = described.find((x) => x.input.id === item.paramId);
21305
21328
  if (!d) continue;
21306
21329
  placedInputs.add(d.input.id);
21307
- inputs.push(inputLine(d, labelOf));
21330
+ inputs.push(line(d));
21308
21331
  } else if (item.type === "output" && item.paramId) {
21309
21332
  const line = outputLine(schema, item, item.paramId);
21310
21333
  if (!line) continue;
@@ -21320,9 +21343,10 @@ function formText(schema) {
21320
21343
  };
21321
21344
  for (const group of getGroups(schema)) groupBlock(group);
21322
21345
  const looseInputs = described.filter((d) => !placedInputs.has(d.input.id));
21323
- if (looseInputs.length) lines.push("", "## Not on the form", "Inputs:", ...looseInputs.map((d) => inputLine(d, labelOf)));
21346
+ if (looseInputs.length) lines.push("", "## Not on the form", "Inputs:", ...looseInputs.map(line));
21324
21347
  const looseOutputs = schema.outputs.filter((o) => !placedOutputs.has(o.id)).map((o) => outputLine(schema, void 0, o.id));
21325
21348
  if (looseOutputs.length) lines.push("", "Other outputs:", ...looseOutputs);
21349
+ if (schema.outputs.some((o) => o.type === "dynamicValueList")) lines.push("", "Some lists are computed in the solve: what they offer depends on other inputs, and an output can repeat an input once per row (a cabinet, a bay). selva_solve returns each list's options and the pick it used; an input repeated per row takes an object of row key to option name.");
21326
21350
  return lines;
21327
21351
  }
21328
21352
  /** Values keyed by what the model saw: label, nickname or id. Dropdown labels become their values. */
@@ -21343,7 +21367,7 @@ function resolveValues(described, given) {
21343
21367
  }
21344
21368
  const options = optionsOf(match.item);
21345
21369
  const pick = (v) => typeof v === "string" && options && Object.hasOwn(options, v) && options[v] !== void 0 ? options[v] : v;
21346
- values[match.input.id] = Array.isArray(value) ? value.map(pick) : pick(value);
21370
+ values[match.input.id] = Array.isArray(value) ? value.map(pick) : typeof value === "object" && value !== null ? JSON.stringify(Object.fromEntries(Object.entries(value).map(([row, v]) => [row, pick(v)]))) : pick(value);
21347
21371
  }
21348
21372
  if (unknown.length) {
21349
21373
  const known = described.map((d) => `"${d.label}"`).join(", ");
@@ -21423,7 +21447,7 @@ function decode(data) {
21423
21447
  }
21424
21448
  return value;
21425
21449
  }
21426
- var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
21450
+ var isRecord$1 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
21427
21451
  /**
21428
21452
  * Each input's options as this solve computed them, name to value, keyed by input id. Only plain
21429
21453
  * lists: an Options Table narrows by the picks on screen, which a static form can't follow.
@@ -21435,7 +21459,7 @@ function solvedOptions(schema, trees) {
21435
21459
  for (const item of Object.values(tree.InnerTree ?? {}).flat()) {
21436
21460
  if (!isValueListType(item.type)) continue;
21437
21461
  const payload = decode(item.data);
21438
- if (!isRecord(payload) || !isRecord(payload.options)) continue;
21462
+ if (!isRecord$1(payload) || !isRecord$1(payload.options)) continue;
21439
21463
  const target = typeof payload.targetInputId === "string" ? payload.targetInputId : schemaTarget;
21440
21464
  const options = Object.entries(payload.options).filter((e) => typeof e[1] === "string");
21441
21465
  if (target && options.length) found.set(target, Object.fromEntries(options));
@@ -21465,9 +21489,9 @@ function readValueLists(schema, paramName, items) {
21465
21489
  const combinations = [];
21466
21490
  for (const item of items) {
21467
21491
  const payload = decode(item.data);
21468
- if (!isRecord(payload)) continue;
21492
+ if (!isRecord$1(payload)) continue;
21469
21493
  const target = typeof payload.targetInputId === "string" ? payload.targetInputId : schemaTarget;
21470
- const names = isRecord(payload.options) ? Object.keys(payload.options) : [];
21494
+ const names = isRecord$1(payload.options) ? Object.keys(payload.options) : [];
21471
21495
  if (target && names.length) {
21472
21496
  const label = labelOf(target);
21473
21497
  const { shown, more } = head(names);
@@ -21475,7 +21499,7 @@ function readValueLists(schema, paramName, items) {
21475
21499
  parts.push(`options for "${label}": ${quoted(shown)}${andMore(more)}`);
21476
21500
  }
21477
21501
  const table = payload.pickTable;
21478
- if (isRecord(table) && Array.isArray(table.inputs) && Array.isArray(table.rows)) {
21502
+ if (isRecord$1(table) && Array.isArray(table.inputs) && Array.isArray(table.rows)) {
21479
21503
  const columns = [...Array.isArray(table.by) ? table.by : [], ...table.inputs].map((id) => labelOf(String(id)));
21480
21504
  const rows = table.rows.filter(Array.isArray).map((r) => r.map(String));
21481
21505
  const { shown, more } = head(rows);
@@ -21512,12 +21536,12 @@ function readCharts(items) {
21512
21536
  const charts = [];
21513
21537
  for (const item of items) {
21514
21538
  const figure = decode(item.data);
21515
- if (!isRecord(figure) || !Array.isArray(figure.data)) continue;
21516
- const rawTitle = (isRecord(figure.layout) ? figure.layout : {}).title;
21517
- const title = typeof rawTitle === "string" ? rawTitle : isRecord(rawTitle) && typeof rawTitle.text === "string" ? rawTitle.text : void 0;
21539
+ if (!isRecord$1(figure) || !Array.isArray(figure.data)) continue;
21540
+ const rawTitle = (isRecord$1(figure.layout) ? figure.layout : {}).title;
21541
+ const title = typeof rawTitle === "string" ? rawTitle : isRecord$1(rawTitle) && typeof rawTitle.text === "string" ? rawTitle.text : void 0;
21518
21542
  const series = [];
21519
21543
  const traces = [];
21520
- for (const trace of figure.data.filter(isRecord)) {
21544
+ for (const trace of figure.data.filter(isRecord$1)) {
21521
21545
  const pairs = pointsOf(trace);
21522
21546
  if (!pairs) continue;
21523
21547
  const [labels, values] = pairs;
@@ -21694,6 +21718,110 @@ async function fileLinks(items, origin, stash) {
21694
21718
  }
21695
21719
  return links;
21696
21720
  }
21721
+ /** Parses an item, unwrapping the JSON strings Compute may wrap it in. */
21722
+ function parseDeep(data) {
21723
+ let value = data;
21724
+ for (let i = 0; i < 3 && typeof value === "string"; i++) try {
21725
+ value = JSON.parse(value);
21726
+ } catch {
21727
+ break;
21728
+ }
21729
+ return value;
21730
+ }
21731
+ var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
21732
+ /** A Plotly figure's title and data, or null when `value` is not one. */
21733
+ function readFigure(value) {
21734
+ if (!isRecord(value) || !Array.isArray(value.data)) return null;
21735
+ const layout = isRecord(value.layout) ? value.layout : {};
21736
+ const title = isRecord(layout.title) ? layout.title.text : layout.title;
21737
+ const array = (v) => Array.isArray(v) ? v.slice(0, MAX_SCALARS) : void 0;
21738
+ const traces = value.data.filter(isRecord).map((t) => {
21739
+ const trace = { type: typeof t.type === "string" ? t.type : "scatter" };
21740
+ if (typeof t.name === "string" && t.name) trace.name = t.name;
21741
+ for (const key of [
21742
+ "labels",
21743
+ "values",
21744
+ "x",
21745
+ "y"
21746
+ ]) {
21747
+ const data = array(t[key]);
21748
+ if (data) trace[key] = data;
21749
+ }
21750
+ return trace;
21751
+ });
21752
+ return {
21753
+ ...typeof title === "string" && title && { title },
21754
+ traces
21755
+ };
21756
+ }
21757
+ var numberText = (v) => typeof v === "number" ? v.toLocaleString("en-US", { maximumFractionDigits: 2 }) : String(v);
21758
+ function chartText(chart) {
21759
+ const parts = chart.traces.map((t) => {
21760
+ const keys = t.labels ?? t.x;
21761
+ const values = t.values ?? t.y;
21762
+ const head = `${t.type}${t.name ? ` "${t.name}"` : ""}`;
21763
+ if (!keys || !values) return head;
21764
+ const pairs = keys.map((k, i) => `${String(k)} ${numberText(values[i])}`);
21765
+ const numbers = values.filter((v) => typeof v === "number");
21766
+ const sum = t.type === "pie" && numbers.length === values.length ? ` (sum ${numberText(numbers.reduce((a, b) => a + b, 0))})` : "";
21767
+ return `${head}: ${pairs.join("; ")}${sum}`;
21768
+ });
21769
+ return `chart${chart.title ? ` "${chart.title}"` : ""}, ${parts.join(" | ")}`;
21770
+ }
21771
+ function readListPayload(value) {
21772
+ return isRecord(value) && ("targetInputId" in value || "options" in value) ? value : null;
21773
+ }
21774
+ /** Option names for values, in the form's words. */
21775
+ var namesOf = (options) => Object.keys(options);
21776
+ var nameOf = (options, value) => (options && Object.keys(options).find((n) => options[n] === value)) ?? value;
21777
+ /** What one computed list output does, in the form's labels. */
21778
+ function listOutputText(payload, labelOf) {
21779
+ const quoted = (ids) => ids.map((id) => `"${labelOf(id)}"`).join(", ");
21780
+ if (payload.rows && payload.members) {
21781
+ const rows = payload.rows.map((r) => `${r.label || r.key}${r.section ? ` (${r.section})` : ""}`);
21782
+ return `${rows.length} rows, each with ${quoted(payload.members)}: ${rows.join(", ")}`;
21783
+ }
21784
+ if (payload.pickTable) {
21785
+ const by = payload.pickTable.by?.length ? `, narrowed by ${quoted(payload.pickTable.by)}` : "";
21786
+ return `fills ${quoted(payload.pickTable.inputs)}${by}`;
21787
+ }
21788
+ const options = payload.options ?? {};
21789
+ return `${payload.targetInputId ? `options for "${labelOf(payload.targetInputId)}"` : "options"}: ${namesOf(options).join(", ") || "none"}`;
21790
+ }
21791
+ /** Each computed list's options and the pick the solve used, as the form would show them. */
21792
+ function listsText(schema, values, labelOf) {
21793
+ const model = buildFormModel(schema, values);
21794
+ const lines = [];
21795
+ const structured = {};
21796
+ for (const [id, options] of Object.entries(model.options)) {
21797
+ const pick = nameOf(options, model.shown[id] ?? values[id]);
21798
+ const label = labelOf(id);
21799
+ structured[label] = {
21800
+ options: namesOf(options),
21801
+ ...pick !== void 0 && { pick }
21802
+ };
21803
+ lines.push(`- "${label}": one of ${namesOf(options).map((n) => `"${n}"`).join(", ")}${pick !== void 0 && pick !== "" ? `; the solve used "${String(pick)}"` : ""}`);
21804
+ }
21805
+ for (const repeat of model.repeats) for (const member of repeat.members) {
21806
+ const label = labelOf(member);
21807
+ const shown = model.shown[member];
21808
+ const rows = repeat.rows.map((row, i) => {
21809
+ const options = model.rowOptions[member]?.[i] ?? {};
21810
+ return {
21811
+ row: row.key,
21812
+ label: row.label ?? row.key,
21813
+ options: namesOf(options),
21814
+ pick: nameOf(options, shown?.[i])
21815
+ };
21816
+ });
21817
+ structured[label] = { rows };
21818
+ lines.push(`- "${label}", per row as a JSON object of row key to option name:`, ...rows.map((r) => ` - ${r.row} (${r.label}): ${r.options.map((n) => `"${n}"`).join(", ")}; the solve used "${String(r.pick)}"`));
21819
+ }
21820
+ return {
21821
+ lines,
21822
+ structured
21823
+ };
21824
+ }
21697
21825
  function sizeText(bytes) {
21698
21826
  if (bytes < 1024) return `${bytes} B`;
21699
21827
  if (bytes < 1048576) return `${(bytes / 1024).toFixed(1)} KB`;
@@ -21703,10 +21831,40 @@ async function summarizeSolve(res, schema, options) {
21703
21831
  const lines = [];
21704
21832
  const structured = {};
21705
21833
  const declared = new Map(schema.outputs.map((o) => [o.nickname, o.type]));
21834
+ const outputId = new Map(schema.outputs.map((o) => [o.nickname, o.id]));
21835
+ const described = describeInputs(schema);
21836
+ const labelOf = (id) => described.find((d) => d.input.id === id)?.label ?? id;
21837
+ const formValues = Object.fromEntries(schema.inputs.filter((i) => i.default !== void 0).map((i) => [i.id, i.default]));
21838
+ Object.assign(formValues, options.values);
21839
+ let anyLists = false;
21706
21840
  let anyFiles = false;
21707
21841
  for (const tree of res.values ?? []) {
21708
21842
  if (isPlumbing(tree)) continue;
21709
21843
  const items = Object.values(tree.InnerTree ?? {}).flat();
21844
+ const kind = declared.get(tree.ParamName);
21845
+ const lists = kind === "dynamicValueList" || items.some((i) => /DynamicValueList/.test(i.type)) ? items.map((i) => readListPayload(parseDeep(i.data))) : [];
21846
+ if (lists.length && lists.every(Boolean)) {
21847
+ const payload = lists[0];
21848
+ const id = outputId.get(tree.ParamName);
21849
+ if (id) formValues[id] = payload;
21850
+ anyLists = true;
21851
+ structured[tree.ParamName] = payload.pickTable ? {
21852
+ fills: payload.pickTable.inputs.map(labelOf),
21853
+ by: (payload.pickTable.by ?? []).map(labelOf)
21854
+ } : payload.rows ? {
21855
+ rows: payload.rows,
21856
+ members: (payload.members ?? []).map(labelOf)
21857
+ } : { options: namesOf(payload.options ?? {}) };
21858
+ lines.push(`${tree.ParamName}: ${listOutputText(payload, labelOf)}`);
21859
+ continue;
21860
+ }
21861
+ const charts = kind === "chart" || items.some((i) => /Plotly/i.test(i.type)) ? items.map((i) => readFigure(parseDeep(i.data))) : [];
21862
+ if (charts.length && charts.every(Boolean)) {
21863
+ const read = charts;
21864
+ structured[tree.ParamName] = read.length === 1 ? read[0] : read;
21865
+ lines.push(`${tree.ParamName}: ${read.map(chartText).join(" || ")}`);
21866
+ continue;
21867
+ }
21710
21868
  const asNumber = declared.get(tree.ParamName) === "number";
21711
21869
  const scalars = items.filter((i) => SCALAR.test(i.type)).map((i) => {
21712
21870
  const v = parseItem(i.data);
@@ -21752,6 +21910,14 @@ async function summarizeSolve(res, schema, options) {
21752
21910
  lines.push(`${tree.ParamName}: ${items.length ? parts.join(", ") : "empty"}`);
21753
21911
  }
21754
21912
  if (!lines.length) lines.push("The solve returned no outputs.");
21913
+ let lists;
21914
+ if (anyLists) {
21915
+ const text = listsText(schema, formValues, labelOf);
21916
+ if (text.lines.length) {
21917
+ lines.push("", "Lists computed in this solve, and what they offer now:", ...text.lines, "");
21918
+ lists = text.structured;
21919
+ }
21920
+ }
21755
21921
  if (anyFiles) lines.push("File links download the file and expire within the hour.");
21756
21922
  if (res.selva?.outcome) lines.push(`Outcome: ${JSON.stringify(res.selva.outcome)}`);
21757
21923
  for (const e of res.errors ?? []) lines.push(`Error: ${e}`);
@@ -21762,6 +21928,7 @@ async function summarizeSolve(res, schema, options) {
21762
21928
  text: lines.join("\n"),
21763
21929
  structured: {
21764
21930
  outputs: structured,
21931
+ ...lists && { lists },
21765
21932
  errors: res.errors ?? [],
21766
21933
  warnings: res.warnings ?? [],
21767
21934
  link: options.link
@@ -21801,7 +21968,7 @@ var captureHdr = () => import("../../../chunks/baseHDR.js").then((m) => m.defaul
21801
21968
  * render it, check what it needs from Compute, upload and compare versions, edit its details and
21802
21969
  * cover, publish a version, and list or create projects. No deletes, share links, tokens or admin.
21803
21970
  */
21804
- var valuesArg = z.record(z.string(), z.unknown()).default({}).describe("Input values keyed by the names selva_describe_definition lists. Dropdowns take an option name.");
21971
+ var valuesArg = z.record(z.string(), z.unknown()).default({}).describe("Input values keyed by the names selva_describe_definition lists. Dropdowns take an option name; an input repeated per row takes an object of row key to option name.");
21805
21972
  async function schemaFor(api, guid, version, signal) {
21806
21973
  if (!version || version === "live") return { schema: await api.call("getDefinitionsByGuidSchema", {
21807
21974
  params: { guid },
@@ -21824,6 +21991,7 @@ async function schemaFor(api, guid, version, signal) {
21824
21991
  async function runSolve(api, definition, values, version, signal) {
21825
21992
  const guid = await resolveDefinition(api, definition, signal);
21826
21993
  const { schema, versionId } = await schemaFor(api, guid, version, signal);
21994
+ const resolved = resolveValues(describeInputs(schema), values);
21827
21995
  return {
21828
21996
  guid,
21829
21997
  schema,
@@ -21831,11 +21999,12 @@ async function runSolve(api, definition, values, version, signal) {
21831
21999
  params: { guid },
21832
22000
  body: {
21833
22001
  inputs: schema.inputs,
21834
- values: resolveValues(describeInputs(schema), values),
22002
+ values: resolved,
21835
22003
  ...versionId && { versionId }
21836
22004
  },
21837
22005
  signal
21838
- })
22006
+ }),
22007
+ resolved
21839
22008
  };
21840
22009
  }
21841
22010
  var SOLVE_CALLS = [
@@ -21939,6 +22108,19 @@ var PREVIEW_LOOKS = [
21939
22108
  "night"
21940
22109
  ];
21941
22110
  var DEFAULT_BACKGROUND = "#E6E6E6";
22111
+ var MAX_CAPTURE_CAMERAS = 6;
22112
+ var CaptureCameraArg = z.object({
22113
+ view: z.enum(CAPTURE_VIEWS).optional().describe("A preset direction. Ignored when azimuth is set."),
22114
+ azimuth: z.number().optional().describe("Degrees around the up axis: 0 from the front, 90 from the right, 180 from the back."),
22115
+ elevation: z.number().min(-89).max(89).optional().describe("Degrees above the horizon. Default 30 when azimuth is set; 90 is nearly top-down."),
22116
+ zoom: z.number().min(.1).max(20).optional().describe("1 fits the geometry, 2 is twice as close, 0.5 shows more around it."),
22117
+ target: z.tuple([
22118
+ z.number(),
22119
+ z.number(),
22120
+ z.number()
22121
+ ]).optional().describe("World point to look at, in the model's units. Default the middle of what is drawn."),
22122
+ label: z.string().max(80).optional()
22123
+ });
21942
22124
  var ListOutput = z.object({
21943
22125
  items: z.array(z.record(z.string(), z.unknown())),
21944
22126
  nextCursor: z.string().optional()
@@ -21946,6 +22128,8 @@ var ListOutput = z.object({
21946
22128
  /** `outputs` is keyed by the definition's own output names, so it can't be closed. */
21947
22129
  var SolveOutput = z.object({
21948
22130
  outputs: z.record(z.string(), z.unknown()),
22131
+ /** Each computed list by input label: its options now and the pick the solve used. */
22132
+ lists: z.record(z.string(), z.unknown()).optional(),
21949
22133
  errors: z.array(z.string()),
21950
22134
  warnings: z.array(z.string()),
21951
22135
  link: z.string(),
@@ -22209,11 +22393,12 @@ function selvaTools(origin, options) {
22209
22393
  calls: SOLVE_CALLS,
22210
22394
  ui: { resourceUri: SOLVE_VIEW_URI },
22211
22395
  async run(api, { definition, values, version, detail }, { signal, apps }) {
22212
- const { guid, schema, res } = await runSolve(api, definition, values, version, signal);
22396
+ const { guid, schema, res, resolved } = await runSolve(api, definition, values, version, signal);
22213
22397
  const summary = await summarizeSolve(res, schema, {
22214
22398
  origin,
22215
22399
  link: pageOf(guid),
22216
- stash
22400
+ stash,
22401
+ values: resolved
22217
22402
  });
22218
22403
  const solveId = await stash.put({
22219
22404
  kind: "solve",
@@ -22286,13 +22471,18 @@ function selvaTools(origin, options) {
22286
22471
  tool({
22287
22472
  name: "selva_capture_preview",
22288
22473
  title: "Render a preview",
22289
- description: "Draws a solve in Selva's own 3D viewer and returns a picture per view, with the look and background the definition opens in unless `look` says otherwise. Pass `solve`, the solve id selva_solve returned, to draw that result without solving again; otherwise it solves `values` first and spends compute like selva_solve. Extra views cost no compute. Each picture is kept for an hour under a preview id: pass one to selva_set_cover_image to make it the cover.",
22474
+ description: "Draws a solve in Selva's own 3D viewer and returns a picture per view, with the look and background the definition opens in unless `look` says otherwise. Pass `solve`, the solve id selva_solve returned, to draw that result without solving again; otherwise it solves `values` first and spends compute like selva_solve. Extra views cost no compute. Aim with preset `views`, or with `cameras` (azimuth, elevation, zoom, target); `sheet` joins them into one labelled grid. The camera fits what is drawn. `hide` leaves out layers or objects by name (the solve's geometry outputs name them); `cutaway` leaves out the walls between each camera and the middle of the scene. Each picture is kept for an hour under a preview id: pass one to selva_set_cover_image to make it the cover.",
22290
22475
  input: z.object({
22291
22476
  definition: definitionArg,
22292
22477
  solve: z.string().optional().describe("A solve id from selva_solve. When given, `values` is ignored."),
22293
22478
  values: valuesArg,
22294
22479
  version: versionArg,
22295
- views: z.array(z.enum(CAPTURE_VIEWS)).min(1).max(4).default(["default"]).describe("Camera directions, a picture each. `default` is the view the definition opens in, or iso when it saves none."),
22480
+ views: z.array(z.enum(CAPTURE_VIEWS)).min(1).max(4).default(["default"]).describe("Camera directions, a picture each, when `cameras` is not given. `default` is the view the definition opens in, or iso when it saves none."),
22481
+ cameras: z.array(CaptureCameraArg).max(MAX_CAPTURE_CAMERAS).optional().describe("One picture per camera, all from the same solve."),
22482
+ sheet: z.boolean().default(false).describe("Return the pictures as one labelled grid instead of one each."),
22483
+ hide: z.array(z.string()).max(50).optional().describe("Layers or object names to leave out. A layer hides its sublayers: \"Room\" hides \"Room/Walls\"."),
22484
+ cutaway: z.boolean().default(false).describe("Leave out tall thin walls standing between each camera and the middle of the scene."),
22485
+ fit: z.boolean().default(true).describe("Fit the camera tightly to what is drawn. False keeps the viewer's looser framing."),
22296
22486
  look: z.enum(PREVIEW_LOOKS).optional().describe("The viewer look. Default: the definition's own. `night` lights lamps."),
22297
22487
  width: z.number().int().min(256).max(2048).default(1200),
22298
22488
  height: z.number().int().min(256).max(2048).default(800),
@@ -22300,7 +22490,8 @@ function selvaTools(origin, options) {
22300
22490
  }),
22301
22491
  calls: SOLVE_CALLS,
22302
22492
  async run(api, args, { signal }) {
22303
- const { definition, solve, values, version, views, look, width, height, grid } = args;
22493
+ const { definition, solve, values, version, views, cameras, sheet, hide, cutaway, fit } = args;
22494
+ const { look, width, height, grid } = args;
22304
22495
  let schema;
22305
22496
  let res;
22306
22497
  if (solve) {
@@ -22310,17 +22501,26 @@ function selvaTools(origin, options) {
22310
22501
  ({schema} = await schemaFor(api, guid, version, signal));
22311
22502
  res = fromJsonBytes(held.data);
22312
22503
  } else ({schema, res} = await runSolve(api, definition, values, version, signal));
22504
+ let hdrMissing;
22505
+ const hdr = () => captureHdr().catch((err) => {
22506
+ hdrMissing = err instanceof Error ? err.message : String(err);
22507
+ });
22313
22508
  let capture;
22314
22509
  try {
22315
22510
  capture = await captureSolve(res, {
22316
22511
  views,
22512
+ cameras,
22513
+ sheet,
22514
+ hide,
22515
+ cutaway,
22516
+ frame: fit,
22317
22517
  width,
22318
22518
  height,
22319
22519
  grid,
22320
22520
  look: look ?? schema.viewerOptions?.look,
22321
22521
  background: schema.viewerOptions?.backgroundColor ?? DEFAULT_BACKGROUND,
22322
22522
  camera: schema.viewerOptions?.camera,
22323
- hdr: captureHdr,
22523
+ hdr,
22324
22524
  html: captureHtml,
22325
22525
  executablePath: options.previewBrowser || void 0,
22326
22526
  signal
@@ -22329,21 +22529,24 @@ function selvaTools(origin, options) {
22329
22529
  if (err instanceof CaptureUnavailableError) throw new Error(`${err.message} An operator sets this up. The solve itself worked: selva_solve still returns its numbers.`, { cause: err });
22330
22530
  throw err;
22331
22531
  }
22332
- if (!capture.drawn) return `${schema.name} solved, but drew nothing: it has no Display output with geometry for these values.`;
22532
+ if (!capture.drawn || !capture.images.length) return `${schema.name} solved, but drew nothing: it has no Display output with geometry for these values.`;
22333
22533
  const lines = [`${schema.name}, ${width}×${height}${look ? `, ${look} look` : ""}.`];
22334
- for (const [i, png] of capture.pngs.entries()) {
22534
+ for (const [i, image] of capture.images.entries()) {
22335
22535
  const previewId = await stash.put({
22336
22536
  kind: "preview",
22337
22537
  name: `${schema.name}.png`,
22338
22538
  contentType: "image/png",
22339
- data: new Uint8Array(Buffer.from(png, "base64"))
22539
+ data: new Uint8Array(Buffer.from(image.png, "base64"))
22340
22540
  });
22341
- lines.push(`${views[i]} view: preview id ${previewId}.`);
22541
+ lines.push(`${i + 1}. ${image.label}: preview id ${previewId}` + (image.cut.length ? `, cut away: ${image.cut.join(", ")}` : "") + ".");
22342
22542
  }
22543
+ if (hide?.length) lines.push(`Hidden: ${hide.join(", ")}.`);
22544
+ if (capture.layers.length) lines.push(`Layers drawn: ${capture.layers.join(", ")}.`);
22545
+ if (hdrMissing) lines.push(`Lit without the HDR environment, which could not be read: ${hdrMissing}`);
22343
22546
  return {
22344
22547
  text: lines.join("\n"),
22345
- images: capture.pngs.map((data) => ({
22346
- data,
22548
+ images: capture.images.map((image) => ({
22549
+ data: image.png,
22347
22550
  mimeType: "image/png"
22348
22551
  }))
22349
22552
  };