phlex-reactive 0.15.3 → 0.15.5
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +184 -0
- data/README.md +92 -12
- data/app/javascript/phlex/reactive/core.js +1 -0
- data/app/javascript/phlex/reactive/core.min.js +6 -6
- data/app/javascript/phlex/reactive/core.min.js.map +4 -4
- data/app/javascript/phlex/reactive/features/bindings.js +129 -16
- data/app/javascript/phlex/reactive/features/bindings.min.js +2 -2
- data/app/javascript/phlex/reactive/features/bindings.min.js.map +3 -3
- data/app/javascript/phlex/reactive/features/countdown.js +140 -0
- data/app/javascript/phlex/reactive/features/countdown.min.js +4 -0
- data/app/javascript/phlex/reactive/features/countdown.min.js.map +10 -0
- data/app/javascript/phlex/reactive/features/persist.js +10 -6
- data/app/javascript/phlex/reactive/features/persist.min.js +2 -2
- data/app/javascript/phlex/reactive/features/persist.min.js.map +3 -3
- data/app/javascript/phlex/reactive/reactive_controller.js +2 -0
- data/app/javascript/phlex/reactive/reactive_controller.min.js +4 -4
- data/app/javascript/phlex/reactive/reactive_controller.min.js.map +8 -7
- data/app/javascript/phlex/reactive/runtime.js +255 -31
- data/lib/phlex/reactive/component/countdown_binding.rb +80 -0
- data/lib/phlex/reactive/component/field_references.rb +130 -0
- data/lib/phlex/reactive/component/helpers.rb +72 -14
- data/lib/phlex/reactive/component/image_fallback_binding.rb +18 -5
- data/lib/phlex/reactive/component/media_binding.rb +9 -1
- data/lib/phlex/reactive/component/media_pattern.rb +17 -17
- data/lib/phlex/reactive/component/selection.rb +24 -2
- data/lib/phlex/reactive/component/show_options.rb +91 -0
- data/lib/phlex/reactive/engine.rb +2 -2
- data/lib/phlex/reactive/js.rb +44 -2
- data/lib/phlex/reactive/response.rb +3 -4
- data/lib/phlex/reactive/show_conditions/compare_terms.rb +142 -0
- data/lib/phlex/reactive/show_conditions.rb +39 -6
- data/lib/phlex/reactive/streamable.rb +6 -4
- data/lib/phlex/reactive/version.rb +1 -1
- metadata +8 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// phlex/reactive/features/countdown — a deadline counted down on the client
|
|
2
|
+
// (issue #400). One of the feature modules the core imports on demand (issue
|
|
3
|
+
// #275); in the default client it is part of the one file.
|
|
4
|
+
//
|
|
5
|
+
// The markup is the Ruby side's (reactive_countdown):
|
|
6
|
+
//
|
|
7
|
+
// data-reactive-countdown='{"until":"<ISO8601>","format":"ms","waiting":"#wait","done":"#done"}'
|
|
8
|
+
//
|
|
9
|
+
// Every tick reads Date.now against the deadline, so a late tick (a throttled
|
|
10
|
+
// background tab, a slept laptop) paints the real remaining time, never a
|
|
11
|
+
// count of missed ticks; a tab that becomes visible again re-reads at once.
|
|
12
|
+
// The text is unpadded minutes, a colon and zero-padded seconds ("1:30"),
|
|
13
|
+
// written as textContent only. The next tick is set for the moment the shown
|
|
14
|
+
// second changes.
|
|
15
|
+
//
|
|
16
|
+
// At zero (or with the deadline already past on connect, which starts no
|
|
17
|
+
// timer) the text is "0:00", data-reactive-countdown-state is "done", the
|
|
18
|
+
// waiting: node hides, the done: node shows, and the element dispatches
|
|
19
|
+
// reactive:countdown-done (bubbling) once. "Once" is per root id (a root
|
|
20
|
+
// without one is its own element), countdown (its id, else its place in the
|
|
21
|
+
// root) and deadline, kept for the life of the document: a morph or a replace
|
|
22
|
+
// that keeps the deadline, or brings back one that already fired, paints the
|
|
23
|
+
// done state again without a second event; a new deadline counts down afresh.
|
|
24
|
+
// The countdown's content is its text: waiting: and done: are nodes beside it,
|
|
25
|
+
// so a root that is itself the countdown has none.
|
|
26
|
+
// No request, no frame reload: the page decides what the event does.
|
|
27
|
+
//
|
|
28
|
+
// This module never imports the core: it reaches a controller through the
|
|
29
|
+
// `core` handle (core.owns).
|
|
30
|
+
|
|
31
|
+
const MARK = "data-reactive-countdown"
|
|
32
|
+
const STATE = "data-reactive-countdown-state"
|
|
33
|
+
|
|
34
|
+
// "<root id>|<countdown key>" -> every deadline it already dispatched for.
|
|
35
|
+
const finished = new Map()
|
|
36
|
+
// A root without an id: a number of its own, so two never share a key.
|
|
37
|
+
const anonymous = new WeakMap()
|
|
38
|
+
let anonymousSeq = 0
|
|
39
|
+
// controller -> the removal of what connect() added.
|
|
40
|
+
const wired = new WeakMap()
|
|
41
|
+
|
|
42
|
+
export function connect(controller, core) {
|
|
43
|
+
const root = controller.element
|
|
44
|
+
if (!root.id && !anonymous.has(root)) anonymous.set(root, `#${++anonymousSeq}`)
|
|
45
|
+
const rootKey = root.id || anonymous.get(root)
|
|
46
|
+
// countdown element -> its pending timer.
|
|
47
|
+
const timers = new Map()
|
|
48
|
+
let queued = false
|
|
49
|
+
|
|
50
|
+
const clear = (el) => {
|
|
51
|
+
clearTimeout(timers.get(el))
|
|
52
|
+
timers.delete(el)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const tick = (el, wire, key) => {
|
|
56
|
+
clear(el)
|
|
57
|
+
const left = Date.parse(wire.until) - Date.now()
|
|
58
|
+
if (!(left > 0)) return finish(el, wire, key)
|
|
59
|
+
const seconds = Math.ceil(left / 1000)
|
|
60
|
+
paint(el, `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`, "running")
|
|
61
|
+
show(wire.waiting, true)
|
|
62
|
+
show(wire.done, false)
|
|
63
|
+
timers.set(
|
|
64
|
+
el,
|
|
65
|
+
setTimeout(() => tick(el, wire, key), ((left - 1) % 1000) + 1),
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const finish = (el, wire, key) => {
|
|
70
|
+
paint(el, "0:00", "done")
|
|
71
|
+
show(wire.waiting, false)
|
|
72
|
+
show(wire.done, true)
|
|
73
|
+
const fired = finished.get(key) ?? new Set()
|
|
74
|
+
if (fired.has(wire.until)) return
|
|
75
|
+
finished.set(key, fired.add(wire.until))
|
|
76
|
+
el.dispatchEvent(new CustomEvent("reactive:countdown-done", { bubbles: true, detail: { until: wire.until } }))
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// A selector that is not valid CSS is ignored, never a stopped clock.
|
|
80
|
+
const show = (selector, visible) => {
|
|
81
|
+
let node
|
|
82
|
+
try {
|
|
83
|
+
node = selector && root.querySelector(selector)
|
|
84
|
+
} catch {}
|
|
85
|
+
if (node && node.hidden === visible) node.hidden = !visible
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Every countdown this root owns, from scratch: a morph may have changed a
|
|
89
|
+
// deadline, written the server's text back, or removed a countdown.
|
|
90
|
+
const sync = () => {
|
|
91
|
+
queued = false
|
|
92
|
+
// A morph that also removed the root: disconnect ran first.
|
|
93
|
+
if (!wired.has(controller)) return
|
|
94
|
+
const seen = new Set()
|
|
95
|
+
const els = [...(root.matches(`[${MARK}]`) ? [root] : []), ...root.querySelectorAll(`[${MARK}]`)]
|
|
96
|
+
els.forEach((el, index) => {
|
|
97
|
+
if (!core.owns(el)) return
|
|
98
|
+
let wire
|
|
99
|
+
try {
|
|
100
|
+
wire = JSON.parse(el.getAttribute(MARK))
|
|
101
|
+
} catch {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
if (Number.isNaN(Date.parse(wire?.until))) return
|
|
105
|
+
seen.add(el)
|
|
106
|
+
tick(el, wire, `${rootKey}|${el.id || index}`)
|
|
107
|
+
})
|
|
108
|
+
for (const el of timers.keys()) if (!seen.has(el)) clear(el)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// A morph of the root or of anything in it (turbo:morph-element bubbles,
|
|
112
|
+
// once per morphed element), a stream rendered into it, a tab woken up:
|
|
113
|
+
// one sync for all of them, after the morph is done.
|
|
114
|
+
const later = () => {
|
|
115
|
+
if (queued) return
|
|
116
|
+
queued = true
|
|
117
|
+
queueMicrotask(sync)
|
|
118
|
+
}
|
|
119
|
+
const woke = () => document.visibilityState === "visible" && sync()
|
|
120
|
+
root.addEventListener("turbo:morph-element", later)
|
|
121
|
+
root.addEventListener("reactive:streamed", later)
|
|
122
|
+
document.addEventListener("visibilitychange", woke)
|
|
123
|
+
wired.set(controller, () => {
|
|
124
|
+
root.removeEventListener("turbo:morph-element", later)
|
|
125
|
+
root.removeEventListener("reactive:streamed", later)
|
|
126
|
+
document.removeEventListener("visibilitychange", woke)
|
|
127
|
+
for (const el of [...timers.keys()]) clear(el)
|
|
128
|
+
})
|
|
129
|
+
sync()
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function disconnect(controller) {
|
|
133
|
+
wired.get(controller)?.()
|
|
134
|
+
wired.delete(controller)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function paint(el, text, state) {
|
|
138
|
+
if (el.textContent !== text) el.textContent = text
|
|
139
|
+
if (el.getAttribute(STATE) !== state) el.setAttribute(STATE, state)
|
|
140
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var g=new Map,l=new WeakMap,A=0,f=new WeakMap;function M(s,c){let n=s.element;if(!n.id&&!l.has(n))l.set(n,`#${++A}`);let S=n.id||l.get(n),r=new Map,m=!1,h=(t)=>{clearTimeout(r.get(t)),r.delete(t)},p=(t,o,e)=>{h(t);let i=Date.parse(o.until)-Date.now();if(!(i>0))return y(t,o,e);let a=Math.ceil(i/1000);E(t,`${Math.floor(a/60)}:${String(a%60).padStart(2,"0")}`,"running"),u(o.waiting,!0),u(o.done,!1),r.set(t,setTimeout(()=>p(t,o,e),(i-1)%1000+1))},y=(t,o,e)=>{E(t,"0:00","done"),u(o.waiting,!1),u(o.done,!0);let i=g.get(e)??new Set;if(i.has(o.until))return;g.set(e,i.add(o.until)),t.dispatchEvent(new CustomEvent("reactive:countdown-done",{bubbles:!0,detail:{until:o.until}}))},u=(t,o)=>{let e;try{e=t&&n.querySelector(t)}catch{}if(e&&e.hidden===o)e.hidden=!o},v=()=>{if(m=!1,!f.has(s))return;let t=new Set;[...n.matches("[data-reactive-countdown]")?[n]:[],...n.querySelectorAll("[data-reactive-countdown]")].forEach((e,i)=>{if(!c.owns(e))return;let a;try{a=JSON.parse(e.getAttribute("data-reactive-countdown"))}catch{return}if(Number.isNaN(Date.parse(a?.until)))return;t.add(e),p(e,a,`${S}|${e.id||i}`)});for(let e of r.keys())if(!t.has(e))h(e)},d=()=>{if(m)return;m=!0,queueMicrotask(v)},b=()=>document.visibilityState==="visible"&&v();n.addEventListener("turbo:morph-element",d),n.addEventListener("reactive:streamed",d),document.addEventListener("visibilitychange",b),f.set(s,()=>{n.removeEventListener("turbo:morph-element",d),n.removeEventListener("reactive:streamed",d),document.removeEventListener("visibilitychange",b);for(let t of[...r.keys()])h(t)}),v()}function w(s){f.get(s)?.(),f.delete(s)}function E(s,c,n){if(s.textContent!==c)s.textContent=c;if(s.getAttribute("data-reactive-countdown-state")!==n)s.setAttribute("data-reactive-countdown-state",n)}export{M as connect,w as disconnect};
|
|
2
|
+
|
|
3
|
+
//# debugId=BEA93E2782D7855864756E2164756E21
|
|
4
|
+
//# sourceMappingURL=countdown.min.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["features/countdown.js"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"// phlex/reactive/features/countdown — a deadline counted down on the client\n// (issue #400). One of the feature modules the core imports on demand (issue\n// #275); in the default client it is part of the one file.\n//\n// The markup is the Ruby side's (reactive_countdown):\n//\n// data-reactive-countdown='{\"until\":\"<ISO8601>\",\"format\":\"ms\",\"waiting\":\"#wait\",\"done\":\"#done\"}'\n//\n// Every tick reads Date.now against the deadline, so a late tick (a throttled\n// background tab, a slept laptop) paints the real remaining time, never a\n// count of missed ticks; a tab that becomes visible again re-reads at once.\n// The text is unpadded minutes, a colon and zero-padded seconds (\"1:30\"),\n// written as textContent only. The next tick is set for the moment the shown\n// second changes.\n//\n// At zero (or with the deadline already past on connect, which starts no\n// timer) the text is \"0:00\", data-reactive-countdown-state is \"done\", the\n// waiting: node hides, the done: node shows, and the element dispatches\n// reactive:countdown-done (bubbling) once. \"Once\" is per root id (a root\n// without one is its own element), countdown (its id, else its place in the\n// root) and deadline, kept for the life of the document: a morph or a replace\n// that keeps the deadline, or brings back one that already fired, paints the\n// done state again without a second event; a new deadline counts down afresh.\n// The countdown's content is its text: waiting: and done: are nodes beside it,\n// so a root that is itself the countdown has none.\n// No request, no frame reload: the page decides what the event does.\n//\n// This module never imports the core: it reaches a controller through the\n// `core` handle (core.owns).\n\nconst MARK = \"data-reactive-countdown\"\nconst STATE = \"data-reactive-countdown-state\"\n\n// \"<root id>|<countdown key>\" -> every deadline it already dispatched for.\nconst finished = new Map()\n// A root without an id: a number of its own, so two never share a key.\nconst anonymous = new WeakMap()\nlet anonymousSeq = 0\n// controller -> the removal of what connect() added.\nconst wired = new WeakMap()\n\nexport function connect(controller, core) {\n const root = controller.element\n if (!root.id && !anonymous.has(root)) anonymous.set(root, `#${++anonymousSeq}`)\n const rootKey = root.id || anonymous.get(root)\n // countdown element -> its pending timer.\n const timers = new Map()\n let queued = false\n\n const clear = (el) => {\n clearTimeout(timers.get(el))\n timers.delete(el)\n }\n\n const tick = (el, wire, key) => {\n clear(el)\n const left = Date.parse(wire.until) - Date.now()\n if (!(left > 0)) return finish(el, wire, key)\n const seconds = Math.ceil(left / 1000)\n paint(el, `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, \"0\")}`, \"running\")\n show(wire.waiting, true)\n show(wire.done, false)\n timers.set(\n el,\n setTimeout(() => tick(el, wire, key), ((left - 1) % 1000) + 1),\n )\n }\n\n const finish = (el, wire, key) => {\n paint(el, \"0:00\", \"done\")\n show(wire.waiting, false)\n show(wire.done, true)\n const fired = finished.get(key) ?? new Set()\n if (fired.has(wire.until)) return\n finished.set(key, fired.add(wire.until))\n el.dispatchEvent(new CustomEvent(\"reactive:countdown-done\", { bubbles: true, detail: { until: wire.until } }))\n }\n\n // A selector that is not valid CSS is ignored, never a stopped clock.\n const show = (selector, visible) => {\n let node\n try {\n node = selector && root.querySelector(selector)\n } catch {}\n if (node && node.hidden === visible) node.hidden = !visible\n }\n\n // Every countdown this root owns, from scratch: a morph may have changed a\n // deadline, written the server's text back, or removed a countdown.\n const sync = () => {\n queued = false\n // A morph that also removed the root: disconnect ran first.\n if (!wired.has(controller)) return\n const seen = new Set()\n const els = [...(root.matches(`[${MARK}]`) ? [root] : []), ...root.querySelectorAll(`[${MARK}]`)]\n els.forEach((el, index) => {\n if (!core.owns(el)) return\n let wire\n try {\n wire = JSON.parse(el.getAttribute(MARK))\n } catch {\n return\n }\n if (Number.isNaN(Date.parse(wire?.until))) return\n seen.add(el)\n tick(el, wire, `${rootKey}|${el.id || index}`)\n })\n for (const el of timers.keys()) if (!seen.has(el)) clear(el)\n }\n\n // A morph of the root or of anything in it (turbo:morph-element bubbles,\n // once per morphed element), a stream rendered into it, a tab woken up:\n // one sync for all of them, after the morph is done.\n const later = () => {\n if (queued) return\n queued = true\n queueMicrotask(sync)\n }\n const woke = () => document.visibilityState === \"visible\" && sync()\n root.addEventListener(\"turbo:morph-element\", later)\n root.addEventListener(\"reactive:streamed\", later)\n document.addEventListener(\"visibilitychange\", woke)\n wired.set(controller, () => {\n root.removeEventListener(\"turbo:morph-element\", later)\n root.removeEventListener(\"reactive:streamed\", later)\n document.removeEventListener(\"visibilitychange\", woke)\n for (const el of [...timers.keys()]) clear(el)\n })\n sync()\n}\n\nexport function disconnect(controller) {\n wired.get(controller)?.()\n wired.delete(controller)\n}\n\nfunction paint(el, text, state) {\n if (el.textContent !== text) el.textContent = text\n if (el.getAttribute(STATE) !== state) el.setAttribute(STATE, state)\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "AAkCA,IAAM,EAAW,IAAI,IAEf,EAAY,IAAI,QAClB,EAAe,EAEb,EAAQ,IAAI,QAEX,SAAS,CAAO,CAAC,EAAY,EAAM,CACxC,IAAM,EAAO,EAAW,QACxB,GAAI,CAAC,EAAK,IAAM,CAAC,EAAU,IAAI,CAAI,EAAG,EAAU,IAAI,EAAM,IAAI,EAAE,GAAc,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G7B,gCA2GiD,CAAK",
|
|
8
|
+
"debugId": "BEA93E2782D7855864756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// persist_clear client op runs.
|
|
5
5
|
//
|
|
6
6
|
// A root that declares
|
|
7
|
-
// data-reactive-persist='{"key","ttl","debounce"[,"fields"][,"restore"]}'
|
|
8
|
-
// keeps a localStorage draft of every persistable OWNED control (write on
|
|
7
|
+
// data-reactive-persist='{"key","ttl","debounce"[,"fields"][,"restore"][,"storage"]}'
|
|
8
|
+
// keeps a localStorage (or, with "storage":"session", sessionStorage) draft of every persistable OWNED control (write on
|
|
9
9
|
// input/change, restore on connect, clear on a successful submit / TTL / the
|
|
10
10
|
// persist_clear op). The storage layer is MODULE-LEVEL and keyed on the root
|
|
11
11
|
// element — the per-root connect/write path and the persist_state /
|
|
@@ -105,8 +105,12 @@ function persistPayload(root) {
|
|
|
105
105
|
return null
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
// The store the root selected: sessionStorage for {"storage":"session"}
|
|
109
|
+
// (issue #397 — this tab only), else localStorage. Never the other one: a
|
|
110
|
+
// missing sessionStorage is "no draft", not a fallback that outlives the tab.
|
|
111
|
+
function persistStorage(payload) {
|
|
109
112
|
try {
|
|
113
|
+
if (payload.storage === "session") return typeof sessionStorage === "undefined" ? null : sessionStorage
|
|
110
114
|
return typeof localStorage === "undefined" ? null : localStorage
|
|
111
115
|
} catch {
|
|
112
116
|
return null // the accessor itself can throw (blocked site data)
|
|
@@ -129,7 +133,7 @@ function persistKeyFor(payload) {
|
|
|
129
133
|
// version, or expired (an expired draft is REMOVED on read). Returns
|
|
130
134
|
// { fields, state } with state null when the draft carries none.
|
|
131
135
|
function persistRead(root, payload) {
|
|
132
|
-
const store = persistStorage()
|
|
136
|
+
const store = persistStorage(payload)
|
|
133
137
|
if (!store) return null
|
|
134
138
|
let raw
|
|
135
139
|
try {
|
|
@@ -157,7 +161,7 @@ function persistRead(root, payload) {
|
|
|
157
161
|
}
|
|
158
162
|
|
|
159
163
|
function persistWrite(root, payload, { fields, state }) {
|
|
160
|
-
const store = persistStorage()
|
|
164
|
+
const store = persistStorage(payload)
|
|
161
165
|
if (!store) return false
|
|
162
166
|
const draft = { v: PERSIST_VERSION, savedAt: Date.now(), fields }
|
|
163
167
|
if (state) draft.state = state
|
|
@@ -172,7 +176,7 @@ function persistWrite(root, payload, { fields, state }) {
|
|
|
172
176
|
|
|
173
177
|
function persistRemove(root, payload) {
|
|
174
178
|
root?.removeAttribute?.(PERSIST_STATE_ATTR)
|
|
175
|
-
const store = persistStorage()
|
|
179
|
+
const store = persistStorage(payload)
|
|
176
180
|
if (!store) return
|
|
177
181
|
try {
|
|
178
182
|
store.removeItem(persistKeyFor(payload))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var m;function
|
|
1
|
+
var m;function se(e){m=e}var L=1,V="phlex-reactive:persist:",G=new Set(["hidden","file","password","submit","button","reset","image"]),A=Symbol("persist-no-value"),k="data-reactive-persist-state",q=":is(lexxy-editor, trix-editor, [contenteditable=''], [contenteditable=true], [contenteditable=plaintext-only])",H=new Set(["lexxy-editor","trix-editor"]),B="lexxy-editor, trix-editor, trix-toolbar",U=["lexxy:change","trix-change"],X=new Set(["","<p></p>","<p><br></p>","<div><br></div>"]),I=new WeakSet,P=new WeakSet,C=new WeakSet;function S(e){let t=e?.getAttribute?.("data-reactive-persist");if(!t||t==="off")return null;try{let s=JSON.parse(t);if(s&&typeof s==="object"&&typeof s.key==="string"&&s.key!=="")return s}catch{}if(!I.has(e))I.add(e),console.warn(`[phlex-reactive] malformed reactive_persist payload ${JSON.stringify(t)} — persistence disabled`);return null}function T(e){try{if(e.storage==="session")return typeof sessionStorage>"u"?null:sessionStorage;return typeof localStorage>"u"?null:localStorage}catch{return null}}function N(e,t){if(e?.getAttribute?.("data-reactive-debug")!=="true"||P.has(e))return;P.add(e),console.info(`[phlex-reactive] reactive_persist: storage unavailable — draft skipped (${t?.name??t})`)}function R(e){return V+e.key}function b(e,t){let s=T(t);if(!s)return null;let n;try{n=s.getItem(R(t))}catch(u){return N(e,u),null}if(!n)return null;let i;try{i=JSON.parse(n)}catch{return null}if(!i||typeof i!=="object"||i.v!==L)return null;let r=Number(t.ttl)*1000;if(!(Number(i.savedAt)+r>Date.now()))return h(e,t),null;let c=i.fields&&typeof i.fields==="object"?i.fields:{},o=i.state&&typeof i.state==="object"?i.state:null;return{fields:c,state:o}}function O(e,t,{fields:s,state:n}){let i=T(t);if(!i)return!1;let r={v:L,savedAt:Date.now(),fields:s};if(n)r.state=n;try{return i.setItem(R(t),JSON.stringify(r)),!0}catch(c){return N(e,c),!1}}function h(e,t){e?.removeAttribute?.(k);let s=T(t);if(!s)return;try{s.removeItem(R(t))}catch(n){N(e,n)}}function g(e,t){let s=Array.isArray(t.fields)?new Set(t.fields):null,n=[],i=(r)=>r.closest('[data-controller~="reactive"]')===e&&r.getAttribute("data-reactive-persist")!=="off";for(let r of e.querySelectorAll("input[name], select[name], textarea[name]")){if(!i(r)||G.has(r.type)||r.closest(B))continue;if(s&&!s.has(r.name))continue;n.push({el:r,name:r.name,kind:"native"})}for(let r of e.querySelectorAll(q)){if(!i(r))continue;let c=Y(r);if(!c||s&&!s.has(c))continue;n.push({el:r,name:c,kind:H.has(r.localName)?"editor":"contenteditable"})}return n}function D(e){return e.hasAttribute("data-reactive-editable")?m.text(e):e.textContent??""}function Y(e){return e.getAttribute("name")||typeof e.name==="string"&&e.name||null}function v(e){return typeof e.value==="string"}function W(e){if(typeof e.isEmpty==="boolean")return e.isEmpty;let t=e.editor?.getDocument?.();if(typeof t?.isEmpty==="function")return t.isEmpty();return X.has(e.value.trim())}function K(e,t,s){if(e?.getAttribute?.("data-reactive-debug")!=="true"||C.has(e))return;C.add(e),console.info(`[phlex-reactive] reactive_persist: could not restore editor ${JSON.stringify(t)} — ${s?.message??s}`)}function y(e){return e.tagName==="SELECT"&&e.multiple}function j(e){let t=new Map;for(let{el:s,name:n}of e){if(s.type==="radio"||!String(n).endsWith("[]"))continue;t.set(n,(t.get(n)??0)+1)}return t}function M(e,t,s){if(!Array.isArray(e))return e;if(s.get(t)!==1||e.length!==1)return A;return e[0]}function _(e,t){let s={},n=(i)=>{let r=s[i];return Array.isArray(r)?r:s[i]=[]};for(let{el:i,name:r,kind:c}of g(e,t)){let o=String(r).endsWith("[]");if(c==="editor"){if(v(i))if(o)n(r).push(i.value);else s[r]=i.value}else if(c==="contenteditable"){let u=D(i);if(o)n(r).push(u);else s[r]=u}else if(i.type==="radio"){if(i.checked)s[r]=i.value;else if(!Object.hasOwn(s,r))s[r]=null}else if(i.type==="checkbox")if(o){let u=n(r);if(i.checked)u.push(i.value)}else s[r]=i.checked;else if(y(i)){let u=[...i.options].filter((f)=>f.selected).map((f)=>f.value);if(o)n(r).push(...u);else s[r]=u}else if(o)n(r).push(i.value);else s[r]=i.value}return s}function Q(e,t,s){let n=t.restore==="always",i=g(e,t),r=j(i),c=new Set;for(let o of i)if(o.kind==="native"&&o.el.type==="checkbox"&&o.el.checked)c.add(o.name);for(let{el:o,name:u,kind:f}of i){if(!Object.hasOwn(s,u))continue;let a=s[u];if(a===null||a===void 0)continue;if(Array.isArray(a)&&y(o)&&(r.get(u)??0)>1)continue;if(Array.isArray(a)&&!(o.type==="checkbox"||y(o))){if(a=M(a,u,r),a===A)continue}if((o.type==="checkbox"||y(o))&&String(u).endsWith("[]")&&!Array.isArray(a))continue;if(f==="editor")J(e,o,u,a,n);else if(f==="contenteditable"){if(!n&&D(o).trim()!=="")continue;o.textContent=String(a)}else if(o.type==="radio"){if(!n&&i.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(!n&&c.has(u))continue;o.checked=a.map(String).includes(o.value)}else if(o.type==="checkbox"){if(!n&&o.checked)continue;o.checked=Boolean(a)}else if(y(o)){if(!n&&[...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(!n&&o.value!=="")continue;o.value=String(a)}}Z(e,t,s)}function J(e,t,s,n,i){if(Array.isArray(n))return;if(!v(t))return;if(!i&&!W(t))return;try{t.value=String(n)}catch(r){K(e,s,r)}}function Z(e,t,s){let n=globalThis.customElements;if(typeof n?.whenDefined!=="function")return;let i=new Set;for(let c of e.querySelectorAll("lexxy-editor, trix-editor"))if(!v(c)&&!n.get?.(c.localName))i.add(c.localName);let r=t.restore==="always";for(let c of i)n.whenDefined(c).then(()=>{if(!e.isConnected)return;let o=g(e,t),u=j(o);for(let{el:f,name:a,kind:p}of o){if(p!=="editor"||f.localName!==c||!Object.hasOwn(s,a))continue;let d=M(s[a],a,u);if(d===null||d===void 0||d===A)continue;J(e,f,a,d,r)}})}function ee(e,t,s=!0){let n=S(e);if(!n){console.warn("[phlex-reactive] persist_state on a root without reactive_persist — skipped");return}if(!t||typeof t!=="object")return;let i=b(e,n),r={...i?.state??{},...t},c=s?_(e,n):i?.fields??{};if(O(e,n,{fields:c,state:r}))e.setAttribute?.(k,JSON.stringify(r))}function te(e){let t=S(e);if(t)h(e,t)}var w=new WeakMap,x=new WeakMap;function ne(e,t){if(typeof e?.addEventListener!=="function")return()=>{};let s=x.get(e);if(!s){let r=new Set,c=(o)=>{for(let u of r)u(o)};e.addEventListener("turbo:submit-end",c),s=[r,c],x.set(e,s)}let[n,i]=s;return n.add(t),()=>{if(n.delete(t),n.size>0)return;e.removeEventListener?.("turbo:submit-end",i),x.delete(e)}}function re(e,t,s,n){let i=e.element,r=S(i);if(!r)return;if(n?.submitted)h(i,r);let c=b(i,r);if(c){if(Q(i,r,c.fields),c.state)i.setAttribute?.(k,JSON.stringify(c.state));t.emit("reactive:persist-restored",{key:r.key,fields:c.fields,state:c.state??{}}),t.reseed()}let o=null,u=()=>{if(o!==null)clearTimeout(o),o=null},f=()=>{u();let l=b(i,r);O(i,r,{fields:_(i,r),state:l?.state??null})},a=()=>{let l=Number(r.debounce)||0;if(l<=0)return f();if(o!==null)clearTimeout(o);o=setTimeout(()=>{o=null,f()},l)},p=(l)=>{if(!l?.detail?.success)return;let E=l.target;if(E?.tagName!=="FORM"||typeof E.contains!=="function")return;if(!E.contains(i))return;u(),h(i,r)},d=["input",...U];for(let l of d)i.addEventListener?.(l,a);i.addEventListener?.("change",f);let z=ne(globalThis.document,p);if(w.set(e,()=>{if(o!==null)f();for(let l of d)i.removeEventListener?.(l,a);i.removeEventListener?.("change",f),z()}),n?.edited&&!n.submitted)f();for(let l of n?.ops??[])l(!0)}function oe(e,t){if(!t)return;let s=S(e);if(!s)return;if(t.submitted)return h(e,s);if(t.edited){let n=b(e,s),i={...n?.fields},r=_(e,s);for(let c of ie(e,s))if(Object.hasOwn(r,c))i[c]=r[c];O(e,s,{fields:i,state:n?.state??null})}for(let n of t.ops??[])n(!1)}function ie(e,t){let s=new Set;for(let{el:n,name:i,kind:r}of g(e,t))if(r==="editor"?v(n)&&!W(n):r==="contenteditable"?n.hasAttribute("data-reactive-editable")?m.text(n)!==m.served(n):(n.textContent??"").trim()!=="":n.type==="checkbox"||n.type==="radio"?n.checked!==n.defaultChecked:n.tagName==="SELECT"?[...n.options].some((o)=>o.selected!==o.hasAttribute("selected")):n.value!==n.defaultValue)s.add(i);return s}function ce(e){let t=w.get(e);w.delete(e),t?.()}function F(e,t){let s=m?.waiting.get(e)?.persist;if(!s||!S(e))return t(!0);(s.ops??=[]).push(t)}function ae(e,t){F(e,(s)=>ee(e,t,s))}function ue(e){F(e,()=>te(e))}export{q as PERSIST_EDITOR_SELECTOR,H as PERSIST_EDITOR_TAGS,oe as abandon,ue as clearRoot,re as connect,ce as disconnect,se as install,ae as writeState};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=A902A72D95342CD264756E2164756E21
|
|
4
4
|
//# sourceMappingURL=persist.min.js.map
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["features/persist.js"],
|
|
4
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// A contenteditable's text: a reactive_editable through the core's collector\n// (issue #351 — line breaks kept, as the request sends it), a bare one as its\n// textContent (#241).\nfunction persistText(el) {\n return el.hasAttribute(\"data-reactive-editable\") ? shared.text(el) : (el.textContent ?? \"\")\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 = persistText(el)\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 && persistText(el).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// document -> the submit-end handlers of its persisted roots. One document\n// listener serves them all: a listener per root made connecting and\n// disconnecting N persisted roots quadratic (the browser scans a target's\n// listeners on each add and remove). Added with the first root, removed with\n// the last. Returns the handler's removal.\nconst submitEnds = new WeakMap()\n\nfunction onSubmitEndOf(doc, handler) {\n if (typeof doc?.addEventListener !== \"function\") return () => {}\n let shared = submitEnds.get(doc)\n if (!shared) {\n const handlers = new Set()\n const listener = (event) => {\n for (const run of handlers) run(event)\n }\n doc.addEventListener(\"turbo:submit-end\", listener)\n shared = [handlers, listener]\n submitEnds.set(doc, shared)\n }\n const [handlers, listener] = shared\n handlers.add(handler)\n return () => {\n handlers.delete(handler)\n if (handlers.size > 0) return\n doc.removeEventListener?.(\"turbo:submit-end\", listener)\n submitEnds.delete(doc)\n }\n}\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 const offSubmitEnd = onSubmitEndOf(globalThis.document, 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 offSubmitEnd()\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.hasAttribute(\"data-reactive-editable\")\n ? shared.text(el) !== shared.served(el)\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"
|
|
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\"][,\"storage\"]}'\n// keeps a localStorage (or, with \"storage\":\"session\", sessionStorage) 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\n// The store the root selected: sessionStorage for {\"storage\":\"session\"}\n// (issue #397 — this tab only), else localStorage. Never the other one: a\n// missing sessionStorage is \"no draft\", not a fallback that outlives the tab.\nfunction persistStorage(payload) {\n try {\n if (payload.storage === \"session\") return typeof sessionStorage === \"undefined\" ? null : sessionStorage\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(payload)\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(payload)\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(payload)\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// A contenteditable's text: a reactive_editable through the core's collector\n// (issue #351 — line breaks kept, as the request sends it), a bare one as its\n// textContent (#241).\nfunction persistText(el) {\n return el.hasAttribute(\"data-reactive-editable\") ? shared.text(el) : (el.textContent ?? \"\")\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 = persistText(el)\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 && persistText(el).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// document -> the submit-end handlers of its persisted roots. One document\n// listener serves them all: a listener per root made connecting and\n// disconnecting N persisted roots quadratic (the browser scans a target's\n// listeners on each add and remove). Added with the first root, removed with\n// the last. Returns the handler's removal.\nconst submitEnds = new WeakMap()\n\nfunction onSubmitEndOf(doc, handler) {\n if (typeof doc?.addEventListener !== \"function\") return () => {}\n let shared = submitEnds.get(doc)\n if (!shared) {\n const handlers = new Set()\n const listener = (event) => {\n for (const run of handlers) run(event)\n }\n doc.addEventListener(\"turbo:submit-end\", listener)\n shared = [handlers, listener]\n submitEnds.set(doc, shared)\n }\n const [handlers, listener] = shared\n handlers.add(handler)\n return () => {\n handlers.delete(handler)\n if (handlers.size > 0) return\n doc.removeEventListener?.(\"turbo:submit-end\", listener)\n submitEnds.delete(doc)\n }\n}\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 const offSubmitEnd = onSubmitEndOf(globalThis.document, 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 offSubmitEnd()\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.hasAttribute(\"data-reactive-editable\")\n ? shared.text(el) !== shared.served(el)\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
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,QAC1B,EAAqB,IAAI,QAI/B,SAAS,CAAc,CAAC,EAAM,CAC5B,IAAM,EAAM,GAAM,eAAe,uBAAuB,EACxD,GAAI,CAAC,GAAO,IAAQ,MAAO,OAAO,KAClC,GAAI,C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
@@ -34,6 +34,7 @@ import * as bindings from "phlex/reactive/features/bindings"
|
|
|
34
34
|
import * as compute from "phlex/reactive/features/compute"
|
|
35
35
|
import * as sortable from "phlex/reactive/features/sortable"
|
|
36
36
|
import * as presence from "phlex/reactive/features/presence"
|
|
37
|
+
import * as countdown from "phlex/reactive/features/countdown"
|
|
37
38
|
import * as effects from "phlex/reactive/features/effects"
|
|
38
39
|
import * as hints from "phlex/reactive/features/hints"
|
|
39
40
|
import * as devtools from "phlex/reactive/features/devtools"
|
|
@@ -67,6 +68,7 @@ if (__SPLIT__) {
|
|
|
67
68
|
registerReactiveFeature("compute", { connect: compute.connect, disconnect: compute.disconnect, seed: compute.seed, recompute: compute.recompute })
|
|
68
69
|
registerReactiveFeature("sortable", { connect: sortable.connect, disconnect: sortable.disconnect })
|
|
69
70
|
registerReactiveFeature("presence", { connect: presence.connect, disconnect: presence.disconnect, set: presence.set })
|
|
71
|
+
registerReactiveFeature("countdown", { connect: countdown.connect, disconnect: countdown.disconnect })
|
|
70
72
|
registerReactiveFeature("effects", { wrap: effects.wrap, sweep: effects.sweep })
|
|
71
73
|
registerReactiveFeature("hints", { optimistic: hints.optimistic, busy: hints.busy, resurrection: hints.resurrection })
|
|
72
74
|
registerReactiveFeature("devtools", {
|