@ggui-ai/ui-gen 0.23.0 → 0.25.0

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 (123) hide show
  1. package/dist/adapter-Cg_rkpGq.d.ts +201 -0
  2. package/dist/adapters/generation-dispatch.d.ts +58 -15
  3. package/dist/adapters/generation-dispatch.js +1418 -180
  4. package/dist/adapters/generation-dispatch.js.map +1 -1
  5. package/dist/adapters/index.js +3 -1
  6. package/dist/adapters/index.js.map +1 -1
  7. package/dist/advanced/index.d.ts +12 -8
  8. package/dist/advanced/index.js +1467 -239
  9. package/dist/advanced/index.js.map +1 -1
  10. package/dist/{axes-CzLEMDeB.d.ts → axes-CKVCzR_x.d.ts} +1 -1
  11. package/dist/bank-CT4eEkta.d.ts +118 -0
  12. package/dist/blueprint-validator.js +153 -59
  13. package/dist/blueprint-validator.js.map +1 -1
  14. package/dist/boilerplate.js +24 -12
  15. package/dist/boilerplate.js.map +1 -1
  16. package/dist/check/index.d.ts +12 -4
  17. package/dist/check/index.js +94 -2
  18. package/dist/check/index.js.map +1 -1
  19. package/dist/classifier/index.d.ts +2 -2
  20. package/dist/compose.d.ts +2 -2
  21. package/dist/{create-ui-generator-D0kbWwln.d.ts → create-ui-generator-DFnnArrv.d.ts} +43 -11
  22. package/dist/{dispatch-wxaIMwZt.d.ts → dispatch-CStl9eAw.d.ts} +5 -3
  23. package/dist/evaluation/axis-checks/index.d.ts +6 -5
  24. package/dist/evaluation/axis-checks/index.js +90 -2
  25. package/dist/evaluation/axis-checks/index.js.map +1 -1
  26. package/dist/evaluation/axis-checks/registry.d.ts +4 -3
  27. package/dist/evaluation/axis-checks/registry.js +88 -1
  28. package/dist/evaluation/axis-checks/registry.js.map +1 -1
  29. package/dist/evaluation/index.d.ts +301 -23
  30. package/dist/evaluation/index.js +746 -30
  31. package/dist/evaluation/index.js.map +1 -1
  32. package/dist/evaluation/types.d.ts +9 -1
  33. package/dist/evaluation/types.js.map +1 -1
  34. package/dist/fragments/index.d.ts +3 -3
  35. package/dist/harness/check/runtime-render/index.d.ts +30 -11
  36. package/dist/harness/check/runtime-render/index.js +203 -60
  37. package/dist/harness/check/runtime-render/index.js.map +1 -1
  38. package/dist/harness/check/runtime-render/render-check-worker.d.ts +8 -1
  39. package/dist/harness/check/runtime-render/render-check-worker.js +72 -32
  40. package/dist/harness/check/runtime-render/render-check-worker.js.map +1 -1
  41. package/dist/harness/index.d.ts +5 -4
  42. package/dist/harness/index.js +33 -15
  43. package/dist/harness/index.js.map +1 -1
  44. package/dist/harness/prompts.js.map +1 -1
  45. package/dist/harness/result-types.d.ts +4 -3
  46. package/dist/harness/runtime.d.ts +11 -4
  47. package/dist/harness/runtime.js +26 -14
  48. package/dist/harness/runtime.js.map +1 -1
  49. package/dist/harness/types-public.d.ts +13 -4
  50. package/dist/harness/types-public.js +33 -15
  51. package/dist/harness/types-public.js.map +1 -1
  52. package/dist/harness/validator-trace-sink.d.ts +4 -3
  53. package/dist/hash.d.ts +1 -1
  54. package/dist/index.d.ts +59 -8
  55. package/dist/index.js +1476 -241
  56. package/dist/index.js.map +1 -1
  57. package/dist/{llm-router-DwwUK1bz.d.ts → llm-router-nfO7wPec.d.ts} +3 -1
  58. package/dist/patch.d.ts +4 -3
  59. package/dist/policy.d.ts +8 -5
  60. package/dist/policy.js.map +1 -1
  61. package/dist/tools/get-primitives-ts.d.ts +1 -1
  62. package/dist/tools/get-primitives-ts.js +1 -1
  63. package/dist/tools/get-primitives-ts.js.map +1 -1
  64. package/dist/tools/render-check-worker.d.ts +7 -1
  65. package/dist/tools/render-check-worker.js +55 -23
  66. package/dist/tools/render-check-worker.js.map +1 -1
  67. package/dist/{types-BOvHNG7K.d.ts → types-Dh1s4K9j.d.ts} +1 -1
  68. package/dist/{types-public-Ow-tNtFE.d.ts → types-public-BJTLpzWn.d.ts} +208 -15
  69. package/dist/validation/index.d.ts +1 -1
  70. package/dist/validation/index.js +1 -1
  71. package/dist/validation/index.js.map +1 -1
  72. package/dist/workflows.d.ts +4 -3
  73. package/package.json +12 -12
  74. package/src/adapters/generation-dispatch.ts +173 -98
  75. package/src/adapters/tools.ts +2 -1
  76. package/src/boilerplate/free-design-prompt.ts +1 -1
  77. package/src/boilerplate/generate.ts +26 -1
  78. package/src/boilerplate/hard-sections.ts +13 -13
  79. package/src/boilerplate/system-prompt.ts +1 -1
  80. package/src/check/index.ts +1 -0
  81. package/src/check/run-tier0.ts +80 -1
  82. package/src/check/sample-props.ts +63 -0
  83. package/src/coding-agent/tools.ts +4 -1
  84. package/src/create-harness.ts +3 -3
  85. package/src/create-ui-generator.ts +204 -95
  86. package/src/evaluation/__fixtures__/png.ts +100 -0
  87. package/src/evaluation/axis-checks/checks/state-merge.ts +1 -1
  88. package/src/evaluation/axis-checks/checks/universal.ts +111 -0
  89. package/src/evaluation/axis-checks/dispatch.ts +4 -1
  90. package/src/evaluation/criteria/bank.ts +85 -0
  91. package/src/evaluation/criteria/context.ts +52 -0
  92. package/src/evaluation/criteria/resolve.ts +159 -0
  93. package/src/evaluation/criteria/select.ts +79 -0
  94. package/src/evaluation/index.ts +23 -0
  95. package/src/evaluation/ink-extent.ts +200 -0
  96. package/src/evaluation/theme-css.ts +12 -5
  97. package/src/evaluation/types-public.ts +200 -11
  98. package/src/evaluation/types.ts +9 -0
  99. package/src/evaluation/visual-evaluator.ts +636 -30
  100. package/src/harness/check/runtime-render/adapter.ts +221 -75
  101. package/src/harness/check/runtime-render/index.ts +75 -2
  102. package/src/harness/check/runtime-render/render-check-host.ts +82 -19
  103. package/src/harness/check/runtime-render/render-check-worker.ts +83 -29
  104. package/src/harness/check/runtime-render/render-check.ts +154 -117
  105. package/src/harness/coding/generate-task-runner.ts +60 -4
  106. package/src/harness/coding/init-session.ts +13 -0
  107. package/src/harness/coding/run-coding-turn.ts +7 -3
  108. package/src/harness/coding/run-eval-round.ts +257 -15
  109. package/src/harness/policy.ts +11 -0
  110. package/src/harness/primitive-slice.ts +104 -0
  111. package/src/harness/runtime.ts +5 -0
  112. package/src/harness/types-public.ts +9 -1
  113. package/src/harness-tool-names.ts +38 -0
  114. package/src/index.ts +16 -0
  115. package/src/policy.ts +7 -4
  116. package/src/run-check.ts +2 -0
  117. package/src/tools/get-primitives-ts.ts +1 -1
  118. package/src/tools/get-wire.ts +1 -1
  119. package/src/tools/render-check-worker.ts +74 -23
  120. package/src/tools/render-check.ts +0 -60
  121. package/src/tools.ts +11 -1
  122. package/src/validation/primitives.ts +1 -1
  123. package/dist/render-check-Blwj8gB6.d.ts +0 -105
@@ -37,4 +37,4 @@ interface Classification {
37
37
  riskTier: RiskTier;
38
38
  }
39
39
 
40
- export type { AxisVector as A, Classification as C, FetchShape as F, LayoutShape as L, RiskTier as R, StreamEventKind as S, ToolingShape as T, WriteTrigger as W, AxisSource as a, RealtimeShape as b, RenderShape as c, StateShape as d, WriteShape as e, AxisProvenance as f };
40
+ export type { AxisVector as A, Classification as C, FetchShape as F, LayoutShape as L, RiskTier as R, StateShape as S, ToolingShape as T, WriteShape as W, RenderShape as a, StreamEventKind as b, AxisSource as c, RealtimeShape as d, WriteTrigger as e, AxisProvenance as f };
@@ -0,0 +1,118 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * The visual criteria bank — ggui#1436 (step 1 of the founder's visual-assessment steer).
5
+ *
6
+ * The bank is DATA, never code (#1437 authors it; #1060's bar-and-judge policy): a versioned set of
7
+ * criteria the judge, an instrument or a person answers off the frame, split as the founder ruled —
8
+ * `severity` is importance, `evaluation` the method, `status` the method's readiness (the only source
9
+ * of an `n/a`), `scope` where a row applies ({} = every card; {kind} / {canvas} / {preset} = one). The
10
+ * general rows are `criteria`; a preset's own expression is a `recipes` row carrying `scope.preset`.
11
+ * This module is the ONE loader: a malformed bank refuses at launch with the offending path named,
12
+ * never mid-run. Fields the loader does not read (`examples`, `fields`, `groups`, `seed`) are page
13
+ * matter and are dropped here; an additive field tomorrow does not break today's loader.
14
+ */
15
+
16
+ /** Where a row applies; every key named must match the card's context. */
17
+ declare const criteriaScopeSchema: z.ZodObject<{
18
+ kind: z.ZodOptional<z.ZodString>;
19
+ canvas: z.ZodOptional<z.ZodString>;
20
+ preset: z.ZodOptional<z.ZodString>;
21
+ }, z.core.$strip>;
22
+ declare const bankRowSchema: z.ZodObject<{
23
+ id: z.ZodString;
24
+ group: z.ZodOptional<z.ZodString>;
25
+ scope: z.ZodDefault<z.ZodObject<{
26
+ kind: z.ZodOptional<z.ZodString>;
27
+ canvas: z.ZodOptional<z.ZodString>;
28
+ preset: z.ZodOptional<z.ZodString>;
29
+ }, z.core.$strip>>;
30
+ severity: z.ZodEnum<{
31
+ must: "must";
32
+ should: "should";
33
+ }>;
34
+ evaluation: z.ZodEnum<{
35
+ instrument: "instrument";
36
+ judge: "judge";
37
+ human: "human";
38
+ }>;
39
+ status: z.ZodEnum<{
40
+ live: "live";
41
+ reference: "reference";
42
+ planned: "planned";
43
+ manual: "manual";
44
+ }>;
45
+ text: z.ZodString;
46
+ evidence: z.ZodString;
47
+ fix: z.ZodOptional<z.ZodString>;
48
+ }, z.core.$strip>;
49
+ declare const criteriaBankSchema: z.ZodObject<{
50
+ version: z.ZodString;
51
+ applies: z.ZodOptional<z.ZodObject<{
52
+ kind: z.ZodOptional<z.ZodArray<z.ZodString>>;
53
+ canvases: z.ZodOptional<z.ZodArray<z.ZodString>>;
54
+ }, z.core.$strip>>;
55
+ criteria: z.ZodArray<z.ZodObject<{
56
+ id: z.ZodString;
57
+ group: z.ZodOptional<z.ZodString>;
58
+ scope: z.ZodDefault<z.ZodObject<{
59
+ kind: z.ZodOptional<z.ZodString>;
60
+ canvas: z.ZodOptional<z.ZodString>;
61
+ preset: z.ZodOptional<z.ZodString>;
62
+ }, z.core.$strip>>;
63
+ severity: z.ZodEnum<{
64
+ must: "must";
65
+ should: "should";
66
+ }>;
67
+ evaluation: z.ZodEnum<{
68
+ instrument: "instrument";
69
+ judge: "judge";
70
+ human: "human";
71
+ }>;
72
+ status: z.ZodEnum<{
73
+ live: "live";
74
+ reference: "reference";
75
+ planned: "planned";
76
+ manual: "manual";
77
+ }>;
78
+ text: z.ZodString;
79
+ evidence: z.ZodString;
80
+ fix: z.ZodOptional<z.ZodString>;
81
+ }, z.core.$strip>>;
82
+ recipes: z.ZodOptional<z.ZodArray<z.ZodObject<{
83
+ id: z.ZodString;
84
+ group: z.ZodOptional<z.ZodString>;
85
+ scope: z.ZodDefault<z.ZodObject<{
86
+ kind: z.ZodOptional<z.ZodString>;
87
+ canvas: z.ZodOptional<z.ZodString>;
88
+ preset: z.ZodOptional<z.ZodString>;
89
+ }, z.core.$strip>>;
90
+ severity: z.ZodEnum<{
91
+ must: "must";
92
+ should: "should";
93
+ }>;
94
+ evaluation: z.ZodEnum<{
95
+ instrument: "instrument";
96
+ judge: "judge";
97
+ human: "human";
98
+ }>;
99
+ status: z.ZodEnum<{
100
+ live: "live";
101
+ reference: "reference";
102
+ planned: "planned";
103
+ manual: "manual";
104
+ }>;
105
+ text: z.ZodString;
106
+ evidence: z.ZodString;
107
+ fix: z.ZodOptional<z.ZodString>;
108
+ }, z.core.$strip>>>;
109
+ }, z.core.$strip>;
110
+ type CriteriaBank = z.infer<typeof criteriaBankSchema>;
111
+ type BankRow = z.infer<typeof bankRowSchema>;
112
+ type CriteriaScope = z.infer<typeof criteriaScopeSchema>;
113
+ /** Every row of the bank — the general criteria, then the recipes. */
114
+ declare function bankRows(bank: CriteriaBank): readonly BankRow[];
115
+ /** The one door for bank data: refuses loudly, naming the path, before anything is judged. */
116
+ declare function parseCriteriaBank(raw: unknown): CriteriaBank;
117
+
118
+ export { type BankRow as B, type CriteriaBank as C, type CriteriaScope as a, bankRows as b, criteriaBankSchema as c, parseCriteriaBank as p };
@@ -20,9 +20,25 @@ var __export = (target, all) => {
20
20
  // src/harness/check/runtime-render/render-check-host.ts
21
21
  var render_check_host_exports = {};
22
22
  __export(render_check_host_exports, {
23
+ DEFAULT_RENDER_CHECK_HOST_BOUNDS: () => DEFAULT_RENDER_CHECK_HOST_BOUNDS,
23
24
  mapSandboxResultToCheckResult: () => mapSandboxResultToCheckResult,
25
+ resolveRenderCheckHostBounds: () => resolveRenderCheckHostBounds,
26
+ resolveWorkerSpawn: () => resolveWorkerSpawn,
24
27
  runRenderCheckViaWorker: () => runRenderCheckViaWorker
25
28
  });
29
+ function resolveRenderCheckHostBounds(bounds = {}) {
30
+ const timeoutMs = bounds.timeoutMs ?? DEFAULT_RENDER_CHECK_HOST_BOUNDS.timeoutMs;
31
+ const heapMb = bounds.heapMb ?? DEFAULT_RENDER_CHECK_HOST_BOUNDS.heapMb;
32
+ if (!Number.isInteger(timeoutMs) || timeoutMs < 2) {
33
+ throw new RangeError(`render-check: timeoutMs must be an integer \u2265 2, got ${timeoutMs}`);
34
+ }
35
+ if (!Number.isInteger(heapMb) || heapMb < 1) {
36
+ throw new RangeError(`render-check: heapMb must be a positive integer, got ${heapMb}`);
37
+ }
38
+ const requestedGrace = bounds.gracePeriodMs ?? DEFAULT_RENDER_CHECK_HOST_BOUNDS.gracePeriodMs;
39
+ const gracePeriodMs = Math.max(1, Math.min(requestedGrace, Math.floor(timeoutMs / 2)));
40
+ return { timeoutMs, heapMb, gracePeriodMs };
41
+ }
26
42
  function resolveWorkerSpawn() {
27
43
  const jsCandidates = [
28
44
  // Sibling — when import.meta.url is already .../harness/check/runtime-render/.
@@ -71,12 +87,12 @@ function unverified(reason, t0) {
71
87
  stats: { actionsChecked: 0, streamsChecked: 0, renderMs: Date.now() - t0 }
72
88
  };
73
89
  }
74
- function mapSandboxResultToCheckResult(result, t0) {
90
+ function mapSandboxResultToCheckResult(result, t0, boundMs = DEFAULT_RENDER_CHECK_HOST_BOUNDS.timeoutMs) {
75
91
  if (result.outcome === "timeout") {
76
92
  return {
77
93
  ok: false,
78
94
  issues: [],
79
- incomplete: { kind: "timeout", elapsedMs: result.durationMs, boundMs: CHECK_TIMEOUT_MS },
95
+ incomplete: { kind: "timeout", elapsedMs: result.durationMs, boundMs },
80
96
  stats: { actionsChecked: 0, streamsChecked: 0, renderMs: Date.now() - t0 }
81
97
  };
82
98
  }
@@ -121,8 +137,9 @@ function mapSandboxResultToCheckResult(result, t0) {
121
137
  );
122
138
  }
123
139
  }
124
- async function runRenderCheckViaWorker(input) {
140
+ async function runRenderCheckViaWorker(input, options = {}) {
125
141
  const t0 = Date.now();
142
+ const bounds = resolveRenderCheckHostBounds(options.bounds);
126
143
  let spawn;
127
144
  try {
128
145
  spawn = resolveWorkerSpawn();
@@ -133,9 +150,10 @@ async function runRenderCheckViaWorker(input) {
133
150
  const result = await runSandboxed({
134
151
  command: spawn.command,
135
152
  args: spawn.args,
136
- timeoutMs: CHECK_TIMEOUT_MS,
153
+ timeoutMs: bounds.timeoutMs,
154
+ gracePeriodMs: bounds.gracePeriodMs,
137
155
  maxStdoutBytes: CHECK_STDOUT_CAP,
138
- nodeHeapMb: CHECK_NODE_HEAP_MB,
156
+ nodeHeapMb: bounds.heapMb,
139
157
  stdin: JSON.stringify(input),
140
158
  // NODE_ENV steers React's production vs development build — keep
141
159
  // parity with the caller; everything else stays on the sandbox's
@@ -147,15 +165,18 @@ async function runRenderCheckViaWorker(input) {
147
165
  end: loadavg()[0] ?? 0,
148
166
  cores: availableParallelism()
149
167
  };
150
- const mapped = mapSandboxResultToCheckResult(result, t0);
168
+ const mapped = mapSandboxResultToCheckResult(result, t0, bounds.timeoutMs);
151
169
  return { ...mapped, stats: { ...mapped.stats, hostLoad } };
152
170
  }
153
- var CHECK_TIMEOUT_MS, CHECK_STDOUT_CAP, CHECK_NODE_HEAP_MB, WORKER_BASENAME;
171
+ var DEFAULT_RENDER_CHECK_HOST_BOUNDS, CHECK_STDOUT_CAP, WORKER_BASENAME;
154
172
  var init_render_check_host = __esm({
155
173
  "src/harness/check/runtime-render/render-check-host.ts"() {
156
- CHECK_TIMEOUT_MS = 3e4;
174
+ DEFAULT_RENDER_CHECK_HOST_BOUNDS = {
175
+ timeoutMs: 3e4,
176
+ heapMb: 512,
177
+ gracePeriodMs: 2e3
178
+ };
157
179
  CHECK_STDOUT_CAP = 2 * 1024 * 1024;
158
- CHECK_NODE_HEAP_MB = 512;
159
180
  WORKER_BASENAME = "render-check-worker";
160
181
  }
161
182
  });
@@ -677,13 +698,13 @@ function editableSurface(el) {
677
698
  function parentLink(node) {
678
699
  return node;
679
700
  }
680
- async function runRenderCheck(input) {
701
+ async function runRenderCheck(input, options = {}) {
681
702
  const g = hostGlobals();
682
703
  if ("window" in g && "document" in g) {
683
704
  return runRenderCheckInProcess(input);
684
705
  }
685
706
  const { runRenderCheckViaWorker: runRenderCheckViaWorker2 } = await Promise.resolve().then(() => (init_render_check_host(), render_check_host_exports));
686
- return runRenderCheckViaWorker2(input);
707
+ return runRenderCheckViaWorker2(input, options);
687
708
  }
688
709
  async function runRenderCheckInProcess(input) {
689
710
  const t0 = Date.now();
@@ -697,7 +718,7 @@ async function runRenderCheckInProcess(input) {
697
718
  const Wire = await import('@ggui-ai/wire');
698
719
  const { GguiWireProvider } = Wire;
699
720
  const moduleResolutions = {
700
- "react": React,
721
+ react: React,
701
722
  "react/jsx-runtime": ReactJsxRuntime,
702
723
  "@ggui-ai/wire": Wire
703
724
  };
@@ -813,14 +834,23 @@ async function runRenderCheckInProcess(input) {
813
834
  )
814
835
  );
815
836
  const timeoutPromise = new Promise((_, reject) => {
816
- setTimeout(() => reject(new Error(`[runtime-render] render exceeded ${RENDER_TIMEOUT_MS}ms \u2014 classified as runtime-hang`)), RENDER_TIMEOUT_MS).unref?.();
837
+ setTimeout(
838
+ () => reject(
839
+ new Error(
840
+ `[runtime-render] render exceeded ${RENDER_TIMEOUT_MS}ms \u2014 classified as runtime-hang`
841
+ )
842
+ ),
843
+ RENDER_TIMEOUT_MS
844
+ ).unref?.();
817
845
  });
818
846
  renderResult = await Promise.race([renderPromise, timeoutPromise]);
819
847
  } catch (e) {
820
848
  const msg = e instanceof Error ? e.message : String(e);
821
849
  const errStack = e instanceof Error ? e.stack ?? "" : "";
822
850
  const baseReason = loopSignature ? `Infinite render loop (${loopSignature}) \u2014 likely setState/dispatch inside useEffect with missing or unstable dependency` : /runtime-hang/.test(msg) ? `Render wall-clock exceeded ${RENDER_TIMEOUT_MS}ms \u2014 likely async effect loop or unresolved promise` : `Render threw: ${msg}`;
823
- const userFrames = errStack.split("\n").map((l) => l.trim()).filter((l) => l.startsWith("at ")).filter((l) => !/(node_modules|happy-dom|@testing-library|react-dom|node:internal|node:async)/.test(l)).slice(0, 5);
851
+ const userFrames = errStack.split("\n").map((l) => l.trim()).filter((l) => l.startsWith("at ")).filter(
852
+ (l) => !/(node_modules|happy-dom|@testing-library|react-dom|node:internal|node:async)/.test(l)
853
+ ).slice(0, 5);
824
854
  const stackSource = boundaryRef.stack ?? capturedComponentStack ?? "";
825
855
  const componentFrames = stackSource.split("\n").map((l) => l.trim()).filter((l) => l.startsWith("at ")).slice(0, 4);
826
856
  const stackBlock = userFrames.length ? `
@@ -1285,9 +1315,7 @@ function idLikeRequiredStringField(schema) {
1285
1315
  const required = schema["required"];
1286
1316
  if (properties === null || typeof properties !== "object") return null;
1287
1317
  if (!Array.isArray(required)) return null;
1288
- for (const [propName, propSchema] of Object.entries(
1289
- properties
1290
- )) {
1318
+ for (const [propName, propSchema] of Object.entries(properties)) {
1291
1319
  if (!/id$/i.test(propName)) continue;
1292
1320
  if (!required.includes(propName)) continue;
1293
1321
  const t = propSchema !== null && typeof propSchema === "object" ? propSchema["type"] : void 0;
@@ -1318,9 +1346,7 @@ async function checkSelectionIdentity(input) {
1318
1346
  return void 0;
1319
1347
  }
1320
1348
  await flushPromises();
1321
- const events = probe.getFireLog().slice(before).filter(
1322
- (e) => e.kind === "action.fired" && e.name === actionName
1323
- );
1349
+ const events = probe.getFireLog().slice(before).filter((e) => e.kind === "action.fired" && e.name === actionName);
1324
1350
  return events.length > 0 ? events[events.length - 1].payload : void 0;
1325
1351
  };
1326
1352
  const first = await payloadFor(group[0]);
@@ -1381,7 +1407,10 @@ async function dispatchTrigger(el, kind, user) {
1381
1407
  case "submit": {
1382
1408
  const form = closestForm(el);
1383
1409
  if (!form) return;
1384
- const ev = new globalThis.Event("submit", { bubbles: true, cancelable: true });
1410
+ const ev = new globalThis.Event("submit", {
1411
+ bubbles: true,
1412
+ cancelable: true
1413
+ });
1385
1414
  toEventDispatcher(form).dispatchEvent(ev);
1386
1415
  return;
1387
1416
  }
@@ -1718,47 +1747,112 @@ function synthesizeFromSchema(schema, hint, warnings, depth, ordinal) {
1718
1747
  }
1719
1748
 
1720
1749
  // src/harness/check/runtime-render/adapter.ts
1721
- var DEFAULT_RUNTIME_RENDER_CHECK = {
1722
- id: "runtime-render",
1723
- run: async (input) => {
1724
- const { sourceCode, compiledCode, contract, fixtureProps } = input;
1725
- if (compiledCode === null) {
1726
- return { status: "not-applicable", issues: [], reason: "no compiled code" };
1727
- }
1728
- if (!contract) {
1729
- return { status: "not-applicable", issues: [], reason: "no contract surface" };
1730
- }
1731
- const mockup = prepareMockupProps({ contract, fixtureProps });
1732
- let result;
1733
- try {
1734
- result = await runRenderCheck({
1735
- sourceCode,
1736
- mockupProps: mockup.props,
1737
- contract
1750
+ init_render_check_host();
1751
+ function createSlotLimiter(maxConcurrent) {
1752
+ if (maxConcurrent === void 0) return (task) => task(0);
1753
+ if (!Number.isInteger(maxConcurrent) || maxConcurrent < 1) {
1754
+ throw new RangeError(
1755
+ `createRuntimeRenderCheck: maxConcurrent must be a positive integer, got ${maxConcurrent}`
1756
+ );
1757
+ }
1758
+ let active = 0;
1759
+ const waiting = [];
1760
+ const acquire = () => {
1761
+ if (active < maxConcurrent) {
1762
+ active += 1;
1763
+ return Promise.resolve(0);
1764
+ }
1765
+ const enqueuedAt = Date.now();
1766
+ return new Promise((resolve) => {
1767
+ waiting.push(() => {
1768
+ active += 1;
1769
+ resolve(Date.now() - enqueuedAt);
1738
1770
  });
1739
- } catch (e) {
1740
- const message = e instanceof Error ? e.message : String(e);
1741
- console.warn(
1742
- `[runtime-render] probe skipped \u2014 infra failure: ${message}`
1743
- );
1744
- return { status: "infra-skipped", issues: [], reason: message };
1771
+ });
1772
+ };
1773
+ const release = () => {
1774
+ active -= 1;
1775
+ const next = waiting.shift();
1776
+ if (next !== void 0) next();
1777
+ };
1778
+ return async (task) => {
1779
+ const waitedMs = await acquire();
1780
+ try {
1781
+ return await task(waitedMs);
1782
+ } finally {
1783
+ release();
1745
1784
  }
1746
- const hostLoad = result.stats.hostLoad;
1747
- const load = hostLoad !== void 0 ? { hostLoad } : {};
1748
- if (result.incomplete !== void 0) {
1749
- const { elapsedMs, boundMs } = result.incomplete;
1750
- const loadNote = hostLoad !== void 0 ? `; host load ${hostLoad.start.toFixed(1)} \u2192 ${hostLoad.end.toFixed(1)} on ${hostLoad.cores} CPUs` : "";
1751
- const reason = `render check did not finish within ${boundMs} ms (stopped at ${elapsedMs} ms)${loadNote}`;
1752
- console.warn(`[runtime-render] probe timed out \u2014 ${reason}`);
1753
- return { status: "timed-out", issues: [], reason, elapsedMs, ...load };
1785
+ };
1786
+ }
1787
+ function queuedField(queuedMs) {
1788
+ return queuedMs > 0 ? { queuedMs } : {};
1789
+ }
1790
+ function toRenderCheckOptions(config) {
1791
+ if (config.timeoutMs === void 0 && config.heapMb === void 0) return void 0;
1792
+ return {
1793
+ bounds: {
1794
+ ...config.timeoutMs !== void 0 ? { timeoutMs: config.timeoutMs } : {},
1795
+ ...config.heapMb !== void 0 ? { heapMb: config.heapMb } : {}
1754
1796
  }
1755
- return {
1756
- status: "ran",
1757
- issues: result.issues.map(toEvalIssue).filter((x) => x !== null),
1758
- ...load
1759
- };
1760
- }
1761
- };
1797
+ };
1798
+ }
1799
+ function createRuntimeRenderCheck(config = {}) {
1800
+ const limit = createSlotLimiter(config.maxConcurrent);
1801
+ const options = toRenderCheckOptions(config);
1802
+ if (options !== void 0) resolveRenderCheckHostBounds(options.bounds);
1803
+ return {
1804
+ id: "runtime-render",
1805
+ run: async (input) => {
1806
+ const { sourceCode, compiledCode, contract, fixtureProps } = input;
1807
+ if (compiledCode === null) {
1808
+ return { status: "not-applicable", issues: [], reason: "no compiled code" };
1809
+ }
1810
+ if (!contract) {
1811
+ return { status: "not-applicable", issues: [], reason: "no contract surface" };
1812
+ }
1813
+ const mockup = prepareMockupProps({ contract, fixtureProps });
1814
+ let queuedMs = 0;
1815
+ let t0 = Date.now();
1816
+ let result;
1817
+ try {
1818
+ result = await limit((waitedMs) => {
1819
+ queuedMs = waitedMs;
1820
+ t0 = Date.now();
1821
+ return runRenderCheck(
1822
+ {
1823
+ sourceCode,
1824
+ mockupProps: mockup.props,
1825
+ contract
1826
+ },
1827
+ options
1828
+ );
1829
+ });
1830
+ } catch (e) {
1831
+ const message = e instanceof Error ? e.message : String(e);
1832
+ console.warn(`[runtime-render] probe skipped \u2014 infra failure: ${message}`);
1833
+ return { status: "infra-skipped", issues: [], reason: message, elapsedMs: Date.now() - t0, ...queuedField(queuedMs) };
1834
+ }
1835
+ const hostLoad = result.stats.hostLoad;
1836
+ const load = hostLoad !== void 0 ? { hostLoad } : {};
1837
+ if (result.incomplete !== void 0) {
1838
+ const { elapsedMs, boundMs } = result.incomplete;
1839
+ const loadNote = hostLoad !== void 0 ? `; host load ${hostLoad.start.toFixed(1)} \u2192 ${hostLoad.end.toFixed(1)} on ${hostLoad.cores} CPUs` : "";
1840
+ const reason = `render check did not finish within ${boundMs} ms (stopped at ${elapsedMs} ms)${loadNote}`;
1841
+ console.warn(`[runtime-render] probe timed out \u2014 ${reason}`);
1842
+ return { status: "timed-out", issues: [], reason, elapsedMs: Date.now() - t0, ...queuedField(queuedMs), ...load };
1843
+ }
1844
+ return {
1845
+ status: "ran",
1846
+ issues: result.issues.map(toEvalIssue).filter((x) => x !== null),
1847
+ elapsedMs: Date.now() - t0,
1848
+ ...queuedField(queuedMs),
1849
+ renderMs: result.stats.renderMs,
1850
+ ...load
1851
+ };
1852
+ }
1853
+ };
1854
+ }
1855
+ var DEFAULT_RUNTIME_RENDER_CHECK = createRuntimeRenderCheck();
1762
1856
  function classifyRenderCrashFix(reason) {
1763
1857
  const r = reason.toLowerCase();
1764
1858
  if (r.includes("too many re-renders") || r.includes("maximum update depth") || r.includes("infinite render loop")) {