@ggui-ai/ui-gen 0.19.0 → 0.20.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.
@@ -5998,6 +5998,46 @@ function runRootWidthCap(input) {
5998
5998
  )
5999
5999
  ];
6000
6000
  }
6001
+ var LABEL_SPECIAL_CHAR = /[^a-z0-9\s]/i;
6002
+ var normText = (s) => s.toLowerCase().replace(/\s+/g, " ").trim();
6003
+ var alnumText = (s) => s.toLowerCase().replace(/[^a-z0-9]/g, "");
6004
+ function visibleText(sourceCode) {
6005
+ const jsx = (sourceCode.match(/>([^<>]*)</g) ?? []).map((m2) => m2.slice(1, -1).replace(/\{[^}]*\}/g, " ")).join(" ");
6006
+ let attrs = "";
6007
+ const attrRx = /\b(?:aria-label|placeholder|title|alt)\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;
6008
+ let m;
6009
+ while ((m = attrRx.exec(sourceCode)) !== null) attrs += " " + (m[1] ?? m[2] ?? "");
6010
+ return jsx + " " + attrs;
6011
+ }
6012
+ function findDroppedActionLabels(sourceCode, contract) {
6013
+ const actionSpec = contract?.actionSpec;
6014
+ if (actionSpec === void 0) return [];
6015
+ if (/\.label\b/.test(sourceCode)) return [];
6016
+ const vis = visibleText(sourceCode);
6017
+ const normVis = normText(vis);
6018
+ const alnumVis = alnumText(vis);
6019
+ const out = [];
6020
+ for (const [name, entry] of Object.entries(actionSpec)) {
6021
+ const label = entry.label;
6022
+ if (typeof label !== "string" || label.length === 0 || label === name) continue;
6023
+ if (!LABEL_SPECIAL_CHAR.test(label)) continue;
6024
+ if (alnumText(label).length < 3) continue;
6025
+ if (normVis.includes(normText(label))) continue;
6026
+ if (alnumVis.includes(alnumText(label))) out.push({ name, label });
6027
+ }
6028
+ return out;
6029
+ }
6030
+ function runActionLabelDropped(input) {
6031
+ if (input.compiledCode === null) return [];
6032
+ return findDroppedActionLabels(input.sourceCode, input.contract).map(
6033
+ ({ name, label }) => mkIssue(
6034
+ "universal.action_label_dropped",
6035
+ `The action "${name}" declares label "${label}", but the rendered control appears to drop its "${label.replace(/[a-z0-9\s]/gi, "").trim()}": the label's words are in the generated source, the full label is not \u2014 a transcription drop (ggui#1190).`,
6036
+ `Render the label EXACTLY as the contract states it \u2014 button text should be the verbatim \`actionSpec.${name}.label\`, or render it from data (\`{x.label}\`), never a re-typed copy that drops "&", "/", "+", etc.`,
6037
+ "warn"
6038
+ )
6039
+ );
6040
+ }
6001
6041
  var UNIVERSAL_CHECKS = [
6002
6042
  {
6003
6043
  id: "universal.icon_name_known",
@@ -6023,6 +6063,12 @@ var UNIVERSAL_CHECKS = [
6023
6063
  values: ALL_RENDER_VALUES,
6024
6064
  run: runRootWidthCap
6025
6065
  },
6066
+ {
6067
+ id: "universal.action_label_dropped",
6068
+ axis: "render",
6069
+ values: ALL_RENDER_VALUES,
6070
+ run: runActionLabelDropped
6071
+ },
6026
6072
  {
6027
6073
  id: "universal.terminal_action_unguarded",
6028
6074
  axis: "render",