@selvajs/selva 4.21.0-beta.19 → 4.21.0-beta.20

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.
@@ -213,7 +213,7 @@ function server_data_serializer(event, state) {
213
213
  let promise_id = 1;
214
214
  let max_nodes = -1;
215
215
  const iterator = create_async_iterator();
216
- const global = "__sveltekit_qors7q";
216
+ const global = "__sveltekit_fk9lbq";
217
217
  /** @param {number} index */
218
218
  function get_replacer(index) {
219
219
  /** @param {any} thing */
@@ -1443,7 +1443,7 @@ async function render_response({ branch, fetched, page_config, status, error = n
1443
1443
  "crossorigin"
1444
1444
  ]);
1445
1445
  }
1446
- const global = "__sveltekit_qors7q";
1446
+ const global = "__sveltekit_fk9lbq";
1447
1447
  const { data, chunks } = data_serializer.get_data(csp);
1448
1448
  if (page_config.ssr && page_config.csr) body += `\n\t\t\t${fetched.map((item) => serialize_data(item, resolve_opts.filterSerializedResponseHeaders, !!(state.prerendering || state.prerender_default === true))).join("\n ")}`;
1449
1449
  if (page_config.csr && client) {
@@ -1467,7 +1467,7 @@ async function render_response({ branch, fetched, page_config, status, error = n
1467
1467
  }
1468
1468
  }
1469
1469
  const blocks = [];
1470
- const properties = [`base: ${base_expression}`, `version: ${s("1795157861261")}`];
1470
+ const properties = [`base: ${base_expression}`, `version: ${s("1795160513911")}`];
1471
1471
  if (assets) properties.push(`assets: ${s(assets)}`);
1472
1472
  if (client.uses_env_dynamic_public) properties.push(`env: ${load_env_eagerly ? "null" : uneval$1(rendered_env)}`);
1473
1473
  if (chunks) {
@@ -2363,7 +2363,7 @@ function redirect_response(status, location) {
2363
2363
  * @param {Response} response
2364
2364
  */
2365
2365
  function with_version_header(response) {
2366
- response.headers.set("x-sveltekit-version", "1795157861261");
2366
+ response.headers.set("x-sveltekit-version", "1795160513911");
2367
2367
  return response;
2368
2368
  }
2369
2369
  /**
@@ -1,6 +1,6 @@
1
1
  var package_default = {
2
2
  name: "@selvajs/selva",
3
- version: "4.21.0-beta.19",
3
+ version: "4.21.0-beta.20",
4
4
  description: "Selva — self-contained Grasshopper-driven web app. Install, configure via .env, deploy.",
5
5
  license: "MIT",
6
6
  author: "VektorNode",
@@ -1 +1 @@
1
- {"version":3,"file":"package.js","names":[],"sources":["../../../package.json"],"sourcesContent":["{\n\t\"name\": \"@selvajs/selva\",\n\t\"version\": \"4.21.0-beta.19\",\n\t\"description\": \"Selva — self-contained Grasshopper-driven web app. Install, configure via .env, deploy.\",\n\t\"license\": \"MIT\",\n\t\"author\": \"VektorNode\",\n\t\"homepage\": \"https://selva.dev\",\n\t\"bugs\": \"https://github.com/VektorNode/selva/issues\",\n\t\"keywords\": [\n\t\t\"grasshopper\",\n\t\t\"rhino\",\n\t\t\"rhino-compute\",\n\t\t\"parametric-design\",\n\t\t\"web-app\",\n\t\t\"sveltekit\"\n\t],\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/VektorNode/selva.git\",\n\t\t\"directory\": \"packages/selva\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"./build/index.js\",\n\t\"files\": [\n\t\t\"build\",\n\t\t\"templates\"\n\t],\n\t\"engines\": {\n\t\t\"node\": \">=24.0.0\"\n\t},\n\t\"selva\": {\n\t\t\"dataFormat\": 3\n\t},\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"dev:lan\": \"vite dev --host\",\n\t\t\"build\": \"rimraf build && vite build && node ./scripts/generate-templates.js && node ./scripts/write-runtime-meta.js\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"start\": \"node build/index.js\",\n\t\t\"clean\": \"rimraf build templates\",\n\t\t\"prepare\": \"svelte-kit sync || echo ''\",\n\t\t\"check\": \"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json\",\n\t\t\"test\": \"vitest run\",\n\t\t\"test:watch\": \"vitest\",\n\t\t\"openapi:generate\": \"node scripts/generate-openapi.js\",\n\t\t\"test:e2e\": \"playwright test\",\n\t\t\"lint\": \"eslint .\",\n\t\t\"lint:types\": \"eslint . --config eslint.typed.config.js\",\n\t\t\"generate:cli-config\": \"node scripts/generate-cli-config.js\"\n\t},\n\t\"dependencies\": {\n\t\t\"@lucide/svelte\": \"catalog:\",\n\t\t\"@supabase/supabase-js\": \"catalog:\",\n\t\t\"@sveltejs/kit\": \"catalog:\",\n\t\t\"bits-ui\": \"catalog:\",\n\t\t\"clsx\": \"catalog:\",\n\t\t\"mode-watcher\": \"catalog:\",\n\t\t\"nodemailer\": \"catalog:\",\n\t\t\"pino\": \"^10.4.0\",\n\t\t\"playwright-core\": \"catalog:\",\n\t\t\"rhino3dm\": \"catalog:\",\n\t\t\"sharp\": \"catalog:\",\n\t\t\"tailwind-merge\": \"catalog:\",\n\t\t\"tailwind-variants\": \"catalog:\",\n\t\t\"three\": \"catalog:\",\n\t\t\"zod\": \"catalog:\"\n\t},\n\t\"optionalDependencies\": {\n\t\t\"@sentry/node\": \"^11.10.0\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@playwright/test\": \"catalog:\",\n\t\t\"@selvajs/compute\": \"workspace:*\",\n\t\t\"@selvajs/config\": \"workspace:*\",\n\t\t\"@selvajs/header-auth-provider\": \"workspace:*\",\n\t\t\"@selvajs/local-provider\": \"workspace:*\",\n\t\t\"@selvajs/mcp\": \"workspace:*\",\n\t\t\"@selvajs/notifications\": \"workspace:*\",\n\t\t\"@selvajs/platform\": \"workspace:*\",\n\t\t\"@selvajs/schemas\": \"workspace:*\",\n\t\t\"@selvajs/server\": \"workspace:*\",\n\t\t\"@selvajs/solve\": \"workspace:*\",\n\t\t\"@selvajs/supabase-provider\": \"workspace:*\",\n\t\t\"@selvajs/ui\": \"workspace:*\",\n\t\t\"@selvajs/visualization\": \"workspace:*\",\n\t\t\"@sveltejs/adapter-node\": \"catalog:\",\n\t\t\"@types/nodemailer\": \"catalog:\",\n\t\t\"@types/three\": \"catalog:\",\n\t\t\"rimraf\": \"catalog:\",\n\t\t\"tw-animate-css\": \"catalog:\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"imports\": {\n\t\t\"#lib/*\": \"./src/lib/*\"\n\t}\n}\n"],"mappings":""}
1
+ {"version":3,"file":"package.js","names":[],"sources":["../../../package.json"],"sourcesContent":["{\n\t\"name\": \"@selvajs/selva\",\n\t\"version\": \"4.21.0-beta.20\",\n\t\"description\": \"Selva — self-contained Grasshopper-driven web app. Install, configure via .env, deploy.\",\n\t\"license\": \"MIT\",\n\t\"author\": \"VektorNode\",\n\t\"homepage\": \"https://selva.dev\",\n\t\"bugs\": \"https://github.com/VektorNode/selva/issues\",\n\t\"keywords\": [\n\t\t\"grasshopper\",\n\t\t\"rhino\",\n\t\t\"rhino-compute\",\n\t\t\"parametric-design\",\n\t\t\"web-app\",\n\t\t\"sveltekit\"\n\t],\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/VektorNode/selva.git\",\n\t\t\"directory\": \"packages/selva\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"./build/index.js\",\n\t\"files\": [\n\t\t\"build\",\n\t\t\"templates\"\n\t],\n\t\"engines\": {\n\t\t\"node\": \">=24.0.0\"\n\t},\n\t\"selva\": {\n\t\t\"dataFormat\": 3\n\t},\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"dev:lan\": \"vite dev --host\",\n\t\t\"build\": \"rimraf build && vite build && node ./scripts/generate-templates.js && node ./scripts/write-runtime-meta.js\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"start\": \"node build/index.js\",\n\t\t\"clean\": \"rimraf build templates\",\n\t\t\"prepare\": \"svelte-kit sync || echo ''\",\n\t\t\"check\": \"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json\",\n\t\t\"test\": \"vitest run\",\n\t\t\"test:watch\": \"vitest\",\n\t\t\"openapi:generate\": \"node scripts/generate-openapi.js\",\n\t\t\"test:e2e\": \"playwright test\",\n\t\t\"lint\": \"eslint .\",\n\t\t\"lint:types\": \"eslint . --config eslint.typed.config.js\",\n\t\t\"generate:cli-config\": \"node scripts/generate-cli-config.js\"\n\t},\n\t\"dependencies\": {\n\t\t\"@lucide/svelte\": \"catalog:\",\n\t\t\"@supabase/supabase-js\": \"catalog:\",\n\t\t\"@sveltejs/kit\": \"catalog:\",\n\t\t\"bits-ui\": \"catalog:\",\n\t\t\"clsx\": \"catalog:\",\n\t\t\"mode-watcher\": \"catalog:\",\n\t\t\"nodemailer\": \"catalog:\",\n\t\t\"pino\": \"^10.4.0\",\n\t\t\"playwright-core\": \"catalog:\",\n\t\t\"rhino3dm\": \"catalog:\",\n\t\t\"sharp\": \"catalog:\",\n\t\t\"tailwind-merge\": \"catalog:\",\n\t\t\"tailwind-variants\": \"catalog:\",\n\t\t\"three\": \"catalog:\",\n\t\t\"zod\": \"catalog:\"\n\t},\n\t\"optionalDependencies\": {\n\t\t\"@sentry/node\": \"^11.10.0\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@playwright/test\": \"catalog:\",\n\t\t\"@selvajs/compute\": \"workspace:*\",\n\t\t\"@selvajs/config\": \"workspace:*\",\n\t\t\"@selvajs/header-auth-provider\": \"workspace:*\",\n\t\t\"@selvajs/local-provider\": \"workspace:*\",\n\t\t\"@selvajs/mcp\": \"workspace:*\",\n\t\t\"@selvajs/notifications\": \"workspace:*\",\n\t\t\"@selvajs/platform\": \"workspace:*\",\n\t\t\"@selvajs/schemas\": \"workspace:*\",\n\t\t\"@selvajs/server\": \"workspace:*\",\n\t\t\"@selvajs/solve\": \"workspace:*\",\n\t\t\"@selvajs/supabase-provider\": \"workspace:*\",\n\t\t\"@selvajs/ui\": \"workspace:*\",\n\t\t\"@selvajs/visualization\": \"workspace:*\",\n\t\t\"@sveltejs/adapter-node\": \"catalog:\",\n\t\t\"@types/nodemailer\": \"catalog:\",\n\t\t\"@types/three\": \"catalog:\",\n\t\t\"rimraf\": \"catalog:\",\n\t\t\"tw-animate-css\": \"catalog:\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"imports\": {\n\t\t\"#lib/*\": \"./src/lib/*\"\n\t}\n}\n"],"mappings":""}
@@ -21179,14 +21179,19 @@ async function capture(response, options) {
21179
21179
  });
21180
21180
  await page.setContent(html, { waitUntil: "load" });
21181
21181
  const hdr = options.hdr ? await options.hdr() : void 0;
21182
- return await page.evaluate((req) => globalThis.selvaCapture(req), {
21182
+ const { pngs, drawn } = await page.evaluate((req) => globalThis.selvaCapture(req), {
21183
21183
  response,
21184
- view: options.view ?? "iso",
21184
+ views: options.views?.length ? options.views : [options.view ?? "iso"],
21185
21185
  grid: options.grid ?? true,
21186
21186
  look: options.look,
21187
21187
  background: options.background,
21188
21188
  hdr
21189
21189
  });
21190
+ return {
21191
+ png: pngs[0] ?? "",
21192
+ pngs,
21193
+ drawn
21194
+ };
21190
21195
  } finally {
21191
21196
  options.signal?.removeEventListener("abort", closePage);
21192
21197
  await page.close().catch(() => {});
@@ -21921,6 +21926,16 @@ var CAPTURE_VIEWS = [
21921
21926
  "right",
21922
21927
  "bottom"
21923
21928
  ];
21929
+ var PREVIEW_LOOKS = [
21930
+ "technical",
21931
+ "studio",
21932
+ "showcase",
21933
+ "arctic",
21934
+ "xray",
21935
+ "lineart",
21936
+ "wireframe",
21937
+ "night"
21938
+ ];
21924
21939
  var DEFAULT_BACKGROUND = "#E6E6E6";
21925
21940
  var ListOutput = z.object({
21926
21941
  items: z.array(z.record(z.string(), z.unknown())),
@@ -21932,6 +21947,8 @@ var SolveOutput = z.object({
21932
21947
  errors: z.array(z.string()),
21933
21948
  warnings: z.array(z.string()),
21934
21949
  link: z.string(),
21950
+ /** For selva_capture_preview, which renders it without solving again. */
21951
+ solveId: z.string().optional(),
21935
21952
  response: z.unknown().optional()
21936
21953
  });
21937
21954
  var PublishOutput = z.object({
@@ -22196,18 +22213,24 @@ function selvaTools(origin, options) {
22196
22213
  link: pageOf(guid),
22197
22214
  stash
22198
22215
  });
22216
+ const solveId = await stash.put({
22217
+ kind: "solve",
22218
+ name: schema.name,
22219
+ contentType: "application/json",
22220
+ data: jsonBytes(res)
22221
+ });
22222
+ const text = `${summary.text}\nSolve id ${solveId}: selva_capture_preview draws it without solving again, for an hour.`;
22223
+ const structured = {
22224
+ ...summary.structured,
22225
+ solveId
22226
+ };
22199
22227
  const meta = apps ? { [SOLVE_VIEW_KEY]: {
22200
22228
  title: schema.name,
22201
22229
  look: schema.viewerOptions?.look,
22202
22230
  background: schema.viewerOptions?.backgroundColor ?? DEFAULT_BACKGROUND,
22203
22231
  load: {
22204
22232
  tool: "selva_solve_geometry",
22205
- arguments: { token: await stash.put({
22206
- kind: "solve",
22207
- name: schema.name,
22208
- contentType: "application/json",
22209
- data: jsonBytes(res)
22210
- }) }
22233
+ arguments: { token: solveId }
22211
22234
  },
22212
22235
  form: {
22213
22236
  tool: "selva_solve",
@@ -22220,7 +22243,8 @@ function selvaTools(origin, options) {
22220
22243
  }
22221
22244
  } } : void 0;
22222
22245
  if (detail !== "full") return {
22223
- ...summary,
22246
+ text,
22247
+ structured,
22224
22248
  meta
22225
22249
  };
22226
22250
  const response = {
@@ -22228,9 +22252,9 @@ function selvaTools(origin, options) {
22228
22252
  values: res.values?.filter((t) => !isPlumbing(t))
22229
22253
  };
22230
22254
  return {
22231
- ...summary,
22255
+ text,
22232
22256
  structured: {
22233
- ...summary.structured,
22257
+ ...structured,
22234
22258
  response
22235
22259
  },
22236
22260
  meta
@@ -22259,27 +22283,38 @@ function selvaTools(origin, options) {
22259
22283
  tool({
22260
22284
  name: "selva_capture_preview",
22261
22285
  title: "Render a preview",
22262
- description: "Solves a definition and draws the result in Selva's own 3D viewer, with the look and background the definition opens in, then returns the picture. Spends compute like selva_solve. The picture is kept for an hour under a preview id: pass it to selva_set_cover_image to make it the cover.",
22286
+ 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.",
22263
22287
  input: z.object({
22264
22288
  definition: definitionArg,
22289
+ solve: z.string().optional().describe("A solve id from selva_solve. When given, `values` is ignored."),
22265
22290
  values: valuesArg,
22266
22291
  version: versionArg,
22267
- view: z.enum(CAPTURE_VIEWS).default("iso").describe("Camera direction."),
22292
+ views: z.array(z.enum(CAPTURE_VIEWS)).min(1).max(4).default(["iso"]).describe("Camera directions, a picture each."),
22293
+ look: z.enum(PREVIEW_LOOKS).optional().describe("The viewer look. Default: the definition's own. `night` lights lamps."),
22268
22294
  width: z.number().int().min(256).max(2048).default(1200),
22269
22295
  height: z.number().int().min(256).max(2048).default(800),
22270
22296
  grid: z.boolean().default(false).describe("Draw the viewer's ground grid.")
22271
22297
  }),
22272
22298
  calls: SOLVE_CALLS,
22273
- async run(api, { definition, values, version, view, width, height, grid }, { signal }) {
22274
- const { schema, res } = await runSolve(api, definition, values, version, signal);
22299
+ async run(api, args, { signal }) {
22300
+ const { definition, solve, values, version, views, look, width, height, grid } = args;
22301
+ let schema;
22302
+ let res;
22303
+ if (solve) {
22304
+ const guid = await resolveDefinition(api, definition, signal);
22305
+ const held = await stash.get(solve, "solve");
22306
+ if (!held) throw new Error("That solve id has expired or is unknown. Leave `solve` out to solve `values` again.");
22307
+ ({schema} = await schemaFor(api, guid, version, signal));
22308
+ res = fromJsonBytes(held.data);
22309
+ } else ({schema, res} = await runSolve(api, definition, values, version, signal));
22275
22310
  let capture;
22276
22311
  try {
22277
22312
  capture = await captureSolve(res, {
22278
- view,
22313
+ views,
22279
22314
  width,
22280
22315
  height,
22281
22316
  grid,
22282
- look: schema.viewerOptions?.look,
22317
+ look: look ?? schema.viewerOptions?.look,
22283
22318
  background: schema.viewerOptions?.backgroundColor ?? DEFAULT_BACKGROUND,
22284
22319
  hdr: captureHdr,
22285
22320
  html: captureHtml,
@@ -22287,22 +22322,26 @@ function selvaTools(origin, options) {
22287
22322
  signal
22288
22323
  });
22289
22324
  } catch (err) {
22290
- if (err instanceof CaptureUnavailableError) throw new Error(`${err.message} An operator sets this up; the solve itself worked.`, { cause: err });
22325
+ 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 });
22291
22326
  throw err;
22292
22327
  }
22293
22328
  if (!capture.drawn) return `${schema.name} solved, but drew nothing: it has no Display output with geometry for these values.`;
22294
- const previewId = await stash.put({
22295
- kind: "preview",
22296
- name: `${schema.name}.png`,
22297
- contentType: "image/png",
22298
- data: new Uint8Array(Buffer.from(capture.png, "base64"))
22299
- });
22329
+ const lines = [`${schema.name}, ${width}×${height}${look ? `, ${look} look` : ""}.`];
22330
+ for (const [i, png] of capture.pngs.entries()) {
22331
+ const previewId = await stash.put({
22332
+ kind: "preview",
22333
+ name: `${schema.name}.png`,
22334
+ contentType: "image/png",
22335
+ data: new Uint8Array(Buffer.from(png, "base64"))
22336
+ });
22337
+ lines.push(`${views[i]} view: preview id ${previewId}.`);
22338
+ }
22300
22339
  return {
22301
- text: `${schema.name}, ${view} view, ${width}×${height}. Preview id ${previewId}.`,
22302
- images: [{
22303
- data: capture.png,
22340
+ text: lines.join("\n"),
22341
+ images: capture.pngs.map((data) => ({
22342
+ data,
22304
22343
  mimeType: "image/png"
22305
- }]
22344
+ }))
22306
22345
  };
22307
22346
  }
22308
22347
  }),