@bettercms-ai/convert 0.12.0 → 0.13.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @bettercms-ai/convert
2
2
 
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0b05aa6: The forms receipt names the file each wired form is in
8
+
9
+ `receipt.forms.wiredForms` lists `{ id, file }` for every form on the site after a
10
+ `--forms` run — wired now or by an earlier one. The server matches the file to the
11
+ component recorded as its owner, so the Forms tab and a component's form prop can say
12
+ which component renders each form. Additive: `wired` is still a number, and a server
13
+ that has never heard of the list accepts the receipt unchanged.
14
+
15
+ ## 0.12.1
16
+
17
+ ### Patch Changes
18
+
19
+ - 6d826cf: The trunk-zero rule is per-country data, not a regex
20
+
21
+ `bcmsPhone` stripped a leading zero from every national number with a bare
22
+ `.replace(/^0/, "")`. That is only correct for countries that actually use a trunk
23
+ prefix. Where the leading digit is part of the number, the submitted value was
24
+ silently corrupted — one digit short, and wrong in a way nobody notices until a
25
+ customer cannot be called back.
26
+
27
+ The country list now carries a `trunk` flag derived from libphonenumber's own example
28
+ numbers, rendered as `data-trunk` on each option, and the zero is dropped only when
29
+ that country says it is a trunk prefix.
30
+
31
+ The inline script exists once per vanilla lane — the Astro component, the converter and
32
+ the server renderer — because each ships as inline script text on someone else's page
33
+ and cannot import at runtime. All three carry the identical change, which
34
+ `src/__tests__/content/form-script-pin.test.ts` pins byte for byte.
35
+
3
36
  ## 0.12.0
4
37
 
5
38
  ### Minor Changes
package/dist/cli.js CHANGED
@@ -6321,6 +6321,7 @@ import MagicString4 from "magic-string";
6321
6321
  var WIRABLE = ["html", "astro", "jsx"];
6322
6322
  var CONTROLS = /* @__PURE__ */ new Set(["input", "select", "textarea"]);
6323
6323
  var FORM_SCRIPT = `<script>
6324
+ function bcmsPhone(cc,raw,trunk){var d=String(raw||'').trim();if(!d)return '';if(d.charAt(0)==='+'){var i=d.replace(/D/g,'');return i?'+'+i:'';}if(!cc)return d;var n=d.replace(/D/g,'');if(trunk&&n.charAt(0)==='0')n=n.slice(1);return n?'+'+cc+n:'';}
6324
6325
  document.querySelectorAll('form[data-bcms-form]').forEach(function(f){
6325
6326
  f.addEventListener('submit',function(e){
6326
6327
  e.preventDefault();
@@ -6336,6 +6337,15 @@ document.querySelectorAll('form[data-bcms-form]').forEach(function(f){
6336
6337
  if(Object.prototype.hasOwnProperty.call(data,k))data[k]=(Array.isArray(data[k])?data[k]:[data[k]]).concat(v);
6337
6338
  else data[k]=v;
6338
6339
  });
6340
+ // Country-picker phone fields post ONE key. The __country select is scaffolding: it is
6341
+ // composed into the field's own value here, AFTER collection, so a showIf that points at a
6342
+ // phone key still compares the raw digits. Then it is removed from the body.
6343
+ f.querySelectorAll('select[name$="__country"]').forEach(function(sel){
6344
+ var k=sel.name.slice(0,-9);
6345
+ var o=sel.options[sel.selectedIndex];
6346
+ data[k]=bcmsPhone(o?(o.getAttribute('data-cc')||''):'',data[k],o?o.getAttribute('data-trunk')==='1':false);
6347
+ delete data[k+'__country'];
6348
+ });
6339
6349
  var body={data:data};
6340
6350
  var tok=f.querySelector('[name="cf-turnstile-response"]');
6341
6351
  if(tok&&tok.value)body['cf-turnstile-response']=tok.value;
@@ -6501,11 +6511,11 @@ async function wireForms(briefIn, sources) {
6501
6511
  }
6502
6512
  if (attrOf(candidate.el, "data-bcms-form")) {
6503
6513
  alreadyWired++;
6504
- onSite.push(form);
6514
+ onSite.push({ form, file: candidate.file });
6505
6515
  continue;
6506
6516
  }
6507
6517
  matched.push({ form, candidate });
6508
- onSite.push(form);
6518
+ onSite.push({ form, file: candidate.file });
6509
6519
  }
6510
6520
  const contents = new Map(sources.map((s) => [s.path, s.content]));
6511
6521
  const byFile = /* @__PURE__ */ new Map();
@@ -6523,7 +6533,7 @@ ${indent}${scriptFor(last.candidate.dialect)}`);
6523
6533
  }
6524
6534
  files.push({ path, operation: "modify", content: source.toString() });
6525
6535
  }
6526
- const notes = onSite.filter((f) => f.status === "draft").map((f) => `publish form ${f.name} in the Forms tab \u2014 a draft form rejects every submission with 403.`);
6536
+ const notes = onSite.filter(({ form }) => form.status === "draft").map(({ form }) => `publish form ${form.name} in the Forms tab \u2014 a draft form rejects every submission with 403.`);
6527
6537
  return {
6528
6538
  files,
6529
6539
  receipt: {
@@ -6540,7 +6550,9 @@ ${indent}${scriptFor(last.candidate.dialect)}`);
6540
6550
  wired: matched.length,
6541
6551
  alreadyWired,
6542
6552
  pending,
6543
- ...notes.length > 0 ? { notes } : {}
6553
+ ...notes.length > 0 ? { notes } : {},
6554
+ // Always, even empty: a run where every form went pending must retire the files an earlier one named.
6555
+ wiredForms: onSite.map(({ form, file }) => ({ id: form.id, file }))
6544
6556
  })
6545
6557
  }
6546
6558
  };
@@ -9595,7 +9607,7 @@ function emitStubs2(dialects, slugs, contents, out) {
9595
9607
  // package.json
9596
9608
  var package_default = {
9597
9609
  name: "@bettercms-ai/convert",
9598
- version: "0.12.0",
9610
+ version: "0.13.0",
9599
9611
  type: "module",
9600
9612
  description: "Deterministic codemod that turns an imported site's text-matched bindings into declared ones \u2014 parser offsets in, one magic-string pass out, plus a receipt of everything it could not do.",
9601
9613
  bin: {
@@ -9635,7 +9647,7 @@ var package_default = {
9635
9647
  },
9636
9648
  devDependencies: {
9637
9649
  "@types/node": "^20",
9638
- esbuild: "^0.27.7",
9650
+ esbuild: "^0.28.1",
9639
9651
  tsup: "^8.5.1",
9640
9652
  typescript: "^5",
9641
9653
  vitest: "^4.1.4"