@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
@@ -5799,6 +5799,50 @@ function runViewportSized(input) {
5799
5799
  )
5800
5800
  ];
5801
5801
  }
5802
+ var TERMINAL_WORDS = /* @__PURE__ */ new Set([
5803
+ "submit",
5804
+ "confirm",
5805
+ "approve",
5806
+ "schedule",
5807
+ "reserve",
5808
+ "book",
5809
+ "pay",
5810
+ "checkout",
5811
+ "purchase",
5812
+ "order"
5813
+ ]);
5814
+ var TERMINAL_LABEL_RX = /\b(submit|confirm|approve|schedule|reserve|book|pay|checkout|purchase|place\s+order)\b/i;
5815
+ var GUARD_RX = /\b(disabled|aria-disabled)\s*=/;
5816
+ function nameWords(name) {
5817
+ return name.split(/(?=[A-Z])|[_\-\s]+/).map((w) => w.toLowerCase()).filter((w) => w.length > 0);
5818
+ }
5819
+ function findUnguardedTerminalControls(sourceCode) {
5820
+ if (GUARD_RX.test(sourceCode)) return [];
5821
+ const names = /* @__PURE__ */ new Set();
5822
+ for (const m of sourceCode.matchAll(/useAction(?:<[^>]*>)?\(\s*['"`]([^'"`]+)['"`]/g)) {
5823
+ const name = m[1] ?? "";
5824
+ if (nameWords(name).some((w) => TERMINAL_WORDS.has(w))) names.add(name);
5825
+ }
5826
+ for (const m of sourceCode.matchAll(/>([^<>{}]{1,60})<\/Button>/g)) {
5827
+ const label = (m[1] ?? "").replace(/\s+/g, " ").trim();
5828
+ if (label.length > 0 && TERMINAL_LABEL_RX.test(label)) names.add(label.slice(0, 40));
5829
+ }
5830
+ return [...names];
5831
+ }
5832
+ function runTerminalActionUnguarded(input) {
5833
+ if (input.compiledCode === null) return [];
5834
+ const found = findUnguardedTerminalControls(input.sourceCode);
5835
+ if (found.length === 0) return [];
5836
+ const list = found.map((t) => `"${t}"`).join(", ");
5837
+ return [
5838
+ mkIssue(
5839
+ "universal.terminal_action_unguarded",
5840
+ `${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.`,
5841
+ '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.',
5842
+ "warn"
5843
+ )
5844
+ ];
5845
+ }
5802
5846
  var UNIVERSAL_CHECKS = [
5803
5847
  {
5804
5848
  id: "universal.icon_name_known",
@@ -5818,6 +5862,12 @@ var UNIVERSAL_CHECKS = [
5818
5862
  values: ALL_RENDER_VALUES,
5819
5863
  run: runViewportSized
5820
5864
  },
5865
+ {
5866
+ id: "universal.terminal_action_unguarded",
5867
+ axis: "render",
5868
+ values: ALL_RENDER_VALUES,
5869
+ run: runTerminalActionUnguarded
5870
+ },
5821
5871
  {
5822
5872
  id: "universal.accent_text_ink",
5823
5873
  axis: "render",