phlex-reactive 0.13.3 → 0.14.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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1097 -630
  3. data/README.md +638 -16
  4. data/app/controllers/phlex/reactive/actions_controller.rb +85 -16
  5. data/app/controllers/phlex/reactive/fragments_controller.rb +310 -0
  6. data/app/javascript/phlex/reactive/core.js +181 -0
  7. data/app/javascript/phlex/reactive/core.min.js +4 -0
  8. data/app/javascript/phlex/reactive/core.min.js.map +11 -0
  9. data/app/javascript/phlex/reactive/early.js +175 -0
  10. data/app/javascript/phlex/reactive/early.min.js +4 -0
  11. data/app/javascript/phlex/reactive/early.min.js.map +10 -0
  12. data/app/javascript/phlex/reactive/features/bindings.js +1511 -0
  13. data/app/javascript/phlex/reactive/features/bindings.min.js +4 -0
  14. data/app/javascript/phlex/reactive/features/bindings.min.js.map +10 -0
  15. data/app/javascript/phlex/reactive/features/compute.js +541 -0
  16. data/app/javascript/phlex/reactive/features/compute.min.js +4 -0
  17. data/app/javascript/phlex/reactive/features/compute.min.js.map +10 -0
  18. data/app/javascript/phlex/reactive/features/defer.js +726 -0
  19. data/app/javascript/phlex/reactive/features/defer.min.js +4 -0
  20. data/app/javascript/phlex/reactive/features/defer.min.js.map +10 -0
  21. data/app/javascript/phlex/reactive/features/devtools.js +242 -0
  22. data/app/javascript/phlex/reactive/features/devtools.min.js +4 -0
  23. data/app/javascript/phlex/reactive/features/devtools.min.js.map +10 -0
  24. data/app/javascript/phlex/reactive/features/effects.js +362 -0
  25. data/app/javascript/phlex/reactive/features/effects.min.js +4 -0
  26. data/app/javascript/phlex/reactive/features/effects.min.js.map +10 -0
  27. data/app/javascript/phlex/reactive/features/form.js +216 -0
  28. data/app/javascript/phlex/reactive/features/form.min.js +4 -0
  29. data/app/javascript/phlex/reactive/features/form.min.js.map +10 -0
  30. data/app/javascript/phlex/reactive/features/hints.js +193 -0
  31. data/app/javascript/phlex/reactive/features/hints.min.js +4 -0
  32. data/app/javascript/phlex/reactive/features/hints.min.js.map +10 -0
  33. data/app/javascript/phlex/reactive/features/persist.js +663 -0
  34. data/app/javascript/phlex/reactive/features/persist.min.js +4 -0
  35. data/app/javascript/phlex/reactive/features/persist.min.js.map +10 -0
  36. data/app/javascript/phlex/reactive/inspect.js +21 -9
  37. data/app/javascript/phlex/reactive/inspect.min.js +2 -2
  38. data/app/javascript/phlex/reactive/inspect.min.js.map +3 -3
  39. data/app/javascript/phlex/reactive/reactive_controller.js +85 -5580
  40. data/app/javascript/phlex/reactive/reactive_controller.min.js +2 -2
  41. data/app/javascript/phlex/reactive/reactive_controller.min.js.map +13 -4
  42. data/app/javascript/phlex/reactive/runtime.js +3690 -0
  43. data/lib/generators/phlex/reactive/install/templates/phlex_reactive.rb.erb +18 -0
  44. data/lib/phlex/reactive/claude/skills/phlex-reactive-debugging/SKILL.md +5 -3
  45. data/lib/phlex/reactive/component/dsl.rb +74 -2
  46. data/lib/phlex/reactive/component/helpers.rb +104 -28
  47. data/lib/phlex/reactive/component/lazy.rb +138 -2
  48. data/lib/phlex/reactive/component/registry.rb +2 -0
  49. data/lib/phlex/reactive/component/selection.rb +71 -0
  50. data/lib/phlex/reactive/doctor/fiber_isolation.rb +86 -0
  51. data/lib/phlex/reactive/doctor.rb +166 -8
  52. data/lib/phlex/reactive/dormant.rb +66 -0
  53. data/lib/phlex/reactive/engine.rb +64 -3
  54. data/lib/phlex/reactive/fragment.rb +233 -0
  55. data/lib/phlex/reactive/inspector/report.rb +24 -3
  56. data/lib/phlex/reactive/inspector.rb +23 -2
  57. data/lib/phlex/reactive/js.rb +61 -12
  58. data/lib/phlex/reactive/mcp/tools/actions_tool.rb +3 -1
  59. data/lib/phlex/reactive/mcp/tools/find_tool.rb +4 -1
  60. data/lib/phlex/reactive/param_schema.rb +68 -54
  61. data/lib/phlex/reactive/pending/markup.rb +128 -0
  62. data/lib/phlex/reactive/pending.rb +25 -21
  63. data/lib/phlex/reactive/show_conditions.rb +84 -56
  64. data/lib/phlex/reactive/streamable.rb +20 -2
  65. data/lib/phlex/reactive/test_helpers/system/reactive_requests_matcher.rb +120 -0
  66. data/lib/phlex/reactive/test_helpers/system.rb +62 -0
  67. data/lib/phlex/reactive/version.rb +1 -1
  68. data/lib/phlex/reactive.rb +84 -0
  69. data/lib/tasks/phlex_reactive.rake +6 -2
  70. metadata +39 -1
@@ -0,0 +1,4 @@
1
+ var P;function ee(e){P=e}var C=1,J="phlex-reactive:persist:",F=new Set(["hidden","file","password","submit","button","reset","image"]),x=Symbol("persist-no-value"),w="data-reactive-persist-state",V=":is(lexxy-editor, trix-editor, [contenteditable=''], [contenteditable=true], [contenteditable=plaintext-only])",z=new Set(["lexxy-editor","trix-editor"]),G="lexxy-editor, trix-editor, trix-toolbar",q=["lexxy:change","trix-change"],H=new Set(["","<p></p>","<p><br></p>","<div><br></div>"]),_=new WeakSet,O=new WeakSet,I=new WeakSet;function h(e){let n=e?.getAttribute?.("data-reactive-persist");if(!n||n==="off")return null;try{let i=JSON.parse(n);if(i&&typeof i==="object"&&typeof i.key==="string"&&i.key!=="")return i}catch{}if(!_.has(e))_.add(e),console.warn(`[phlex-reactive] malformed reactive_persist payload ${JSON.stringify(n)} — persistence disabled`);return null}function k(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function A(e,n){if(e?.getAttribute?.("data-reactive-debug")!=="true"||O.has(e))return;O.add(e),console.info(`[phlex-reactive] reactive_persist: storage unavailable — draft skipped (${n?.name??n})`)}function T(e){return J+e.key}function S(e,n){let i=k();if(!i)return null;let r;try{r=i.getItem(T(n))}catch(u){return A(e,u),null}if(!r)return null;let t;try{t=JSON.parse(r)}catch{return null}if(!t||typeof t!=="object"||t.v!==C)return null;let s=Number(n.ttl)*1000;if(!(Number(t.savedAt)+s>Date.now()))return m(e,n),null;let c=t.fields&&typeof t.fields==="object"?t.fields:{},o=t.state&&typeof t.state==="object"?t.state:null;return{fields:c,state:o}}function N(e,n,{fields:i,state:r}){let t=k();if(!t)return!1;let s={v:C,savedAt:Date.now(),fields:i};if(r)s.state=r;try{return t.setItem(T(n),JSON.stringify(s)),!0}catch(c){return A(e,c),!1}}function m(e,n){e?.removeAttribute?.(w);let i=k();if(!i)return;try{i.removeItem(T(n))}catch(r){A(e,r)}}function b(e,n){let i=Array.isArray(n.fields)?new Set(n.fields):null,r=[],t=(s)=>s.closest('[data-controller~="reactive"]')===e&&s.getAttribute("data-reactive-persist")!=="off";for(let s of e.querySelectorAll("input[name], select[name], textarea[name]")){if(!t(s)||F.has(s.type)||s.closest(G))continue;if(i&&!i.has(s.name))continue;r.push({el:s,name:s.name,kind:"native"})}for(let s of e.querySelectorAll(V)){if(!t(s))continue;let c=B(s);if(!c||i&&!i.has(c))continue;r.push({el:s,name:c,kind:z.has(s.localName)?"editor":"contenteditable"})}return r}function B(e){return e.getAttribute("name")||typeof e.name==="string"&&e.name||null}function g(e){return typeof e.value==="string"}function D(e){if(typeof e.isEmpty==="boolean")return e.isEmpty;let n=e.editor?.getDocument?.();if(typeof n?.isEmpty==="function")return n.isEmpty();return H.has(e.value.trim())}function U(e,n,i){if(e?.getAttribute?.("data-reactive-debug")!=="true"||I.has(e))return;I.add(e),console.info(`[phlex-reactive] reactive_persist: could not restore editor ${JSON.stringify(n)} — ${i?.message??i}`)}function y(e){return e.tagName==="SELECT"&&e.multiple}function L(e){let n=new Map;for(let{el:i,name:r}of e){if(i.type==="radio"||!String(r).endsWith("[]"))continue;n.set(r,(n.get(r)??0)+1)}return n}function W(e,n,i){if(!Array.isArray(e))return e;if(i.get(n)!==1||e.length!==1)return x;return e[0]}function R(e,n){let i={},r=(t)=>{let s=i[t];return Array.isArray(s)?s:i[t]=[]};for(let{el:t,name:s,kind:c}of b(e,n)){let o=String(s).endsWith("[]");if(c==="editor"){if(g(t))if(o)r(s).push(t.value);else i[s]=t.value}else if(c==="contenteditable"){let u=t.textContent??"";if(o)r(s).push(u);else i[s]=u}else if(t.type==="radio"){if(t.checked)i[s]=t.value;else if(!Object.hasOwn(i,s))i[s]=null}else if(t.type==="checkbox")if(o){let u=r(s);if(t.checked)u.push(t.value)}else i[s]=t.checked;else if(y(t)){let u=[...t.options].filter((l)=>l.selected).map((l)=>l.value);if(o)r(s).push(...u);else i[s]=u}else if(o)r(s).push(t.value);else i[s]=t.value}return i}function X(e,n,i){let r=n.restore==="always",t=b(e,n),s=L(t),c=new Set;for(let o of t)if(o.kind==="native"&&o.el.type==="checkbox"&&o.el.checked)c.add(o.name);for(let{el:o,name:u,kind:l}of t){if(!Object.hasOwn(i,u))continue;let a=i[u];if(a===null||a===void 0)continue;if(Array.isArray(a)&&y(o)&&(s.get(u)??0)>1)continue;if(Array.isArray(a)&&!(o.type==="checkbox"||y(o))){if(a=W(a,u,s),a===x)continue}if((o.type==="checkbox"||y(o))&&String(u).endsWith("[]")&&!Array.isArray(a))continue;if(l==="editor")j(e,o,u,a,r);else if(l==="contenteditable"){if(!r&&(o.textContent??"").trim()!=="")continue;o.textContent=String(a)}else if(o.type==="radio"){if(!r&&t.some((p)=>p.kind==="native"&&p.el.type==="radio"&&p.name===u&&p.el.checked))continue;o.checked=o.value===String(a)}else if(o.type==="checkbox"&&Array.isArray(a)){if(!r&&c.has(u))continue;o.checked=a.map(String).includes(o.value)}else if(o.type==="checkbox"){if(!r&&o.checked)continue;o.checked=Boolean(a)}else if(y(o)){if(!r&&[...o.options].some((d)=>d.selected))continue;let p=new Set((Array.isArray(a)?a:[a]).map(String));for(let d of o.options)d.selected=p.has(d.value)}else{if(!r&&o.value!=="")continue;o.value=String(a)}}Y(e,n,i)}function j(e,n,i,r,t){if(Array.isArray(r))return;if(!g(n))return;if(!t&&!D(n))return;try{n.value=String(r)}catch(s){U(e,i,s)}}function Y(e,n,i){let r=globalThis.customElements;if(typeof r?.whenDefined!=="function")return;let t=new Set;for(let c of e.querySelectorAll("lexxy-editor, trix-editor"))if(!g(c)&&!r.get?.(c.localName))t.add(c.localName);let s=n.restore==="always";for(let c of t)r.whenDefined(c).then(()=>{if(!e.isConnected)return;let o=b(e,n),u=L(o);for(let{el:l,name:a,kind:p}of o){if(p!=="editor"||l.localName!==c||!Object.hasOwn(i,a))continue;let d=W(i[a],a,u);if(d===null||d===void 0||d===x)continue;j(e,l,a,d,s)}})}function K(e,n,i=!0){let r=h(e);if(!r){console.warn("[phlex-reactive] persist_state on a root without reactive_persist — skipped");return}if(!n||typeof n!=="object")return;let t=S(e,r),s={...t?.state??{},...n},c=i?R(e,r):t?.fields??{};if(N(e,r,{fields:c,state:s}))e.setAttribute?.(w,JSON.stringify(s))}function Q(e){let n=h(e);if(n)m(e,n)}var E=new WeakMap;function te(e,n,i,r){let t=e.element,s=h(t);if(!s)return;if(r?.submitted)m(t,s);let c=S(t,s);if(c){if(X(t,s,c.fields),c.state)t.setAttribute?.(w,JSON.stringify(c.state));n.emit("reactive:persist-restored",{key:s.key,fields:c.fields,state:c.state??{}}),n.reseed()}let o=null,u=()=>{if(o!==null)clearTimeout(o),o=null},l=()=>{u();let f=S(t,s);N(t,s,{fields:R(t,s),state:f?.state??null})},a=()=>{let f=Number(s.debounce)||0;if(f<=0)return l();if(o!==null)clearTimeout(o);o=setTimeout(()=>{o=null,l()},f)},p=(f)=>{if(!f?.detail?.success)return;let v=f.target;if(v?.tagName!=="FORM"||typeof v.contains!=="function")return;if(!v.contains(t))return;u(),m(t,s)},d=["input",...q];for(let f of d)t.addEventListener?.(f,a);if(t.addEventListener?.("change",l),document.addEventListener?.("turbo:submit-end",p),E.set(e,()=>{if(o!==null)l();for(let f of d)t.removeEventListener?.(f,a);t.removeEventListener?.("change",l),document.removeEventListener?.("turbo:submit-end",p)}),r?.edited&&!r.submitted)l();for(let f of r?.ops??[])f(!0)}function ne(e,n){if(!n)return;let i=h(e);if(!i)return;if(n.submitted)return m(e,i);if(n.edited){let r=S(e,i),t={...r?.fields},s=R(e,i);for(let c of Z(e,i))if(Object.hasOwn(s,c))t[c]=s[c];N(e,i,{fields:t,state:r?.state??null})}for(let r of n.ops??[])r(!1)}function Z(e,n){let i=new Set;for(let{el:r,name:t,kind:s}of b(e,n))if(s==="editor"?g(r)&&!D(r):s==="contenteditable"?(r.textContent??"").trim()!=="":r.type==="checkbox"||r.type==="radio"?r.checked!==r.defaultChecked:r.tagName==="SELECT"?[...r.options].some((o)=>o.selected!==o.hasAttribute("selected")):r.value!==r.defaultValue)i.add(t);return i}function ie(e){let n=E.get(e);E.delete(e),n?.()}function M(e,n){let i=P?.waiting.get(e)?.persist;if(!i||!h(e))return n(!0);(i.ops??=[]).push(n)}function re(e,n){M(e,(i)=>K(e,n,i))}function se(e){M(e,()=>Q(e))}export{V as PERSIST_EDITOR_SELECTOR,z as PERSIST_EDITOR_TAGS,ne as abandon,se as clearRoot,te as connect,ie as disconnect,ee as install,re as writeState};
2
+
3
+ //# debugId=F778B9094B33FD2C64756E2164756E21
4
+ //# sourceMappingURL=persist.min.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["features/persist.js"],
4
+ "sourcesContent": [
5
+ "// Client-only drafts (issue #239) — reactive_persist. A FEATURE MODULE of the\n// reactive controller (issue #275): the core imports it only when a root on\n// the page declares data-reactive-persist, or when a persist_state /\n// persist_clear client op runs.\n//\n// A root that declares\n// data-reactive-persist='{\"key\",\"ttl\",\"debounce\"[,\"fields\"][,\"restore\"]}'\n// keeps a localStorage draft of every persistable OWNED control (write on\n// input/change, restore on connect, clear on a successful submit / TTL / the\n// persist_clear op). The storage layer is MODULE-LEVEL and keyed on the root\n// element — the per-root connect/write path and the persist_state /\n// persist_clear client ops (which receive only the element) share it. Every\n// storage access is try/catch'd: a private window, a quota error or blocked\n// storage degrades to \"no draft\", never a thrown bootstrap. Nothing here\n// leaves the browser: no token, no POST, and phlex-reactive never writes\n// markup into the DOM: native controls are replayed via\n// .value/.checked/.selected, a bare [contenteditable] via textContent, and a\n// rich editor (lexxy-editor, trix-editor — issue #241) through its OWN\n// `value` setter, the same sanitizing import path a paste takes. Never\n// innerHTML.\n//\n// The feature contract (reactive_controller.js \"Feature modules\"):\n// install(shared) once, when the module loads\n// connect(controller, core, morphed, pending) per root connection\n// disconnect(controller, core) before the core's teardown\n// abandon(root, pending) the root left before connect\n// `core` is the controller's handle for features: core.emit(name, detail)\n// raw-dispatches a lifecycle event from the root; core.reseed() re-runs the\n// connect-time seeds that read field values (dirty baseline, show bindings,\n// on-complete arming, filter, tags, nested JSON, compute).\n//\n// TIMING. On the first root of a page that needs it, this module is still on\n// its way when the controller connects, so the restore runs a moment AFTER\n// connect() — and the connect-time seeds, which ran on the server's values,\n// are re-run (core.reseed()). On any later root the module is loaded and the\n// restore runs inside connect() as it always did.\n//\n// While a root waits for this module:\n// * it writes no draft, and its action requests are held back (they would\n// post the server's blanks) — the core's side of it;\n// * the core records, in `pending`, that the user edited a field and that\n// the form was submitted successfully; connect() drafts the edit, or\n// forgets the draft instead of restoring it;\n// * a persist_state / persist_clear op waits in pending.ops — its snapshot\n// would overwrite the draft with those blanks.\n// A root that leaves before the module arrives is handed to abandon().\n\n// The core's shared state (install()): shared.waiting maps a root to\n// { persist: pending } while that root waits for this module.\nlet shared\n\nexport function install(given) {\n shared = given\n}\n\nconst PERSIST_VERSION = 1\nconst PERSIST_PREFIX = \"phlex-reactive:persist:\"\n// Never persisted regardless of author intent: no server default to restore\n// into (hidden, file), secrets (password), and non-value controls.\nconst PERSIST_EXCLUDED_TYPES = new Set([\"hidden\", \"file\", \"password\", \"submit\", \"button\", \"reset\", \"image\"])\nconst PERSIST_NO_VALUE = Symbol(\"persist-no-value\")\nconst PERSIST_STATE_ATTR = \"data-reactive-persist-state\"\n// The editor query the core's #collectFields reads (minus the [name] guard —\n// an editor's name may live on its IDL `name` getter: Trix's `input=`-paired\n// hidden input). The core holds the same two constants (EDITOR_SELECTOR,\n// EDITOR_TAGS); a feature never imports the core, so they are repeated here\n// and spec/javascript/reactive_persist.test.js pins that they stay equal.\nexport const PERSIST_EDITOR_SELECTOR =\n \":is(lexxy-editor, trix-editor, [contenteditable=''], [contenteditable=true], [contenteditable=plaintext-only])\"\nexport const PERSIST_EDITOR_TAGS = new Set([\"lexxy-editor\", \"trix-editor\"])\n// An editor's own chrome: Lexxy renders its toolbar (a `lexxy-code-language`\n// select, the link dialog's `href` input) INSIDE <lexxy-editor>, Trix as a\n// sibling <trix-toolbar>. Those are named native controls that are not the\n// user's fields — never drafted, never restored into.\nconst PERSIST_EDITOR_CHROME = \"lexxy-editor, trix-editor, trix-toolbar\"\n// The editors' own bubbling change events — the keystroke signal for the\n// draft write, since neither lets its contenteditable's native `input` bubble.\nconst PERSIST_EDITOR_CHANGE_EVENTS = [\"lexxy:change\", \"trix-change\"]\n// \"Is this editor empty\" when it exposes no predicate of its own (Lexxy's\n// `isEmpty`, Trix's `editor.getDocument().isEmpty()`): Lexxy's own empty\n// list plus the Trix / contenteditable empties. Exact strings, no HTML\n// parsing — an attachment-only body stays non-blank.\nconst PERSIST_EMPTY_HTML = new Set([\"\", \"<p></p>\", \"<p><br></p>\", \"<div><br></div>\"])\n// Once-per-root guards: a malformed payload warns once; the storage-failure\n// and editor-restore dev notes (debug mode only) print once each.\nconst persistPayloadWarned = new WeakSet()\nconst persistFailureNoted = new WeakSet()\nconst persistEditorNoted = new WeakSet()\n\n// The root's parsed payload, or null (undeclared / malformed → warned once).\n// A control-level \"off\" (reactive_persist_skip) is never a root payload.\nfunction persistPayload(root) {\n const raw = root?.getAttribute?.(\"data-reactive-persist\")\n if (!raw || raw === \"off\") return null\n try {\n const payload = JSON.parse(raw)\n if (payload && typeof payload === \"object\" && typeof payload.key === \"string\" && payload.key !== \"\") return payload\n } catch {\n // fall through to the warn\n }\n if (!persistPayloadWarned.has(root)) {\n persistPayloadWarned.add(root)\n console.warn(`[phlex-reactive] malformed reactive_persist payload ${JSON.stringify(raw)} — persistence disabled`)\n }\n return null\n}\n\nfunction persistStorage() {\n try {\n return typeof localStorage === \"undefined\" ? null : localStorage\n } catch {\n return null // the accessor itself can throw (blocked site data)\n }\n}\n\n// The dev lens for \"why did nothing come back\": ONLY under data-reactive-debug\n// (Phlex::Reactive.debug), once per root — production stays silent.\nfunction persistNoteFailure(root, error) {\n if (root?.getAttribute?.(\"data-reactive-debug\") !== \"true\" || persistFailureNoted.has(root)) return\n persistFailureNoted.add(root)\n console.info(`[phlex-reactive] reactive_persist: storage unavailable — draft skipped (${error?.name ?? error})`)\n}\n\nfunction persistKeyFor(payload) {\n return PERSIST_PREFIX + payload.key\n}\n\n// Read + validate the draft: null when absent, unparsable, another schema\n// version, or expired (an expired draft is REMOVED on read). Returns\n// { fields, state } with state null when the draft carries none.\nfunction persistRead(root, payload) {\n const store = persistStorage()\n if (!store) return null\n let raw\n try {\n raw = store.getItem(persistKeyFor(payload))\n } catch (error) {\n persistNoteFailure(root, error)\n return null\n }\n if (!raw) return null\n let draft\n try {\n draft = JSON.parse(raw)\n } catch {\n return null\n }\n if (!draft || typeof draft !== \"object\" || draft.v !== PERSIST_VERSION) return null\n const ttlMs = Number(payload.ttl) * 1000\n if (!(Number(draft.savedAt) + ttlMs > Date.now())) {\n persistRemove(root, payload)\n return null\n }\n const fields = draft.fields && typeof draft.fields === \"object\" ? draft.fields : {}\n const state = draft.state && typeof draft.state === \"object\" ? draft.state : null\n return { fields, state }\n}\n\nfunction persistWrite(root, payload, { fields, state }) {\n const store = persistStorage()\n if (!store) return false\n const draft = { v: PERSIST_VERSION, savedAt: Date.now(), fields }\n if (state) draft.state = state\n try {\n store.setItem(persistKeyFor(payload), JSON.stringify(draft))\n return true\n } catch (error) {\n persistNoteFailure(root, error)\n return false\n }\n}\n\nfunction persistRemove(root, payload) {\n root?.removeAttribute?.(PERSIST_STATE_ATTR)\n const store = persistStorage()\n if (!store) return\n try {\n store.removeItem(persistKeyFor(payload))\n } catch (error) {\n persistNoteFailure(root, error)\n }\n}\n\n// The persistable controls this root OWNS (#15: a nested reactive root's\n// controls are its own), minus the excluded types, the reactive_persist_skip\n// marker, and — when `fields` narrows the set — any undeclared name. Each\n// entry is { el, name, kind } with kind \"native\" (input/select/textarea),\n// \"editor\" (lexxy-editor / trix-editor) or \"contenteditable\" (a bare named\n// editable element) — issue #241.\nfunction persistControls(root, payload) {\n const allow = Array.isArray(payload.fields) ? new Set(payload.fields) : null\n const out = []\n const owned = (el) =>\n el.closest('[data-controller~=\"reactive\"]') === root && el.getAttribute(\"data-reactive-persist\") !== \"off\"\n for (const el of root.querySelectorAll(\"input[name], select[name], textarea[name]\")) {\n if (!owned(el) || PERSIST_EXCLUDED_TYPES.has(el.type) || el.closest(PERSIST_EDITOR_CHROME)) continue\n if (allow && !allow.has(el.name)) continue\n out.push({ el, name: el.name, kind: \"native\" })\n }\n for (const el of root.querySelectorAll(PERSIST_EDITOR_SELECTOR)) {\n if (!owned(el)) continue\n const name = persistEditorName(el)\n if (!name || (allow && !allow.has(name))) continue\n out.push({ el, name, kind: PERSIST_EDITOR_TAGS.has(el.localName) ? \"editor\" : \"contenteditable\" })\n }\n return out\n}\n\n// The attribute first (Lexxy, a bare contenteditable — which has no `name`\n// IDL property at all), then the IDL getter (Trix resolves it through its\n// `input=`-paired hidden input, which is itself excluded as type=hidden).\nfunction persistEditorName(el) {\n return el.getAttribute(\"name\") || (typeof el.name === \"string\" && el.name) || null\n}\n\n// An editor is READY once its custom element has upgraded and connected: only\n// then does it expose the string `value` accessor (Lexxy's setter throws\n// before connectedCallback created its editor; Trix's discards the value).\nfunction persistEditorReady(el) {\n return typeof el.value === \"string\"\n}\n\n// Ask the editor whether it is empty (Lexxy `isEmpty`; Trix\n// `editor.getDocument().isEmpty()`), else the exact-string fallback. An\n// attachment-only server body is therefore NON-blank and never overwritten.\nfunction persistEditorBlank(el) {\n if (typeof el.isEmpty === \"boolean\") return el.isEmpty\n const doc = el.editor?.getDocument?.()\n if (typeof doc?.isEmpty === \"function\") return doc.isEmpty()\n return PERSIST_EMPTY_HTML.has(el.value.trim())\n}\n\n// The editor-restore dev lens: ONLY under data-reactive-debug, once per root.\nfunction persistNoteEditorFailure(root, name, error) {\n if (root?.getAttribute?.(\"data-reactive-debug\") !== \"true\" || persistEditorNoted.has(root)) return\n persistEditorNoted.add(root)\n console.info(\n `[phlex-reactive] reactive_persist: could not restore editor ${JSON.stringify(name)} — ${error?.message ?? error}`,\n )\n}\n\nfunction persistSelectMultiple(el) {\n return el.tagName === \"SELECT\" && el.multiple\n}\n\n// How many controls can contribute a value under each `[]` name, counted the\n// way persistSnapshot fills the slot — a radio is the exception there and here.\n// A group of ONE is unambiguous: its single entry can only have come from that\n// control.\nfunction persistGroupSizes(controls) {\n const sizes = new Map()\n for (const { el, name } of controls) {\n if (el.type === \"radio\" || !String(name).endsWith(\"[]\")) continue\n sizes.set(name, (sizes.get(name) ?? 0) + 1)\n }\n return sizes\n}\n\n// The value a control that cannot pick its own entry out of a list may take.\n// A list belongs to a `[]` group, and in a group of two or more nothing says\n// which entry came from which control — restoring it would paste\n// \"freeform,news\" into a text field. A group of ONE has no such ambiguity, and\n// refusing it would silently drop the draft of a plain field whose name merely\n// ends in `[]` (a list JS maintains), which worked before groups existed.\n// Returns PERSIST_NO_VALUE when the control must keep what the server rendered.\nfunction persistGenericValue(value, name, sizes) {\n if (!Array.isArray(value)) return value\n if (sizes.get(name) !== 1 || value.length !== 1) return PERSIST_NO_VALUE\n\n return value[0]\n}\n\n// Snapshot the owned controls: radio → the checked value (null when the group\n// has none, so a restore leaves it alone), checkbox → checked, multi-select →\n// the selected values, a rich editor → its serialized `value` (omitted while\n// the element hasn't upgraded — never a phantom \"\"), a bare contenteditable →\n// its textContent, else .value. Mirrors the core's #collectFields reads.\nfunction persistSnapshot(root, payload) {\n const fields = {}\n // A `[]` name is a group for every control that can contribute a value —\n // checkboxes, selects, text inputs, editors and contenteditables all append\n // to one array, mirroring #collectFields. The one exception is a RADIO group,\n // which means \"pick one\" and keeps its single value with or without the\n // suffix, exactly as the collector treats it.\n //\n // Reading the slot without this (fields[name] ?? []) breaks as soon as a\n // non-checkbox shares the group's name: a text input or an editor leaves a\n // string there, `.push` on it throws inside the draft write, and that write\n // is swallowed — the root then persists nothing at all, silently. Editors\n // are collected AFTER the native controls, so they always land last.\n const groupSlot = (name) => {\n const existing = fields[name]\n return Array.isArray(existing) ? existing : (fields[name] = [])\n }\n for (const { el, name, kind } of persistControls(root, payload)) {\n const group = String(name).endsWith(\"[]\")\n if (kind === \"editor\") {\n if (persistEditorReady(el)) {\n if (group) groupSlot(name).push(el.value)\n else fields[name] = el.value\n }\n } else if (kind === \"contenteditable\") {\n const text = el.textContent ?? \"\"\n if (group) groupSlot(name).push(text)\n else fields[name] = text\n } else if (el.type === \"radio\") {\n if (el.checked) fields[name] = el.value\n else if (!Object.hasOwn(fields, name)) fields[name] = null\n } else if (el.type === \"checkbox\") {\n // A `[]` group drafts the list of ticked values, mirroring #collectFields\n // (issue #258). Without this the boxes overwrote each other and the draft\n // held one boolean, which the restore then applied to every box of the\n // group. A lone checkbox keeps the boolean it has always been.\n if (group) {\n const slot = groupSlot(name)\n if (el.checked) slot.push(el.value)\n } else {\n fields[name] = el.checked\n }\n } else if (persistSelectMultiple(el)) {\n const selected = [...el.options].filter((o) => o.selected).map((o) => o.value)\n if (group) groupSlot(name).push(...selected)\n else fields[name] = selected\n } else if (group) {\n groupSlot(name).push(el.value)\n } else {\n fields[name] = el.value\n }\n }\n return fields\n}\n\n// Replay the draft into the owned controls. Default (restore: blank): a\n// control the server rendered NON-BLANK keeps its value — a 422 re-render's\n// submitted values beat an older draft. restore: \"always\" lets the draft win.\n// Values land via .value/.checked/.selected, textContent, or the editor's own\n// `value` setter — never HTML written by us.\nfunction persistApply(root, payload, fields) {\n const always = payload.restore === \"always\"\n const controls = persistControls(root, payload)\n // Which group names the SERVER rendered with a box already ticked. Computed\n // BEFORE the loop on purpose: the loop writes `checked`, so asking this\n // question from inside it would read THIS restore's own work — the first box\n // it ticks makes every later box of the same group look server-rendered, and\n // a draft of two values comes back as one. The radio branch below asks the\n // same question inline and stays correct only because a radio group holds a\n // single value.\n const groupSizes = persistGroupSizes(controls)\n const serverTicked = new Set()\n for (const control of controls) {\n if (control.kind === \"native\" && control.el.type === \"checkbox\" && control.el.checked) {\n serverTicked.add(control.name)\n }\n }\n for (const { el, name, kind } of controls) {\n if (!Object.hasOwn(fields, name)) continue\n let value = fields[name]\n if (value === null || value === undefined) continue\n // A multi-select reads a list by matching option values, which is only\n // sound when the list is ITS list. In a group with another contributor the\n // entries are mixed, and a text value that happens to equal an option\n // would select it — measured, a draft of [\"blue\",\"freitext\"] from a select\n // plus a text field selected both options. `?? 0` because a name without\n // the suffix is not in the map at all, and a plain `<select multiple\n // name=\"colors\">` must keep restoring.\n if (Array.isArray(value) && persistSelectMultiple(el) && (groupSizes.get(name) ?? 0) > 1) continue\n\n // An array belongs to a `[]` group, and only a control that can pick ITS\n // entry out of the list may read it: a checkbox matches by value, a\n // multi-select by option. Everything else — editors, contenteditables,\n // text inputs — keeps what the server rendered, because the list does not\n // record which entry came from which control. This sits ABOVE the branch\n // chain on purpose: below the editor branch it would never fire for the\n // very controls that land last in the snapshot.\n if (Array.isArray(value) && !(el.type === \"checkbox\" || persistSelectMultiple(el))) {\n value = persistGenericValue(value, name, groupSizes)\n if (value === PERSIST_NO_VALUE) continue\n }\n // The mirror, for a draft written BEFORE a group was drafted as a list\n // (#258): there `features[]` held ONE boolean, and applying it here ticks\n // every box of the group — precisely the state this fix removes, for as\n // long as the draft lives (default ttl 7 days). A group key that is not a\n // list is stale by definition, so the control keeps what the server\n // rendered and the next snapshot overwrites the key. It reads for a\n // multi-select too: 0.13.2 wrote last-writer-wins per name, so a checkbox\n // in a mixed group could leave its boolean under the select's name, and\n // under `restore: \"always\"` the select would then deselect everything —\n // `wanted` being Set{\"true\"} matches no option. Asking for the `[]` suffix\n // is what leaves a lone `gift` checkbox on the boolean it has always held —\n // and scoping the rule to the one key whose meaning changed is why\n // PERSIST_VERSION stays at 1: bumping it would also throw away the drafted\n // prose of every form that has no checkbox group at all.\n if ((el.type === \"checkbox\" || persistSelectMultiple(el)) && String(name).endsWith(\"[]\") && !Array.isArray(value)) {\n continue\n }\n if (kind === \"editor\") {\n persistApplyEditor(root, el, name, value, always)\n } else if (kind === \"contenteditable\") {\n if (!always && (el.textContent ?? \"\").trim() !== \"\") continue\n el.textContent = String(value)\n } else if (el.type === \"radio\") {\n if (!always && controls.some((c) => c.kind === \"native\" && c.el.type === \"radio\" && c.name === name && c.el.checked)) continue\n el.checked = el.value === String(value)\n } else if (el.type === \"checkbox\" && Array.isArray(value)) {\n // A drafted group ticks exactly the boxes it held. One box the SERVER\n // rendered ticked means it had a say, and the draft yields for the whole\n // group.\n if (!always && serverTicked.has(name)) continue\n el.checked = value.map(String).includes(el.value)\n } else if (el.type === \"checkbox\") {\n if (!always && el.checked) continue\n el.checked = Boolean(value)\n } else if (persistSelectMultiple(el)) {\n if (!always && [...el.options].some((o) => o.selected)) continue\n const wanted = new Set((Array.isArray(value) ? value : [value]).map(String))\n for (const o of el.options) o.selected = wanted.has(o.value)\n } else {\n if (!always && el.value !== \"\") continue\n el.value = String(value)\n }\n }\n persistDeferEditors(root, payload, fields)\n}\n\n// A ready editor takes the value through its own setter; the setter is the\n// editor's sanitizing import (Trix HTMLParser, Lexxy $generateNodesFromDOM +\n// sanitizer). A throw (Lexxy before its editor exists) never escapes connect.\nfunction persistApplyEditor(root, el, name, value, always) {\n // A list never reaches here: both callers resolve it through\n // persistGenericValue first — the group of two or more has no mapping back to\n // this editor, the group of one does. Belt and braces, because this is the\n // one apply path with a second entry point.\n if (Array.isArray(value)) return\n if (!persistEditorReady(el)) return // not upgraded yet — persistDeferEditors re-applies after define\n if (!always && !persistEditorBlank(el)) return\n try {\n el.value = String(value)\n } catch (error) {\n persistNoteEditorFailure(root, name, error)\n }\n}\n\n// An editor whose custom element is not defined yet (Trix defines its elements\n// in a setTimeout after load; a lazily imported Lexxy) cannot take a value now.\n// Re-apply per TAG once it is defined — re-querying the controls (the upgrade\n// may replace the node) and re-checking restore: blank at that moment — unless\n// the root has left the document meanwhile.\nfunction persistDeferEditors(root, payload, fields) {\n const registry = globalThis.customElements\n if (typeof registry?.whenDefined !== \"function\") return\n const pending = new Set()\n for (const el of root.querySelectorAll(\"lexxy-editor, trix-editor\")) {\n if (!persistEditorReady(el) && !registry.get?.(el.localName)) pending.add(el.localName)\n }\n const always = payload.restore === \"always\"\n for (const tag of pending) {\n registry.whenDefined(tag).then(() => {\n if (!root.isConnected) return\n const deferred = persistControls(root, payload)\n const sizes = persistGroupSizes(deferred)\n for (const { el, name, kind } of deferred) {\n if (kind !== \"editor\" || el.localName !== tag || !Object.hasOwn(fields, name)) continue\n const value = persistGenericValue(fields[name], name, sizes)\n if (value === null || value === undefined || value === PERSIST_NO_VALUE) continue\n persistApplyEditor(root, el, name, value, always)\n }\n })\n }\n}\n\n// The persist_state op body: merge a FLAT bag into the root's draft (re-\n// snapshotting the fields so the write is whole) and mirror it on the root.\n// A root without reactive_persist is a call-site bug — warn and skip.\n// `restored` false: the root never restored (it left before this module\n// arrived), so its controls hold the server's blanks — keep the drafted\n// fields and merge the bag only.\nfunction persistWriteState(root, state, restored = true) {\n const payload = persistPayload(root)\n if (!payload) {\n console.warn(\"[phlex-reactive] persist_state on a root without reactive_persist — skipped\")\n return\n }\n if (!state || typeof state !== \"object\") return\n const current = persistRead(root, payload)\n const merged = { ...(current?.state ?? {}), ...state }\n const fields = restored ? persistSnapshot(root, payload) : (current?.fields ?? {})\n if (persistWrite(root, payload, { fields, state: merged })) {\n root.setAttribute?.(PERSIST_STATE_ATTR, JSON.stringify(merged))\n }\n}\n\nfunction persistClearRoot(root) {\n const payload = persistPayload(root)\n if (payload) persistRemove(root, payload)\n}\n\n// --- Per-root wiring -------------------------------------------------------\n\n// controller -> the closure that flushes and unwires the connection this\n// feature is wired to. Its timer and handlers are locals of connect(), not a\n// record's fields: the minifier renames a local, never a property (#310).\nconst wired = new WeakMap()\n\n// Restore the draft into the owned controls, expose the state bag, announce,\n// then arm the write listeners. The restore reads ONCE and never writes back:\n// nothing is wired until it has completed, so no listener can clobber the\n// draft with the server's blanks. The submit-end listener is DOCUMENT-level\n// (the event fires on the form, which is usually an ANCESTOR of this root)\n// and gated on the form containing this root.\n//\n// `pending` is what the core recorded while this root waited for the module\n// (undefined when it never had to): see TIMING at the top.\nexport function connect(controller, core, _morphed, pending) {\n const root = controller.element\n const payload = persistPayload(root)\n if (!payload) return\n // Submitted successfully while we were on our way: the draft is done with.\n if (pending?.submitted) persistRemove(root, payload)\n const draft = persistRead(root, payload)\n if (draft) {\n persistApply(root, payload, draft.fields)\n if (draft.state) root.setAttribute?.(PERSIST_STATE_ATTR, JSON.stringify(draft.state))\n core.emit(\"reactive:persist-restored\", { key: payload.key, fields: draft.fields, state: draft.state ?? {} })\n // If the connect-time seeds ran before this restore, they ran on the\n // server's values; they read fields.\n core.reseed()\n }\n\n // ONE pending keystroke write per root (a snapshot is a full pass, so\n // per-field timers would only multiply writes).\n let timer = null\n const cancel = () => {\n if (timer !== null) {\n clearTimeout(timer)\n timer = null\n }\n }\n // Snapshot every persistable owned control and write. Re-reads the current\n // draft first so a state bag written by persist_state survives the write\n // (the bag lives in storage, not on the connection — the op has none).\n const writeNow = () => {\n cancel()\n const current = persistRead(root, payload)\n persistWrite(root, payload, { fields: persistSnapshot(root, payload), state: current?.state ?? null })\n }\n // Trailing-edge debounce for keystrokes.\n const onInput = () => {\n const ms = Number(payload.debounce) || 0\n if (ms <= 0) return writeNow()\n if (timer !== null) clearTimeout(timer)\n timer = setTimeout(() => {\n timer = null\n writeNow()\n }, ms)\n }\n // A SUCCESSFUL Turbo form submission of the form that owns this root\n // forgets the draft. tagName (not instanceof) so a cross-realm form counts.\n const onSubmitEnd = (event) => {\n if (!event?.detail?.success) return\n const form = event.target\n if (form?.tagName !== \"FORM\" || typeof form.contains !== \"function\") return\n if (!form.contains(root)) return\n // Drop a pending keystroke write too — the disconnect flush that follows\n // Turbo's redirect visit would otherwise resurrect the just-cleared draft.\n cancel()\n persistRemove(root, payload)\n }\n // Rich editors (#241): Lexical and Trix swallow the native `input` of\n // their contenteditable, so their own bubbling change events are the\n // keystroke signal — same trailing-edge debounce as `input`.\n const inputs = [\"input\", ...PERSIST_EDITOR_CHANGE_EVENTS]\n for (const event of inputs) root.addEventListener?.(event, onInput)\n root.addEventListener?.(\"change\", writeNow)\n document.addEventListener?.(\"turbo:submit-end\", onSubmitEnd)\n wired.set(controller, () => {\n if (timer !== null) writeNow()\n for (const event of inputs) root.removeEventListener?.(event, onInput)\n root.removeEventListener?.(\"change\", writeNow)\n document.removeEventListener?.(\"turbo:submit-end\", onSubmitEnd)\n })\n\n // An edit made while we were on our way had no listener to draft it: draft\n // it now, with everything the restore just filled in around it.\n if (pending?.edited && !pending.submitted) writeNow()\n for (const op of pending?.ops ?? []) op(true)\n}\n\n// The root left before this module could connect to it. Nothing was restored\n// into it, so its controls hold what the server rendered plus whatever the\n// user did: forget the draft if the form was submitted; otherwise keep the\n// drafted fields, add the ones the user CHANGED, and run the ops that waited.\nexport function abandon(root, pending) {\n if (!pending) return\n const payload = persistPayload(root)\n if (!payload) return\n if (pending.submitted) return persistRemove(root, payload)\n if (pending.edited) {\n const current = persistRead(root, payload)\n const fields = { ...current?.fields }\n const snapshot = persistSnapshot(root, payload)\n for (const name of changedNames(root, payload)) {\n if (Object.hasOwn(snapshot, name)) fields[name] = snapshot[name]\n }\n persistWrite(root, payload, { fields, state: current?.state ?? null })\n }\n for (const op of pending.ops ?? []) op(false)\n}\n\n// The names of the owned controls the user changed on a root that never\n// restored: those whose live state differs from what the SERVER rendered (the\n// DOM keeps that as defaultValue / defaultChecked / the `selected` attribute), so a\n// server-prefilled value is never mistaken for an edit, and an emptied field\n// or an unticked box counts as one. An editor has no such default: it counts\n// once it holds anything.\nfunction changedNames(root, payload) {\n const names = new Set()\n for (const { el, name, kind } of persistControls(root, payload)) {\n const changed =\n kind === \"editor\"\n ? persistEditorReady(el) && !persistEditorBlank(el)\n : kind === \"contenteditable\"\n ? (el.textContent ?? \"\").trim() !== \"\"\n : el.type === \"checkbox\" || el.type === \"radio\"\n ? el.checked !== el.defaultChecked\n : el.tagName === \"SELECT\"\n ? [...el.options].some((option) => option.selected !== option.hasAttribute(\"selected\"))\n : el.value !== el.defaultValue\n if (changed) names.add(name)\n }\n return names\n}\n\n// Flush a pending write while the fields are still readable (Turbo\n// disconnects before leaving the page — a fast visit otherwise loses the last\n// keystrokes), then drop every listener: the closure connect() stored does both.\nexport function disconnect(controller) {\n const off = wired.get(controller)\n wired.delete(controller)\n off?.()\n}\n\n// --- The persist_state / persist_clear client ops --------------------------\n\n// A root that is still waiting for this module shows the server's blanks: an\n// op that snapshots or clears it now would destroy the draft the restore is\n// about to read. Such an op waits in the root's pending record and runs after\n// the restore (connect) — or, if the root leaves first, without one (abandon).\n// Any other root runs it at once.\nfunction whenRestored(root, op) {\n const pending = shared?.waiting.get(root)?.persist\n // (No payload: connect() will not restore this root, so nothing would ever\n // run a queued op — a morph can take the marker away while we load.)\n if (!pending || !persistPayload(root)) return op(true)\n ;(pending.ops ??= []).push(op)\n}\n\nexport function writeState(root, state) {\n whenRestored(root, (restored) => persistWriteState(root, state, restored))\n}\n\nexport function clearRoot(root) {\n whenRestored(root, () => persistClearRoot(root))\n}\n"
6
+ ],
7
+ "mappings": "AAiDA,IAAI,EAEG,SAAS,EAAO,CAAC,EAAO,CAC7B,EAAS,EAGX,IAAM,EAAkB,EAClB,EAAiB,0BAGjB,EAAyB,IAAI,IAAI,CAAC,SAAU,OAAQ,WAAY,SAAU,SAAU,QAAS,OAAO,CAAC,EACrG,EAAmB,OAAO,kBAAkB,EAC5C,EAAqB,8BAMd,EACX,iHACW,EAAsB,IAAI,IAAI,CAAC,eAAgB,aAAa,CAAC,EAKpE,EAAwB,0CAGxB,EAA+B,CAAC,eAAgB,aAAa,EAK7D,EAAqB,IAAI,IAAI,CAAC,GAAI,UAAW,cAAe,iBAAiB,CAAC,EAG9E,EAAuB,IAAI,QAC3B,EAAsB,IAAI,QAC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,QAG3C,GAAI,CAAC,GAAW,CAAC,EAAe,CAAI,EAAG,OAAO,EAAG,EAAI,GACnD,EAAQ,MAAQ,CAAC,GAAG,KAAK,CAAE,EAGxB,SAAS,EAAU,CAAC,EAAM,EAAO,CACtC,EAAa,EAAM,CAAC,IAAa,EAAkB,EAAM,EAAO,CAAQ,CAAC,EAGpE,SAAS,EAAS,CAAC,EAAM,CAC9B,EAAa,EAAM,IAAM,EAAiB,CAAI,CAAC",
8
+ "debugId": "F778B9094B33FD2C64756E2164756E21",
9
+ "names": []
10
+ }
@@ -163,20 +163,32 @@ function eventOf(dataAction) {
163
163
  }
164
164
 
165
165
  // Client-only op triggers ([data-reactive-ops-param]) — a menu toggle, a DOM op
166
- // chain that never round-trips. Report the parsed ops (names) when decodable.
166
+ // chain that never round-trips. Issue #271: the attr holds one on_client
167
+ // binding record per call ({on, window?, ops, …}, space-joined when mix-ed),
168
+ // reported as one { event, ops } entry each. A legacy [[op, args]] list keeps
169
+ // the data-action prefix as its event; an undecodable attr is reported raw.
167
170
  function ownedClientOps(root, allRoots) {
168
- return scopedQuery(root, "[data-reactive-ops-param]", allRoots).map((el) => {
171
+ return scopedQuery(root, "[data-reactive-ops-param]", allRoots).flatMap((el) => {
169
172
  const raw = el.getAttribute("data-reactive-ops-param")
170
- let ops = raw
171
- try {
172
- ops = JSON.parse(raw)
173
- } catch {
174
- // leave the raw string — a malformed ops attr shouldn't break the scan
175
- }
176
- return { event: eventOf(el.getAttribute("data-action")), ops }
173
+ const event = eventOf(el.getAttribute("data-action"))
174
+ const legacy = parseJson(raw)
175
+ if (Array.isArray(legacy)) return [{ event, ops: legacy }]
176
+ const records = (raw ?? "").split(" ").map(parseJson).filter((r) => r && typeof r === "object" && !Array.isArray(r))
177
+ if (records.length === 0) return [{ event, ops: raw }]
178
+ return records.map((r) => ({ event: r.on ? `${r.on}${r.window ? "@window" : ""}` : event, ops: r.ops }))
177
179
  })
178
180
  }
179
181
 
182
+ // JSON.parse that answers undefined instead of throwing — a malformed attr
183
+ // must never break the scan.
184
+ function parseJson(raw) {
185
+ try {
186
+ return JSON.parse(raw)
187
+ } catch {
188
+ return undefined
189
+ }
190
+ }
191
+
180
192
  // Compute reducers bound on this root ([data-reactive-compute-reducer-param]) —
181
193
  // the client-side data-binding twins of reactive_compute. Report reducer names.
182
194
  function ownedComputes(root, allRoots) {
@@ -1,4 +1,4 @@
1
- function u(t=document){let e=Array.from(t.querySelectorAll('[data-controller~="reactive"]'));return e.map((a)=>c(a,e))}function w(t=document){let e=u(t),a=globalThis.console;if(a&&typeof a.log==="function")a.log(`[phlex-reactive] ${e.length} reactive root(s)`);if(a&&typeof a.table==="function")a.table(e.map((r)=>({id:r.id,component:r.component??(r.opaque?"(opaque token)":null),actions:r.triggers.map((i)=>i.action).join(", "),fields:r.fields.join(", "),computes:r.computes.join(", ")})));return e}function c(t,e){let a=t.getAttribute("data-reactive-token-value"),r=s(a);return{id:t.id||null,component:r.opaque?null:r.c??null,gid:r.gid??null,stateKeys:r.s?Object.keys(r.s):[],tokenVersion:r.v??null,opaque:!!r.opaque,status:p(t),triggers:g(t,e),clientOps:b(t,e),computes:l(t,e),fields:v(t,e),show:A(t,e),text:y(t,e),filter:h(t)}}function s(t){if(!t)return{opaque:!0};try{let e=t.split("--")[0],a=d(e),r=JSON.parse(a),i=r&&r._rails&&r._rails.data?r._rails.data:r;if(!i||typeof i!=="object")return{opaque:!0};return i}catch{return{opaque:!0}}}function d(t){return(globalThis.atob||((a)=>Buffer.from(a,"base64").toString("binary")))(t)}function p(t){return{error:t.getAttribute("data-reactive-error"),busy:t.getAttribute("aria-busy")==="true"||t.hasAttribute("data-reactive-busy"),dirty:t.hasAttribute("data-reactive-dirty")}}var f='[data-controller~="reactive"]';function m(t,e){return t.closest(f)===e}function n(t,e,a){return Array.from(t.querySelectorAll(e)).filter((r)=>m(r,t))}function g(t,e){return n(t,"[data-reactive-action-param]",e).map((a)=>({action:a.getAttribute("data-reactive-action-param"),event:o(a.getAttribute("data-action")),params:a.getAttribute("data-reactive-params-param"),debounce:a.getAttribute("data-reactive-debounce-param"),throttle:a.getAttribute("data-reactive-throttle-param"),confirm:a.getAttribute("data-reactive-confirm-param"),optimistic:a.getAttribute("data-reactive-optimistic-param"),loading:a.getAttribute("data-reactive-loading-param")}))}function o(t){if(!t)return null;let e=t.indexOf("->");return e===-1?null:t.slice(0,e)}function b(t,e){return n(t,"[data-reactive-ops-param]",e).map((a)=>{let r=a.getAttribute("data-reactive-ops-param"),i=r;try{i=JSON.parse(r)}catch{}return{event:o(a.getAttribute("data-action")),ops:i}})}function l(t,e){return n(t,"[data-reactive-compute-reducer-param]",e).map((a)=>a.getAttribute("data-reactive-compute-reducer-param"))}function v(t,e){return n(t,"input[name], select[name], textarea[name]",e).map((a)=>a.getAttribute("name"))}function A(t,e){return n(t,"[data-reactive-show-field]",e).map((a)=>({field:a.getAttribute("data-reactive-show-field"),equals:a.getAttribute("data-reactive-show-equals"),not:a.getAttribute("data-reactive-show-not"),in:a.getAttribute("data-reactive-show-in")}))}function y(t,e){return n(t,"[data-reactive-text]",e).map((a)=>a.getAttribute("data-reactive-text"))}function h(t){let e=t.getAttribute("data-reactive-filter-input");if(!e)return null;return{input:e,option:t.getAttribute("data-reactive-filter-option"),group:t.getAttribute("data-reactive-filter-group"),empty:t.getAttribute("data-reactive-filter-empty")}}export{w as report,u as scan};
1
+ function p(t=document){let e=Array.from(t.querySelectorAll('[data-controller~="reactive"]'));return e.map((r)=>f(r,e))}function S(t=document){let e=p(t),r=globalThis.console;if(r&&typeof r.log==="function")r.log(`[phlex-reactive] ${e.length} reactive root(s)`);if(r&&typeof r.table==="function")r.table(e.map((a)=>({id:a.id,component:a.component??(a.opaque?"(opaque token)":null),actions:a.triggers.map((n)=>n.action).join(", "),fields:a.fields.join(", "),computes:a.computes.join(", ")})));return e}function f(t,e){let r=t.getAttribute("data-reactive-token-value"),a=m(r);return{id:t.id||null,component:a.opaque?null:a.c??null,gid:a.gid??null,stateKeys:a.s?Object.keys(a.s):[],tokenVersion:a.v??null,opaque:!!a.opaque,status:b(t),triggers:A(t,e),clientOps:y(t,e),computes:w(t,e),fields:h(t,e),show:q(t,e),text:O(t,e),filter:x(t)}}function m(t){if(!t)return{opaque:!0};try{let e=t.split("--")[0],r=g(e),a=JSON.parse(r),n=a&&a._rails&&a._rails.data?a._rails.data:a;if(!n||typeof n!=="object")return{opaque:!0};return n}catch{return{opaque:!0}}}function g(t){return(globalThis.atob||((r)=>Buffer.from(r,"base64").toString("binary")))(t)}function b(t){return{error:t.getAttribute("data-reactive-error"),busy:t.getAttribute("aria-busy")==="true"||t.hasAttribute("data-reactive-busy"),dirty:t.hasAttribute("data-reactive-dirty")}}var l='[data-controller~="reactive"]';function v(t,e){return t.closest(l)===e}function o(t,e,r){return Array.from(t.querySelectorAll(e)).filter((a)=>v(a,t))}function A(t,e){return o(t,"[data-reactive-action-param]",e).map((r)=>({action:r.getAttribute("data-reactive-action-param"),event:d(r.getAttribute("data-action")),params:r.getAttribute("data-reactive-params-param"),debounce:r.getAttribute("data-reactive-debounce-param"),throttle:r.getAttribute("data-reactive-throttle-param"),confirm:r.getAttribute("data-reactive-confirm-param"),optimistic:r.getAttribute("data-reactive-optimistic-param"),loading:r.getAttribute("data-reactive-loading-param")}))}function d(t){if(!t)return null;let e=t.indexOf("->");return e===-1?null:t.slice(0,e)}function y(t,e){return o(t,"[data-reactive-ops-param]",e).flatMap((r)=>{let a=r.getAttribute("data-reactive-ops-param"),n=d(r.getAttribute("data-action")),u=s(a);if(Array.isArray(u))return[{event:n,ops:u}];let c=(a??"").split(" ").map(s).filter((i)=>i&&typeof i==="object"&&!Array.isArray(i));if(c.length===0)return[{event:n,ops:a}];return c.map((i)=>({event:i.on?`${i.on}${i.window?"@window":""}`:n,ops:i.ops}))})}function s(t){try{return JSON.parse(t)}catch{return}}function w(t,e){return o(t,"[data-reactive-compute-reducer-param]",e).map((r)=>r.getAttribute("data-reactive-compute-reducer-param"))}function h(t,e){return o(t,"input[name], select[name], textarea[name]",e).map((r)=>r.getAttribute("name"))}function q(t,e){return o(t,"[data-reactive-show-field]",e).map((r)=>({field:r.getAttribute("data-reactive-show-field"),equals:r.getAttribute("data-reactive-show-equals"),not:r.getAttribute("data-reactive-show-not"),in:r.getAttribute("data-reactive-show-in")}))}function O(t,e){return o(t,"[data-reactive-text]",e).map((r)=>r.getAttribute("data-reactive-text"))}function x(t){let e=t.getAttribute("data-reactive-filter-input");if(!e)return null;return{input:e,option:t.getAttribute("data-reactive-filter-option"),group:t.getAttribute("data-reactive-filter-group"),empty:t.getAttribute("data-reactive-filter-empty")}}export{S as report,p as scan};
2
2
 
3
- //# debugId=C4F6AC69EE45C88764756E2164756E21
3
+ //# debugId=041E72D906D0F77464756E2164756E21
4
4
  //# sourceMappingURL=inspect.min.js.map
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["inspect.js"],
4
4
  "sourcesContent": [
5
- "// The on-demand client inspector (issue #168) — the browser half of the\n// debugging toolkit, the client twin of `phlex_reactive:actions` / the MCP tools.\n//\n// It is a STANDALONE module (the confirm.js / compute.js precedent): it does NOT\n// touch the hot-path reactive_controller.js and costs NOTHING until you import\n// it. Loaded on demand from the console (the engine pins it), it scans the live\n// DOM and maps every reactive root + bound trigger back to the server\n// Component#action names — so you can answer \"what's reactive on this page, what\n// does each control POST, and which component owns it?\" without reading source.\n//\n// (await import(\"phlex/reactive/inspect\")).report() // console.table\n// const roots = (await import(\"phlex/reactive/inspect\")).scan() // data\n//\n// The server↔client mapping is BY NAME: scan()'s `component` + each trigger's\n// `action` are exactly the Component#action identifiers `phlex_reactive:actions`\n// and the MCP tools list. The docs page shows the two side by side.\n//\n// It reads the SAME DOM contract reactive_controller.js writes (roots\n// [data-controller~=\"reactive\"] with id + data-reactive-token-value; triggers\n// [data-reactive-action-param] with data-action/params/modifiers; client-only\n// [data-reactive-ops-param]; computes [data-reactive-compute-reducer-param]; the\n// show/filter/text binding families). It never mutates anything — pure read.\n\n// Scan `root` (default the whole document) and return one entry per reactive\n// root, deepest-scoped: each trigger is attributed to its NEAREST reactive root,\n// so a nested root doesn't double-count its parent's triggers.\nexport function scan(root = document) {\n const roots = Array.from(root.querySelectorAll('[data-controller~=\"reactive\"]'))\n return roots.map((el) => inspectRoot(el, roots))\n}\n\n// console.table the inventory (roots + a flattened trigger table), and return\n// the same data scan() does so `report()` is also usable programmatically. Safe\n// on an empty document (logs an empty table, throws nothing).\nexport function report(root = document) {\n const roots = scan(root)\n const console = globalThis.console\n\n // Guard each console method independently — a host page (or a test harness)\n // may ship a partial console, and report() must never throw over logging.\n if (console && typeof console.log === \"function\") {\n console.log(`[phlex-reactive] ${roots.length} reactive root(s)`)\n }\n if (console && typeof console.table === \"function\") {\n console.table(\n roots.map((r) => ({\n id: r.id,\n component: r.component ?? (r.opaque ? \"(opaque token)\" : null),\n actions: r.triggers.map((t) => t.action).join(\", \"),\n fields: r.fields.join(\", \"),\n computes: r.computes.join(\", \"),\n })),\n )\n }\n return roots\n}\n\n// --- one root --------------------------------------------------------------\n\nfunction inspectRoot(el, allRoots) {\n const token = el.getAttribute(\"data-reactive-token-value\")\n const payload = decodeToken(token)\n\n return {\n id: el.id || null,\n component: payload.opaque ? null : (payload.c ?? null),\n gid: payload.gid ?? null,\n stateKeys: payload.s ? Object.keys(payload.s) : [],\n tokenVersion: payload.v ?? null,\n opaque: !!payload.opaque,\n status: readStatus(el),\n triggers: ownedTriggers(el, allRoots),\n clientOps: ownedClientOps(el, allRoots),\n computes: ownedComputes(el, allRoots),\n fields: ownedFields(el, allRoots),\n show: ownedShow(el, allRoots),\n text: ownedText(el, allRoots),\n filter: readFilter(el),\n }\n}\n\n// The signed identity is base64(JSON)--signature under the Rails 7.1+ JSON\n// message serializer. Decode the segment BEFORE the \"--\", JSON-parse it, and\n// unwrap the MessageVerifier envelope ({_rails:{data:…}}) to the {c,gid,s,v}\n// payload. Degrade to { opaque: true } on anything that isn't JSON-decodable —\n// a Marshal-serialized payload (older apps) simply isn't readable client-side,\n// and that's fine: the inspector shows \"(opaque token)\" rather than throwing.\nfunction decodeToken(token) {\n if (!token) return { opaque: true }\n\n try {\n const segment = token.split(\"--\")[0]\n const json = atobUtf8(segment)\n const parsed = JSON.parse(json)\n const data = parsed && parsed._rails && parsed._rails.data ? parsed._rails.data : parsed\n if (!data || typeof data !== \"object\") return { opaque: true }\n return data\n } catch {\n return { opaque: true }\n }\n}\n\n// base64 → string. Uses the platform atob; a malformed/urlsafe segment throws,\n// which decodeToken catches and reports as opaque.\nfunction atobUtf8(b64) {\n const decode = globalThis.atob || ((s) => Buffer.from(s, \"base64\").toString(\"binary\"))\n return decode(b64)\n}\n\n// The at-a-glance runtime state the controller stamps on the root. Names/flags\n// only — never a value that could be sensitive.\nfunction readStatus(el) {\n return {\n error: el.getAttribute(\"data-reactive-error\"),\n busy: el.getAttribute(\"aria-busy\") === \"true\" || el.hasAttribute(\"data-reactive-busy\"),\n dirty: el.hasAttribute(\"data-reactive-dirty\"),\n }\n}\n\n// --- ownership scoping -----------------------------------------------------\n//\n// An element belongs to a root when its NEAREST reactive-root ancestor is that\n// root (matching the controller's own ownership walk). closest() finds the\n// nearest ancestor matching the selector; the element itself can be the root\n// (for a root that also carries a binding), so we start the walk from the\n// element and accept `el` as its own owner.\n\nconst ROOT_SELECTOR = '[data-controller~=\"reactive\"]'\n\nfunction ownedBy(node, root) {\n return node.closest(ROOT_SELECTOR) === root\n}\n\n// Query `root` for `selector`, keeping only elements whose nearest reactive\n// root IS `root` — so a nested root's matches are excluded here and attributed\n// to that inner root instead.\nfunction scopedQuery(root, selector, allRoots) {\n return Array.from(root.querySelectorAll(selector)).filter((node) => ownedBy(node, root))\n}\n\n// --- the binding families --------------------------------------------------\n\nfunction ownedTriggers(root, allRoots) {\n return scopedQuery(root, \"[data-reactive-action-param]\", allRoots).map((el) => ({\n action: el.getAttribute(\"data-reactive-action-param\"),\n event: eventOf(el.getAttribute(\"data-action\")),\n params: el.getAttribute(\"data-reactive-params-param\"),\n debounce: el.getAttribute(\"data-reactive-debounce-param\"),\n throttle: el.getAttribute(\"data-reactive-throttle-param\"),\n confirm: el.getAttribute(\"data-reactive-confirm-param\"),\n optimistic: el.getAttribute(\"data-reactive-optimistic-param\"),\n loading: el.getAttribute(\"data-reactive-loading-param\"),\n }))\n}\n\n// The Stimulus data-action descriptor is \"event->controller#method\"; the event\n// is the part before \"->\" (a bare \"controller#method\" has an implicit default\n// event, which we report as null).\nfunction eventOf(dataAction) {\n if (!dataAction) return null\n const arrow = dataAction.indexOf(\"->\")\n return arrow === -1 ? null : dataAction.slice(0, arrow)\n}\n\n// Client-only op triggers ([data-reactive-ops-param]) — a menu toggle, a DOM op\n// chain that never round-trips. Report the parsed ops (names) when decodable.\nfunction ownedClientOps(root, allRoots) {\n return scopedQuery(root, \"[data-reactive-ops-param]\", allRoots).map((el) => {\n const raw = el.getAttribute(\"data-reactive-ops-param\")\n let ops = raw\n try {\n ops = JSON.parse(raw)\n } catch {\n // leave the raw string — a malformed ops attr shouldn't break the scan\n }\n return { event: eventOf(el.getAttribute(\"data-action\")), ops }\n })\n}\n\n// Compute reducers bound on this root ([data-reactive-compute-reducer-param]) —\n// the client-side data-binding twins of reactive_compute. Report reducer names.\nfunction ownedComputes(root, allRoots) {\n return scopedQuery(root, \"[data-reactive-compute-reducer-param]\", allRoots).map((el) =>\n el.getAttribute(\"data-reactive-compute-reducer-param\"),\n )\n}\n\n// The named form controls the dispatch would collect and send — the same\n// selector the controller's field walk uses. Names only, never values.\nfunction ownedFields(root, allRoots) {\n return scopedQuery(root, \"input[name], select[name], textarea[name]\", allRoots).map((el) =>\n el.getAttribute(\"name\"),\n )\n}\n\n// reactive_show bindings: which owned field controls each element's visibility.\nfunction ownedShow(root, allRoots) {\n return scopedQuery(root, \"[data-reactive-show-field]\", allRoots).map((el) => ({\n field: el.getAttribute(\"data-reactive-show-field\"),\n equals: el.getAttribute(\"data-reactive-show-equals\"),\n not: el.getAttribute(\"data-reactive-show-not\"),\n in: el.getAttribute(\"data-reactive-show-in\"),\n }))\n}\n\n// reactive_text spans (data-reactive-text=<name>) the client writes via\n// textContent — report the binding names.\nfunction ownedText(root, allRoots) {\n return scopedQuery(root, \"[data-reactive-text]\", allRoots).map((el) =>\n el.getAttribute(\"data-reactive-text\"),\n )\n}\n\n// reactive_filter lives on the ROOT itself (the input/option/group/empty\n// selectors it narrows client-side). Null when the root declares no filter.\nfunction readFilter(el) {\n const input = el.getAttribute(\"data-reactive-filter-input\")\n if (!input) return null\n return {\n input,\n option: el.getAttribute(\"data-reactive-filter-option\"),\n group: el.getAttribute(\"data-reactive-filter-group\"),\n empty: el.getAttribute(\"data-reactive-filter-empty\"),\n }\n}\n"
5
+ "// The on-demand client inspector (issue #168) — the browser half of the\n// debugging toolkit, the client twin of `phlex_reactive:actions` / the MCP tools.\n//\n// It is a STANDALONE module (the confirm.js / compute.js precedent): it does NOT\n// touch the hot-path reactive_controller.js and costs NOTHING until you import\n// it. Loaded on demand from the console (the engine pins it), it scans the live\n// DOM and maps every reactive root + bound trigger back to the server\n// Component#action names — so you can answer \"what's reactive on this page, what\n// does each control POST, and which component owns it?\" without reading source.\n//\n// (await import(\"phlex/reactive/inspect\")).report() // console.table\n// const roots = (await import(\"phlex/reactive/inspect\")).scan() // data\n//\n// The server↔client mapping is BY NAME: scan()'s `component` + each trigger's\n// `action` are exactly the Component#action identifiers `phlex_reactive:actions`\n// and the MCP tools list. The docs page shows the two side by side.\n//\n// It reads the SAME DOM contract reactive_controller.js writes (roots\n// [data-controller~=\"reactive\"] with id + data-reactive-token-value; triggers\n// [data-reactive-action-param] with data-action/params/modifiers; client-only\n// [data-reactive-ops-param]; computes [data-reactive-compute-reducer-param]; the\n// show/filter/text binding families). It never mutates anything — pure read.\n\n// Scan `root` (default the whole document) and return one entry per reactive\n// root, deepest-scoped: each trigger is attributed to its NEAREST reactive root,\n// so a nested root doesn't double-count its parent's triggers.\nexport function scan(root = document) {\n const roots = Array.from(root.querySelectorAll('[data-controller~=\"reactive\"]'))\n return roots.map((el) => inspectRoot(el, roots))\n}\n\n// console.table the inventory (roots + a flattened trigger table), and return\n// the same data scan() does so `report()` is also usable programmatically. Safe\n// on an empty document (logs an empty table, throws nothing).\nexport function report(root = document) {\n const roots = scan(root)\n const console = globalThis.console\n\n // Guard each console method independently — a host page (or a test harness)\n // may ship a partial console, and report() must never throw over logging.\n if (console && typeof console.log === \"function\") {\n console.log(`[phlex-reactive] ${roots.length} reactive root(s)`)\n }\n if (console && typeof console.table === \"function\") {\n console.table(\n roots.map((r) => ({\n id: r.id,\n component: r.component ?? (r.opaque ? \"(opaque token)\" : null),\n actions: r.triggers.map((t) => t.action).join(\", \"),\n fields: r.fields.join(\", \"),\n computes: r.computes.join(\", \"),\n })),\n )\n }\n return roots\n}\n\n// --- one root --------------------------------------------------------------\n\nfunction inspectRoot(el, allRoots) {\n const token = el.getAttribute(\"data-reactive-token-value\")\n const payload = decodeToken(token)\n\n return {\n id: el.id || null,\n component: payload.opaque ? null : (payload.c ?? null),\n gid: payload.gid ?? null,\n stateKeys: payload.s ? Object.keys(payload.s) : [],\n tokenVersion: payload.v ?? null,\n opaque: !!payload.opaque,\n status: readStatus(el),\n triggers: ownedTriggers(el, allRoots),\n clientOps: ownedClientOps(el, allRoots),\n computes: ownedComputes(el, allRoots),\n fields: ownedFields(el, allRoots),\n show: ownedShow(el, allRoots),\n text: ownedText(el, allRoots),\n filter: readFilter(el),\n }\n}\n\n// The signed identity is base64(JSON)--signature under the Rails 7.1+ JSON\n// message serializer. Decode the segment BEFORE the \"--\", JSON-parse it, and\n// unwrap the MessageVerifier envelope ({_rails:{data:…}}) to the {c,gid,s,v}\n// payload. Degrade to { opaque: true } on anything that isn't JSON-decodable —\n// a Marshal-serialized payload (older apps) simply isn't readable client-side,\n// and that's fine: the inspector shows \"(opaque token)\" rather than throwing.\nfunction decodeToken(token) {\n if (!token) return { opaque: true }\n\n try {\n const segment = token.split(\"--\")[0]\n const json = atobUtf8(segment)\n const parsed = JSON.parse(json)\n const data = parsed && parsed._rails && parsed._rails.data ? parsed._rails.data : parsed\n if (!data || typeof data !== \"object\") return { opaque: true }\n return data\n } catch {\n return { opaque: true }\n }\n}\n\n// base64 → string. Uses the platform atob; a malformed/urlsafe segment throws,\n// which decodeToken catches and reports as opaque.\nfunction atobUtf8(b64) {\n const decode = globalThis.atob || ((s) => Buffer.from(s, \"base64\").toString(\"binary\"))\n return decode(b64)\n}\n\n// The at-a-glance runtime state the controller stamps on the root. Names/flags\n// only — never a value that could be sensitive.\nfunction readStatus(el) {\n return {\n error: el.getAttribute(\"data-reactive-error\"),\n busy: el.getAttribute(\"aria-busy\") === \"true\" || el.hasAttribute(\"data-reactive-busy\"),\n dirty: el.hasAttribute(\"data-reactive-dirty\"),\n }\n}\n\n// --- ownership scoping -----------------------------------------------------\n//\n// An element belongs to a root when its NEAREST reactive-root ancestor is that\n// root (matching the controller's own ownership walk). closest() finds the\n// nearest ancestor matching the selector; the element itself can be the root\n// (for a root that also carries a binding), so we start the walk from the\n// element and accept `el` as its own owner.\n\nconst ROOT_SELECTOR = '[data-controller~=\"reactive\"]'\n\nfunction ownedBy(node, root) {\n return node.closest(ROOT_SELECTOR) === root\n}\n\n// Query `root` for `selector`, keeping only elements whose nearest reactive\n// root IS `root` — so a nested root's matches are excluded here and attributed\n// to that inner root instead.\nfunction scopedQuery(root, selector, allRoots) {\n return Array.from(root.querySelectorAll(selector)).filter((node) => ownedBy(node, root))\n}\n\n// --- the binding families --------------------------------------------------\n\nfunction ownedTriggers(root, allRoots) {\n return scopedQuery(root, \"[data-reactive-action-param]\", allRoots).map((el) => ({\n action: el.getAttribute(\"data-reactive-action-param\"),\n event: eventOf(el.getAttribute(\"data-action\")),\n params: el.getAttribute(\"data-reactive-params-param\"),\n debounce: el.getAttribute(\"data-reactive-debounce-param\"),\n throttle: el.getAttribute(\"data-reactive-throttle-param\"),\n confirm: el.getAttribute(\"data-reactive-confirm-param\"),\n optimistic: el.getAttribute(\"data-reactive-optimistic-param\"),\n loading: el.getAttribute(\"data-reactive-loading-param\"),\n }))\n}\n\n// The Stimulus data-action descriptor is \"event->controller#method\"; the event\n// is the part before \"->\" (a bare \"controller#method\" has an implicit default\n// event, which we report as null).\nfunction eventOf(dataAction) {\n if (!dataAction) return null\n const arrow = dataAction.indexOf(\"->\")\n return arrow === -1 ? null : dataAction.slice(0, arrow)\n}\n\n// Client-only op triggers ([data-reactive-ops-param]) — a menu toggle, a DOM op\n// chain that never round-trips. Issue #271: the attr holds one on_client\n// binding record per call ({on, window?, ops, …}, space-joined when mix-ed),\n// reported as one { event, ops } entry each. A legacy [[op, args]] list keeps\n// the data-action prefix as its event; an undecodable attr is reported raw.\nfunction ownedClientOps(root, allRoots) {\n return scopedQuery(root, \"[data-reactive-ops-param]\", allRoots).flatMap((el) => {\n const raw = el.getAttribute(\"data-reactive-ops-param\")\n const event = eventOf(el.getAttribute(\"data-action\"))\n const legacy = parseJson(raw)\n if (Array.isArray(legacy)) return [{ event, ops: legacy }]\n const records = (raw ?? \"\").split(\" \").map(parseJson).filter((r) => r && typeof r === \"object\" && !Array.isArray(r))\n if (records.length === 0) return [{ event, ops: raw }]\n return records.map((r) => ({ event: r.on ? `${r.on}${r.window ? \"@window\" : \"\"}` : event, ops: r.ops }))\n })\n}\n\n// JSON.parse that answers undefined instead of throwing — a malformed attr\n// must never break the scan.\nfunction parseJson(raw) {\n try {\n return JSON.parse(raw)\n } catch {\n return undefined\n }\n}\n\n// Compute reducers bound on this root ([data-reactive-compute-reducer-param]) —\n// the client-side data-binding twins of reactive_compute. Report reducer names.\nfunction ownedComputes(root, allRoots) {\n return scopedQuery(root, \"[data-reactive-compute-reducer-param]\", allRoots).map((el) =>\n el.getAttribute(\"data-reactive-compute-reducer-param\"),\n )\n}\n\n// The named form controls the dispatch would collect and send — the same\n// selector the controller's field walk uses. Names only, never values.\nfunction ownedFields(root, allRoots) {\n return scopedQuery(root, \"input[name], select[name], textarea[name]\", allRoots).map((el) =>\n el.getAttribute(\"name\"),\n )\n}\n\n// reactive_show bindings: which owned field controls each element's visibility.\nfunction ownedShow(root, allRoots) {\n return scopedQuery(root, \"[data-reactive-show-field]\", allRoots).map((el) => ({\n field: el.getAttribute(\"data-reactive-show-field\"),\n equals: el.getAttribute(\"data-reactive-show-equals\"),\n not: el.getAttribute(\"data-reactive-show-not\"),\n in: el.getAttribute(\"data-reactive-show-in\"),\n }))\n}\n\n// reactive_text spans (data-reactive-text=<name>) the client writes via\n// textContent — report the binding names.\nfunction ownedText(root, allRoots) {\n return scopedQuery(root, \"[data-reactive-text]\", allRoots).map((el) =>\n el.getAttribute(\"data-reactive-text\"),\n )\n}\n\n// reactive_filter lives on the ROOT itself (the input/option/group/empty\n// selectors it narrows client-side). Null when the root declares no filter.\nfunction readFilter(el) {\n const input = el.getAttribute(\"data-reactive-filter-input\")\n if (!input) return null\n return {\n input,\n option: el.getAttribute(\"data-reactive-filter-option\"),\n group: el.getAttribute(\"data-reactive-filter-group\"),\n empty: el.getAttribute(\"data-reactive-filter-empty\"),\n }\n}\n"
6
6
  ],
7
- "mappings": "AA0BO,SAAS,CAAI,CAAC,EAAO,SAAU,CACpC,IAAM,EAAQ,MAAM,KAAK,EAAK,iBAAiB,+BAA+B,CAAC,EAC/E,OAAO,EAAM,IAAI,CAAC,IAAO,EAAY,EAAI,CAAK,CAAC,EAM1C,SAAS,CAAM,CAAC,EAAO,SAAU,CACtC,IAAM,EAAQ,EAAK,CAAI,EACjB,EAAU,WAAW,QAI3B,GAAI,GAAW,OAAO,EAAQ,MAAQ,WACpC,EAAQ,IAAI,oBAAoB,EAAM,yBAAyB,EAEjE,GAAI,GAAW,OAAO,EAAQ,QAAU,WACtC,EAAQ,MACN,EAAM,IAAI,CAAC,KAAO,CAChB,GAAI,EAAE,GACN,UAAW,EAAE,YAAc,EAAE,OAAS,iBAAmB,MACzD,QAAS,EAAE,SAAS,IAAI,CAAC,IAAM,EAAE,MAAM,EAAE,KAAK,IAAI,EAClD,OAAQ,E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