@ggui-ai/ui-gen 0.17.0 → 0.18.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 (36) hide show
  1. package/dist/adapters/generation-dispatch.js +252 -108
  2. package/dist/adapters/generation-dispatch.js.map +1 -1
  3. package/dist/adapters/index.js.map +1 -1
  4. package/dist/advanced/index.js +261 -113
  5. package/dist/advanced/index.js.map +1 -1
  6. package/dist/boilerplate.js +27 -3
  7. package/dist/boilerplate.js.map +1 -1
  8. package/dist/check/index.js +70 -0
  9. package/dist/check/index.js.map +1 -1
  10. package/dist/evaluation/axis-checks/index.js +50 -0
  11. package/dist/evaluation/axis-checks/index.js.map +1 -1
  12. package/dist/evaluation/axis-checks/registry.js +50 -0
  13. package/dist/evaluation/axis-checks/registry.js.map +1 -1
  14. package/dist/evaluation/index.js +50 -0
  15. package/dist/evaluation/index.js.map +1 -1
  16. package/dist/harness/index.js +27 -3
  17. package/dist/harness/index.js.map +1 -1
  18. package/dist/harness/prompts.js +4 -0
  19. package/dist/harness/prompts.js.map +1 -1
  20. package/dist/harness/runtime.js +27 -3
  21. package/dist/harness/runtime.js.map +1 -1
  22. package/dist/harness/types-public.js +27 -3
  23. package/dist/harness/types-public.js.map +1 -1
  24. package/dist/index.js +261 -113
  25. package/dist/index.js.map +1 -1
  26. package/package.json +12 -12
  27. package/src/boilerplate/free-design-prompt.ts +2 -0
  28. package/src/boilerplate/generate.ts +8 -1
  29. package/src/boilerplate/hard-sections.ts +31 -2
  30. package/src/boilerplate/system-prompt.ts +2 -0
  31. package/src/boilerplate/templates/layouts/fullscreen-desktop.tsx.tmpl +5 -3
  32. package/src/boilerplate/templates/layouts/fullscreen-mobile.tsx.tmpl +3 -3
  33. package/src/boilerplate/templates/layouts/fullscreen-universal.tsx.tmpl +5 -3
  34. package/src/check/run-tier0.ts +152 -0
  35. package/src/contract-context.ts +13 -0
  36. package/src/evaluation/axis-checks/checks/universal.ts +64 -0
@@ -400,6 +400,50 @@ function runViewportSized(input) {
400
400
  )
401
401
  ];
402
402
  }
403
+ var TERMINAL_WORDS = /* @__PURE__ */ new Set([
404
+ "submit",
405
+ "confirm",
406
+ "approve",
407
+ "schedule",
408
+ "reserve",
409
+ "book",
410
+ "pay",
411
+ "checkout",
412
+ "purchase",
413
+ "order"
414
+ ]);
415
+ var TERMINAL_LABEL_RX = /\b(submit|confirm|approve|schedule|reserve|book|pay|checkout|purchase|place\s+order)\b/i;
416
+ var GUARD_RX = /\b(disabled|aria-disabled)\s*=/;
417
+ function nameWords(name) {
418
+ return name.split(/(?=[A-Z])|[_\-\s]+/).map((w) => w.toLowerCase()).filter((w) => w.length > 0);
419
+ }
420
+ function findUnguardedTerminalControls(sourceCode) {
421
+ if (GUARD_RX.test(sourceCode)) return [];
422
+ const names = /* @__PURE__ */ new Set();
423
+ for (const m of sourceCode.matchAll(/useAction(?:<[^>]*>)?\(\s*['"`]([^'"`]+)['"`]/g)) {
424
+ const name = m[1] ?? "";
425
+ if (nameWords(name).some((w) => TERMINAL_WORDS.has(w))) names.add(name);
426
+ }
427
+ for (const m of sourceCode.matchAll(/>([^<>{}]{1,60})<\/Button>/g)) {
428
+ const label = (m[1] ?? "").replace(/\s+/g, " ").trim();
429
+ if (label.length > 0 && TERMINAL_LABEL_RX.test(label)) names.add(label.slice(0, 40));
430
+ }
431
+ return [...names];
432
+ }
433
+ function runTerminalActionUnguarded(input) {
434
+ if (input.compiledCode === null) return [];
435
+ const found = findUnguardedTerminalControls(input.sourceCode);
436
+ if (found.length === 0) return [];
437
+ const list = found.map((t) => `"${t}"`).join(", ");
438
+ return [
439
+ mkIssue(
440
+ "universal.terminal_action_unguarded",
441
+ `${list} reads as an action the user means once, and nothing in this component disables the control after it fires \u2014 a double-click sends it twice.`,
442
+ 'Hold the fired state (`const [submitted, setSubmitted] = useState(false)`), set it in the handler, and pass `disabled={submitted}` to that control with a word that says so ("Submitted"). If the action IS meant to repeat \u2014 sending a message, adding an item \u2014 leave it armed and ignore this.',
443
+ "warn"
444
+ )
445
+ ];
446
+ }
403
447
  var UNIVERSAL_CHECKS = [
404
448
  {
405
449
  id: "universal.icon_name_known",
@@ -419,6 +463,12 @@ var UNIVERSAL_CHECKS = [
419
463
  values: ALL_RENDER_VALUES,
420
464
  run: runViewportSized
421
465
  },
466
+ {
467
+ id: "universal.terminal_action_unguarded",
468
+ axis: "render",
469
+ values: ALL_RENDER_VALUES,
470
+ run: runTerminalActionUnguarded
471
+ },
422
472
  {
423
473
  id: "universal.accent_text_ink",
424
474
  axis: "render",