@selvajs/selva 4.20.1-beta.3 → 4.20.1-beta.5
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.
- package/build/adapter-node.js +1 -1
- package/build/client/_app/version.json +1 -1
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/runtime-meta.json +1 -1
- package/build/server/.vite/manifest.json +1 -0
- package/build/server/chunks/engine.server.js +2 -2
- package/build/server/chunks/engine.server.js.map +1 -1
- package/build/server/chunks/grasshopper.js +204 -160
- package/build/server/chunks/grasshopper.js.map +1 -1
- package/build/server/chunks/instance.js +3 -3
- package/build/server/chunks/internal.js +1 -1
- package/build/server/chunks/package.js +1 -1
- package/build/server/chunks/package.js.map +1 -1
- package/build/server/chunks/providers.server.js +77 -52
- package/build/server/chunks/providers.server.js.map +1 -1
- package/build/server/chunks/solve.server.js +27 -1
- package/build/server/chunks/solve.server.js.map +1 -1
- package/build/server/entries/hooks.server.js +21 -9
- package/build/server/entries/hooks.server.js.map +1 -1
- package/build/server/entries/pages/library/_guid_/_page.server.ts.js +2 -2
- package/build/server/entries/pages/library/_guid_/_page.server.ts.js.map +1 -1
- package/package.json +8 -8
|
@@ -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 = "
|
|
216
|
+
const global = "__sveltekit_1w4zbvb";
|
|
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 = "
|
|
1446
|
+
const global = "__sveltekit_1w4zbvb";
|
|
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("
|
|
1470
|
+
const properties = [`base: ${base_expression}`, `version: ${s("1794217168156")}`];
|
|
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", "
|
|
2366
|
+
response.headers.set("x-sveltekit-version", "1794217168156");
|
|
2367
2367
|
return response;
|
|
2368
2368
|
}
|
|
2369
2369
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","names":[],"sources":["../../../package.json"],"sourcesContent":["{\n\t\"name\": \"@selvajs/selva\",\n\t\"version\": \"4.20.1-beta.
|
|
1
|
+
{"version":3,"file":"package.js","names":[],"sources":["../../../package.json"],"sourcesContent":["{\n\t\"name\": \"@selvajs/selva\",\n\t\"version\": \"4.20.1-beta.5\",\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\"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\"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":""}
|
|
@@ -5045,7 +5045,7 @@ function tokenToRow(t) {
|
|
|
5045
5045
|
* whenever a migration is added — `migration-head.test.ts` asserts it
|
|
5046
5046
|
* matches the migrations directory, so CI catches drift.
|
|
5047
5047
|
*/
|
|
5048
|
-
var EXPECTED_MIGRATION_HEAD = "
|
|
5048
|
+
var EXPECTED_MIGRATION_HEAD = "20261108140000";
|
|
5049
5049
|
// ../providers/supabase/src/data/client.ts
|
|
5050
5050
|
/** Default schema every engine store targets. */
|
|
5051
5051
|
var DEFAULT_SCHEMA = "selva";
|
|
@@ -5454,7 +5454,7 @@ function mapError$1(e) {
|
|
|
5454
5454
|
* `user_profiles` is too coarse for cross-user reads, so `assertCanManagePermissions` /
|
|
5455
5455
|
* `assertCanReadPermissions` enforce the auth boundary here instead.
|
|
5456
5456
|
*
|
|
5457
|
-
* `user_profiles.disabled` mirrors `
|
|
5457
|
+
* `user_profiles.disabled` mirrors the user's ban and `app_metadata.disabled` via
|
|
5458
5458
|
* the `sync_auth_user_disabled` trigger, so admin-count queries can exclude
|
|
5459
5459
|
* disabled admins with a single indexed query instead of cross-referencing
|
|
5460
5460
|
* the auth admin API per candidate.
|
|
@@ -6072,7 +6072,7 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
|
|
|
6072
6072
|
if (this.tokenVerification === "strict" || isSymmetricJwt(token)) return this.verifyViaGetUser(token);
|
|
6073
6073
|
const claims = await this.getClaimsOrNull(token);
|
|
6074
6074
|
if (!claims) return null;
|
|
6075
|
-
if (claims.
|
|
6075
|
+
if (claims.app_metadata?.disabled === true) return null;
|
|
6076
6076
|
const sessionId = typeof claims.session_id === "string" ? claims.session_id : claims.sub;
|
|
6077
6077
|
if (this.shouldRevalidate(sessionId)) {
|
|
6078
6078
|
const fresh = await this.verifyViaGetUser(token);
|
|
@@ -6094,7 +6094,7 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
|
|
|
6094
6094
|
async verifyViaGetUser(token) {
|
|
6095
6095
|
const { data, error } = await this.anon.auth.getUser(token);
|
|
6096
6096
|
if (error || !data.user) return null;
|
|
6097
|
-
if (data.user
|
|
6097
|
+
if (isDisabled(data.user)) return null;
|
|
6098
6098
|
return this.hydrate(data.user);
|
|
6099
6099
|
}
|
|
6100
6100
|
/** Local JWT verification. Returns the claims, or null if invalid/expired. */
|
|
@@ -6160,11 +6160,13 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
|
|
|
6160
6160
|
async disableUser(id) {
|
|
6161
6161
|
const { data: existing, error: fetchError } = await this.admin.auth.admin.getUserById(id);
|
|
6162
6162
|
if (fetchError || !existing.user) return "not_found";
|
|
6163
|
-
const
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6163
|
+
const { error } = await this.admin.auth.admin.updateUserById(id, {
|
|
6164
|
+
ban_duration: BAN_FOREVER,
|
|
6165
|
+
app_metadata: {
|
|
6166
|
+
...existing.user.app_metadata ?? {},
|
|
6167
|
+
disabled: true
|
|
6168
|
+
}
|
|
6169
|
+
});
|
|
6168
6170
|
if (error) {
|
|
6169
6171
|
const e = error;
|
|
6170
6172
|
if (e.status === 404 || /not.?found/i.test(e.message ?? "")) return "not_found";
|
|
@@ -6188,7 +6190,7 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
|
|
|
6188
6190
|
password
|
|
6189
6191
|
});
|
|
6190
6192
|
if (error || !data.user || !data.session) return null;
|
|
6191
|
-
if (data.user
|
|
6193
|
+
if (isDisabled(data.user)) return null;
|
|
6192
6194
|
return {
|
|
6193
6195
|
user: this.hydrate(data.user),
|
|
6194
6196
|
sessionToken: data.session.access_token
|
|
@@ -6201,7 +6203,7 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
|
|
|
6201
6203
|
email: user.email ?? void 0,
|
|
6202
6204
|
createdAt: user.created_at ?? void 0,
|
|
6203
6205
|
lastLoginAt: user.last_sign_in_at ?? void 0,
|
|
6204
|
-
disabled: user
|
|
6206
|
+
disabled: isDisabled(user),
|
|
6205
6207
|
metadata: user.user_metadata
|
|
6206
6208
|
};
|
|
6207
6209
|
}
|
|
@@ -6297,7 +6299,7 @@ var SupabaseOAuthAuth = class {
|
|
|
6297
6299
|
async exchangeOAuthCode(code) {
|
|
6298
6300
|
const { data, error } = await this.anon.auth.exchangeCodeForSession(code);
|
|
6299
6301
|
if (error || !data.user || !data.session) return null;
|
|
6300
|
-
if (data.user
|
|
6302
|
+
if (isDisabled(data.user)) return null;
|
|
6301
6303
|
return {
|
|
6302
6304
|
user: this.hydrate(data.user),
|
|
6303
6305
|
sessionToken: data.session.access_token,
|
|
@@ -6305,6 +6307,12 @@ var SupabaseOAuthAuth = class {
|
|
|
6305
6307
|
};
|
|
6306
6308
|
}
|
|
6307
6309
|
};
|
|
6310
|
+
var BAN_FOREVER = "876000h";
|
|
6311
|
+
/** Disabled by an admin: flagged in app_metadata or banned. Never `user_metadata`, which the user writes. */
|
|
6312
|
+
function isDisabled(user) {
|
|
6313
|
+
if (user.app_metadata?.disabled === true) return true;
|
|
6314
|
+
return user.banned_until ? Date.parse(user.banned_until) > Date.now() : false;
|
|
6315
|
+
}
|
|
6308
6316
|
/**
|
|
6309
6317
|
* Supabase-backed `ISessionRefresh`. `refreshSession` uses the anon client —
|
|
6310
6318
|
* a refresh token authenticates itself. `revokeSession` uses the service-role
|
|
@@ -6322,7 +6330,7 @@ var SupabaseSessionRefresh = class {
|
|
|
6322
6330
|
async refreshSession(refreshToken) {
|
|
6323
6331
|
const { data, error } = await this.anon.auth.refreshSession({ refresh_token: refreshToken });
|
|
6324
6332
|
if (error || !data.session) return null;
|
|
6325
|
-
if (data.user
|
|
6333
|
+
if (data.user !== null && isDisabled(data.user)) return null;
|
|
6326
6334
|
return {
|
|
6327
6335
|
sessionToken: data.session.access_token,
|
|
6328
6336
|
refreshToken: data.session.refresh_token
|
|
@@ -6392,7 +6400,7 @@ var SupabaseEmailLinkAuth = class {
|
|
|
6392
6400
|
type
|
|
6393
6401
|
});
|
|
6394
6402
|
if (error || !data.user || !data.session) return null;
|
|
6395
|
-
if (data.user
|
|
6403
|
+
if (isDisabled(data.user)) return null;
|
|
6396
6404
|
return {
|
|
6397
6405
|
user: this.hydrate(data.user),
|
|
6398
6406
|
sessionToken: data.session.access_token,
|
|
@@ -33901,6 +33909,40 @@ var unlimitedFetch = ((input, init) => (0, import_undici.fetch)(input, {
|
|
|
33901
33909
|
function fetchForDeadline(deadlineMs) {
|
|
33902
33910
|
return deadlineMs >= UNDICI_DEFAULT_LIMIT_MS ? unlimitedFetch : void 0;
|
|
33903
33911
|
}
|
|
33912
|
+
/**
|
|
33913
|
+
* False for a header carrying only the proxy's `affinity`, from a child that sends no timing:
|
|
33914
|
+
* read as zeros, it would put the whole solve on `compute_link`.
|
|
33915
|
+
*/
|
|
33916
|
+
function reportsTiming(rhino) {
|
|
33917
|
+
return rhino.cacheHit === true || rhino.decode !== void 0 || rhino.solve !== void 0 || rhino.encode !== void 0;
|
|
33918
|
+
}
|
|
33919
|
+
/**
|
|
33920
|
+
* `total` is the server's headers-to-out wall time, so browser `ttfb − total`
|
|
33921
|
+
* ≈ network+send latency. When the compute server reports its own timing
|
|
33922
|
+
* (VektorNode fork), `rhino_*` is time on the compute server and `compute_link`
|
|
33923
|
+
* is everything between it (network + queue wait). `rhino_cache` is 1 when the
|
|
33924
|
+
* compute server answered from its own result cache.
|
|
33925
|
+
*/
|
|
33926
|
+
function buildServerTiming(parts) {
|
|
33927
|
+
let header = `load;dur=${parts.defLoadMs.toFixed(1)}, tree;dur=${parts.treeBuildMs.toFixed(1)}, solve;dur=${parts.solveMs.toFixed(1)}, serialize;dur=${parts.serializeMs.toFixed(1)}, gzip;dur=${parts.gzipMs.toFixed(1)}, total;dur=${parts.serverTotalMs.toFixed(1)}`;
|
|
33928
|
+
const rhino = parts.rhino;
|
|
33929
|
+
if (rhino && reportsTiming(rhino)) {
|
|
33930
|
+
const decode = rhino.decode ?? 0;
|
|
33931
|
+
const solve = rhino.solve ?? 0;
|
|
33932
|
+
const encode = rhino.encode ?? 0;
|
|
33933
|
+
const computeLinkMs = Math.max(0, parts.solveMs - decode - solve - encode);
|
|
33934
|
+
header += `, rhino_decode;dur=${decode.toFixed(1)}, rhino_solve;dur=${solve.toFixed(1)}, rhino_encode;dur=${encode.toFixed(1)}, compute_link;dur=${computeLinkMs.toFixed(1)}, rhino_cache;dur=${rhino.cacheHit ? 1 : 0}`;
|
|
33935
|
+
if (rhino.gh !== void 0) header += `, rhino_gh;dur=${rhino.gh.toFixed(1)}`;
|
|
33936
|
+
if (rhino.recomputed) header += `, rhino_recomputed;desc="${rhino.recomputed.ran}/${rhino.recomputed.total}"`;
|
|
33937
|
+
}
|
|
33938
|
+
if (rhino?.affinity) header += `, rhino_affinity;desc=${rhino.affinity}`;
|
|
33939
|
+
for (const [label, ms] of parts.prepMarks) header += `, p_${label};dur=${ms.toFixed(1)}`;
|
|
33940
|
+
const settle = parts.settle;
|
|
33941
|
+
header += `, selva_cache;dur=${settle.fromCache ? 1 : 0}`;
|
|
33942
|
+
if (settle.definitionReuploaded !== void 0) header += `, def_reupload;dur=${settle.definitionReuploaded ? 1 : 0}`;
|
|
33943
|
+
if (parts.defBytes) header += `, def_bytes;desc=${parts.defBytes}`;
|
|
33944
|
+
return header;
|
|
33945
|
+
}
|
|
33904
33946
|
/** Rhino.Compute's own default `--timeout`, for a server that can't report its own. */
|
|
33905
33947
|
var DEFAULT_SOLVE_DEADLINE_MS = 1e5;
|
|
33906
33948
|
/**
|
|
@@ -33988,7 +34030,7 @@ function createClientCache(config) {
|
|
|
33988
34030
|
draining.delete(entry);
|
|
33989
34031
|
entry.scheduler.dispose();
|
|
33990
34032
|
}
|
|
33991
|
-
async function build(server
|
|
34033
|
+
async function build(server) {
|
|
33992
34034
|
const debugVerbose = config.debug === "verbose";
|
|
33993
34035
|
const longFetch = fetchForDeadline(MAX_SOLVE_DEADLINE_MS);
|
|
33994
34036
|
const clientConfig = {
|
|
@@ -34000,8 +34042,13 @@ function createClientCache(config) {
|
|
|
34000
34042
|
...longFetch && { fetch: longFetch }
|
|
34001
34043
|
};
|
|
34002
34044
|
if (config.debug) clientConfig.onServerTiming = (t) => {
|
|
34045
|
+
const routed = t.affinity ? ` | session ${t.affinity}` : "";
|
|
34003
34046
|
if (t.cacheHit) {
|
|
34004
|
-
debugLog(
|
|
34047
|
+
debugLog(`[Compute/rhino-cache] solve-cache (cachesolve): HIT (cached result, solve skipped)${routed}`);
|
|
34048
|
+
return;
|
|
34049
|
+
}
|
|
34050
|
+
if (!reportsTiming(t)) {
|
|
34051
|
+
debugLog(`[Compute/rhino-cache] no solve timing${routed}`);
|
|
34005
34052
|
return;
|
|
34006
34053
|
}
|
|
34007
34054
|
const decode = t.decode ?? 0;
|
|
@@ -34010,9 +34057,8 @@ function createClientCache(config) {
|
|
|
34010
34057
|
const defCache = decode <= 1 ? "HIT (definition reused, no re-upload/parse)" : "miss (full parse)";
|
|
34011
34058
|
const solveCache = config.cachesolve ? "miss (solved fresh)" : "off";
|
|
34012
34059
|
const ran = t.recomputed ? ` | ran ${t.recomputed.ran}/${t.recomputed.total} objects` : "";
|
|
34013
|
-
debugLog(`[Compute/rhino-cache] decode=${decode}ms solve=${solve}ms encode=${encode}ms | definition-cache: ${defCache} | solve-cache (cachesolve): ${solveCache}${ran}`);
|
|
34060
|
+
debugLog(`[Compute/rhino-cache] decode=${decode}ms solve=${solve}ms encode=${encode}ms | definition-cache: ${defCache} | solve-cache (cachesolve): ${solveCache}${ran}${routed}`);
|
|
34014
34061
|
};
|
|
34015
|
-
if (definitionGuid) clientConfig.headers = { "X-Selva-Definition": definitionGuid };
|
|
34016
34062
|
const client = await GrasshopperClient.create(clientConfig);
|
|
34017
34063
|
const probe = createConcurrencyProbe(client, debugLog);
|
|
34018
34064
|
const readReported = async () => await Promise.resolve(client.serverStats?.getLimits?.()).catch(() => null) ?? null;
|
|
@@ -34079,14 +34125,14 @@ function createClientCache(config) {
|
|
|
34079
34125
|
retire(entry);
|
|
34080
34126
|
}
|
|
34081
34127
|
const self = {
|
|
34082
|
-
async getClient(server
|
|
34128
|
+
async getClient(server) {
|
|
34083
34129
|
const key = server.id;
|
|
34084
34130
|
const existing = cache.get(key);
|
|
34085
34131
|
if (existing) {
|
|
34086
34132
|
cache.delete(key);
|
|
34087
34133
|
cache.set(key, existing);
|
|
34088
34134
|
if (!cacheEnabled || await deploymentChecks.get(existing)?.() !== false) return existing;
|
|
34089
|
-
return self.getClient(server
|
|
34135
|
+
return self.getClient(server);
|
|
34090
34136
|
}
|
|
34091
34137
|
const inFlight = pending.get(key);
|
|
34092
34138
|
if (inFlight) return inFlight.promise;
|
|
@@ -34103,7 +34149,7 @@ function createClientCache(config) {
|
|
|
34103
34149
|
const promise = (async () => {
|
|
34104
34150
|
let entry;
|
|
34105
34151
|
try {
|
|
34106
|
-
entry = await build(server
|
|
34152
|
+
entry = await build(server);
|
|
34107
34153
|
} catch (err) {
|
|
34108
34154
|
if (!token.stale) failed.set(key, {
|
|
34109
34155
|
error: err,
|
|
@@ -34424,32 +34470,6 @@ function createResponseEncoder(response, maxBytes) {
|
|
|
34424
34470
|
};
|
|
34425
34471
|
} };
|
|
34426
34472
|
}
|
|
34427
|
-
/**
|
|
34428
|
-
* `total` is the server's headers-to-out wall time, so browser `ttfb − total`
|
|
34429
|
-
* ≈ network+send latency. When the compute server reports its own timing
|
|
34430
|
-
* (VektorNode fork), `rhino_*` is time on the compute server and `compute_link`
|
|
34431
|
-
* is everything between it (network + queue wait). `rhino_cache` is 1 when the
|
|
34432
|
-
* compute server answered from its own result cache.
|
|
34433
|
-
*/
|
|
34434
|
-
function buildServerTiming(parts) {
|
|
34435
|
-
let header = `load;dur=${parts.defLoadMs.toFixed(1)}, tree;dur=${parts.treeBuildMs.toFixed(1)}, solve;dur=${parts.solveMs.toFixed(1)}, serialize;dur=${parts.serializeMs.toFixed(1)}, gzip;dur=${parts.gzipMs.toFixed(1)}, total;dur=${parts.serverTotalMs.toFixed(1)}`;
|
|
34436
|
-
const rhino = parts.rhino;
|
|
34437
|
-
if (rhino) {
|
|
34438
|
-
const decode = rhino.decode ?? 0;
|
|
34439
|
-
const solve = rhino.solve ?? 0;
|
|
34440
|
-
const encode = rhino.encode ?? 0;
|
|
34441
|
-
const computeLinkMs = Math.max(0, parts.solveMs - decode - solve - encode);
|
|
34442
|
-
header += `, rhino_decode;dur=${decode.toFixed(1)}, rhino_solve;dur=${solve.toFixed(1)}, rhino_encode;dur=${encode.toFixed(1)}, compute_link;dur=${computeLinkMs.toFixed(1)}, rhino_cache;dur=${rhino.cacheHit ? 1 : 0}`;
|
|
34443
|
-
if (rhino.gh !== void 0) header += `, rhino_gh;dur=${rhino.gh.toFixed(1)}`;
|
|
34444
|
-
if (rhino.recomputed) header += `, rhino_recomputed;desc="${rhino.recomputed.ran}/${rhino.recomputed.total}"`;
|
|
34445
|
-
}
|
|
34446
|
-
for (const [label, ms] of parts.prepMarks) header += `, p_${label};dur=${ms.toFixed(1)}`;
|
|
34447
|
-
const settle = parts.settle;
|
|
34448
|
-
header += `, selva_cache;dur=${settle.fromCache ? 1 : 0}`;
|
|
34449
|
-
if (settle.definitionReuploaded !== void 0) header += `, def_reupload;dur=${settle.definitionReuploaded ? 1 : 0}`;
|
|
34450
|
-
if (parts.defBytes) header += `, def_bytes;desc=${parts.defBytes}`;
|
|
34451
|
-
return header;
|
|
34452
|
-
}
|
|
34453
34473
|
function createSolveCacheSingleFlight(options = {}) {
|
|
34454
34474
|
const inflight = /* @__PURE__ */ new Map();
|
|
34455
34475
|
function free(key, flight) {
|
|
@@ -34535,8 +34555,9 @@ function buildSolveInputTree(inputs, values) {
|
|
|
34535
34555
|
}
|
|
34536
34556
|
/**
|
|
34537
34557
|
* Runs one solve against a warm scheduler and classifies how it ended: a solved response, or an
|
|
34538
|
-
* expected failure as a value instead of a throw.
|
|
34539
|
-
*
|
|
34558
|
+
* expected failure as a value instead of a throw. Single-flight shares this part, so its args come
|
|
34559
|
+
* from the caller that started the flight. Anything per caller must be in the coalesce key, or,
|
|
34560
|
+
* like `sessionId`, be harmless for the joiners to inherit.
|
|
34540
34561
|
*/
|
|
34541
34562
|
function shed(durationMs, reason, message) {
|
|
34542
34563
|
return {
|
|
@@ -34597,6 +34618,8 @@ async function runSolvePipeline(args) {
|
|
|
34597
34618
|
const detail = await args.client.scheduler.solveDetailed(args.definitionSource, args.inputTree, {
|
|
34598
34619
|
signal: args.signal,
|
|
34599
34620
|
selvaevents: args.selvaEvents,
|
|
34621
|
+
sessionId: args.sessionId,
|
|
34622
|
+
headers: args.headers,
|
|
34600
34623
|
onServerTiming: (t) => {
|
|
34601
34624
|
rhino = t;
|
|
34602
34625
|
}
|
|
@@ -34666,8 +34689,8 @@ var SolveEngine = class {
|
|
|
34666
34689
|
this.byteCache = createDefinitionByteCache(this.limits.computeDefinitionCacheBytes);
|
|
34667
34690
|
this.singleFlight = createSolveCacheSingleFlight({ onJoin: options.onSolveCoalesced });
|
|
34668
34691
|
}
|
|
34669
|
-
getClient(server
|
|
34670
|
-
return this.clientCache.getClient(server
|
|
34692
|
+
getClient(server) {
|
|
34693
|
+
return this.clientCache.getClient(server);
|
|
34671
34694
|
}
|
|
34672
34695
|
definitionRef(versionId, load) {
|
|
34673
34696
|
return this.byteCache.getOrLoad(versionId, load);
|
|
@@ -34706,7 +34729,7 @@ var SolveEngine = class {
|
|
|
34706
34729
|
};
|
|
34707
34730
|
let client;
|
|
34708
34731
|
try {
|
|
34709
|
-
client = await this.clientCache.getClient(args.server
|
|
34732
|
+
client = await this.clientCache.getClient(args.server);
|
|
34710
34733
|
} catch (error) {
|
|
34711
34734
|
if (args.signal.aborted) return {
|
|
34712
34735
|
kind: "client_abort",
|
|
@@ -34742,6 +34765,8 @@ var SolveEngine = class {
|
|
|
34742
34765
|
client,
|
|
34743
34766
|
responseMaxBytes: this.limits.computeResponseMaxBytes,
|
|
34744
34767
|
selvaEvents: args.selvaEvents,
|
|
34768
|
+
sessionId: args.sessionId,
|
|
34769
|
+
...args.definitionGuid && { headers: { "X-Selva-Definition": args.definitionGuid } },
|
|
34745
34770
|
signal
|
|
34746
34771
|
}), args.signal);
|
|
34747
34772
|
if (args.signal.aborted) return {
|