haori 0.41.2 → 0.41.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +1 -1
- package/README.md +1 -1
- package/dist/haori.cjs.js +2 -2
- package/dist/haori.es.js +35 -8
- package/dist/haori.iife.js +2 -2
- package/dist/index.d.ts +8 -5
- package/package.json +1 -1
package/README.ja.md
CHANGED
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Haori.js is a lightweight, HTML-first UI library that enables dynamic user interfaces primarily through HTML attributes. It lets you declare data bindings, conditional rendering, list rendering, form two-way binding, server fetches, and HTML imports without writing much JavaScript.
|
|
4
4
|
|
|
5
|
-
Version: 0.41.
|
|
5
|
+
Version: 0.41.3
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
package/dist/haori.cjs.js
CHANGED
|
@@ -24,6 +24,6 @@ ${R}
|
|
|
24
24
|
${r}
|
|
25
25
|
);`)}catch{try{i=new Function(`"use strict";
|
|
26
26
|
${r}
|
|
27
|
-
`)}catch(n){m.error("[Haori]",`Invalid each-rendered-run script: ${n}`)}}if(i)try{i.call(e)}catch(n){m.error("[Haori]",`each-rendered-run execution error: ${n}`)}}static runEachRenderedChange(e){const t=`${u.prefix}each-rendered-change`,r=e.getTarget();if(!r.hasAttribute(t))return;const i=String(r.getAttribute(t)??"").trim().toLowerCase();let n=!1;if(i==="always"?n=!0:i!==""&&i!=="once"&&(f.EACH_RENDERED_CHANGE_WARNED.has(r)||(f.EACH_RENDERED_CHANGE_WARNED.add(r),m.warn("[Haori]",`Invalid ${t} value: "${i}". Use "once" (default) or "always".`))),f.countEachRenderedRows(e)!==0){if(!n){if(f.EACH_RENDERED_CHANGE_FIRED.has(r))return;f.EACH_RENDERED_CHANGE_FIRED.add(r)}try{r.dispatchEvent(new Event("change",{bubbles:!0}))}catch(s){m.error("[Haori]",`each-rendered-change dispatch error: ${s}`)}}}static countEachRenderedRows(e){let t=0;for(const r of e.getChildElementFragments())r.getTarget().hasAttribute(`${u.prefix}row`)&&(t+=1);return t}static performEachUpdate(e){const t=f.resolveEachItems(e);if(t===null)return Promise.reject(new Error("Invalid each attribute."));let r=e.getTemplate();const i=e.getAttribute(`${u.prefix}each-key`),n=f.createBindingSignature({key:i?String(i):null,items:t});if(r===null){let s=!1;if(e.getChildren().forEach(a=>{if(!s&&a instanceof T){if(a.hasAttribute(`${u.prefix}each-before`)||a.hasAttribute(`${u.prefix}each-after`))return;r=a.clone(),f.markFreshInitializationSkippable(r),e.setTemplate(r),s=!0,e.removeChild(a);const o=a.getTarget();o.parentNode&&o.parentNode.removeChild(o),a.setMounted(!1)}}),!s){const a=e.getTarget();Array.from(a.children).filter(l=>!l.hasAttribute(`${u.prefix}each-before`)&&!l.hasAttribute(`${u.prefix}each-after`)).forEach(l=>{if(!s){const d=N.get(l);d instanceof T&&(r=d.clone(),f.markFreshInitializationSkippable(r),e.setTemplate(r),s=!0)}const c=N.get(l);c instanceof T&&e.getChildren().includes(c)&&(e.removeChild(c),c.setMounted(!1)),l.parentNode&&l.parentNode.removeChild(l)})}return this.updateDiff(e,t).then(()=>{e.setEachInputSignature(n)})}return e.getEachInputSignature()===n?f.reevaluateEachRows(e):this.updateDiff(e,t).then(()=>{e.setEachInputSignature(n)})}static reevaluateEachRows(e){if(f.isRowLocalEachTemplate(e))return Promise.resolve();const t=e.getChildElementFragments().filter(r=>!r.hasAttribute(`${u.prefix}each-before`)&&!r.hasAttribute(`${u.prefix}each-after`));return t.length===0?Promise.resolve():Promise.all(t.map(r=>f.evaluateAll(r))).then(()=>{})}static resolveEachItems(e){const t=e.getAttributeEvaluation(`${u.prefix}each`),r=t?.value;return t?.hasUnresolvedReference||r===!1||r===null||r===void 0?[]:Array.isArray(r)?r:(m.error("[Haori]","Invalid each attribute:",r),null)}static canSkipUnchangedNestedEach(e){if(!e.hasAttribute(`${u.prefix}each`)||e.getEachInputSignature()===null)return!1;const t=e.getParent();if(t?.closestByAttribute(`${u.prefix}derive`)||t?.closestByAttribute(`${u.prefix}derive-name`)||t?.closestByAttribute(`${u.prefix}if`)||t?.closestByAttribute(`${u.prefix}fetch`)||t?.closestByAttribute(`${u.prefix}import`)||f.hasNonEachDynamicElementState(e)||!f.isRowLocalEachTemplate(e))return!1;const r=f.resolveEachItems(e);if(r===null)return!1;const i=e.getAttribute(`${u.prefix}each-key`),n=f.createBindingSignature({key:i?String(i):null,items:r});return e.getEachInputSignature()===n}static isRowLocalEachTemplate(e){const t=e.getRowLocalTemplate();if(t!==null)return t;const r=e.getTemplate(),i=e.getAttribute(`${u.prefix}each-arg`);if(r===null||!i)return e.setRowLocalTemplate(!1),!1;const n=new Set([String(i)]),s=e.getAttribute(`${u.prefix}each-index`);s&&n.add(String(s));const a=f.isRowLocalSubtree(r,n);return e.setRowLocalTemplate(a),a}static isRowLocalSubtree(e,t){for(const i of e.getAttributeNames()){const n=e.getRawAttribute(i),s=typeof n=="string"?n:"";if(s.includes("{{")){if(!f.areExpressionsRowLocal(f.extractInterpolations(s),t))return!1;continue}if(!i.startsWith(u.prefix))continue;const a=i.slice(u.prefix.length);if(f.ROW_LOCAL_EXPRESSION_ATTRIBUTES.has(a)){if(!f.areExpressionsRowLocal([s],t))return!1;continue}if(!f.ROW_LOCAL_STATIC_ATTRIBUTES.has(a))return!1}let r=t;if(e.hasAttribute(`${u.prefix}each`)){const i=e.getRawAttribute(`${u.prefix}each-arg`);if(typeof i!="string"||i==="")return!1;const n=new Set(t);n.add(i);const s=e.getRawAttribute(`${u.prefix}each-index`);typeof s=="string"&&s!==""&&n.add(s),r=n}for(const i of e.getChildren())if(i instanceof T){if(!f.isRowLocalSubtree(i,r))return!1}else if(i instanceof Q){const n=i.getRawText();if(n.includes("{{")&&!f.areExpressionsRowLocal(f.extractInterpolations(n),t))return!1}return!0}static areExpressionsRowLocal(e,t){for(const r of e){const i=r.trim();if(i==="")continue;const n=J.getFreeIdentifiers(i);if(n.length===0||n.some(s=>!t.has(s)))return!1}return!0}static extractInterpolations(e){const t=[],r=/\{\{([\s\S]*?)\}\}/g;let i=r.exec(e);for(;i!==null;)t.push(i[1]),i=r.exec(e);return t}static canSkipStableDerivedSubtree(e){return!e.hasAttribute(`${u.prefix}derive`)||e.hasAttribute(`${u.prefix}if`)||e.hasAttribute(`${u.prefix}each`)||e.hasAttribute(`${u.prefix}fetch`)||e.hasAttribute(`${u.prefix}import`)?!1:!f.hasDisallowedDerivedSubtreeDescendant(e)}static hasDisallowedDerivedSubtreeDescendant(e){return e.getChildren().some(t=>t instanceof T?t.hasAttribute(`${u.prefix}derive`)||t.hasAttribute(`${u.prefix}derive-name`)||t.hasAttribute(`${u.prefix}fetch`)||t.hasAttribute(`${u.prefix}import`)?!0:f.hasDisallowedDerivedSubtreeDescendant(t):!1)}static createDescendantBindingSignature(e,t){return f.recordDerivedSubtreeSignatureComputation(e,t),f.createBindingSignature(e.getDescendantBindingData())}static createDeriveInputSignature(e,t,r){const i=typeof r=="string"?r.trim():"";return!t||i===""?null:f.createBindingSignature({expression:t,name:i,scope:e.getBindingData()})}static refreshDerivedSubtreeSignature(e){if(!f.canSkipStableDerivedSubtree(e)){e.setDeriveSubtreeSignature(null),f.logDerivedSubtreeProfileSnapshot(e,"skip-ineligible");return}e.setDeriveSubtreeSignature(f.createDescendantBindingSignature(e,"refresh")),f.logDerivedSubtreeProfileSnapshot(e,"refresh")}static getOrCreateDerivedSubtreeProfile(e){if(!j.isEnabled()||!e.hasAttribute(`${u.prefix}derive`))return null;const t=f.DERIVE_SUBTREE_PROFILES.get(e);if(t)return t;const r={hostId:f.createDerivedSubtreeHostId(e),signatureComputeTotal:0,signatureComputeFromEvaluateAll:0,signatureComputeFromRefresh:0,skipHitCount:0,skipMissCount:0,skipIneligibleCount:0};return f.DERIVE_SUBTREE_PROFILES.set(e,r),r}static resolveElementId(e){return e.getAttribute("id")??""}static createDerivedSubtreeHostId(e){const t=[];let r=e;for(;r;){const i=r.getTarget();if(!(i instanceof HTMLElement))break;let n=i.tagName.toLowerCase();const s=f.resolveElementId(i).trim();if(s!==""){n+=`#${s}`,t.unshift(n);break}const a=r.getRawAttribute(`${u.prefix}derive-name`);typeof a=="string"&&a.trim()!==""&&(n+=`[${u.prefix}derive-name="${a.trim()}"]`);const o=r.getParent();if(o){const l=o.getChildren().filter(c=>c instanceof T).findIndex(c=>c===r);n+=`:nth-child(${l+1})`}t.unshift(n),r=o}return t.join(" > ")}static recordDerivedSubtreeSignatureComputation(e,t){const r=f.getOrCreateDerivedSubtreeProfile(e);if(r!==null){if(r.signatureComputeTotal+=1,t==="refresh"){r.signatureComputeFromRefresh+=1;return}r.signatureComputeFromEvaluateAll+=1}}static logDerivedSubtreeProfileSnapshot(e,t){const r=f.getOrCreateDerivedSubtreeProfile(e);r!==null&&(t==="skip-hit"?r.skipHitCount+=1:t==="skip-miss"?r.skipMissCount+=1:t==="skip-ineligible"&&(r.skipIneligibleCount+=1),m.info("[Haori][derive-profile]",{reason:t,hostId:r.hostId,signatureComputeTotal:r.signatureComputeTotal,signatureComputeFromEvaluateAll:r.signatureComputeFromEvaluateAll,signatureComputeFromRefresh:r.signatureComputeFromRefresh,skipHitCount:r.skipHitCount,skipMissCount:r.skipMissCount,skipIneligibleCount:r.skipIneligibleCount}))}static hasNonEachDynamicElementState(e){const t=new Set([`${u.prefix}each`,`${u.prefix}each-key`,`${u.prefix}each-arg`,`${u.prefix}each-index`]);return e.getAttributeNames().some(i=>{if(t.has(i))return!1;if(i.startsWith(`${u.prefix}attr-`)||i.startsWith(u.prefix))return!0;const n=e.getRawAttribute(i);return typeof n=="string"&&n.includes("{{")})?!0:e.getChildren().some(i=>i instanceof Q&&i.hasDynamicContent())}static markFreshInitializationSkippable(e){const t=e.getAttributeNames().some(n=>f.isFreshInitializationDynamicAttribute(e,n)),r=e.getChildren().some(n=>n instanceof T?!f.markFreshInitializationSkippable(n):n instanceof Q?n.hasDynamicContent():!1),i=!t&&!r;return e.setFreshInitializationSkippable(i),i}static isFreshInitializationDynamicAttribute(e,t){if(t.startsWith(`${u.prefix}attr-`)||t.startsWith(u.prefix))return!0;const r=e.getRawAttribute(t);return typeof r=="string"&&r.includes("{{")}static updateDiff(e,t){const r=e.getTemplate();if(r===null)return m.error("[Haori]","Template is not set for each element."),Promise.resolve();let i=e.getAttribute(`${u.prefix}each-index`);i&&(i=String(i));const n=e.getAttribute(`${u.prefix}each-key`),s=e.getAttribute(`${u.prefix}each-arg`),a=t.map((E,v)=>f.createListKey(E,n?String(n):null,v)),o=new Set(a),l=new Map;a.forEach(E=>{l.set(E,(l.get(E)??0)+1)}),n&&o.size!==a.length&&f.warnDuplicateEachKey(String(n));const c=[];let d=e.getChildren().filter(E=>E instanceof T).filter(E=>!E.hasAttribute(`${u.prefix}each-before`)&&!E.hasAttribute(`${u.prefix}each-after`));const h=d.map(E=>E.getListKey()),y=new Set;d=d.filter((E,v)=>{const R=String(E.getListKey()),k=l.get(R)??0;if(k===0){y.add(E);const x=E.getListKey();return x!==null&&H.rowRemove(E.getTarget(),x,v),c.push(E.remove()),!1}return l.set(R,k-1),!0});const A=d.map(E=>E.getListKey()),S=new Map;d.forEach(E=>{const v=E.getListKey();if(v===null)return;const R=S.get(v);R?R.push(E):S.set(v,[E])});const P=e.getChildElementFragments().filter(E=>!y.has(E)),D=P.filter(E=>E.hasAttribute(`${u.prefix}each-before`)).length;let L=Promise.resolve();return a.forEach((E,v)=>{const R=t[v],k=v;let x;const q=S.get(E)?.shift();if(q){x=q;const G=D+v;L=L.then(()=>f.updateRowFragment(x,R,i,k,s?String(s):null,E).then(_=>f.repositionEachRow(e,x,P,G).then(Z=>{if(Z!==null&&H.rowMove(x.getTarget(),E,Z-D,v),!!_)return f.clearUserEditMarks(x),f.evaluateAll(x).then(()=>f.applyRowFormValues(e,x,R))})))}else{x=r.clone();const G=D+v;L=L.then(()=>f.updateRowFragment(x,R,i,k,s?String(s):null,E).then(()=>{const _=P[G]??null;return e.insertBefore(x,_).then(()=>{P.splice(G,0,x)}).then(()=>f.initializeFreshEachRow(x)).then(()=>f.applyRowFormValues(e,x,R)).then(()=>{H.rowAdd(x.getTarget(),E,k,R)})}))}}),Promise.all(c).then(()=>L).then(()=>{const E=a.filter(G=>G!==null),v=A.filter(G=>G!==null),R=new Set(v),k=E.filter(G=>!R.has(G)),q=h.filter(G=>G!==null).filter(G=>!o.has(G));H.eachUpdate(e.getTarget(),k,q,E)})}static warnDuplicateEachKey(e){!j.isEnabled()||f.WARNED_DUPLICATE_EACH_KEYS.has(e)||(f.WARNED_DUPLICATE_EACH_KEYS.add(e),m.warn("[Haori]",`${u.prefix}each-key="${e}" の値が配列の中で重複しています。行は出現順で対応付けますが、キーによる行の識別はできません。`))}static repositionEachRow(e,t,r,i){const n=r.indexOf(t);if(n===-1||n===i)return Promise.resolve(null);r.splice(n,1);const s=r[i]??null;return r.splice(i,0,t),e.insertBefore(t,s).then(()=>n)}static applyRowFormValues(e,t,r){return!e.hasAttribute(`${u.prefix}form-list`)||!F.isCollectedListFromEachSource(e)||typeof r!="object"||r===null||Array.isArray(r)?Promise.resolve():F.syncRowValues(t,r)}static createListKey(e,t,r){let i;if(typeof e=="object"&&e!==null)if(t){const n=e[t];n==null?i=`__index_${r}`:typeof n=="object"?i=JSON.stringify(n):i=String(n)}else i=`__index_${r}`;else i=String(e);return i}static updateRowFragment(e,t,r,i,n,s){let a;if(typeof t=="object"&&t!==null)a=n?{[n]:{...t}}:{...t};else if(n)a={[n]:t};else return m.error("[Haori]",`Primitive value requires '${u.prefix}each-arg' attribute: ${t}`),Promise.resolve(!1);r&&(a[r]=i);const o=a,l=f.createBindingSignature({listKey:s,bindingData:o});return e.getListKey()===s&&e.getRenderSignature()===l?Promise.resolve(!1):(e.setListKey(s),e.setRenderSignature(l),e.setBindingData(o),e.setAttribute(`${u.prefix}row`,s).then(()=>!0))}static needsScheduledEvaluateAll(e){const t=[e];for(;t.length>0;){const r=t.pop();if(r.getChildElementFragments().forEach(i=>{t.push(i)}),r!==e&&!r.isMounted()&&f.hasMountSensitiveAttribute(r))return!0}return!1}static hasMountSensitiveAttribute(e){return["fetch","import"].some(t=>e.hasAttribute(`${u.prefix}${t}`))}static createBindingSignature(e,t=new WeakMap,r={value:0}){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);if(typeof e=="function")return`[Function:${e.name||"anonymous"}]`;if(typeof e=="symbol")return e.toString();if(e instanceof Date)return`[Date:${e.toISOString()}]`;if(typeof File<"u"&&e instanceof File)return`[File:${e.name}:${e.size}:${e.lastModified}:${e.type}]`;if(typeof Blob<"u"&&e instanceof Blob)return`[Blob:${e.size}:${e.type}]`;if(Array.isArray(e)){if(t.has(e))return`[Circular:${t.get(e)}]`;const i=`array-${r.value}`;return r.value+=1,t.set(e,i),`[${e.map(n=>f.createBindingSignature(n,t,r)).join(",")}]`}if(typeof e=="object"){if(t.has(e))return`[Circular:${t.get(e)}]`;const i=`object-${r.value}`;r.value+=1,t.set(e,i);const n=e;return`{${Object.keys(n).sort().map(s=>`${JSON.stringify(s)}:${f.createBindingSignature(n[s],t,r)}`).join(",")}}`}return String(e)}static scheduleEvaluateAll(e){setTimeout(()=>{f.evaluateAll(e)},100)}};f.ATTRIBUTE_ALIAS_SUFFIX="attr-",f.PRIORITY_ATTRIBUTE_SUFFIXES=["bind","store","url-param","derive-name","derive","if","each"],f.DEFERRED_ATTRIBUTE_SUFFIXES=["fetch"],f.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES=["bind","derive","derive-name","if","each","fetch","import","url-param","store","validity","validity-message"],f.ATTRIBUTE_PLACEHOLDER_REGEX=/\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/,f.ROW_LOCAL_EXPRESSION_ATTRIBUTES=new Set(["each","if","derive"]),f.ROW_LOCAL_STATIC_ATTRIBUTES=new Set(["each-arg","each-key","each-index","each-before","each-after","derive-name","row","form","form-arg","form-list","form-object","form-detach","store","store-params","store-arg","store-type","enhance","enhance-new"]),f.REACTIVE_FETCH_STATES=new WeakMap,f.REACTIVE_IMPORT_STATES=new WeakMap,f.DERIVE_SUBTREE_PROFILES=new WeakMap,f.EACH_UPDATE_STATES=new WeakMap,f.EACH_RENDERED_CHANGE_FIRED=new WeakSet,f.EACH_RENDERED_CHANGE_WARNED=new WeakSet,f.WARNED_DUPLICATE_EACH_KEYS=new Set,f.ABSENT_PATH=Symbol("absent");let O=f;const he=class he{constructor(e=document){this.customEventHandlers=new Map,this.builtinListenersAdded=!1,this.deferred=!1,this.deferredProcedures=[],this.onClick=t=>this.delegate(t,"click"),this.onChange=t=>this.delegate(t,"change"),this.onInput=t=>this.delegate(t,"input"),this.onLoadCapture=t=>this.delegate(t,"load"),this.onWindowLoad=()=>{if(this.deferred){this.deferredProcedures.push(()=>this.runWindowLoadProcedure());return}this.runWindowLoadProcedure()},this.onPopstate=t=>{const r=t.state;!r||r[he.HISTORY_STATE_KEY]!==!0||location.reload()},this.root=e}runWindowLoadProcedure(){const e=document.documentElement,t=N.get(e);t&&new te(t,"load").run()}start(){this.deferred=!1,this.addBuiltinListeners(),this.subscribeDeclaredCustomEvents(),this.observeCustomEventDeclarations()}startDeferred(){this.deferred=!0,this.addBuiltinListeners(),this.subscribeDeclaredCustomEvents()}release(){if(!this.deferred)return;this.deferred=!1,this.subscribeDeclaredCustomEvents(),this.observeCustomEventDeclarations();const e=this.deferredProcedures.splice(0);for(const t of e)try{t()}catch(r){m.error("[Haori]","Deferred event handling error:",r)}}addBuiltinListeners(){this.builtinListenersAdded||(this.builtinListenersAdded=!0,this.root.addEventListener("click",this.onClick),this.root.addEventListener("change",this.onChange),this.root.addEventListener("input",this.onInput),this.root.addEventListener("load",this.onLoadCapture,!0),window.addEventListener("load",this.onWindowLoad,{once:!0}),window.addEventListener("popstate",this.onPopstate))}stop(){this.root.removeEventListener("click",this.onClick),this.root.removeEventListener("change",this.onChange),this.root.removeEventListener("input",this.onInput),this.root.removeEventListener("load",this.onLoadCapture,!0),window.removeEventListener("load",this.onWindowLoad),window.removeEventListener("popstate",this.onPopstate),this.builtinListenersAdded=!1,this.deferred=!1,this.deferredProcedures.length=0;for(const[e,t]of this.customEventHandlers)window.removeEventListener(e,t,!0);this.customEventHandlers.clear(),this.customEventObserver?.disconnect(),this.customEventObserver=void 0}get onAttributeName(){return`${u.prefix}on`}subscribeDeclaredCustomEvents(){this.root.querySelectorAll(`[${this.onAttributeName}]`).forEach(t=>this.subscribeCustomEvent(t.getAttribute(this.onAttributeName)))}subscribeCustomEvent(e){if(e===null||e==="")return;if(he.BUILTIN_EVENT_NAMES.has(e)){m.warn("[Haori]",`data-on="${e}" は組み込みイベントです。data-${e}-* を使用してください(data-on はカスタムイベント専用)。`);return}if(this.customEventHandlers.has(e))return;const t=r=>this.runCustomEventProcedures(e,r);this.customEventHandlers.set(e,t),window.addEventListener(e,t,!0)}runCustomEventProcedures(e,t){if(this.deferred){this.deferredProcedures.push(()=>this.runCustomEventProcedures(e,t));return}this.root.querySelectorAll(`[${this.onAttributeName}]`).forEach(i=>{if(i.getAttribute(this.onAttributeName)!==e)return;const n=N.get(i);n instanceof T&&new te(n,"on",t).run().catch(s=>{m.error("[Haori]","Procedure execution error:",s)})})}observeCustomEventDeclarations(){if(typeof MutationObserver>"u")return;const e=this.root instanceof Document?this.root:this.root.ownerDocument??document,t=this.root instanceof Document?e.body:this.root;t&&(this.customEventObserver=new MutationObserver(r=>{for(const i of r)i.addedNodes.forEach(n=>{n instanceof HTMLElement&&(n.hasAttribute(this.onAttributeName)&&this.subscribeCustomEvent(n.getAttribute(this.onAttributeName)),n.querySelectorAll(`[${this.onAttributeName}]`).forEach(s=>this.subscribeCustomEvent(s.getAttribute(this.onAttributeName))))})}),this.customEventObserver.observe(t,{childList:!0,subtree:!0}))}delegate(e,t){const r=this.getElementFromTarget(e.target,t);if(r){if(t==="input"){const i=`${u.prefix}input-`;if(!r.getAttributeNames().some(s=>s.startsWith(i))){this.recordUserEdit(r);return}}if(r.hasAttribute(`${u.prefix}${t}-prevent`)&&e.preventDefault(),this.deferred){this.deferredProcedures.push(()=>{r.isConnected&&this.runProcedureFor(r,t,e)});return}this.runProcedureFor(r,t,e)}}runProcedureFor(e,t,r){const i=N.get(e);if(!i)return;(t==="change"||t==="input")&&this.syncUserEdit(e);const n=()=>{new te(i,t,r).run().catch(s=>{m.error("[Haori]","Procedure execution error:",s)})};if(t==="click"&&e.hasAttribute(`${u.prefix}click-defer`)){typeof requestAnimationFrame<"u"?requestAnimationFrame(()=>n()):setTimeout(n,0);return}n()}recordUserEdit(e){if(!(!(e instanceof HTMLInputElement)&&!(e instanceof HTMLSelectElement)&&!(e instanceof HTMLTextAreaElement))){if(this.deferred){this.deferredProcedures.push(()=>{e.isConnected&&this.syncUserEdit(e)});return}this.syncUserEdit(e)}}syncUserEdit(e){const t=N.get(e);if(t instanceof T&&(t.syncValue(),t.markUserEdit(),e instanceof HTMLInputElement&&e.type==="radio"&&e.name)){const r=document.getElementsByName(e.name);for(const i of Array.from(r)){if(i===e||!(i instanceof HTMLInputElement)||i.type!=="radio"||i.form!==e.form)continue;const n=N.get(i);n instanceof T&&(n.syncValue(),n.markUserEdit())}}}getElementFromTarget(e,t){if(!e)return null;if(e instanceof HTMLElement)return t==="click"?this.findClickableElement(e):e;if(e instanceof Node){const r=e.parentElement;return r?t==="click"?this.findClickableElement(r):r:null}return null}findClickableElement(e){const t=`${u.prefix}click-`,r=`${u.prefix}click-passive`;let i=e;for(;i;){if(i.getAttributeNames().some(s=>s.startsWith(t)&&s!==r))return i;if(i.hasAttribute(r))return null;i=i.parentElement}return null}};he.HISTORY_STATE_KEY="__haoriHistoryState__",he.BUILTIN_EVENT_NAMES=new Set(["click","change","input","load"]);let Le=he;const U=class U{static isHtmlElement(e){if(!(e instanceof Element))return!1;const t=e.ownerDocument?.defaultView?.HTMLElement;return typeof t<"u"&&e instanceof t}static syncTree(e){(e instanceof Element||e instanceof DocumentFragment)&&(U.isHtmlElement(e)&&U.syncElement(e),e.querySelectorAll("*").forEach(t=>{U.syncElement(t)}))}static syncElement(e){const t=U.registrations.get(e),r=N.get(e);if(!r||!U.shouldObserve(r)){t&&(t.observer.disconnect(),U.registrations.delete(e));return}if(typeof IntersectionObserver>"u")return;const i=U.resolveRoot(r),n=U.resolveRootMargin(r),s=U.resolveThreshold(r),a=r.hasAttribute(`${u.prefix}intersect-once`);if(t&&t.observer.root===i&&t.observer.rootMargin===n&&U.sameThreshold(t.observer.thresholds,s)&&t.once===a){t.fragment=r;return}t&&(t.observer.disconnect(),U.registrations.delete(e));const o=new IntersectionObserver(l=>{const c=U.registrations.get(e);c&&l.forEach(d=>{!d.isIntersecting||c.running||U.isDisabled(c.fragment)||(c.running=!0,new te(c.fragment,"intersect").runWithResult().then(h=>{h&&c.once&&(c.observer.disconnect(),U.registrations.delete(e))}).catch(h=>{m.error("[Haori]","Intersect procedure execution error:",h)}).finally(()=>{const h=U.registrations.get(e);h&&(h.running=!1)}))})},{root:i,rootMargin:n,threshold:s});o.observe(e),U.registrations.set(e,{fragment:r,observer:o,once:a,running:!1})}static cleanupTree(e){if(U.isHtmlElement(e)){const t=U.registrations.get(e);t&&(t.observer.disconnect(),U.registrations.delete(e))}(e instanceof Element||e instanceof DocumentFragment)&&e.querySelectorAll("*").forEach(t=>{const r=U.registrations.get(t);r&&(r.observer.disconnect(),U.registrations.delete(t))})}static disconnectAll(){U.registrations.forEach(e=>{e.observer.disconnect()}),U.registrations.clear()}static shouldObserve(e){return e.getAttributeNames().some(t=>{if(!t.startsWith(`${u.prefix}intersect-`))return!1;const r=t.slice(`${u.prefix}intersect-`.length);return!U.CONFIG_KEYS.has(r)})}static resolveRoot(e){const t=`${u.prefix}intersect-root`;if(!e.hasAttribute(t))return null;const r=e.getAttribute(t);if(typeof r!="string"||r.trim()==="")return null;const i=z.query(r,t,document);return U.isHtmlElement(i)?i:(m.error("[Haori]",`Intersect root element not found: ${r}`),null)}static resolveRootMargin(e){const t=`${u.prefix}intersect-root-margin`,r=e.getAttribute(t);return r===null||r===!1||r===""?"0px":String(r)}static resolveThreshold(e){const t=`${u.prefix}intersect-threshold`,r=e.getAttribute(t),i=typeof r=="number"?r:Number.parseFloat(String(r??0));return Number.isNaN(i)?0:Math.min(1,Math.max(0,i))}static isDisabled(e){const t=`${u.prefix}intersect-disabled`,r=e.getAttribute(t);if(r===null||r===!1)return!1;if(typeof r=="boolean")return r;const i=String(r).trim().toLowerCase();return i!==""&&i!=="false"&&i!=="0"}static sameThreshold(e,t){return e.length===1&&e[0]===t}};U.CONFIG_KEYS=new Set(["root","root-margin","threshold","disabled","once"]),U.registrations=new Map;let ce=U;const w=class w{static syncTree(e){(e instanceof Element||e instanceof DocumentFragment)&&(w.isHtmlElement(e)&&w.syncElement(e),e.querySelectorAll("*").forEach(t=>{w.syncElement(t)}))}static syncElement(e){const t=w.registrations.get(e);if(!t&&!w.hasPollAttribute(e))return;const r=N.get(e);if(!(r instanceof T)||!w.shouldObserve(r)){t&&w.teardown(e,t);return}const i=w.buildConfigKey(r);if(t){if(t.configKey===i){t.fragment=r;return}w.teardown(e,t)}w.startPolling(e,r,i)}static cleanupTree(e){if(w.isHtmlElement(e)){const t=w.registrations.get(e);t&&w.teardown(e,t)}(e instanceof Element||e instanceof DocumentFragment)&&e.querySelectorAll("*").forEach(t=>{const r=w.registrations.get(t);r&&w.teardown(t,r)})}static disconnectAll(){w.registrations.forEach(e=>{w.clearTimers(e)}),w.registrations.clear(),w.visibilityListener&&typeof document<"u"&&document.removeEventListener("visibilitychange",w.visibilityListener),w.visibilityListener=null}static isHtmlElement(e){if(!(e instanceof Element))return!1;const t=e.ownerDocument?.defaultView?.HTMLElement;return typeof t<"u"&&e instanceof t}static hasPollAttribute(e){const t=`${u.prefix}poll-`,r=e.attributes;for(let i=0;i<r.length;i+=1)if(r[i].name.startsWith(t))return!0;return!1}static shouldObserve(e){const t=`${u.prefix}poll-`;return e.getAttributeNames().some(r=>r.startsWith(t)?!w.CONFIG_KEYS.has(r.slice(t.length)):!1)}static buildConfigKey(e){const t=`${u.prefix}poll-`;return e.getAttributeNames().filter(r=>r.startsWith(t)).sort().map(r=>`${r}=${e.getRawAttribute(r)??""}`).join(`
|
|
28
|
-
`)}static startPolling(e,t,r){const i={fragment:t,configKey:r,intervalMs:w.resolveInterval(t),timeoutMs:w.resolveTimeout(t),errorLimit:w.resolveErrorLimit(t),startedAt:performance.now(),intervalTimerId:null,timeoutTimerId:null,fetching:!1,paused:!1,stopped:!1,timedOut:!1,stopReason:null,count:0,consecutiveErrors:0};w.registrations.set(e,i),w.ensureVisibilityListener(),i.timeoutMs!==null&&(i.timeoutTimerId=setTimeout(()=>{w.handleTimeout(e)},i.timeoutMs)),w.injectState(i),w.tick(e)}static async tick(e){const t=w.registrations.get(e);if(!t||t.stopped||t.fetching)return;if(t.intervalTimerId=null,!e.isConnected){await w.stop(e,t,"detached");return}const r=w.isHidden(e)||w.isDisabled(t.fragment);if(r!==t.paused&&(t.paused=r,await w.injectState(t)),r){w.schedule(e,t);return}if(w.isUntilSatisfied(t.fragment)){await w.stop(e,t,"until");return}t.fetching=!0,t.count+=1;let i=!1;try{i=await new te(t.fragment,"poll").runWithResult()}catch(n){m.error("[Haori]","Poll procedure execution error:",n)}finally{t.fetching=!1}if(!(w.registrations.get(e)!==t||t.stopped)){if(i)t.consecutiveErrors=0;else if(t.consecutiveErrors+=1,t.errorLimit!==null&&t.consecutiveErrors>=t.errorLimit){await w.stop(e,t,"error");return}if(await w.restoreStateIfCleared(t),i&&w.isUntilSatisfied(t.fragment)){await w.stop(e,t,"until");return}w.schedule(e,t)}}static schedule(e,t){t.stopped||t.intervalTimerId!==null||(t.intervalTimerId=setTimeout(()=>{w.tick(e)},t.intervalMs))}static async handleTimeout(e){const t=w.registrations.get(e);!t||t.stopped||(t.timeoutTimerId=null,t.timedOut=!0,e.isConnected&&H.pollTimeout(e,t.count,w.elapsed(t)),await w.stop(e,t,"timeout"))}static async stop(e,t,r){if(!t.stopped){if(t.stopped=!0,t.stopReason=r,t.paused=!1,w.clearTimers(t),r==="detached"){w.registrations.delete(e);return}await w.injectState(t),e.isConnected&&H.pollStop(e,r,t.count,w.elapsed(t))}}static teardown(e,t){w.clearTimers(t),w.registrations.delete(e)}static clearTimers(e){e.intervalTimerId!==null&&(clearTimeout(e.intervalTimerId),e.intervalTimerId=null),e.timeoutTimerId!==null&&(clearTimeout(e.timeoutTimerId),e.timeoutTimerId=null)}static elapsed(e){return Math.round(performance.now()-e.startedAt)}static ensureVisibilityListener(){if(w.visibilityListener||typeof document>"u")return;const e=()=>{document.visibilityState==="visible"&&Array.from(w.registrations.entries()).forEach(([t,r])=>{r.stopped||r.fetching||(r.intervalTimerId!==null&&(clearTimeout(r.intervalTimerId),r.intervalTimerId=null),w.tick(t))})};w.visibilityListener=e,document.addEventListener("visibilitychange",e)}static injectState(e){const t=w.resolveStateFragments(e);if(t.length===0)return Promise.resolve();const r={running:!e.stopped,paused:e.paused,stopped:e.stopped,timedOut:e.timedOut,stopReason:e.stopReason,count:e.count,elapsedMs:w.elapsed(e)};return Promise.all(t.map(i=>{const n=i.getTarget(),s={...i.getRawBindingData()??{},_poll:r};return O.setBindingData(n,s,{reflectToAttribute:!1,kind:"nonSupply",sequence:T.nextSequence()})})).then(()=>{})}static async restoreStateIfCleared(e){w.resolveStateFragments(e).some(i=>(i.getRawBindingData()??{})._poll===void 0)&&await w.injectState(e)}static resolveStateFragments(e){const t=`${u.prefix}poll-state`,r=e.fragment;if(!r.hasAttribute(t))return[];const i=r.getAttribute(t);if(typeof i!="string"||i.trim()==="")return r.getTarget().isConnected?[r]:[];const n=z.queryAll(i,t,document);if(n.length===0)return m.error("[Haori]",`Poll state element not found: ${i}`),[];const s=[];return n.forEach(a=>{if(!a.isConnected)return;const o=N.get(a);o instanceof T&&s.push(o)}),s}static resolveInterval(e){const t=`${u.prefix}poll-interval`;if(!e.hasAttribute(t))return w.DEFAULT_INTERVAL_MS;const r=w.toNumber(e.getAttribute(t));return r===null?(m.warn("[Haori]",`${t} は数値で指定してください。既定値 ${w.DEFAULT_INTERVAL_MS}ms を使用します。`),w.DEFAULT_INTERVAL_MS):r<w.MIN_INTERVAL_MS?(m.warn("[Haori]",`${t} の下限は ${w.MIN_INTERVAL_MS}ms です。${r}ms は下限へ切り上げます。`),w.MIN_INTERVAL_MS):r}static resolveTimeout(e){const t=`${u.prefix}poll-timeout`;if(!e.hasAttribute(t))return null;const r=w.toNumber(e.getAttribute(t));return r===null||r<=0?(m.warn("[Haori]",`${t} は正の数値で指定してください。無制限として扱います。`),null):r}static resolveErrorLimit(e){const t=`${u.prefix}poll-error-limit`;if(!e.hasAttribute(t))return null;const r=w.toNumber(e.getAttribute(t));return r===null||r<1?(m.warn("[Haori]",`${t} は 1 以上の数値で指定してください。無制限として扱います。`),null):Math.floor(r)}static toNumber(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e!="string"||e.trim()==="")return null;const t=Number(e.trim());return Number.isFinite(t)?t:null}static isHidden(e){return e.closest(`[${u.prefix}if-false]`)!==null}static isDisabled(e){const t=`${u.prefix}poll-disabled`;return e.hasAttribute(t)?w.isTruthy(e.getAttribute(t)):!1}static isUntilSatisfied(e){const t=`${u.prefix}poll-until`;if(!e.hasAttribute(t))return!1;const r=e.getAttributeEvaluation(t);return r?r.hasUnresolvedReference?(m.warn("[Haori]",`${t} に未解決の参照が含まれています(停止条件は成立扱いにしません):`,e.getRawAttribute(t),e.getTarget()),!1):w.isTruthy(r.value):!1}static isTruthy(e){if(e==null||e===!1)return!1;if(typeof e=="boolean")return e;if(typeof e=="string"){const t=e.trim().toLowerCase();return t!==""&&t!=="false"&&t!=="0"}return!!e}};w.CONFIG_KEYS=new Set(["interval","timeout","until","error-limit","disabled","state"]),w.DEFAULT_INTERVAL_MS=5e3,w.MIN_INTERVAL_MS=100,w.registrations=new Map,w.visibilityListener=null;let de=w;const pt="0.41.2";function Ut(g){typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>g()):Promise.resolve().then(g)}const B=class B{static isHtmlElement(e){if(!(e instanceof Element))return!1;const t=e.ownerDocument?.defaultView?.HTMLElement;return typeof t<"u"&&e instanceof t}static syncTree(e){(e instanceof Element||e instanceof DocumentFragment)&&(B.isHtmlElement(e)&&B.syncElement(e),e.querySelectorAll("*").forEach(t=>{B.syncElement(t)}))}static syncElement(e){const t=B.registrations.get(e),r=N.get(e);if(!(r instanceof T)||!B.shouldObserve(r)){t&&(t.observer.disconnect(),B.registrations.delete(e));return}if(typeof IntersectionObserver>"u")return;const i=B.resolveVarName(r);if(i===""){t&&(t.observer.disconnect(),B.registrations.delete(e)),m.warn("[Haori]",'data-each-visible requires a variable name (e.g. data-each-visible="visibleRange").');return}const n=B.resolveRoot(r),s=B.resolveRootMargin(r);if(t&&t.observer.root===n&&t.observer.rootMargin===s&&t.varName===i){t.fragment=r,B.refreshRows(t);return}t&&(t.observer.disconnect(),B.registrations.delete(e));const a=new IntersectionObserver(l=>{const c=B.registrations.get(e);if(!c)return;let d=!1;l.forEach(h=>{const y=h.target;c.observedRows.has(y)&&(h.isIntersecting?c.visibleRows.has(y)||(c.visibleRows.add(y),d=!0):c.visibleRows.delete(y)&&(d=!0))}),d&&B.scheduleCompute(c)},{root:n,rootMargin:s,threshold:B.THRESHOLD}),o={fragment:r,observer:a,varName:i,root:n,rootMargin:s,observedRows:new Set,visibleRows:new Set,scheduled:!1,lastSnapshot:null};B.registrations.set(e,o),B.refreshRows(o)}static cleanupTree(e){if(B.isHtmlElement(e)){const t=B.registrations.get(e);t&&(t.observer.disconnect(),B.registrations.delete(e))}(e instanceof Element||e instanceof DocumentFragment)&&e.querySelectorAll("*").forEach(t=>{const r=B.registrations.get(t);r&&(r.observer.disconnect(),B.registrations.delete(t))})}static disconnectAll(){B.registrations.forEach(e=>{e.observer.disconnect()}),B.registrations.clear()}static shouldObserve(e){return e.hasAttribute(`${u.prefix}each`)&&e.hasAttribute(`${u.prefix}each-visible`)}static resolveVarName(e){const t=e.getRawAttribute(`${u.prefix}each-visible`);return typeof t=="string"?t.trim():""}static resolveRoot(e){const t=`${u.prefix}each-visible-root`;if(!e.hasAttribute(t))return null;const r=e.getAttribute(t);if(typeof r!="string"||r.trim()==="")return null;const i=z.query(r,t,document);return B.isHtmlElement(i)?i:(m.error("[Haori]",`Visible range root element not found: ${r}`),null)}static resolveRootMargin(e){const t=`${u.prefix}each-visible-margin`,r=e.getAttribute(t);return r===null||r===!1||r===""?B.DEFAULT_ROOT_MARGIN:String(r)}static realRowElements(e){return e.getChildren().filter(t=>t instanceof T&&!t.hasAttribute(`${u.prefix}each-before`)&&!t.hasAttribute(`${u.prefix}each-after`)).map(t=>t.getTarget())}static refreshRows(e){const t=B.realRowElements(e.fragment),r=new Set(t);for(const i of[...e.observedRows])r.has(i)||(e.observer.unobserve(i),e.observedRows.delete(i),e.visibleRows.delete(i));for(const i of t)e.observedRows.has(i)||(e.observer.observe(i),e.observedRows.add(i));B.scheduleCompute(e)}static scheduleCompute(e){e.scheduled||(e.scheduled=!0,Ut(()=>{e.scheduled=!1;const t=e.fragment.getTarget();B.registrations.get(t)===e&&B.computeAndPublish(e)}))}static computeAndPublish(e){const t=B.realRowElements(e.fragment),r=new Map;t.forEach((a,o)=>r.set(a,o));const i=[];for(const a of e.visibleRows){const o=r.get(a);o!==void 0&&i.push(o)}let n;if(i.length===0)n={first:-1,last:-1,firstLabel:0,lastLabel:0,count:0,total:t.length,empty:!0};else{let a=i[0],o=i[0];for(const l of i)l<a&&(a=l),l>o&&(o=l);n={first:a,last:o,firstLabel:a+1,lastLabel:o+1,count:i.length,total:t.length,empty:!1}}const s=JSON.stringify(n);s!==e.lastSnapshot&&(e.lastSnapshot=s,B.publish(e,n))}static publish(e,t){const r=B.resolveBindOwner(e.fragment);if(!r){m.warn("[Haori]","data-each-visible found no ancestor data-bind scope to publish into.");return}const i=r.getTarget(),n={...r.getRawBindingData()??{}};n[e.varName]={...t};const s=e.fragment.getTarget(),a=i===s?new Set:new Set([e.fragment]);O.setBindingData(i,n,{skipFragments:a,reflectToAttribute:!1,kind:"nonSupply",sequence:T.nextSequence()}).catch(o=>{m.error("[Haori]","Failed to publish visible range:",o)})}static resolveBindOwner(e){const t=`${u.prefix}bind`;let r=e.getParent();for(;r;){if(r.hasAttribute(t))return r;r=r.getParent()}return e.hasAttribute(t)?e:null}};B.THRESHOLD=0,B.DEFAULT_ROOT_MARGIN="0px",B.registrations=new Map;let ae=B;const K=class K{static disconnectMutationObservers(){K._mutationObservers.forEach(e=>{e.disconnect()}),K._mutationObservers.length=0}static async init(){if(K._initialized)return;K._initialized=!0,K.disconnectMutationObservers(),T.setPendingMutationFlusher(()=>{K.flushPendingMutations()});const e=new Le;K._dispatcher=e,e.startDeferred();try{const t=await Promise.allSettled([O.scan(document.head),O.scan(document.body)]),[r,i]=t;r.status!=="fulfilled"&&m.error("[Haori]","Failed to build head fragment:",r.reason),i.status!=="fulfilled"&&m.error("[Haori]","Failed to build body fragment:",i.reason),await V.wait(),document.body.setAttribute("data-haori-ready",""),K.observe(document.head),K.observe(document.body),ce.syncTree(document.body),de.syncTree(document.body),ae.syncTree(document.body)}finally{e.release()}H.ready(pt)}static getDispatcher(){return K._dispatcher}static isExternallyManaged(e){return(e instanceof Element?e:e?.parentElement??null)?.closest(`[${u.prefix}external]`)!=null}static observe(e){const t=new MutationObserver(r=>{K.processMutations(r)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),K._mutationObservers.push(t)}static flushPendingMutations(){for(const e of K._mutationObservers){const t=e.takeRecords();if(t.length===0)continue;const r=t.filter(K.isBindAttributeRecord),i=t.filter(n=>!K.isBindAttributeRecord(n));r.length>0&&K.processMutations(r,T.nextSequence()),i.length>0&&Promise.resolve().then(()=>{K.processMutations(i)})}}static isBindAttributeRecord(e){return e.type==="attributes"&&e.attributeName===`${u.prefix}bind`}static processMutations(e,t){for(const r of e)try{if(K.isExternallyManaged(r.target))continue;switch(r.type){case"attributes":{const i=r.target;if(r.attributeName&&i.hasAttribute("data-haori-click-lock")&&(r.attributeName==="disabled"||r.attributeName==="data-haori-click-lock")||r.attributeName&&i.hasAttribute(pe)&&(r.attributeName==="disabled"||r.attributeName===pe)||r.attributeName&&O.isAliasedAttributeReflection(i,r.attributeName))break;O.setAttribute(i,r.attributeName,i.getAttribute(r.attributeName),!0,t),ce.syncElement(i),de.syncElement(i),ae.syncElement(i);break}case"childList":{Array.from(r.removedNodes).forEach(i=>{ce.cleanupTree(i),de.cleanupTree(i),ae.cleanupTree(i),O.removeNode(i)}),Array.from(r.addedNodes).forEach(i=>{i.parentElement instanceof Element&&(O.addNode(i.parentElement,i),ce.syncTree(i),de.syncTree(i),ae.syncTree(i))}),r.target instanceof Element&&ae.syncElement(r.target);break}case"characterData":{r.target instanceof Text||r.target instanceof Comment?O.changeText(r.target,r.target.textContent):m.warn("[Haori]","Unsupported character data type:",r.target);break}default:m.warn("[Haori]","Unknown mutation type:",r.type);continue}}catch(i){m.error("[Haori]","Error processing mutation:",i)}}};K._initialized=!1,K._mutationObservers=[],K._dispatcher=null;let Re=K;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Re.init):Re.init();const Vt=()=>ne.waitForRenders(),qt=ne.enhancers;exports.Core=O;exports.Enhance=ee;exports.Env=u;exports.Form=F;exports.Fragment=N;exports.Haori=ne;exports.Log=m;exports.Queue=V;exports.default=ne;exports.enhancers=qt;exports.version=pt;exports.waitForRenders=Vt;
|
|
27
|
+
`)}catch(n){m.error("[Haori]",`Invalid each-rendered-run script: ${n}`)}}if(i)try{i.call(e)}catch(n){m.error("[Haori]",`each-rendered-run execution error: ${n}`)}}static runEachRenderedChange(e){const t=`${u.prefix}each-rendered-change`,r=e.getTarget();if(!r.hasAttribute(t))return;const i=String(r.getAttribute(t)??"").trim().toLowerCase();let n=!1;if(i==="always"?n=!0:i!==""&&i!=="once"&&(f.EACH_RENDERED_CHANGE_WARNED.has(r)||(f.EACH_RENDERED_CHANGE_WARNED.add(r),m.warn("[Haori]",`Invalid ${t} value: "${i}". Use "once" (default) or "always".`))),f.countEachRenderedRows(e)!==0){if(!n){if(f.EACH_RENDERED_CHANGE_FIRED.has(r))return;f.EACH_RENDERED_CHANGE_FIRED.add(r)}try{r.dispatchEvent(new Event("change",{bubbles:!0}))}catch(s){m.error("[Haori]",`each-rendered-change dispatch error: ${s}`)}}}static countEachRenderedRows(e){let t=0;for(const r of e.getChildElementFragments())r.getTarget().hasAttribute(`${u.prefix}row`)&&(t+=1);return t}static performEachUpdate(e){const t=f.resolveEachItems(e);if(t===null)return Promise.reject(new Error("Invalid each attribute."));let r=e.getTemplate();const i=e.getAttribute(`${u.prefix}each-key`),n=f.createBindingSignature({key:i?String(i):null,items:t});if(r===null){let s=!1;if(e.getChildren().forEach(a=>{if(!s&&a instanceof T){if(a.hasAttribute(`${u.prefix}each-before`)||a.hasAttribute(`${u.prefix}each-after`))return;r=a.clone(),f.markFreshInitializationSkippable(r),e.setTemplate(r),s=!0,e.removeChild(a);const o=a.getTarget();o.parentNode&&o.parentNode.removeChild(o),a.setMounted(!1)}}),!s){const a=e.getTarget();Array.from(a.children).filter(l=>!l.hasAttribute(`${u.prefix}each-before`)&&!l.hasAttribute(`${u.prefix}each-after`)).forEach(l=>{if(!s){const d=N.get(l);d instanceof T&&(r=d.clone(),f.markFreshInitializationSkippable(r),e.setTemplate(r),s=!0)}const c=N.get(l);c instanceof T&&e.getChildren().includes(c)&&(e.removeChild(c),c.setMounted(!1)),l.parentNode&&l.parentNode.removeChild(l)})}return this.updateDiff(e,t).then(()=>{e.setEachInputSignature(n)})}return e.getEachInputSignature()===n?f.reevaluateEachRows(e):this.updateDiff(e,t).then(()=>{e.setEachInputSignature(n)})}static reevaluateEachRows(e){if(f.isRowLocalEachTemplate(e))return Promise.resolve();const t=e.getChildElementFragments().filter(r=>!r.hasAttribute(`${u.prefix}each-before`)&&!r.hasAttribute(`${u.prefix}each-after`));return t.length===0?Promise.resolve():Promise.all(t.map(r=>f.evaluateAll(r))).then(()=>{})}static resolveEachItems(e){const t=e.getAttributeEvaluation(`${u.prefix}each`),r=t?.value;return t?.hasUnresolvedReference||r===!1||r===null||r===void 0?[]:Array.isArray(r)?r:(m.error("[Haori]","Invalid each attribute:",r),null)}static canSkipUnchangedNestedEach(e){if(!e.hasAttribute(`${u.prefix}each`)||e.getEachInputSignature()===null)return!1;const t=e.getParent();if(t?.closestByAttribute(`${u.prefix}derive`)||t?.closestByAttribute(`${u.prefix}derive-name`)||t?.closestByAttribute(`${u.prefix}if`)||t?.closestByAttribute(`${u.prefix}fetch`)||t?.closestByAttribute(`${u.prefix}import`)||f.hasNonEachDynamicElementState(e)||!f.isRowLocalEachTemplate(e))return!1;const r=f.resolveEachItems(e);if(r===null)return!1;const i=e.getAttribute(`${u.prefix}each-key`),n=f.createBindingSignature({key:i?String(i):null,items:r});return e.getEachInputSignature()===n}static isRowLocalEachTemplate(e){const t=e.getRowLocalTemplate();if(t!==null)return t;const r=e.getTemplate(),i=e.getAttribute(`${u.prefix}each-arg`);if(r===null||!i)return e.setRowLocalTemplate(!1),!1;const n=new Set([String(i)]),s=e.getAttribute(`${u.prefix}each-index`);s&&n.add(String(s));const a=f.isRowLocalSubtree(r,n);return e.setRowLocalTemplate(a),a}static isRowLocalSubtree(e,t){for(const i of e.getAttributeNames()){const n=e.getRawAttribute(i),s=typeof n=="string"?n:"";if(s.includes("{{")){if(!f.areExpressionsRowLocal(f.extractInterpolations(s),t))return!1;continue}if(!i.startsWith(u.prefix))continue;const a=i.slice(u.prefix.length);if(f.ROW_LOCAL_EXPRESSION_ATTRIBUTES.has(a)){if(!f.areExpressionsRowLocal([s],t))return!1;continue}if(!f.ROW_LOCAL_STATIC_ATTRIBUTES.has(a))return!1}let r=t;if(e.hasAttribute(`${u.prefix}each`)){const i=e.getRawAttribute(`${u.prefix}each-arg`);if(typeof i!="string"||i==="")return!1;const n=new Set(t);n.add(i);const s=e.getRawAttribute(`${u.prefix}each-index`);typeof s=="string"&&s!==""&&n.add(s),r=n}for(const i of e.getChildren())if(i instanceof T){if(!f.isRowLocalSubtree(i,r))return!1}else if(i instanceof Q){const n=i.getRawText();if(n.includes("{{")&&!f.areExpressionsRowLocal(f.extractInterpolations(n),t))return!1}return!0}static areExpressionsRowLocal(e,t){for(const r of e){const i=r.trim();if(i==="")continue;const n=J.getFreeIdentifiers(i);if(n.length===0||n.some(s=>!t.has(s)))return!1}return!0}static extractInterpolations(e){const t=[],r=/\{\{([\s\S]*?)\}\}/g;let i=r.exec(e);for(;i!==null;)t.push(i[1]),i=r.exec(e);return t}static canSkipStableDerivedSubtree(e){return!e.hasAttribute(`${u.prefix}derive`)||e.hasAttribute(`${u.prefix}if`)||e.hasAttribute(`${u.prefix}each`)||e.hasAttribute(`${u.prefix}fetch`)||e.hasAttribute(`${u.prefix}import`)?!1:!f.hasDisallowedDerivedSubtreeDescendant(e)}static hasDisallowedDerivedSubtreeDescendant(e){return e.getChildren().some(t=>t instanceof T?t.hasAttribute(`${u.prefix}derive`)||t.hasAttribute(`${u.prefix}derive-name`)||t.hasAttribute(`${u.prefix}fetch`)||t.hasAttribute(`${u.prefix}import`)?!0:f.hasDisallowedDerivedSubtreeDescendant(t):!1)}static createDescendantBindingSignature(e,t){return f.recordDerivedSubtreeSignatureComputation(e,t),f.createBindingSignature(e.getDescendantBindingData())}static createDeriveInputSignature(e,t,r){const i=typeof r=="string"?r.trim():"";return!t||i===""?null:f.createBindingSignature({expression:t,name:i,scope:e.getBindingData()})}static refreshDerivedSubtreeSignature(e){if(!f.canSkipStableDerivedSubtree(e)){e.setDeriveSubtreeSignature(null),f.logDerivedSubtreeProfileSnapshot(e,"skip-ineligible");return}e.setDeriveSubtreeSignature(f.createDescendantBindingSignature(e,"refresh")),f.logDerivedSubtreeProfileSnapshot(e,"refresh")}static getOrCreateDerivedSubtreeProfile(e){if(!j.isEnabled()||!e.hasAttribute(`${u.prefix}derive`))return null;const t=f.DERIVE_SUBTREE_PROFILES.get(e);if(t)return t;const r={hostId:f.createDerivedSubtreeHostId(e),signatureComputeTotal:0,signatureComputeFromEvaluateAll:0,signatureComputeFromRefresh:0,skipHitCount:0,skipMissCount:0,skipIneligibleCount:0};return f.DERIVE_SUBTREE_PROFILES.set(e,r),r}static resolveElementId(e){return e.getAttribute("id")??""}static createDerivedSubtreeHostId(e){const t=[];let r=e;for(;r;){const i=r.getTarget();if(!(i instanceof HTMLElement))break;let n=i.tagName.toLowerCase();const s=f.resolveElementId(i).trim();if(s!==""){n+=`#${s}`,t.unshift(n);break}const a=r.getRawAttribute(`${u.prefix}derive-name`);typeof a=="string"&&a.trim()!==""&&(n+=`[${u.prefix}derive-name="${a.trim()}"]`);const o=r.getParent();if(o){const l=o.getChildren().filter(c=>c instanceof T).findIndex(c=>c===r);n+=`:nth-child(${l+1})`}t.unshift(n),r=o}return t.join(" > ")}static recordDerivedSubtreeSignatureComputation(e,t){const r=f.getOrCreateDerivedSubtreeProfile(e);if(r!==null){if(r.signatureComputeTotal+=1,t==="refresh"){r.signatureComputeFromRefresh+=1;return}r.signatureComputeFromEvaluateAll+=1}}static logDerivedSubtreeProfileSnapshot(e,t){const r=f.getOrCreateDerivedSubtreeProfile(e);r!==null&&(t==="skip-hit"?r.skipHitCount+=1:t==="skip-miss"?r.skipMissCount+=1:t==="skip-ineligible"&&(r.skipIneligibleCount+=1),m.info("[Haori][derive-profile]",{reason:t,hostId:r.hostId,signatureComputeTotal:r.signatureComputeTotal,signatureComputeFromEvaluateAll:r.signatureComputeFromEvaluateAll,signatureComputeFromRefresh:r.signatureComputeFromRefresh,skipHitCount:r.skipHitCount,skipMissCount:r.skipMissCount,skipIneligibleCount:r.skipIneligibleCount}))}static hasNonEachDynamicElementState(e){const t=new Set([`${u.prefix}each`,`${u.prefix}each-key`,`${u.prefix}each-arg`,`${u.prefix}each-index`]);return e.getAttributeNames().some(i=>{if(t.has(i))return!1;if(i.startsWith(`${u.prefix}attr-`)||i.startsWith(u.prefix))return!0;const n=e.getRawAttribute(i);return typeof n=="string"&&n.includes("{{")})?!0:e.getChildren().some(i=>i instanceof Q&&i.hasDynamicContent())}static markFreshInitializationSkippable(e){const t=e.getAttributeNames().some(n=>f.isFreshInitializationDynamicAttribute(e,n)),r=e.getChildren().some(n=>n instanceof T?!f.markFreshInitializationSkippable(n):n instanceof Q?n.hasDynamicContent():!1),i=!t&&!r;return e.setFreshInitializationSkippable(i),i}static isFreshInitializationDynamicAttribute(e,t){if(t.startsWith(`${u.prefix}attr-`)||t.startsWith(u.prefix))return!0;const r=e.getRawAttribute(t);return typeof r=="string"&&r.includes("{{")}static updateDiff(e,t){const r=e.getTemplate();if(r===null)return m.error("[Haori]","Template is not set for each element."),Promise.resolve();let i=e.getAttribute(`${u.prefix}each-index`);i&&(i=String(i));const n=e.getAttribute(`${u.prefix}each-key`),s=e.getAttribute(`${u.prefix}each-arg`),a=t.map((E,v)=>f.createListKey(E,n?String(n):null,v)),o=new Set(a),l=new Map;a.forEach(E=>{l.set(E,(l.get(E)??0)+1)}),n&&o.size!==a.length&&f.warnDuplicateEachKey(String(n));const c=[];let d=e.getChildren().filter(E=>E instanceof T).filter(E=>!E.hasAttribute(`${u.prefix}each-before`)&&!E.hasAttribute(`${u.prefix}each-after`));const h=d.map(E=>E.getListKey()),y=new Set;d=d.filter((E,v)=>{const R=String(E.getListKey()),k=l.get(R)??0;if(k===0){y.add(E);const x=E.getListKey();return x!==null&&H.rowRemove(E.getTarget(),x,v),c.push(E.remove()),!1}return l.set(R,k-1),!0});const A=d.map(E=>E.getListKey()),S=new Map;d.forEach(E=>{const v=E.getListKey();if(v===null)return;const R=S.get(v);R?R.push(E):S.set(v,[E])});const P=e.getChildElementFragments().filter(E=>!y.has(E)),D=P.filter(E=>E.hasAttribute(`${u.prefix}each-before`)).length;let L=Promise.resolve();return a.forEach((E,v)=>{const R=t[v],k=v;let x;const q=S.get(E)?.shift();if(q){x=q;const G=D+v;L=L.then(()=>f.updateRowFragment(x,R,i,k,s?String(s):null,E).then(_=>f.repositionEachRow(e,x,P,G).then(Z=>{if(Z!==null&&H.rowMove(x.getTarget(),E,Z-D,v),!!_)return f.clearUserEditMarks(x),f.evaluateAll(x).then(()=>f.applyRowFormValues(e,x,R))})))}else{x=r.clone();const G=D+v;L=L.then(()=>f.updateRowFragment(x,R,i,k,s?String(s):null,E).then(()=>{const _=P[G]??null;return e.insertBefore(x,_).then(()=>{P.splice(G,0,x)}).then(()=>f.initializeFreshEachRow(x)).then(()=>f.applyRowFormValues(e,x,R)).then(()=>{H.rowAdd(x.getTarget(),E,k,R)})}))}}),Promise.all(c).then(()=>L).then(()=>{const E=a.filter(G=>G!==null),v=A.filter(G=>G!==null),R=new Set(v),k=E.filter(G=>!R.has(G)),q=h.filter(G=>G!==null).filter(G=>!o.has(G));H.eachUpdate(e.getTarget(),k,q,E)})}static warnDuplicateEachKey(e){!j.isEnabled()||f.WARNED_DUPLICATE_EACH_KEYS.has(e)||(f.WARNED_DUPLICATE_EACH_KEYS.add(e),m.warn("[Haori]",`${u.prefix}each-key="${e}" の値が配列の中で重複しています。行は出現順で対応付けますが、キーによる行の識別はできません。`))}static repositionEachRow(e,t,r,i){const n=r.indexOf(t);if(n===-1||n===i)return Promise.resolve(null);r.splice(n,1);const s=r[i]??null;return r.splice(i,0,t),e.insertBefore(t,s).then(()=>n)}static applyRowFormValues(e,t,r){return!e.hasAttribute(`${u.prefix}form-list`)||!F.isCollectedListFromEachSource(e)||typeof r!="object"||r===null||Array.isArray(r)?Promise.resolve():F.syncRowValues(t,r)}static createListKey(e,t,r){let i;if(typeof e=="object"&&e!==null)if(t){const n=e[t];n==null?i=`__index_${r}`:typeof n=="object"?i=JSON.stringify(n):i=String(n)}else i=`__index_${r}`;else i=String(e);return i}static updateRowFragment(e,t,r,i,n,s){let a;if(typeof t=="object"&&t!==null)a=n?{[n]:{...t}}:{...t};else if(n)a={[n]:t};else return m.error("[Haori]",`Primitive value requires '${u.prefix}each-arg' attribute: ${t}`),Promise.resolve(!1);r&&(a[r]=i);const o=a,l=f.createBindingSignature({listKey:s,bindingData:o});return e.getListKey()===s&&e.getRenderSignature()===l?Promise.resolve(!1):(e.setListKey(s),e.setRenderSignature(l),e.setBindingData(o),e.setAttribute(`${u.prefix}row`,s).then(()=>!0))}static needsScheduledEvaluateAll(e){const t=[e];for(;t.length>0;){const r=t.pop();if(r.getChildElementFragments().forEach(i=>{t.push(i)}),r!==e&&!r.isMounted()&&f.hasMountSensitiveAttribute(r))return!0}return!1}static hasMountSensitiveAttribute(e){return["fetch","import"].some(t=>e.hasAttribute(`${u.prefix}${t}`))}static createBindingSignature(e,t=new WeakMap,r={value:0}){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);if(typeof e=="function")return`[Function:${e.name||"anonymous"}]`;if(typeof e=="symbol")return e.toString();if(e instanceof Date)return`[Date:${e.toISOString()}]`;if(typeof File<"u"&&e instanceof File)return`[File:${e.name}:${e.size}:${e.lastModified}:${e.type}]`;if(typeof Blob<"u"&&e instanceof Blob)return`[Blob:${e.size}:${e.type}]`;if(Array.isArray(e)){if(t.has(e))return`[Circular:${t.get(e)}]`;const i=`array-${r.value}`;return r.value+=1,t.set(e,i),`[${e.map(n=>f.createBindingSignature(n,t,r)).join(",")}]`}if(typeof e=="object"){if(t.has(e))return`[Circular:${t.get(e)}]`;const i=`object-${r.value}`;r.value+=1,t.set(e,i);const n=e;return`{${Object.keys(n).sort().map(s=>`${JSON.stringify(s)}:${f.createBindingSignature(n[s],t,r)}`).join(",")}}`}return String(e)}static scheduleEvaluateAll(e){setTimeout(()=>{f.evaluateAll(e)},100)}};f.ATTRIBUTE_ALIAS_SUFFIX="attr-",f.PRIORITY_ATTRIBUTE_SUFFIXES=["bind","store","url-param","derive-name","derive","if","each"],f.DEFERRED_ATTRIBUTE_SUFFIXES=["fetch"],f.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES=["bind","derive","derive-name","if","each","fetch","import","url-param","store","validity","validity-message"],f.ATTRIBUTE_PLACEHOLDER_REGEX=/\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/,f.ROW_LOCAL_EXPRESSION_ATTRIBUTES=new Set(["each","if","derive"]),f.ROW_LOCAL_STATIC_ATTRIBUTES=new Set(["each-arg","each-key","each-index","each-before","each-after","derive-name","row","form","form-arg","form-list","form-object","form-detach","store","store-params","store-arg","store-type","enhance","enhance-new"]),f.REACTIVE_FETCH_STATES=new WeakMap,f.REACTIVE_IMPORT_STATES=new WeakMap,f.DERIVE_SUBTREE_PROFILES=new WeakMap,f.EACH_UPDATE_STATES=new WeakMap,f.EACH_RENDERED_CHANGE_FIRED=new WeakSet,f.EACH_RENDERED_CHANGE_WARNED=new WeakSet,f.WARNED_DUPLICATE_EACH_KEYS=new Set,f.ABSENT_PATH=Symbol("absent");let O=f;const he=class he{constructor(e=document){this.customEventHandlers=new Map,this.builtinListenersAdded=!1,this.deferred=!1,this.deferredProcedures=[],this.onClick=t=>this.delegate(t,"click"),this.onChange=t=>this.delegate(t,"change"),this.onInput=t=>this.delegate(t,"input"),this.onLoadCapture=t=>this.delegate(t,"load"),this.onWindowLoad=()=>{if(this.deferred){this.deferredProcedures.push(()=>this.runWindowLoadProcedure());return}this.runWindowLoadProcedure()},this.onPopstate=t=>{const r=t.state;!r||r[he.HISTORY_STATE_KEY]!==!0||location.reload()},this.root=e}runWindowLoadProcedure(){const e=document.documentElement,t=N.get(e);t&&new te(t,"load").run()}start(){this.deferred=!1,this.addBuiltinListeners(),this.subscribeDeclaredCustomEvents(),this.observeCustomEventDeclarations()}startDeferred(){this.deferred=!0,this.addBuiltinListeners(),this.subscribeDeclaredCustomEvents()}release(){if(!this.deferred)return;this.deferred=!1,this.subscribeDeclaredCustomEvents(),this.observeCustomEventDeclarations();const e=this.deferredProcedures.splice(0);for(const t of e)try{t()}catch(r){m.error("[Haori]","Deferred event handling error:",r)}}addBuiltinListeners(){this.builtinListenersAdded||(this.builtinListenersAdded=!0,this.root.addEventListener("click",this.onClick),this.root.addEventListener("change",this.onChange),this.root.addEventListener("input",this.onInput),this.root.addEventListener("load",this.onLoadCapture,!0),window.addEventListener("load",this.onWindowLoad,{once:!0}),window.addEventListener("popstate",this.onPopstate))}stop(){this.root.removeEventListener("click",this.onClick),this.root.removeEventListener("change",this.onChange),this.root.removeEventListener("input",this.onInput),this.root.removeEventListener("load",this.onLoadCapture,!0),window.removeEventListener("load",this.onWindowLoad),window.removeEventListener("popstate",this.onPopstate),this.builtinListenersAdded=!1,this.deferred=!1,this.deferredProcedures.length=0;for(const[e,t]of this.customEventHandlers)window.removeEventListener(e,t,!0);this.customEventHandlers.clear(),this.customEventObserver?.disconnect(),this.customEventObserver=void 0}get onAttributeName(){return`${u.prefix}on`}subscribeDeclaredCustomEvents(){this.root.querySelectorAll(`[${this.onAttributeName}]`).forEach(t=>this.subscribeCustomEvent(t.getAttribute(this.onAttributeName)))}subscribeCustomEvent(e){if(e===null||e==="")return;if(he.BUILTIN_EVENT_NAMES.has(e)){m.warn("[Haori]",`data-on="${e}" は組み込みイベントです。data-${e}-* を使用してください(data-on はカスタムイベント専用)。`);return}if(this.customEventHandlers.has(e))return;const t=r=>this.runCustomEventProcedures(e,r);this.customEventHandlers.set(e,t),window.addEventListener(e,t,!0)}runCustomEventProcedures(e,t){if(this.deferred){this.deferredProcedures.push(()=>this.runCustomEventProcedures(e,t));return}this.root.querySelectorAll(`[${this.onAttributeName}]`).forEach(i=>{if(i.getAttribute(this.onAttributeName)!==e)return;const n=N.get(i);n instanceof T&&new te(n,"on",t).run().catch(s=>{m.error("[Haori]","Procedure execution error:",s)})})}observeCustomEventDeclarations(){if(typeof MutationObserver>"u")return;const e=this.root instanceof Document?this.root:this.root.ownerDocument??document,t=this.root instanceof Document?e.body:this.root;t&&(this.customEventObserver=new MutationObserver(r=>{for(const i of r)i.addedNodes.forEach(n=>{n instanceof HTMLElement&&(n.hasAttribute(this.onAttributeName)&&this.subscribeCustomEvent(n.getAttribute(this.onAttributeName)),n.querySelectorAll(`[${this.onAttributeName}]`).forEach(s=>this.subscribeCustomEvent(s.getAttribute(this.onAttributeName))))})}),this.customEventObserver.observe(t,{childList:!0,subtree:!0}))}delegate(e,t){const r=this.getElementFromTarget(e.target,t);if(r){if(t==="input"){const i=`${u.prefix}input-`;if(!r.getAttributeNames().some(s=>s.startsWith(i))){this.recordUserEdit(r);return}}if(r.hasAttribute(`${u.prefix}${t}-prevent`)&&e.preventDefault(),this.deferred){this.deferredProcedures.push(()=>{r.isConnected&&this.runProcedureFor(r,t,e)});return}this.runProcedureFor(r,t,e)}}runProcedureFor(e,t,r){const i=N.get(e);if(!i)return;(t==="change"||t==="input")&&this.syncUserEdit(e);const n=()=>{new te(i,t,r).run().catch(s=>{m.error("[Haori]","Procedure execution error:",s)})};if(t==="click"&&e.hasAttribute(`${u.prefix}click-defer`)){typeof requestAnimationFrame<"u"?requestAnimationFrame(()=>n()):setTimeout(n,0);return}n()}recordUserEdit(e){if(!(!(e instanceof HTMLInputElement)&&!(e instanceof HTMLSelectElement)&&!(e instanceof HTMLTextAreaElement))){if(this.deferred){this.deferredProcedures.push(()=>{e.isConnected&&this.markUserEditOnly(e)});return}this.markUserEditOnly(e)}}markUserEditOnly(e){const t=N.get(e);t instanceof T&&t.markUserEdit()}syncUserEdit(e){const t=N.get(e);if(t instanceof T&&(t.syncValue(),t.markUserEdit(),e instanceof HTMLInputElement&&e.type==="radio"&&e.name)){const r=document.getElementsByName(e.name);for(const i of Array.from(r)){if(i===e||!(i instanceof HTMLInputElement)||i.type!=="radio"||i.form!==e.form)continue;const n=N.get(i);n instanceof T&&(n.syncValue(),n.markUserEdit())}}}getElementFromTarget(e,t){if(!e)return null;if(e instanceof HTMLElement)return t==="click"?this.findClickableElement(e):e;if(e instanceof Node){const r=e.parentElement;return r?t==="click"?this.findClickableElement(r):r:null}return null}findClickableElement(e){const t=`${u.prefix}click-`,r=`${u.prefix}click-passive`;let i=e;for(;i;){if(i.getAttributeNames().some(s=>s.startsWith(t)&&s!==r))return i;if(i.hasAttribute(r))return null;i=i.parentElement}return null}};he.HISTORY_STATE_KEY="__haoriHistoryState__",he.BUILTIN_EVENT_NAMES=new Set(["click","change","input","load"]);let Le=he;const U=class U{static isHtmlElement(e){if(!(e instanceof Element))return!1;const t=e.ownerDocument?.defaultView?.HTMLElement;return typeof t<"u"&&e instanceof t}static syncTree(e){(e instanceof Element||e instanceof DocumentFragment)&&(U.isHtmlElement(e)&&U.syncElement(e),e.querySelectorAll("*").forEach(t=>{U.syncElement(t)}))}static syncElement(e){const t=U.registrations.get(e),r=N.get(e);if(!r||!U.shouldObserve(r)){t&&(t.observer.disconnect(),U.registrations.delete(e));return}if(typeof IntersectionObserver>"u")return;const i=U.resolveRoot(r),n=U.resolveRootMargin(r),s=U.resolveThreshold(r),a=r.hasAttribute(`${u.prefix}intersect-once`);if(t&&t.observer.root===i&&t.observer.rootMargin===n&&U.sameThreshold(t.observer.thresholds,s)&&t.once===a){t.fragment=r;return}t&&(t.observer.disconnect(),U.registrations.delete(e));const o=new IntersectionObserver(l=>{const c=U.registrations.get(e);c&&l.forEach(d=>{!d.isIntersecting||c.running||U.isDisabled(c.fragment)||(c.running=!0,new te(c.fragment,"intersect").runWithResult().then(h=>{h&&c.once&&(c.observer.disconnect(),U.registrations.delete(e))}).catch(h=>{m.error("[Haori]","Intersect procedure execution error:",h)}).finally(()=>{const h=U.registrations.get(e);h&&(h.running=!1)}))})},{root:i,rootMargin:n,threshold:s});o.observe(e),U.registrations.set(e,{fragment:r,observer:o,once:a,running:!1})}static cleanupTree(e){if(U.isHtmlElement(e)){const t=U.registrations.get(e);t&&(t.observer.disconnect(),U.registrations.delete(e))}(e instanceof Element||e instanceof DocumentFragment)&&e.querySelectorAll("*").forEach(t=>{const r=U.registrations.get(t);r&&(r.observer.disconnect(),U.registrations.delete(t))})}static disconnectAll(){U.registrations.forEach(e=>{e.observer.disconnect()}),U.registrations.clear()}static shouldObserve(e){return e.getAttributeNames().some(t=>{if(!t.startsWith(`${u.prefix}intersect-`))return!1;const r=t.slice(`${u.prefix}intersect-`.length);return!U.CONFIG_KEYS.has(r)})}static resolveRoot(e){const t=`${u.prefix}intersect-root`;if(!e.hasAttribute(t))return null;const r=e.getAttribute(t);if(typeof r!="string"||r.trim()==="")return null;const i=z.query(r,t,document);return U.isHtmlElement(i)?i:(m.error("[Haori]",`Intersect root element not found: ${r}`),null)}static resolveRootMargin(e){const t=`${u.prefix}intersect-root-margin`,r=e.getAttribute(t);return r===null||r===!1||r===""?"0px":String(r)}static resolveThreshold(e){const t=`${u.prefix}intersect-threshold`,r=e.getAttribute(t),i=typeof r=="number"?r:Number.parseFloat(String(r??0));return Number.isNaN(i)?0:Math.min(1,Math.max(0,i))}static isDisabled(e){const t=`${u.prefix}intersect-disabled`,r=e.getAttribute(t);if(r===null||r===!1)return!1;if(typeof r=="boolean")return r;const i=String(r).trim().toLowerCase();return i!==""&&i!=="false"&&i!=="0"}static sameThreshold(e,t){return e.length===1&&e[0]===t}};U.CONFIG_KEYS=new Set(["root","root-margin","threshold","disabled","once"]),U.registrations=new Map;let ce=U;const w=class w{static syncTree(e){(e instanceof Element||e instanceof DocumentFragment)&&(w.isHtmlElement(e)&&w.syncElement(e),e.querySelectorAll("*").forEach(t=>{w.syncElement(t)}))}static syncElement(e){const t=w.registrations.get(e);if(!t&&!w.hasPollAttribute(e))return;const r=N.get(e);if(!(r instanceof T)||!w.shouldObserve(r)){t&&w.teardown(e,t);return}const i=w.buildConfigKey(r);if(t){if(t.configKey===i){t.fragment=r;return}w.teardown(e,t)}w.startPolling(e,r,i)}static cleanupTree(e){if(w.isHtmlElement(e)){const t=w.registrations.get(e);t&&w.teardown(e,t)}(e instanceof Element||e instanceof DocumentFragment)&&e.querySelectorAll("*").forEach(t=>{const r=w.registrations.get(t);r&&w.teardown(t,r)})}static disconnectAll(){w.registrations.forEach(e=>{w.clearTimers(e)}),w.registrations.clear(),w.visibilityListener&&typeof document<"u"&&document.removeEventListener("visibilitychange",w.visibilityListener),w.visibilityListener=null}static isHtmlElement(e){if(!(e instanceof Element))return!1;const t=e.ownerDocument?.defaultView?.HTMLElement;return typeof t<"u"&&e instanceof t}static hasPollAttribute(e){const t=`${u.prefix}poll-`,r=e.attributes;for(let i=0;i<r.length;i+=1)if(r[i].name.startsWith(t))return!0;return!1}static shouldObserve(e){const t=`${u.prefix}poll-`;return e.getAttributeNames().some(r=>r.startsWith(t)?!w.CONFIG_KEYS.has(r.slice(t.length)):!1)}static buildConfigKey(e){const t=`${u.prefix}poll-`;return e.getAttributeNames().filter(r=>r.startsWith(t)).sort().map(r=>`${r}=${e.getRawAttribute(r)??""}`).join(`
|
|
28
|
+
`)}static startPolling(e,t,r){const i={fragment:t,configKey:r,intervalMs:w.resolveInterval(t),timeoutMs:w.resolveTimeout(t),errorLimit:w.resolveErrorLimit(t),startedAt:performance.now(),intervalTimerId:null,timeoutTimerId:null,fetching:!1,paused:!1,stopped:!1,timedOut:!1,stopReason:null,count:0,consecutiveErrors:0};w.registrations.set(e,i),w.ensureVisibilityListener(),i.timeoutMs!==null&&(i.timeoutTimerId=setTimeout(()=>{w.handleTimeout(e)},i.timeoutMs)),w.injectState(i),w.tick(e)}static async tick(e){const t=w.registrations.get(e);if(!t||t.stopped||t.fetching)return;if(t.intervalTimerId=null,!e.isConnected){await w.stop(e,t,"detached");return}const r=w.isHidden(e)||w.isDisabled(t.fragment);if(r!==t.paused&&(t.paused=r,await w.injectState(t)),r){w.schedule(e,t);return}if(w.isUntilSatisfied(t.fragment)){await w.stop(e,t,"until");return}t.fetching=!0,t.count+=1;let i=!1;try{i=await new te(t.fragment,"poll").runWithResult()}catch(n){m.error("[Haori]","Poll procedure execution error:",n)}finally{t.fetching=!1}if(!(w.registrations.get(e)!==t||t.stopped)){if(i)t.consecutiveErrors=0;else if(t.consecutiveErrors+=1,t.errorLimit!==null&&t.consecutiveErrors>=t.errorLimit){await w.stop(e,t,"error");return}if(await w.restoreStateIfCleared(t),i&&w.isUntilSatisfied(t.fragment)){await w.stop(e,t,"until");return}w.schedule(e,t)}}static schedule(e,t){t.stopped||t.intervalTimerId!==null||(t.intervalTimerId=setTimeout(()=>{w.tick(e)},t.intervalMs))}static async handleTimeout(e){const t=w.registrations.get(e);!t||t.stopped||(t.timeoutTimerId=null,t.timedOut=!0,e.isConnected&&H.pollTimeout(e,t.count,w.elapsed(t)),await w.stop(e,t,"timeout"))}static async stop(e,t,r){if(!t.stopped){if(t.stopped=!0,t.stopReason=r,t.paused=!1,w.clearTimers(t),r==="detached"){w.registrations.delete(e);return}await w.injectState(t),e.isConnected&&H.pollStop(e,r,t.count,w.elapsed(t))}}static teardown(e,t){w.clearTimers(t),w.registrations.delete(e)}static clearTimers(e){e.intervalTimerId!==null&&(clearTimeout(e.intervalTimerId),e.intervalTimerId=null),e.timeoutTimerId!==null&&(clearTimeout(e.timeoutTimerId),e.timeoutTimerId=null)}static elapsed(e){return Math.round(performance.now()-e.startedAt)}static ensureVisibilityListener(){if(w.visibilityListener||typeof document>"u")return;const e=()=>{document.visibilityState==="visible"&&Array.from(w.registrations.entries()).forEach(([t,r])=>{r.stopped||r.fetching||(r.intervalTimerId!==null&&(clearTimeout(r.intervalTimerId),r.intervalTimerId=null),w.tick(t))})};w.visibilityListener=e,document.addEventListener("visibilitychange",e)}static injectState(e){const t=w.resolveStateFragments(e);if(t.length===0)return Promise.resolve();const r={running:!e.stopped,paused:e.paused,stopped:e.stopped,timedOut:e.timedOut,stopReason:e.stopReason,count:e.count,elapsedMs:w.elapsed(e)};return Promise.all(t.map(i=>{const n=i.getTarget(),s={...i.getRawBindingData()??{},_poll:r};return O.setBindingData(n,s,{reflectToAttribute:!1,kind:"nonSupply",sequence:T.nextSequence()})})).then(()=>{})}static async restoreStateIfCleared(e){w.resolveStateFragments(e).some(i=>(i.getRawBindingData()??{})._poll===void 0)&&await w.injectState(e)}static resolveStateFragments(e){const t=`${u.prefix}poll-state`,r=e.fragment;if(!r.hasAttribute(t))return[];const i=r.getAttribute(t);if(typeof i!="string"||i.trim()==="")return r.getTarget().isConnected?[r]:[];const n=z.queryAll(i,t,document);if(n.length===0)return m.error("[Haori]",`Poll state element not found: ${i}`),[];const s=[];return n.forEach(a=>{if(!a.isConnected)return;const o=N.get(a);o instanceof T&&s.push(o)}),s}static resolveInterval(e){const t=`${u.prefix}poll-interval`;if(!e.hasAttribute(t))return w.DEFAULT_INTERVAL_MS;const r=w.toNumber(e.getAttribute(t));return r===null?(m.warn("[Haori]",`${t} は数値で指定してください。既定値 ${w.DEFAULT_INTERVAL_MS}ms を使用します。`),w.DEFAULT_INTERVAL_MS):r<w.MIN_INTERVAL_MS?(m.warn("[Haori]",`${t} の下限は ${w.MIN_INTERVAL_MS}ms です。${r}ms は下限へ切り上げます。`),w.MIN_INTERVAL_MS):r}static resolveTimeout(e){const t=`${u.prefix}poll-timeout`;if(!e.hasAttribute(t))return null;const r=w.toNumber(e.getAttribute(t));return r===null||r<=0?(m.warn("[Haori]",`${t} は正の数値で指定してください。無制限として扱います。`),null):r}static resolveErrorLimit(e){const t=`${u.prefix}poll-error-limit`;if(!e.hasAttribute(t))return null;const r=w.toNumber(e.getAttribute(t));return r===null||r<1?(m.warn("[Haori]",`${t} は 1 以上の数値で指定してください。無制限として扱います。`),null):Math.floor(r)}static toNumber(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e!="string"||e.trim()==="")return null;const t=Number(e.trim());return Number.isFinite(t)?t:null}static isHidden(e){return e.closest(`[${u.prefix}if-false]`)!==null}static isDisabled(e){const t=`${u.prefix}poll-disabled`;return e.hasAttribute(t)?w.isTruthy(e.getAttribute(t)):!1}static isUntilSatisfied(e){const t=`${u.prefix}poll-until`;if(!e.hasAttribute(t))return!1;const r=e.getAttributeEvaluation(t);return r?r.hasUnresolvedReference?(m.warn("[Haori]",`${t} に未解決の参照が含まれています(停止条件は成立扱いにしません):`,e.getRawAttribute(t),e.getTarget()),!1):w.isTruthy(r.value):!1}static isTruthy(e){if(e==null||e===!1)return!1;if(typeof e=="boolean")return e;if(typeof e=="string"){const t=e.trim().toLowerCase();return t!==""&&t!=="false"&&t!=="0"}return!!e}};w.CONFIG_KEYS=new Set(["interval","timeout","until","error-limit","disabled","state"]),w.DEFAULT_INTERVAL_MS=5e3,w.MIN_INTERVAL_MS=100,w.registrations=new Map,w.visibilityListener=null;let de=w;const pt="0.41.3";function Ut(g){typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>g()):Promise.resolve().then(g)}const B=class B{static isHtmlElement(e){if(!(e instanceof Element))return!1;const t=e.ownerDocument?.defaultView?.HTMLElement;return typeof t<"u"&&e instanceof t}static syncTree(e){(e instanceof Element||e instanceof DocumentFragment)&&(B.isHtmlElement(e)&&B.syncElement(e),e.querySelectorAll("*").forEach(t=>{B.syncElement(t)}))}static syncElement(e){const t=B.registrations.get(e),r=N.get(e);if(!(r instanceof T)||!B.shouldObserve(r)){t&&(t.observer.disconnect(),B.registrations.delete(e));return}if(typeof IntersectionObserver>"u")return;const i=B.resolveVarName(r);if(i===""){t&&(t.observer.disconnect(),B.registrations.delete(e)),m.warn("[Haori]",'data-each-visible requires a variable name (e.g. data-each-visible="visibleRange").');return}const n=B.resolveRoot(r),s=B.resolveRootMargin(r);if(t&&t.observer.root===n&&t.observer.rootMargin===s&&t.varName===i){t.fragment=r,B.refreshRows(t);return}t&&(t.observer.disconnect(),B.registrations.delete(e));const a=new IntersectionObserver(l=>{const c=B.registrations.get(e);if(!c)return;let d=!1;l.forEach(h=>{const y=h.target;c.observedRows.has(y)&&(h.isIntersecting?c.visibleRows.has(y)||(c.visibleRows.add(y),d=!0):c.visibleRows.delete(y)&&(d=!0))}),d&&B.scheduleCompute(c)},{root:n,rootMargin:s,threshold:B.THRESHOLD}),o={fragment:r,observer:a,varName:i,root:n,rootMargin:s,observedRows:new Set,visibleRows:new Set,scheduled:!1,lastSnapshot:null};B.registrations.set(e,o),B.refreshRows(o)}static cleanupTree(e){if(B.isHtmlElement(e)){const t=B.registrations.get(e);t&&(t.observer.disconnect(),B.registrations.delete(e))}(e instanceof Element||e instanceof DocumentFragment)&&e.querySelectorAll("*").forEach(t=>{const r=B.registrations.get(t);r&&(r.observer.disconnect(),B.registrations.delete(t))})}static disconnectAll(){B.registrations.forEach(e=>{e.observer.disconnect()}),B.registrations.clear()}static shouldObserve(e){return e.hasAttribute(`${u.prefix}each`)&&e.hasAttribute(`${u.prefix}each-visible`)}static resolveVarName(e){const t=e.getRawAttribute(`${u.prefix}each-visible`);return typeof t=="string"?t.trim():""}static resolveRoot(e){const t=`${u.prefix}each-visible-root`;if(!e.hasAttribute(t))return null;const r=e.getAttribute(t);if(typeof r!="string"||r.trim()==="")return null;const i=z.query(r,t,document);return B.isHtmlElement(i)?i:(m.error("[Haori]",`Visible range root element not found: ${r}`),null)}static resolveRootMargin(e){const t=`${u.prefix}each-visible-margin`,r=e.getAttribute(t);return r===null||r===!1||r===""?B.DEFAULT_ROOT_MARGIN:String(r)}static realRowElements(e){return e.getChildren().filter(t=>t instanceof T&&!t.hasAttribute(`${u.prefix}each-before`)&&!t.hasAttribute(`${u.prefix}each-after`)).map(t=>t.getTarget())}static refreshRows(e){const t=B.realRowElements(e.fragment),r=new Set(t);for(const i of[...e.observedRows])r.has(i)||(e.observer.unobserve(i),e.observedRows.delete(i),e.visibleRows.delete(i));for(const i of t)e.observedRows.has(i)||(e.observer.observe(i),e.observedRows.add(i));B.scheduleCompute(e)}static scheduleCompute(e){e.scheduled||(e.scheduled=!0,Ut(()=>{e.scheduled=!1;const t=e.fragment.getTarget();B.registrations.get(t)===e&&B.computeAndPublish(e)}))}static computeAndPublish(e){const t=B.realRowElements(e.fragment),r=new Map;t.forEach((a,o)=>r.set(a,o));const i=[];for(const a of e.visibleRows){const o=r.get(a);o!==void 0&&i.push(o)}let n;if(i.length===0)n={first:-1,last:-1,firstLabel:0,lastLabel:0,count:0,total:t.length,empty:!0};else{let a=i[0],o=i[0];for(const l of i)l<a&&(a=l),l>o&&(o=l);n={first:a,last:o,firstLabel:a+1,lastLabel:o+1,count:i.length,total:t.length,empty:!1}}const s=JSON.stringify(n);s!==e.lastSnapshot&&(e.lastSnapshot=s,B.publish(e,n))}static publish(e,t){const r=B.resolveBindOwner(e.fragment);if(!r){m.warn("[Haori]","data-each-visible found no ancestor data-bind scope to publish into.");return}const i=r.getTarget(),n={...r.getRawBindingData()??{}};n[e.varName]={...t};const s=e.fragment.getTarget(),a=i===s?new Set:new Set([e.fragment]);O.setBindingData(i,n,{skipFragments:a,reflectToAttribute:!1,kind:"nonSupply",sequence:T.nextSequence()}).catch(o=>{m.error("[Haori]","Failed to publish visible range:",o)})}static resolveBindOwner(e){const t=`${u.prefix}bind`;let r=e.getParent();for(;r;){if(r.hasAttribute(t))return r;r=r.getParent()}return e.hasAttribute(t)?e:null}};B.THRESHOLD=0,B.DEFAULT_ROOT_MARGIN="0px",B.registrations=new Map;let ae=B;const K=class K{static disconnectMutationObservers(){K._mutationObservers.forEach(e=>{e.disconnect()}),K._mutationObservers.length=0}static async init(){if(K._initialized)return;K._initialized=!0,K.disconnectMutationObservers(),T.setPendingMutationFlusher(()=>{K.flushPendingMutations()});const e=new Le;K._dispatcher=e,e.startDeferred();try{const t=await Promise.allSettled([O.scan(document.head),O.scan(document.body)]),[r,i]=t;r.status!=="fulfilled"&&m.error("[Haori]","Failed to build head fragment:",r.reason),i.status!=="fulfilled"&&m.error("[Haori]","Failed to build body fragment:",i.reason),await V.wait(),document.body.setAttribute("data-haori-ready",""),K.observe(document.head),K.observe(document.body),ce.syncTree(document.body),de.syncTree(document.body),ae.syncTree(document.body)}finally{e.release()}H.ready(pt)}static getDispatcher(){return K._dispatcher}static isExternallyManaged(e){return(e instanceof Element?e:e?.parentElement??null)?.closest(`[${u.prefix}external]`)!=null}static observe(e){const t=new MutationObserver(r=>{K.processMutations(r)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),K._mutationObservers.push(t)}static flushPendingMutations(){for(const e of K._mutationObservers){const t=e.takeRecords();if(t.length===0)continue;const r=t.filter(K.isBindAttributeRecord),i=t.filter(n=>!K.isBindAttributeRecord(n));r.length>0&&K.processMutations(r,T.nextSequence()),i.length>0&&Promise.resolve().then(()=>{K.processMutations(i)})}}static isBindAttributeRecord(e){return e.type==="attributes"&&e.attributeName===`${u.prefix}bind`}static processMutations(e,t){for(const r of e)try{if(K.isExternallyManaged(r.target))continue;switch(r.type){case"attributes":{const i=r.target;if(r.attributeName&&i.hasAttribute("data-haori-click-lock")&&(r.attributeName==="disabled"||r.attributeName==="data-haori-click-lock")||r.attributeName&&i.hasAttribute(pe)&&(r.attributeName==="disabled"||r.attributeName===pe)||r.attributeName&&O.isAliasedAttributeReflection(i,r.attributeName))break;O.setAttribute(i,r.attributeName,i.getAttribute(r.attributeName),!0,t),ce.syncElement(i),de.syncElement(i),ae.syncElement(i);break}case"childList":{Array.from(r.removedNodes).forEach(i=>{ce.cleanupTree(i),de.cleanupTree(i),ae.cleanupTree(i),O.removeNode(i)}),Array.from(r.addedNodes).forEach(i=>{i.parentElement instanceof Element&&(O.addNode(i.parentElement,i),ce.syncTree(i),de.syncTree(i),ae.syncTree(i))}),r.target instanceof Element&&ae.syncElement(r.target);break}case"characterData":{r.target instanceof Text||r.target instanceof Comment?O.changeText(r.target,r.target.textContent):m.warn("[Haori]","Unsupported character data type:",r.target);break}default:m.warn("[Haori]","Unknown mutation type:",r.type);continue}}catch(i){m.error("[Haori]","Error processing mutation:",i)}}};K._initialized=!1,K._mutationObservers=[],K._dispatcher=null;let Re=K;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Re.init):Re.init();const Vt=()=>ne.waitForRenders(),qt=ne.enhancers;exports.Core=O;exports.Enhance=ee;exports.Env=u;exports.Form=F;exports.Fragment=N;exports.Haori=ne;exports.Log=m;exports.Queue=V;exports.default=ne;exports.enhancers=qt;exports.version=pt;exports.waitForRenders=Vt;
|
|
29
29
|
//# sourceMappingURL=haori.cjs.js.map
|
package/dist/haori.es.js
CHANGED
|
@@ -3349,10 +3349,13 @@ const M = class M extends N {
|
|
|
3349
3349
|
/**
|
|
3350
3350
|
* この入力欄がユーザーに編集されたことを記録します。
|
|
3351
3351
|
*
|
|
3352
|
-
* DOM で `change` / `input`
|
|
3353
|
-
*
|
|
3354
|
-
*
|
|
3355
|
-
*
|
|
3352
|
+
* DOM で `change` / `input` が発火した時点に呼び出します。イベントを伴って値を
|
|
3353
|
+
* 反映した場合(`Form.setValues()` など)も、その発火を通じて呼ばれます。
|
|
3354
|
+
* イベントを伴わない反映(`syncBindingValue()` や `Core.setBindingData()` 由来の
|
|
3355
|
+
* 書き戻し)では呼び出しません。
|
|
3356
|
+
*
|
|
3357
|
+
* 内部値の同期(`syncValue()`)とは独立です。手続きを起動しない `input` では
|
|
3358
|
+
* 発番だけを行い、内部値は同期しません(`EventDispatcher.recordUserEdit()`)。
|
|
3356
3359
|
*
|
|
3357
3360
|
* @returns 発番した編集の通番
|
|
3358
3361
|
*/
|
|
@@ -11964,13 +11967,23 @@ const fe = class fe {
|
|
|
11964
11967
|
n();
|
|
11965
11968
|
}
|
|
11966
11969
|
/**
|
|
11967
|
-
* 手続きを起動しない `input`
|
|
11970
|
+
* 手続きを起動しない `input` について、ユーザー編集の通番だけを発番します。
|
|
11968
11971
|
*
|
|
11969
11972
|
* `data-input-*` を宣言していない入力欄でも、打鍵は編集として記録しなければ
|
|
11970
11973
|
* なりません(記録しないと、反映待ちの書き込みが打鍵の後に着弾して打った文字を
|
|
11971
11974
|
* 消します)。初期化中は手続きと同じく保留し、フラグメントが確定した後に記録
|
|
11972
11975
|
* します。
|
|
11973
11976
|
*
|
|
11977
|
+
* **内部値は同期しません**(`syncUserEdit()` との違い)。内部値は「バインドデータへ
|
|
11978
|
+
* 載っている値」を表し、DOM が先に進むことは許されています(値収集は DOM を真として
|
|
11979
|
+
* 読みます。`ElementFragment.getValueForCollection()`)。ここで同期すると、まだ
|
|
11980
|
+
* バインドデータへ載っていない値が内部値だけに載った状態になり、次の逆方向同期
|
|
11981
|
+
* (`Form.syncValues()`)が古いバインドデータで入力欄を上書きして値を消します。
|
|
11982
|
+
* 反映待ちの書き込みからの保護は通番の発番だけで成立します。
|
|
11983
|
+
*
|
|
11984
|
+
* 内部値を DOM から取り込むのは、値がバインドデータへ載る機会(`change` の双方向
|
|
11985
|
+
* コミット、または `data-input-*` を宣言した要素の手続き)と同じ時点だけです。
|
|
11986
|
+
*
|
|
11974
11987
|
* 対象は値を持つ入力要素だけです。`contenteditable` など値収集の対象でない要素で
|
|
11975
11988
|
* `input` が発火しても、記録すべき編集はありません。
|
|
11976
11989
|
*
|
|
@@ -11981,16 +11994,30 @@ const fe = class fe {
|
|
|
11981
11994
|
if (!(!(e instanceof HTMLInputElement) && !(e instanceof HTMLSelectElement) && !(e instanceof HTMLTextAreaElement))) {
|
|
11982
11995
|
if (this.deferred) {
|
|
11983
11996
|
this.deferredProcedures.push(() => {
|
|
11984
|
-
e.isConnected && this.
|
|
11997
|
+
e.isConnected && this.markUserEditOnly(e);
|
|
11985
11998
|
});
|
|
11986
11999
|
return;
|
|
11987
12000
|
}
|
|
11988
|
-
this.
|
|
12001
|
+
this.markUserEditOnly(e);
|
|
11989
12002
|
}
|
|
11990
12003
|
}
|
|
12004
|
+
/**
|
|
12005
|
+
* 内部値を同期せず、ユーザー編集の通番だけを発番します。
|
|
12006
|
+
*
|
|
12007
|
+
* @param element 編集された要素
|
|
12008
|
+
* @returns 戻り値はない。
|
|
12009
|
+
*/
|
|
12010
|
+
markUserEditOnly(e) {
|
|
12011
|
+
const t = N.get(e);
|
|
12012
|
+
t instanceof T && t.markUserEdit();
|
|
12013
|
+
}
|
|
11991
12014
|
/**
|
|
11992
12015
|
* `change` / `input` の対象要素について、内部値の同期とユーザー編集の記録を行います。
|
|
11993
12016
|
*
|
|
12017
|
+
* 呼び出すのは、値がバインドデータへ載る機会と同じ時点に限ります(`change` の
|
|
12018
|
+
* 双方向コミット、または `data-input-*` を宣言した要素の手続き)。手続きを
|
|
12019
|
+
* 起動しない `input` では内部値を同期してはいけません(`recordUserEdit()`)。
|
|
12020
|
+
*
|
|
11994
12021
|
* @param element 編集された要素
|
|
11995
12022
|
* @returns 戻り値はない。
|
|
11996
12023
|
*/
|
|
@@ -12728,7 +12755,7 @@ w.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
12728
12755
|
"state"
|
|
12729
12756
|
]), w.DEFAULT_INTERVAL_MS = 5e3, w.MIN_INTERVAL_MS = 100, w.registrations = /* @__PURE__ */ new Map(), w.visibilityListener = null;
|
|
12730
12757
|
let ce = w;
|
|
12731
|
-
const Ht = "0.41.
|
|
12758
|
+
const Ht = "0.41.3";
|
|
12732
12759
|
function Ut(g) {
|
|
12733
12760
|
typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => g()) : Promise.resolve().then(g);
|
|
12734
12761
|
}
|
package/dist/haori.iife.js
CHANGED
|
@@ -24,6 +24,6 @@ ${R}
|
|
|
24
24
|
${r}
|
|
25
25
|
);`)}catch{try{i=new Function(`"use strict";
|
|
26
26
|
${r}
|
|
27
|
-
`)}catch(n){m.error("[Haori]",`Invalid each-rendered-run script: ${n}`)}}if(i)try{i.call(e)}catch(n){m.error("[Haori]",`each-rendered-run execution error: ${n}`)}}static runEachRenderedChange(e){const t=`${u.prefix}each-rendered-change`,r=e.getTarget();if(!r.hasAttribute(t))return;const i=String(r.getAttribute(t)??"").trim().toLowerCase();let n=!1;if(i==="always"?n=!0:i!==""&&i!=="once"&&(f.EACH_RENDERED_CHANGE_WARNED.has(r)||(f.EACH_RENDERED_CHANGE_WARNED.add(r),m.warn("[Haori]",`Invalid ${t} value: "${i}". Use "once" (default) or "always".`))),f.countEachRenderedRows(e)!==0){if(!n){if(f.EACH_RENDERED_CHANGE_FIRED.has(r))return;f.EACH_RENDERED_CHANGE_FIRED.add(r)}try{r.dispatchEvent(new Event("change",{bubbles:!0}))}catch(s){m.error("[Haori]",`each-rendered-change dispatch error: ${s}`)}}}static countEachRenderedRows(e){let t=0;for(const r of e.getChildElementFragments())r.getTarget().hasAttribute(`${u.prefix}row`)&&(t+=1);return t}static performEachUpdate(e){const t=f.resolveEachItems(e);if(t===null)return Promise.reject(new Error("Invalid each attribute."));let r=e.getTemplate();const i=e.getAttribute(`${u.prefix}each-key`),n=f.createBindingSignature({key:i?String(i):null,items:t});if(r===null){let s=!1;if(e.getChildren().forEach(a=>{if(!s&&a instanceof T){if(a.hasAttribute(`${u.prefix}each-before`)||a.hasAttribute(`${u.prefix}each-after`))return;r=a.clone(),f.markFreshInitializationSkippable(r),e.setTemplate(r),s=!0,e.removeChild(a);const o=a.getTarget();o.parentNode&&o.parentNode.removeChild(o),a.setMounted(!1)}}),!s){const a=e.getTarget();Array.from(a.children).filter(l=>!l.hasAttribute(`${u.prefix}each-before`)&&!l.hasAttribute(`${u.prefix}each-after`)).forEach(l=>{if(!s){const d=N.get(l);d instanceof T&&(r=d.clone(),f.markFreshInitializationSkippable(r),e.setTemplate(r),s=!0)}const c=N.get(l);c instanceof T&&e.getChildren().includes(c)&&(e.removeChild(c),c.setMounted(!1)),l.parentNode&&l.parentNode.removeChild(l)})}return this.updateDiff(e,t).then(()=>{e.setEachInputSignature(n)})}return e.getEachInputSignature()===n?f.reevaluateEachRows(e):this.updateDiff(e,t).then(()=>{e.setEachInputSignature(n)})}static reevaluateEachRows(e){if(f.isRowLocalEachTemplate(e))return Promise.resolve();const t=e.getChildElementFragments().filter(r=>!r.hasAttribute(`${u.prefix}each-before`)&&!r.hasAttribute(`${u.prefix}each-after`));return t.length===0?Promise.resolve():Promise.all(t.map(r=>f.evaluateAll(r))).then(()=>{})}static resolveEachItems(e){const t=e.getAttributeEvaluation(`${u.prefix}each`),r=t?.value;return t?.hasUnresolvedReference||r===!1||r===null||r===void 0?[]:Array.isArray(r)?r:(m.error("[Haori]","Invalid each attribute:",r),null)}static canSkipUnchangedNestedEach(e){if(!e.hasAttribute(`${u.prefix}each`)||e.getEachInputSignature()===null)return!1;const t=e.getParent();if(t?.closestByAttribute(`${u.prefix}derive`)||t?.closestByAttribute(`${u.prefix}derive-name`)||t?.closestByAttribute(`${u.prefix}if`)||t?.closestByAttribute(`${u.prefix}fetch`)||t?.closestByAttribute(`${u.prefix}import`)||f.hasNonEachDynamicElementState(e)||!f.isRowLocalEachTemplate(e))return!1;const r=f.resolveEachItems(e);if(r===null)return!1;const i=e.getAttribute(`${u.prefix}each-key`),n=f.createBindingSignature({key:i?String(i):null,items:r});return e.getEachInputSignature()===n}static isRowLocalEachTemplate(e){const t=e.getRowLocalTemplate();if(t!==null)return t;const r=e.getTemplate(),i=e.getAttribute(`${u.prefix}each-arg`);if(r===null||!i)return e.setRowLocalTemplate(!1),!1;const n=new Set([String(i)]),s=e.getAttribute(`${u.prefix}each-index`);s&&n.add(String(s));const a=f.isRowLocalSubtree(r,n);return e.setRowLocalTemplate(a),a}static isRowLocalSubtree(e,t){for(const i of e.getAttributeNames()){const n=e.getRawAttribute(i),s=typeof n=="string"?n:"";if(s.includes("{{")){if(!f.areExpressionsRowLocal(f.extractInterpolations(s),t))return!1;continue}if(!i.startsWith(u.prefix))continue;const a=i.slice(u.prefix.length);if(f.ROW_LOCAL_EXPRESSION_ATTRIBUTES.has(a)){if(!f.areExpressionsRowLocal([s],t))return!1;continue}if(!f.ROW_LOCAL_STATIC_ATTRIBUTES.has(a))return!1}let r=t;if(e.hasAttribute(`${u.prefix}each`)){const i=e.getRawAttribute(`${u.prefix}each-arg`);if(typeof i!="string"||i==="")return!1;const n=new Set(t);n.add(i);const s=e.getRawAttribute(`${u.prefix}each-index`);typeof s=="string"&&s!==""&&n.add(s),r=n}for(const i of e.getChildren())if(i instanceof T){if(!f.isRowLocalSubtree(i,r))return!1}else if(i instanceof Z){const n=i.getRawText();if(n.includes("{{")&&!f.areExpressionsRowLocal(f.extractInterpolations(n),t))return!1}return!0}static areExpressionsRowLocal(e,t){for(const r of e){const i=r.trim();if(i==="")continue;const n=J.getFreeIdentifiers(i);if(n.length===0||n.some(s=>!t.has(s)))return!1}return!0}static extractInterpolations(e){const t=[],r=/\{\{([\s\S]*?)\}\}/g;let i=r.exec(e);for(;i!==null;)t.push(i[1]),i=r.exec(e);return t}static canSkipStableDerivedSubtree(e){return!e.hasAttribute(`${u.prefix}derive`)||e.hasAttribute(`${u.prefix}if`)||e.hasAttribute(`${u.prefix}each`)||e.hasAttribute(`${u.prefix}fetch`)||e.hasAttribute(`${u.prefix}import`)?!1:!f.hasDisallowedDerivedSubtreeDescendant(e)}static hasDisallowedDerivedSubtreeDescendant(e){return e.getChildren().some(t=>t instanceof T?t.hasAttribute(`${u.prefix}derive`)||t.hasAttribute(`${u.prefix}derive-name`)||t.hasAttribute(`${u.prefix}fetch`)||t.hasAttribute(`${u.prefix}import`)?!0:f.hasDisallowedDerivedSubtreeDescendant(t):!1)}static createDescendantBindingSignature(e,t){return f.recordDerivedSubtreeSignatureComputation(e,t),f.createBindingSignature(e.getDescendantBindingData())}static createDeriveInputSignature(e,t,r){const i=typeof r=="string"?r.trim():"";return!t||i===""?null:f.createBindingSignature({expression:t,name:i,scope:e.getBindingData()})}static refreshDerivedSubtreeSignature(e){if(!f.canSkipStableDerivedSubtree(e)){e.setDeriveSubtreeSignature(null),f.logDerivedSubtreeProfileSnapshot(e,"skip-ineligible");return}e.setDeriveSubtreeSignature(f.createDescendantBindingSignature(e,"refresh")),f.logDerivedSubtreeProfileSnapshot(e,"refresh")}static getOrCreateDerivedSubtreeProfile(e){if(!q.isEnabled()||!e.hasAttribute(`${u.prefix}derive`))return null;const t=f.DERIVE_SUBTREE_PROFILES.get(e);if(t)return t;const r={hostId:f.createDerivedSubtreeHostId(e),signatureComputeTotal:0,signatureComputeFromEvaluateAll:0,signatureComputeFromRefresh:0,skipHitCount:0,skipMissCount:0,skipIneligibleCount:0};return f.DERIVE_SUBTREE_PROFILES.set(e,r),r}static resolveElementId(e){return e.getAttribute("id")??""}static createDerivedSubtreeHostId(e){const t=[];let r=e;for(;r;){const i=r.getTarget();if(!(i instanceof HTMLElement))break;let n=i.tagName.toLowerCase();const s=f.resolveElementId(i).trim();if(s!==""){n+=`#${s}`,t.unshift(n);break}const a=r.getRawAttribute(`${u.prefix}derive-name`);typeof a=="string"&&a.trim()!==""&&(n+=`[${u.prefix}derive-name="${a.trim()}"]`);const o=r.getParent();if(o){const l=o.getChildren().filter(c=>c instanceof T).findIndex(c=>c===r);n+=`:nth-child(${l+1})`}t.unshift(n),r=o}return t.join(" > ")}static recordDerivedSubtreeSignatureComputation(e,t){const r=f.getOrCreateDerivedSubtreeProfile(e);if(r!==null){if(r.signatureComputeTotal+=1,t==="refresh"){r.signatureComputeFromRefresh+=1;return}r.signatureComputeFromEvaluateAll+=1}}static logDerivedSubtreeProfileSnapshot(e,t){const r=f.getOrCreateDerivedSubtreeProfile(e);r!==null&&(t==="skip-hit"?r.skipHitCount+=1:t==="skip-miss"?r.skipMissCount+=1:t==="skip-ineligible"&&(r.skipIneligibleCount+=1),m.info("[Haori][derive-profile]",{reason:t,hostId:r.hostId,signatureComputeTotal:r.signatureComputeTotal,signatureComputeFromEvaluateAll:r.signatureComputeFromEvaluateAll,signatureComputeFromRefresh:r.signatureComputeFromRefresh,skipHitCount:r.skipHitCount,skipMissCount:r.skipMissCount,skipIneligibleCount:r.skipIneligibleCount}))}static hasNonEachDynamicElementState(e){const t=new Set([`${u.prefix}each`,`${u.prefix}each-key`,`${u.prefix}each-arg`,`${u.prefix}each-index`]);return e.getAttributeNames().some(i=>{if(t.has(i))return!1;if(i.startsWith(`${u.prefix}attr-`)||i.startsWith(u.prefix))return!0;const n=e.getRawAttribute(i);return typeof n=="string"&&n.includes("{{")})?!0:e.getChildren().some(i=>i instanceof Z&&i.hasDynamicContent())}static markFreshInitializationSkippable(e){const t=e.getAttributeNames().some(n=>f.isFreshInitializationDynamicAttribute(e,n)),r=e.getChildren().some(n=>n instanceof T?!f.markFreshInitializationSkippable(n):n instanceof Z?n.hasDynamicContent():!1),i=!t&&!r;return e.setFreshInitializationSkippable(i),i}static isFreshInitializationDynamicAttribute(e,t){if(t.startsWith(`${u.prefix}attr-`)||t.startsWith(u.prefix))return!0;const r=e.getRawAttribute(t);return typeof r=="string"&&r.includes("{{")}static updateDiff(e,t){const r=e.getTemplate();if(r===null)return m.error("[Haori]","Template is not set for each element."),Promise.resolve();let i=e.getAttribute(`${u.prefix}each-index`);i&&(i=String(i));const n=e.getAttribute(`${u.prefix}each-key`),s=e.getAttribute(`${u.prefix}each-arg`),a=t.map((E,v)=>f.createListKey(E,n?String(n):null,v)),o=new Set(a),l=new Map;a.forEach(E=>{l.set(E,(l.get(E)??0)+1)}),n&&o.size!==a.length&&f.warnDuplicateEachKey(String(n));const c=[];let d=e.getChildren().filter(E=>E instanceof T).filter(E=>!E.hasAttribute(`${u.prefix}each-before`)&&!E.hasAttribute(`${u.prefix}each-after`));const h=d.map(E=>E.getListKey()),y=new Set;d=d.filter((E,v)=>{const R=String(E.getListKey()),M=l.get(R)??0;if(M===0){y.add(E);const x=E.getListKey();return x!==null&&H.rowRemove(E.getTarget(),x,v),c.push(E.remove()),!1}return l.set(R,M-1),!0});const A=d.map(E=>E.getListKey()),S=new Map;d.forEach(E=>{const v=E.getListKey();if(v===null)return;const R=S.get(v);R?R.push(E):S.set(v,[E])});const P=e.getChildElementFragments().filter(E=>!y.has(E)),D=P.filter(E=>E.hasAttribute(`${u.prefix}each-before`)).length;let L=Promise.resolve();return a.forEach((E,v)=>{const R=t[v],M=v;let x;const j=S.get(E)?.shift();if(j){x=j;const G=D+v;L=L.then(()=>f.updateRowFragment(x,R,i,M,s?String(s):null,E).then(te=>f.repositionEachRow(e,x,P,G).then(Q=>{if(Q!==null&&H.rowMove(x.getTarget(),E,Q-D,v),!!te)return f.clearUserEditMarks(x),f.evaluateAll(x).then(()=>f.applyRowFormValues(e,x,R))})))}else{x=r.clone();const G=D+v;L=L.then(()=>f.updateRowFragment(x,R,i,M,s?String(s):null,E).then(()=>{const te=P[G]??null;return e.insertBefore(x,te).then(()=>{P.splice(G,0,x)}).then(()=>f.initializeFreshEachRow(x)).then(()=>f.applyRowFormValues(e,x,R)).then(()=>{H.rowAdd(x.getTarget(),E,M,R)})}))}}),Promise.all(c).then(()=>L).then(()=>{const E=a.filter(G=>G!==null),v=A.filter(G=>G!==null),R=new Set(v),M=E.filter(G=>!R.has(G)),j=h.filter(G=>G!==null).filter(G=>!o.has(G));H.eachUpdate(e.getTarget(),M,j,E)})}static warnDuplicateEachKey(e){!q.isEnabled()||f.WARNED_DUPLICATE_EACH_KEYS.has(e)||(f.WARNED_DUPLICATE_EACH_KEYS.add(e),m.warn("[Haori]",`${u.prefix}each-key="${e}" の値が配列の中で重複しています。行は出現順で対応付けますが、キーによる行の識別はできません。`))}static repositionEachRow(e,t,r,i){const n=r.indexOf(t);if(n===-1||n===i)return Promise.resolve(null);r.splice(n,1);const s=r[i]??null;return r.splice(i,0,t),e.insertBefore(t,s).then(()=>n)}static applyRowFormValues(e,t,r){return!e.hasAttribute(`${u.prefix}form-list`)||!F.isCollectedListFromEachSource(e)||typeof r!="object"||r===null||Array.isArray(r)?Promise.resolve():F.syncRowValues(t,r)}static createListKey(e,t,r){let i;if(typeof e=="object"&&e!==null)if(t){const n=e[t];n==null?i=`__index_${r}`:typeof n=="object"?i=JSON.stringify(n):i=String(n)}else i=`__index_${r}`;else i=String(e);return i}static updateRowFragment(e,t,r,i,n,s){let a;if(typeof t=="object"&&t!==null)a=n?{[n]:{...t}}:{...t};else if(n)a={[n]:t};else return m.error("[Haori]",`Primitive value requires '${u.prefix}each-arg' attribute: ${t}`),Promise.resolve(!1);r&&(a[r]=i);const o=a,l=f.createBindingSignature({listKey:s,bindingData:o});return e.getListKey()===s&&e.getRenderSignature()===l?Promise.resolve(!1):(e.setListKey(s),e.setRenderSignature(l),e.setBindingData(o),e.setAttribute(`${u.prefix}row`,s).then(()=>!0))}static needsScheduledEvaluateAll(e){const t=[e];for(;t.length>0;){const r=t.pop();if(r.getChildElementFragments().forEach(i=>{t.push(i)}),r!==e&&!r.isMounted()&&f.hasMountSensitiveAttribute(r))return!0}return!1}static hasMountSensitiveAttribute(e){return["fetch","import"].some(t=>e.hasAttribute(`${u.prefix}${t}`))}static createBindingSignature(e,t=new WeakMap,r={value:0}){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);if(typeof e=="function")return`[Function:${e.name||"anonymous"}]`;if(typeof e=="symbol")return e.toString();if(e instanceof Date)return`[Date:${e.toISOString()}]`;if(typeof File<"u"&&e instanceof File)return`[File:${e.name}:${e.size}:${e.lastModified}:${e.type}]`;if(typeof Blob<"u"&&e instanceof Blob)return`[Blob:${e.size}:${e.type}]`;if(Array.isArray(e)){if(t.has(e))return`[Circular:${t.get(e)}]`;const i=`array-${r.value}`;return r.value+=1,t.set(e,i),`[${e.map(n=>f.createBindingSignature(n,t,r)).join(",")}]`}if(typeof e=="object"){if(t.has(e))return`[Circular:${t.get(e)}]`;const i=`object-${r.value}`;r.value+=1,t.set(e,i);const n=e;return`{${Object.keys(n).sort().map(s=>`${JSON.stringify(s)}:${f.createBindingSignature(n[s],t,r)}`).join(",")}}`}return String(e)}static scheduleEvaluateAll(e){setTimeout(()=>{f.evaluateAll(e)},100)}};f.ATTRIBUTE_ALIAS_SUFFIX="attr-",f.PRIORITY_ATTRIBUTE_SUFFIXES=["bind","store","url-param","derive-name","derive","if","each"],f.DEFERRED_ATTRIBUTE_SUFFIXES=["fetch"],f.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES=["bind","derive","derive-name","if","each","fetch","import","url-param","store","validity","validity-message"],f.ATTRIBUTE_PLACEHOLDER_REGEX=/\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/,f.ROW_LOCAL_EXPRESSION_ATTRIBUTES=new Set(["each","if","derive"]),f.ROW_LOCAL_STATIC_ATTRIBUTES=new Set(["each-arg","each-key","each-index","each-before","each-after","derive-name","row","form","form-arg","form-list","form-object","form-detach","store","store-params","store-arg","store-type","enhance","enhance-new"]),f.REACTIVE_FETCH_STATES=new WeakMap,f.REACTIVE_IMPORT_STATES=new WeakMap,f.DERIVE_SUBTREE_PROFILES=new WeakMap,f.EACH_UPDATE_STATES=new WeakMap,f.EACH_RENDERED_CHANGE_FIRED=new WeakSet,f.EACH_RENDERED_CHANGE_WARNED=new WeakSet,f.WARNED_DUPLICATE_EACH_KEYS=new Set,f.ABSENT_PATH=Symbol("absent");let B=f;const he=class he{constructor(e=document){this.customEventHandlers=new Map,this.builtinListenersAdded=!1,this.deferred=!1,this.deferredProcedures=[],this.onClick=t=>this.delegate(t,"click"),this.onChange=t=>this.delegate(t,"change"),this.onInput=t=>this.delegate(t,"input"),this.onLoadCapture=t=>this.delegate(t,"load"),this.onWindowLoad=()=>{if(this.deferred){this.deferredProcedures.push(()=>this.runWindowLoadProcedure());return}this.runWindowLoadProcedure()},this.onPopstate=t=>{const r=t.state;!r||r[he.HISTORY_STATE_KEY]!==!0||location.reload()},this.root=e}runWindowLoadProcedure(){const e=document.documentElement,t=N.get(e);t&&new ee(t,"load").run()}start(){this.deferred=!1,this.addBuiltinListeners(),this.subscribeDeclaredCustomEvents(),this.observeCustomEventDeclarations()}startDeferred(){this.deferred=!0,this.addBuiltinListeners(),this.subscribeDeclaredCustomEvents()}release(){if(!this.deferred)return;this.deferred=!1,this.subscribeDeclaredCustomEvents(),this.observeCustomEventDeclarations();const e=this.deferredProcedures.splice(0);for(const t of e)try{t()}catch(r){m.error("[Haori]","Deferred event handling error:",r)}}addBuiltinListeners(){this.builtinListenersAdded||(this.builtinListenersAdded=!0,this.root.addEventListener("click",this.onClick),this.root.addEventListener("change",this.onChange),this.root.addEventListener("input",this.onInput),this.root.addEventListener("load",this.onLoadCapture,!0),window.addEventListener("load",this.onWindowLoad,{once:!0}),window.addEventListener("popstate",this.onPopstate))}stop(){this.root.removeEventListener("click",this.onClick),this.root.removeEventListener("change",this.onChange),this.root.removeEventListener("input",this.onInput),this.root.removeEventListener("load",this.onLoadCapture,!0),window.removeEventListener("load",this.onWindowLoad),window.removeEventListener("popstate",this.onPopstate),this.builtinListenersAdded=!1,this.deferred=!1,this.deferredProcedures.length=0;for(const[e,t]of this.customEventHandlers)window.removeEventListener(e,t,!0);this.customEventHandlers.clear(),this.customEventObserver?.disconnect(),this.customEventObserver=void 0}get onAttributeName(){return`${u.prefix}on`}subscribeDeclaredCustomEvents(){this.root.querySelectorAll(`[${this.onAttributeName}]`).forEach(t=>this.subscribeCustomEvent(t.getAttribute(this.onAttributeName)))}subscribeCustomEvent(e){if(e===null||e==="")return;if(he.BUILTIN_EVENT_NAMES.has(e)){m.warn("[Haori]",`data-on="${e}" は組み込みイベントです。data-${e}-* を使用してください(data-on はカスタムイベント専用)。`);return}if(this.customEventHandlers.has(e))return;const t=r=>this.runCustomEventProcedures(e,r);this.customEventHandlers.set(e,t),window.addEventListener(e,t,!0)}runCustomEventProcedures(e,t){if(this.deferred){this.deferredProcedures.push(()=>this.runCustomEventProcedures(e,t));return}this.root.querySelectorAll(`[${this.onAttributeName}]`).forEach(i=>{if(i.getAttribute(this.onAttributeName)!==e)return;const n=N.get(i);n instanceof T&&new ee(n,"on",t).run().catch(s=>{m.error("[Haori]","Procedure execution error:",s)})})}observeCustomEventDeclarations(){if(typeof MutationObserver>"u")return;const e=this.root instanceof Document?this.root:this.root.ownerDocument??document,t=this.root instanceof Document?e.body:this.root;t&&(this.customEventObserver=new MutationObserver(r=>{for(const i of r)i.addedNodes.forEach(n=>{n instanceof HTMLElement&&(n.hasAttribute(this.onAttributeName)&&this.subscribeCustomEvent(n.getAttribute(this.onAttributeName)),n.querySelectorAll(`[${this.onAttributeName}]`).forEach(s=>this.subscribeCustomEvent(s.getAttribute(this.onAttributeName))))})}),this.customEventObserver.observe(t,{childList:!0,subtree:!0}))}delegate(e,t){const r=this.getElementFromTarget(e.target,t);if(r){if(t==="input"){const i=`${u.prefix}input-`;if(!r.getAttributeNames().some(s=>s.startsWith(i))){this.recordUserEdit(r);return}}if(r.hasAttribute(`${u.prefix}${t}-prevent`)&&e.preventDefault(),this.deferred){this.deferredProcedures.push(()=>{r.isConnected&&this.runProcedureFor(r,t,e)});return}this.runProcedureFor(r,t,e)}}runProcedureFor(e,t,r){const i=N.get(e);if(!i)return;(t==="change"||t==="input")&&this.syncUserEdit(e);const n=()=>{new ee(i,t,r).run().catch(s=>{m.error("[Haori]","Procedure execution error:",s)})};if(t==="click"&&e.hasAttribute(`${u.prefix}click-defer`)){typeof requestAnimationFrame<"u"?requestAnimationFrame(()=>n()):setTimeout(n,0);return}n()}recordUserEdit(e){if(!(!(e instanceof HTMLInputElement)&&!(e instanceof HTMLSelectElement)&&!(e instanceof HTMLTextAreaElement))){if(this.deferred){this.deferredProcedures.push(()=>{e.isConnected&&this.syncUserEdit(e)});return}this.syncUserEdit(e)}}syncUserEdit(e){const t=N.get(e);if(t instanceof T&&(t.syncValue(),t.markUserEdit(),e instanceof HTMLInputElement&&e.type==="radio"&&e.name)){const r=document.getElementsByName(e.name);for(const i of Array.from(r)){if(i===e||!(i instanceof HTMLInputElement)||i.type!=="radio"||i.form!==e.form)continue;const n=N.get(i);n instanceof T&&(n.syncValue(),n.markUserEdit())}}}getElementFromTarget(e,t){if(!e)return null;if(e instanceof HTMLElement)return t==="click"?this.findClickableElement(e):e;if(e instanceof Node){const r=e.parentElement;return r?t==="click"?this.findClickableElement(r):r:null}return null}findClickableElement(e){const t=`${u.prefix}click-`,r=`${u.prefix}click-passive`;let i=e;for(;i;){if(i.getAttributeNames().some(s=>s.startsWith(t)&&s!==r))return i;if(i.hasAttribute(r))return null;i=i.parentElement}return null}};he.HISTORY_STATE_KEY="__haoriHistoryState__",he.BUILTIN_EVENT_NAMES=new Set(["click","change","input","load"]);let Pe=he;const U=class U{static isHtmlElement(e){if(!(e instanceof Element))return!1;const t=e.ownerDocument?.defaultView?.HTMLElement;return typeof t<"u"&&e instanceof t}static syncTree(e){(e instanceof Element||e instanceof DocumentFragment)&&(U.isHtmlElement(e)&&U.syncElement(e),e.querySelectorAll("*").forEach(t=>{U.syncElement(t)}))}static syncElement(e){const t=U.registrations.get(e),r=N.get(e);if(!r||!U.shouldObserve(r)){t&&(t.observer.disconnect(),U.registrations.delete(e));return}if(typeof IntersectionObserver>"u")return;const i=U.resolveRoot(r),n=U.resolveRootMargin(r),s=U.resolveThreshold(r),a=r.hasAttribute(`${u.prefix}intersect-once`);if(t&&t.observer.root===i&&t.observer.rootMargin===n&&U.sameThreshold(t.observer.thresholds,s)&&t.once===a){t.fragment=r;return}t&&(t.observer.disconnect(),U.registrations.delete(e));const o=new IntersectionObserver(l=>{const c=U.registrations.get(e);c&&l.forEach(d=>{!d.isIntersecting||c.running||U.isDisabled(c.fragment)||(c.running=!0,new ee(c.fragment,"intersect").runWithResult().then(h=>{h&&c.once&&(c.observer.disconnect(),U.registrations.delete(e))}).catch(h=>{m.error("[Haori]","Intersect procedure execution error:",h)}).finally(()=>{const h=U.registrations.get(e);h&&(h.running=!1)}))})},{root:i,rootMargin:n,threshold:s});o.observe(e),U.registrations.set(e,{fragment:r,observer:o,once:a,running:!1})}static cleanupTree(e){if(U.isHtmlElement(e)){const t=U.registrations.get(e);t&&(t.observer.disconnect(),U.registrations.delete(e))}(e instanceof Element||e instanceof DocumentFragment)&&e.querySelectorAll("*").forEach(t=>{const r=U.registrations.get(t);r&&(r.observer.disconnect(),U.registrations.delete(t))})}static disconnectAll(){U.registrations.forEach(e=>{e.observer.disconnect()}),U.registrations.clear()}static shouldObserve(e){return e.getAttributeNames().some(t=>{if(!t.startsWith(`${u.prefix}intersect-`))return!1;const r=t.slice(`${u.prefix}intersect-`.length);return!U.CONFIG_KEYS.has(r)})}static resolveRoot(e){const t=`${u.prefix}intersect-root`;if(!e.hasAttribute(t))return null;const r=e.getAttribute(t);if(typeof r!="string"||r.trim()==="")return null;const i=z.query(r,t,document);return U.isHtmlElement(i)?i:(m.error("[Haori]",`Intersect root element not found: ${r}`),null)}static resolveRootMargin(e){const t=`${u.prefix}intersect-root-margin`,r=e.getAttribute(t);return r===null||r===!1||r===""?"0px":String(r)}static resolveThreshold(e){const t=`${u.prefix}intersect-threshold`,r=e.getAttribute(t),i=typeof r=="number"?r:Number.parseFloat(String(r??0));return Number.isNaN(i)?0:Math.min(1,Math.max(0,i))}static isDisabled(e){const t=`${u.prefix}intersect-disabled`,r=e.getAttribute(t);if(r===null||r===!1)return!1;if(typeof r=="boolean")return r;const i=String(r).trim().toLowerCase();return i!==""&&i!=="false"&&i!=="0"}static sameThreshold(e,t){return e.length===1&&e[0]===t}};U.CONFIG_KEYS=new Set(["root","root-margin","threshold","disabled","once"]),U.registrations=new Map;let ce=U;const w=class w{static syncTree(e){(e instanceof Element||e instanceof DocumentFragment)&&(w.isHtmlElement(e)&&w.syncElement(e),e.querySelectorAll("*").forEach(t=>{w.syncElement(t)}))}static syncElement(e){const t=w.registrations.get(e);if(!t&&!w.hasPollAttribute(e))return;const r=N.get(e);if(!(r instanceof T)||!w.shouldObserve(r)){t&&w.teardown(e,t);return}const i=w.buildConfigKey(r);if(t){if(t.configKey===i){t.fragment=r;return}w.teardown(e,t)}w.startPolling(e,r,i)}static cleanupTree(e){if(w.isHtmlElement(e)){const t=w.registrations.get(e);t&&w.teardown(e,t)}(e instanceof Element||e instanceof DocumentFragment)&&e.querySelectorAll("*").forEach(t=>{const r=w.registrations.get(t);r&&w.teardown(t,r)})}static disconnectAll(){w.registrations.forEach(e=>{w.clearTimers(e)}),w.registrations.clear(),w.visibilityListener&&typeof document<"u"&&document.removeEventListener("visibilitychange",w.visibilityListener),w.visibilityListener=null}static isHtmlElement(e){if(!(e instanceof Element))return!1;const t=e.ownerDocument?.defaultView?.HTMLElement;return typeof t<"u"&&e instanceof t}static hasPollAttribute(e){const t=`${u.prefix}poll-`,r=e.attributes;for(let i=0;i<r.length;i+=1)if(r[i].name.startsWith(t))return!0;return!1}static shouldObserve(e){const t=`${u.prefix}poll-`;return e.getAttributeNames().some(r=>r.startsWith(t)?!w.CONFIG_KEYS.has(r.slice(t.length)):!1)}static buildConfigKey(e){const t=`${u.prefix}poll-`;return e.getAttributeNames().filter(r=>r.startsWith(t)).sort().map(r=>`${r}=${e.getRawAttribute(r)??""}`).join(`
|
|
28
|
-
`)}static startPolling(e,t,r){const i={fragment:t,configKey:r,intervalMs:w.resolveInterval(t),timeoutMs:w.resolveTimeout(t),errorLimit:w.resolveErrorLimit(t),startedAt:performance.now(),intervalTimerId:null,timeoutTimerId:null,fetching:!1,paused:!1,stopped:!1,timedOut:!1,stopReason:null,count:0,consecutiveErrors:0};w.registrations.set(e,i),w.ensureVisibilityListener(),i.timeoutMs!==null&&(i.timeoutTimerId=setTimeout(()=>{w.handleTimeout(e)},i.timeoutMs)),w.injectState(i),w.tick(e)}static async tick(e){const t=w.registrations.get(e);if(!t||t.stopped||t.fetching)return;if(t.intervalTimerId=null,!e.isConnected){await w.stop(e,t,"detached");return}const r=w.isHidden(e)||w.isDisabled(t.fragment);if(r!==t.paused&&(t.paused=r,await w.injectState(t)),r){w.schedule(e,t);return}if(w.isUntilSatisfied(t.fragment)){await w.stop(e,t,"until");return}t.fetching=!0,t.count+=1;let i=!1;try{i=await new ee(t.fragment,"poll").runWithResult()}catch(n){m.error("[Haori]","Poll procedure execution error:",n)}finally{t.fetching=!1}if(!(w.registrations.get(e)!==t||t.stopped)){if(i)t.consecutiveErrors=0;else if(t.consecutiveErrors+=1,t.errorLimit!==null&&t.consecutiveErrors>=t.errorLimit){await w.stop(e,t,"error");return}if(await w.restoreStateIfCleared(t),i&&w.isUntilSatisfied(t.fragment)){await w.stop(e,t,"until");return}w.schedule(e,t)}}static schedule(e,t){t.stopped||t.intervalTimerId!==null||(t.intervalTimerId=setTimeout(()=>{w.tick(e)},t.intervalMs))}static async handleTimeout(e){const t=w.registrations.get(e);!t||t.stopped||(t.timeoutTimerId=null,t.timedOut=!0,e.isConnected&&H.pollTimeout(e,t.count,w.elapsed(t)),await w.stop(e,t,"timeout"))}static async stop(e,t,r){if(!t.stopped){if(t.stopped=!0,t.stopReason=r,t.paused=!1,w.clearTimers(t),r==="detached"){w.registrations.delete(e);return}await w.injectState(t),e.isConnected&&H.pollStop(e,r,t.count,w.elapsed(t))}}static teardown(e,t){w.clearTimers(t),w.registrations.delete(e)}static clearTimers(e){e.intervalTimerId!==null&&(clearTimeout(e.intervalTimerId),e.intervalTimerId=null),e.timeoutTimerId!==null&&(clearTimeout(e.timeoutTimerId),e.timeoutTimerId=null)}static elapsed(e){return Math.round(performance.now()-e.startedAt)}static ensureVisibilityListener(){if(w.visibilityListener||typeof document>"u")return;const e=()=>{document.visibilityState==="visible"&&Array.from(w.registrations.entries()).forEach(([t,r])=>{r.stopped||r.fetching||(r.intervalTimerId!==null&&(clearTimeout(r.intervalTimerId),r.intervalTimerId=null),w.tick(t))})};w.visibilityListener=e,document.addEventListener("visibilitychange",e)}static injectState(e){const t=w.resolveStateFragments(e);if(t.length===0)return Promise.resolve();const r={running:!e.stopped,paused:e.paused,stopped:e.stopped,timedOut:e.timedOut,stopReason:e.stopReason,count:e.count,elapsedMs:w.elapsed(e)};return Promise.all(t.map(i=>{const n=i.getTarget(),s={...i.getRawBindingData()??{},_poll:r};return B.setBindingData(n,s,{reflectToAttribute:!1,kind:"nonSupply",sequence:T.nextSequence()})})).then(()=>{})}static async restoreStateIfCleared(e){w.resolveStateFragments(e).some(i=>(i.getRawBindingData()??{})._poll===void 0)&&await w.injectState(e)}static resolveStateFragments(e){const t=`${u.prefix}poll-state`,r=e.fragment;if(!r.hasAttribute(t))return[];const i=r.getAttribute(t);if(typeof i!="string"||i.trim()==="")return r.getTarget().isConnected?[r]:[];const n=z.queryAll(i,t,document);if(n.length===0)return m.error("[Haori]",`Poll state element not found: ${i}`),[];const s=[];return n.forEach(a=>{if(!a.isConnected)return;const o=N.get(a);o instanceof T&&s.push(o)}),s}static resolveInterval(e){const t=`${u.prefix}poll-interval`;if(!e.hasAttribute(t))return w.DEFAULT_INTERVAL_MS;const r=w.toNumber(e.getAttribute(t));return r===null?(m.warn("[Haori]",`${t} は数値で指定してください。既定値 ${w.DEFAULT_INTERVAL_MS}ms を使用します。`),w.DEFAULT_INTERVAL_MS):r<w.MIN_INTERVAL_MS?(m.warn("[Haori]",`${t} の下限は ${w.MIN_INTERVAL_MS}ms です。${r}ms は下限へ切り上げます。`),w.MIN_INTERVAL_MS):r}static resolveTimeout(e){const t=`${u.prefix}poll-timeout`;if(!e.hasAttribute(t))return null;const r=w.toNumber(e.getAttribute(t));return r===null||r<=0?(m.warn("[Haori]",`${t} は正の数値で指定してください。無制限として扱います。`),null):r}static resolveErrorLimit(e){const t=`${u.prefix}poll-error-limit`;if(!e.hasAttribute(t))return null;const r=w.toNumber(e.getAttribute(t));return r===null||r<1?(m.warn("[Haori]",`${t} は 1 以上の数値で指定してください。無制限として扱います。`),null):Math.floor(r)}static toNumber(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e!="string"||e.trim()==="")return null;const t=Number(e.trim());return Number.isFinite(t)?t:null}static isHidden(e){return e.closest(`[${u.prefix}if-false]`)!==null}static isDisabled(e){const t=`${u.prefix}poll-disabled`;return e.hasAttribute(t)?w.isTruthy(e.getAttribute(t)):!1}static isUntilSatisfied(e){const t=`${u.prefix}poll-until`;if(!e.hasAttribute(t))return!1;const r=e.getAttributeEvaluation(t);return r?r.hasUnresolvedReference?(m.warn("[Haori]",`${t} に未解決の参照が含まれています(停止条件は成立扱いにしません):`,e.getRawAttribute(t),e.getTarget()),!1):w.isTruthy(r.value):!1}static isTruthy(e){if(e==null||e===!1)return!1;if(typeof e=="boolean")return e;if(typeof e=="string"){const t=e.trim().toLowerCase();return t!==""&&t!=="false"&&t!=="0"}return!!e}};w.CONFIG_KEYS=new Set(["interval","timeout","until","error-limit","disabled","state"]),w.DEFAULT_INTERVAL_MS=5e3,w.MIN_INTERVAL_MS=100,w.registrations=new Map,w.visibilityListener=null;let de=w;const ht="0.41.2";function Vt(g){typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>g()):Promise.resolve().then(g)}const O=class O{static isHtmlElement(e){if(!(e instanceof Element))return!1;const t=e.ownerDocument?.defaultView?.HTMLElement;return typeof t<"u"&&e instanceof t}static syncTree(e){(e instanceof Element||e instanceof DocumentFragment)&&(O.isHtmlElement(e)&&O.syncElement(e),e.querySelectorAll("*").forEach(t=>{O.syncElement(t)}))}static syncElement(e){const t=O.registrations.get(e),r=N.get(e);if(!(r instanceof T)||!O.shouldObserve(r)){t&&(t.observer.disconnect(),O.registrations.delete(e));return}if(typeof IntersectionObserver>"u")return;const i=O.resolveVarName(r);if(i===""){t&&(t.observer.disconnect(),O.registrations.delete(e)),m.warn("[Haori]",'data-each-visible requires a variable name (e.g. data-each-visible="visibleRange").');return}const n=O.resolveRoot(r),s=O.resolveRootMargin(r);if(t&&t.observer.root===n&&t.observer.rootMargin===s&&t.varName===i){t.fragment=r,O.refreshRows(t);return}t&&(t.observer.disconnect(),O.registrations.delete(e));const a=new IntersectionObserver(l=>{const c=O.registrations.get(e);if(!c)return;let d=!1;l.forEach(h=>{const y=h.target;c.observedRows.has(y)&&(h.isIntersecting?c.visibleRows.has(y)||(c.visibleRows.add(y),d=!0):c.visibleRows.delete(y)&&(d=!0))}),d&&O.scheduleCompute(c)},{root:n,rootMargin:s,threshold:O.THRESHOLD}),o={fragment:r,observer:a,varName:i,root:n,rootMargin:s,observedRows:new Set,visibleRows:new Set,scheduled:!1,lastSnapshot:null};O.registrations.set(e,o),O.refreshRows(o)}static cleanupTree(e){if(O.isHtmlElement(e)){const t=O.registrations.get(e);t&&(t.observer.disconnect(),O.registrations.delete(e))}(e instanceof Element||e instanceof DocumentFragment)&&e.querySelectorAll("*").forEach(t=>{const r=O.registrations.get(t);r&&(r.observer.disconnect(),O.registrations.delete(t))})}static disconnectAll(){O.registrations.forEach(e=>{e.observer.disconnect()}),O.registrations.clear()}static shouldObserve(e){return e.hasAttribute(`${u.prefix}each`)&&e.hasAttribute(`${u.prefix}each-visible`)}static resolveVarName(e){const t=e.getRawAttribute(`${u.prefix}each-visible`);return typeof t=="string"?t.trim():""}static resolveRoot(e){const t=`${u.prefix}each-visible-root`;if(!e.hasAttribute(t))return null;const r=e.getAttribute(t);if(typeof r!="string"||r.trim()==="")return null;const i=z.query(r,t,document);return O.isHtmlElement(i)?i:(m.error("[Haori]",`Visible range root element not found: ${r}`),null)}static resolveRootMargin(e){const t=`${u.prefix}each-visible-margin`,r=e.getAttribute(t);return r===null||r===!1||r===""?O.DEFAULT_ROOT_MARGIN:String(r)}static realRowElements(e){return e.getChildren().filter(t=>t instanceof T&&!t.hasAttribute(`${u.prefix}each-before`)&&!t.hasAttribute(`${u.prefix}each-after`)).map(t=>t.getTarget())}static refreshRows(e){const t=O.realRowElements(e.fragment),r=new Set(t);for(const i of[...e.observedRows])r.has(i)||(e.observer.unobserve(i),e.observedRows.delete(i),e.visibleRows.delete(i));for(const i of t)e.observedRows.has(i)||(e.observer.observe(i),e.observedRows.add(i));O.scheduleCompute(e)}static scheduleCompute(e){e.scheduled||(e.scheduled=!0,Vt(()=>{e.scheduled=!1;const t=e.fragment.getTarget();O.registrations.get(t)===e&&O.computeAndPublish(e)}))}static computeAndPublish(e){const t=O.realRowElements(e.fragment),r=new Map;t.forEach((a,o)=>r.set(a,o));const i=[];for(const a of e.visibleRows){const o=r.get(a);o!==void 0&&i.push(o)}let n;if(i.length===0)n={first:-1,last:-1,firstLabel:0,lastLabel:0,count:0,total:t.length,empty:!0};else{let a=i[0],o=i[0];for(const l of i)l<a&&(a=l),l>o&&(o=l);n={first:a,last:o,firstLabel:a+1,lastLabel:o+1,count:i.length,total:t.length,empty:!1}}const s=JSON.stringify(n);s!==e.lastSnapshot&&(e.lastSnapshot=s,O.publish(e,n))}static publish(e,t){const r=O.resolveBindOwner(e.fragment);if(!r){m.warn("[Haori]","data-each-visible found no ancestor data-bind scope to publish into.");return}const i=r.getTarget(),n={...r.getRawBindingData()??{}};n[e.varName]={...t};const s=e.fragment.getTarget(),a=i===s?new Set:new Set([e.fragment]);B.setBindingData(i,n,{skipFragments:a,reflectToAttribute:!1,kind:"nonSupply",sequence:T.nextSequence()}).catch(o=>{m.error("[Haori]","Failed to publish visible range:",o)})}static resolveBindOwner(e){const t=`${u.prefix}bind`;let r=e.getParent();for(;r;){if(r.hasAttribute(t))return r;r=r.getParent()}return e.hasAttribute(t)?e:null}};O.THRESHOLD=0,O.DEFAULT_ROOT_MARGIN="0px",O.registrations=new Map;let ae=O;const K=class K{static disconnectMutationObservers(){K._mutationObservers.forEach(e=>{e.disconnect()}),K._mutationObservers.length=0}static async init(){if(K._initialized)return;K._initialized=!0,K.disconnectMutationObservers(),T.setPendingMutationFlusher(()=>{K.flushPendingMutations()});const e=new Pe;K._dispatcher=e,e.startDeferred();try{const t=await Promise.allSettled([B.scan(document.head),B.scan(document.body)]),[r,i]=t;r.status!=="fulfilled"&&m.error("[Haori]","Failed to build head fragment:",r.reason),i.status!=="fulfilled"&&m.error("[Haori]","Failed to build body fragment:",i.reason),await V.wait(),document.body.setAttribute("data-haori-ready",""),K.observe(document.head),K.observe(document.body),ce.syncTree(document.body),de.syncTree(document.body),ae.syncTree(document.body)}finally{e.release()}H.ready(ht)}static getDispatcher(){return K._dispatcher}static isExternallyManaged(e){return(e instanceof Element?e:e?.parentElement??null)?.closest(`[${u.prefix}external]`)!=null}static observe(e){const t=new MutationObserver(r=>{K.processMutations(r)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),K._mutationObservers.push(t)}static flushPendingMutations(){for(const e of K._mutationObservers){const t=e.takeRecords();if(t.length===0)continue;const r=t.filter(K.isBindAttributeRecord),i=t.filter(n=>!K.isBindAttributeRecord(n));r.length>0&&K.processMutations(r,T.nextSequence()),i.length>0&&Promise.resolve().then(()=>{K.processMutations(i)})}}static isBindAttributeRecord(e){return e.type==="attributes"&&e.attributeName===`${u.prefix}bind`}static processMutations(e,t){for(const r of e)try{if(K.isExternallyManaged(r.target))continue;switch(r.type){case"attributes":{const i=r.target;if(r.attributeName&&i.hasAttribute("data-haori-click-lock")&&(r.attributeName==="disabled"||r.attributeName==="data-haori-click-lock")||r.attributeName&&i.hasAttribute(pe)&&(r.attributeName==="disabled"||r.attributeName===pe)||r.attributeName&&B.isAliasedAttributeReflection(i,r.attributeName))break;B.setAttribute(i,r.attributeName,i.getAttribute(r.attributeName),!0,t),ce.syncElement(i),de.syncElement(i),ae.syncElement(i);break}case"childList":{Array.from(r.removedNodes).forEach(i=>{ce.cleanupTree(i),de.cleanupTree(i),ae.cleanupTree(i),B.removeNode(i)}),Array.from(r.addedNodes).forEach(i=>{i.parentElement instanceof Element&&(B.addNode(i.parentElement,i),ce.syncTree(i),de.syncTree(i),ae.syncTree(i))}),r.target instanceof Element&&ae.syncElement(r.target);break}case"characterData":{r.target instanceof Text||r.target instanceof Comment?B.changeText(r.target,r.target.textContent):m.warn("[Haori]","Unsupported character data type:",r.target);break}default:m.warn("[Haori]","Unknown mutation type:",r.type);continue}}catch(i){m.error("[Haori]","Error processing mutation:",i)}}};K._initialized=!1,K._mutationObservers=[],K._dispatcher=null;let Re=K;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Re.init):Re.init();const qt=()=>re.waitForRenders(),Wt=re.enhancers,jt=Object.freeze(Object.defineProperty({__proto__:null,Core:B,Enhance:_,Env:u,Form:F,Fragment:N,Haori:re,Log:m,Queue:V,default:re,enhancers:Wt,version:ht,waitForRenders:qt},Symbol.toStringTag,{value:"Module"})),$e=re;for(const[g,e]of Object.entries(jt))g in $e||Object.defineProperty($e,g,{value:e,writable:!0,enumerable:!0,configurable:!0});return $e}();
|
|
27
|
+
`)}catch(n){m.error("[Haori]",`Invalid each-rendered-run script: ${n}`)}}if(i)try{i.call(e)}catch(n){m.error("[Haori]",`each-rendered-run execution error: ${n}`)}}static runEachRenderedChange(e){const t=`${u.prefix}each-rendered-change`,r=e.getTarget();if(!r.hasAttribute(t))return;const i=String(r.getAttribute(t)??"").trim().toLowerCase();let n=!1;if(i==="always"?n=!0:i!==""&&i!=="once"&&(f.EACH_RENDERED_CHANGE_WARNED.has(r)||(f.EACH_RENDERED_CHANGE_WARNED.add(r),m.warn("[Haori]",`Invalid ${t} value: "${i}". Use "once" (default) or "always".`))),f.countEachRenderedRows(e)!==0){if(!n){if(f.EACH_RENDERED_CHANGE_FIRED.has(r))return;f.EACH_RENDERED_CHANGE_FIRED.add(r)}try{r.dispatchEvent(new Event("change",{bubbles:!0}))}catch(s){m.error("[Haori]",`each-rendered-change dispatch error: ${s}`)}}}static countEachRenderedRows(e){let t=0;for(const r of e.getChildElementFragments())r.getTarget().hasAttribute(`${u.prefix}row`)&&(t+=1);return t}static performEachUpdate(e){const t=f.resolveEachItems(e);if(t===null)return Promise.reject(new Error("Invalid each attribute."));let r=e.getTemplate();const i=e.getAttribute(`${u.prefix}each-key`),n=f.createBindingSignature({key:i?String(i):null,items:t});if(r===null){let s=!1;if(e.getChildren().forEach(a=>{if(!s&&a instanceof T){if(a.hasAttribute(`${u.prefix}each-before`)||a.hasAttribute(`${u.prefix}each-after`))return;r=a.clone(),f.markFreshInitializationSkippable(r),e.setTemplate(r),s=!0,e.removeChild(a);const o=a.getTarget();o.parentNode&&o.parentNode.removeChild(o),a.setMounted(!1)}}),!s){const a=e.getTarget();Array.from(a.children).filter(l=>!l.hasAttribute(`${u.prefix}each-before`)&&!l.hasAttribute(`${u.prefix}each-after`)).forEach(l=>{if(!s){const d=N.get(l);d instanceof T&&(r=d.clone(),f.markFreshInitializationSkippable(r),e.setTemplate(r),s=!0)}const c=N.get(l);c instanceof T&&e.getChildren().includes(c)&&(e.removeChild(c),c.setMounted(!1)),l.parentNode&&l.parentNode.removeChild(l)})}return this.updateDiff(e,t).then(()=>{e.setEachInputSignature(n)})}return e.getEachInputSignature()===n?f.reevaluateEachRows(e):this.updateDiff(e,t).then(()=>{e.setEachInputSignature(n)})}static reevaluateEachRows(e){if(f.isRowLocalEachTemplate(e))return Promise.resolve();const t=e.getChildElementFragments().filter(r=>!r.hasAttribute(`${u.prefix}each-before`)&&!r.hasAttribute(`${u.prefix}each-after`));return t.length===0?Promise.resolve():Promise.all(t.map(r=>f.evaluateAll(r))).then(()=>{})}static resolveEachItems(e){const t=e.getAttributeEvaluation(`${u.prefix}each`),r=t?.value;return t?.hasUnresolvedReference||r===!1||r===null||r===void 0?[]:Array.isArray(r)?r:(m.error("[Haori]","Invalid each attribute:",r),null)}static canSkipUnchangedNestedEach(e){if(!e.hasAttribute(`${u.prefix}each`)||e.getEachInputSignature()===null)return!1;const t=e.getParent();if(t?.closestByAttribute(`${u.prefix}derive`)||t?.closestByAttribute(`${u.prefix}derive-name`)||t?.closestByAttribute(`${u.prefix}if`)||t?.closestByAttribute(`${u.prefix}fetch`)||t?.closestByAttribute(`${u.prefix}import`)||f.hasNonEachDynamicElementState(e)||!f.isRowLocalEachTemplate(e))return!1;const r=f.resolveEachItems(e);if(r===null)return!1;const i=e.getAttribute(`${u.prefix}each-key`),n=f.createBindingSignature({key:i?String(i):null,items:r});return e.getEachInputSignature()===n}static isRowLocalEachTemplate(e){const t=e.getRowLocalTemplate();if(t!==null)return t;const r=e.getTemplate(),i=e.getAttribute(`${u.prefix}each-arg`);if(r===null||!i)return e.setRowLocalTemplate(!1),!1;const n=new Set([String(i)]),s=e.getAttribute(`${u.prefix}each-index`);s&&n.add(String(s));const a=f.isRowLocalSubtree(r,n);return e.setRowLocalTemplate(a),a}static isRowLocalSubtree(e,t){for(const i of e.getAttributeNames()){const n=e.getRawAttribute(i),s=typeof n=="string"?n:"";if(s.includes("{{")){if(!f.areExpressionsRowLocal(f.extractInterpolations(s),t))return!1;continue}if(!i.startsWith(u.prefix))continue;const a=i.slice(u.prefix.length);if(f.ROW_LOCAL_EXPRESSION_ATTRIBUTES.has(a)){if(!f.areExpressionsRowLocal([s],t))return!1;continue}if(!f.ROW_LOCAL_STATIC_ATTRIBUTES.has(a))return!1}let r=t;if(e.hasAttribute(`${u.prefix}each`)){const i=e.getRawAttribute(`${u.prefix}each-arg`);if(typeof i!="string"||i==="")return!1;const n=new Set(t);n.add(i);const s=e.getRawAttribute(`${u.prefix}each-index`);typeof s=="string"&&s!==""&&n.add(s),r=n}for(const i of e.getChildren())if(i instanceof T){if(!f.isRowLocalSubtree(i,r))return!1}else if(i instanceof Z){const n=i.getRawText();if(n.includes("{{")&&!f.areExpressionsRowLocal(f.extractInterpolations(n),t))return!1}return!0}static areExpressionsRowLocal(e,t){for(const r of e){const i=r.trim();if(i==="")continue;const n=J.getFreeIdentifiers(i);if(n.length===0||n.some(s=>!t.has(s)))return!1}return!0}static extractInterpolations(e){const t=[],r=/\{\{([\s\S]*?)\}\}/g;let i=r.exec(e);for(;i!==null;)t.push(i[1]),i=r.exec(e);return t}static canSkipStableDerivedSubtree(e){return!e.hasAttribute(`${u.prefix}derive`)||e.hasAttribute(`${u.prefix}if`)||e.hasAttribute(`${u.prefix}each`)||e.hasAttribute(`${u.prefix}fetch`)||e.hasAttribute(`${u.prefix}import`)?!1:!f.hasDisallowedDerivedSubtreeDescendant(e)}static hasDisallowedDerivedSubtreeDescendant(e){return e.getChildren().some(t=>t instanceof T?t.hasAttribute(`${u.prefix}derive`)||t.hasAttribute(`${u.prefix}derive-name`)||t.hasAttribute(`${u.prefix}fetch`)||t.hasAttribute(`${u.prefix}import`)?!0:f.hasDisallowedDerivedSubtreeDescendant(t):!1)}static createDescendantBindingSignature(e,t){return f.recordDerivedSubtreeSignatureComputation(e,t),f.createBindingSignature(e.getDescendantBindingData())}static createDeriveInputSignature(e,t,r){const i=typeof r=="string"?r.trim():"";return!t||i===""?null:f.createBindingSignature({expression:t,name:i,scope:e.getBindingData()})}static refreshDerivedSubtreeSignature(e){if(!f.canSkipStableDerivedSubtree(e)){e.setDeriveSubtreeSignature(null),f.logDerivedSubtreeProfileSnapshot(e,"skip-ineligible");return}e.setDeriveSubtreeSignature(f.createDescendantBindingSignature(e,"refresh")),f.logDerivedSubtreeProfileSnapshot(e,"refresh")}static getOrCreateDerivedSubtreeProfile(e){if(!q.isEnabled()||!e.hasAttribute(`${u.prefix}derive`))return null;const t=f.DERIVE_SUBTREE_PROFILES.get(e);if(t)return t;const r={hostId:f.createDerivedSubtreeHostId(e),signatureComputeTotal:0,signatureComputeFromEvaluateAll:0,signatureComputeFromRefresh:0,skipHitCount:0,skipMissCount:0,skipIneligibleCount:0};return f.DERIVE_SUBTREE_PROFILES.set(e,r),r}static resolveElementId(e){return e.getAttribute("id")??""}static createDerivedSubtreeHostId(e){const t=[];let r=e;for(;r;){const i=r.getTarget();if(!(i instanceof HTMLElement))break;let n=i.tagName.toLowerCase();const s=f.resolveElementId(i).trim();if(s!==""){n+=`#${s}`,t.unshift(n);break}const a=r.getRawAttribute(`${u.prefix}derive-name`);typeof a=="string"&&a.trim()!==""&&(n+=`[${u.prefix}derive-name="${a.trim()}"]`);const o=r.getParent();if(o){const l=o.getChildren().filter(c=>c instanceof T).findIndex(c=>c===r);n+=`:nth-child(${l+1})`}t.unshift(n),r=o}return t.join(" > ")}static recordDerivedSubtreeSignatureComputation(e,t){const r=f.getOrCreateDerivedSubtreeProfile(e);if(r!==null){if(r.signatureComputeTotal+=1,t==="refresh"){r.signatureComputeFromRefresh+=1;return}r.signatureComputeFromEvaluateAll+=1}}static logDerivedSubtreeProfileSnapshot(e,t){const r=f.getOrCreateDerivedSubtreeProfile(e);r!==null&&(t==="skip-hit"?r.skipHitCount+=1:t==="skip-miss"?r.skipMissCount+=1:t==="skip-ineligible"&&(r.skipIneligibleCount+=1),m.info("[Haori][derive-profile]",{reason:t,hostId:r.hostId,signatureComputeTotal:r.signatureComputeTotal,signatureComputeFromEvaluateAll:r.signatureComputeFromEvaluateAll,signatureComputeFromRefresh:r.signatureComputeFromRefresh,skipHitCount:r.skipHitCount,skipMissCount:r.skipMissCount,skipIneligibleCount:r.skipIneligibleCount}))}static hasNonEachDynamicElementState(e){const t=new Set([`${u.prefix}each`,`${u.prefix}each-key`,`${u.prefix}each-arg`,`${u.prefix}each-index`]);return e.getAttributeNames().some(i=>{if(t.has(i))return!1;if(i.startsWith(`${u.prefix}attr-`)||i.startsWith(u.prefix))return!0;const n=e.getRawAttribute(i);return typeof n=="string"&&n.includes("{{")})?!0:e.getChildren().some(i=>i instanceof Z&&i.hasDynamicContent())}static markFreshInitializationSkippable(e){const t=e.getAttributeNames().some(n=>f.isFreshInitializationDynamicAttribute(e,n)),r=e.getChildren().some(n=>n instanceof T?!f.markFreshInitializationSkippable(n):n instanceof Z?n.hasDynamicContent():!1),i=!t&&!r;return e.setFreshInitializationSkippable(i),i}static isFreshInitializationDynamicAttribute(e,t){if(t.startsWith(`${u.prefix}attr-`)||t.startsWith(u.prefix))return!0;const r=e.getRawAttribute(t);return typeof r=="string"&&r.includes("{{")}static updateDiff(e,t){const r=e.getTemplate();if(r===null)return m.error("[Haori]","Template is not set for each element."),Promise.resolve();let i=e.getAttribute(`${u.prefix}each-index`);i&&(i=String(i));const n=e.getAttribute(`${u.prefix}each-key`),s=e.getAttribute(`${u.prefix}each-arg`),a=t.map((E,v)=>f.createListKey(E,n?String(n):null,v)),o=new Set(a),l=new Map;a.forEach(E=>{l.set(E,(l.get(E)??0)+1)}),n&&o.size!==a.length&&f.warnDuplicateEachKey(String(n));const c=[];let d=e.getChildren().filter(E=>E instanceof T).filter(E=>!E.hasAttribute(`${u.prefix}each-before`)&&!E.hasAttribute(`${u.prefix}each-after`));const h=d.map(E=>E.getListKey()),y=new Set;d=d.filter((E,v)=>{const R=String(E.getListKey()),M=l.get(R)??0;if(M===0){y.add(E);const x=E.getListKey();return x!==null&&H.rowRemove(E.getTarget(),x,v),c.push(E.remove()),!1}return l.set(R,M-1),!0});const A=d.map(E=>E.getListKey()),S=new Map;d.forEach(E=>{const v=E.getListKey();if(v===null)return;const R=S.get(v);R?R.push(E):S.set(v,[E])});const P=e.getChildElementFragments().filter(E=>!y.has(E)),D=P.filter(E=>E.hasAttribute(`${u.prefix}each-before`)).length;let L=Promise.resolve();return a.forEach((E,v)=>{const R=t[v],M=v;let x;const j=S.get(E)?.shift();if(j){x=j;const G=D+v;L=L.then(()=>f.updateRowFragment(x,R,i,M,s?String(s):null,E).then(te=>f.repositionEachRow(e,x,P,G).then(Q=>{if(Q!==null&&H.rowMove(x.getTarget(),E,Q-D,v),!!te)return f.clearUserEditMarks(x),f.evaluateAll(x).then(()=>f.applyRowFormValues(e,x,R))})))}else{x=r.clone();const G=D+v;L=L.then(()=>f.updateRowFragment(x,R,i,M,s?String(s):null,E).then(()=>{const te=P[G]??null;return e.insertBefore(x,te).then(()=>{P.splice(G,0,x)}).then(()=>f.initializeFreshEachRow(x)).then(()=>f.applyRowFormValues(e,x,R)).then(()=>{H.rowAdd(x.getTarget(),E,M,R)})}))}}),Promise.all(c).then(()=>L).then(()=>{const E=a.filter(G=>G!==null),v=A.filter(G=>G!==null),R=new Set(v),M=E.filter(G=>!R.has(G)),j=h.filter(G=>G!==null).filter(G=>!o.has(G));H.eachUpdate(e.getTarget(),M,j,E)})}static warnDuplicateEachKey(e){!q.isEnabled()||f.WARNED_DUPLICATE_EACH_KEYS.has(e)||(f.WARNED_DUPLICATE_EACH_KEYS.add(e),m.warn("[Haori]",`${u.prefix}each-key="${e}" の値が配列の中で重複しています。行は出現順で対応付けますが、キーによる行の識別はできません。`))}static repositionEachRow(e,t,r,i){const n=r.indexOf(t);if(n===-1||n===i)return Promise.resolve(null);r.splice(n,1);const s=r[i]??null;return r.splice(i,0,t),e.insertBefore(t,s).then(()=>n)}static applyRowFormValues(e,t,r){return!e.hasAttribute(`${u.prefix}form-list`)||!F.isCollectedListFromEachSource(e)||typeof r!="object"||r===null||Array.isArray(r)?Promise.resolve():F.syncRowValues(t,r)}static createListKey(e,t,r){let i;if(typeof e=="object"&&e!==null)if(t){const n=e[t];n==null?i=`__index_${r}`:typeof n=="object"?i=JSON.stringify(n):i=String(n)}else i=`__index_${r}`;else i=String(e);return i}static updateRowFragment(e,t,r,i,n,s){let a;if(typeof t=="object"&&t!==null)a=n?{[n]:{...t}}:{...t};else if(n)a={[n]:t};else return m.error("[Haori]",`Primitive value requires '${u.prefix}each-arg' attribute: ${t}`),Promise.resolve(!1);r&&(a[r]=i);const o=a,l=f.createBindingSignature({listKey:s,bindingData:o});return e.getListKey()===s&&e.getRenderSignature()===l?Promise.resolve(!1):(e.setListKey(s),e.setRenderSignature(l),e.setBindingData(o),e.setAttribute(`${u.prefix}row`,s).then(()=>!0))}static needsScheduledEvaluateAll(e){const t=[e];for(;t.length>0;){const r=t.pop();if(r.getChildElementFragments().forEach(i=>{t.push(i)}),r!==e&&!r.isMounted()&&f.hasMountSensitiveAttribute(r))return!0}return!1}static hasMountSensitiveAttribute(e){return["fetch","import"].some(t=>e.hasAttribute(`${u.prefix}${t}`))}static createBindingSignature(e,t=new WeakMap,r={value:0}){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);if(typeof e=="function")return`[Function:${e.name||"anonymous"}]`;if(typeof e=="symbol")return e.toString();if(e instanceof Date)return`[Date:${e.toISOString()}]`;if(typeof File<"u"&&e instanceof File)return`[File:${e.name}:${e.size}:${e.lastModified}:${e.type}]`;if(typeof Blob<"u"&&e instanceof Blob)return`[Blob:${e.size}:${e.type}]`;if(Array.isArray(e)){if(t.has(e))return`[Circular:${t.get(e)}]`;const i=`array-${r.value}`;return r.value+=1,t.set(e,i),`[${e.map(n=>f.createBindingSignature(n,t,r)).join(",")}]`}if(typeof e=="object"){if(t.has(e))return`[Circular:${t.get(e)}]`;const i=`object-${r.value}`;r.value+=1,t.set(e,i);const n=e;return`{${Object.keys(n).sort().map(s=>`${JSON.stringify(s)}:${f.createBindingSignature(n[s],t,r)}`).join(",")}}`}return String(e)}static scheduleEvaluateAll(e){setTimeout(()=>{f.evaluateAll(e)},100)}};f.ATTRIBUTE_ALIAS_SUFFIX="attr-",f.PRIORITY_ATTRIBUTE_SUFFIXES=["bind","store","url-param","derive-name","derive","if","each"],f.DEFERRED_ATTRIBUTE_SUFFIXES=["fetch"],f.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES=["bind","derive","derive-name","if","each","fetch","import","url-param","store","validity","validity-message"],f.ATTRIBUTE_PLACEHOLDER_REGEX=/\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/,f.ROW_LOCAL_EXPRESSION_ATTRIBUTES=new Set(["each","if","derive"]),f.ROW_LOCAL_STATIC_ATTRIBUTES=new Set(["each-arg","each-key","each-index","each-before","each-after","derive-name","row","form","form-arg","form-list","form-object","form-detach","store","store-params","store-arg","store-type","enhance","enhance-new"]),f.REACTIVE_FETCH_STATES=new WeakMap,f.REACTIVE_IMPORT_STATES=new WeakMap,f.DERIVE_SUBTREE_PROFILES=new WeakMap,f.EACH_UPDATE_STATES=new WeakMap,f.EACH_RENDERED_CHANGE_FIRED=new WeakSet,f.EACH_RENDERED_CHANGE_WARNED=new WeakSet,f.WARNED_DUPLICATE_EACH_KEYS=new Set,f.ABSENT_PATH=Symbol("absent");let B=f;const he=class he{constructor(e=document){this.customEventHandlers=new Map,this.builtinListenersAdded=!1,this.deferred=!1,this.deferredProcedures=[],this.onClick=t=>this.delegate(t,"click"),this.onChange=t=>this.delegate(t,"change"),this.onInput=t=>this.delegate(t,"input"),this.onLoadCapture=t=>this.delegate(t,"load"),this.onWindowLoad=()=>{if(this.deferred){this.deferredProcedures.push(()=>this.runWindowLoadProcedure());return}this.runWindowLoadProcedure()},this.onPopstate=t=>{const r=t.state;!r||r[he.HISTORY_STATE_KEY]!==!0||location.reload()},this.root=e}runWindowLoadProcedure(){const e=document.documentElement,t=N.get(e);t&&new ee(t,"load").run()}start(){this.deferred=!1,this.addBuiltinListeners(),this.subscribeDeclaredCustomEvents(),this.observeCustomEventDeclarations()}startDeferred(){this.deferred=!0,this.addBuiltinListeners(),this.subscribeDeclaredCustomEvents()}release(){if(!this.deferred)return;this.deferred=!1,this.subscribeDeclaredCustomEvents(),this.observeCustomEventDeclarations();const e=this.deferredProcedures.splice(0);for(const t of e)try{t()}catch(r){m.error("[Haori]","Deferred event handling error:",r)}}addBuiltinListeners(){this.builtinListenersAdded||(this.builtinListenersAdded=!0,this.root.addEventListener("click",this.onClick),this.root.addEventListener("change",this.onChange),this.root.addEventListener("input",this.onInput),this.root.addEventListener("load",this.onLoadCapture,!0),window.addEventListener("load",this.onWindowLoad,{once:!0}),window.addEventListener("popstate",this.onPopstate))}stop(){this.root.removeEventListener("click",this.onClick),this.root.removeEventListener("change",this.onChange),this.root.removeEventListener("input",this.onInput),this.root.removeEventListener("load",this.onLoadCapture,!0),window.removeEventListener("load",this.onWindowLoad),window.removeEventListener("popstate",this.onPopstate),this.builtinListenersAdded=!1,this.deferred=!1,this.deferredProcedures.length=0;for(const[e,t]of this.customEventHandlers)window.removeEventListener(e,t,!0);this.customEventHandlers.clear(),this.customEventObserver?.disconnect(),this.customEventObserver=void 0}get onAttributeName(){return`${u.prefix}on`}subscribeDeclaredCustomEvents(){this.root.querySelectorAll(`[${this.onAttributeName}]`).forEach(t=>this.subscribeCustomEvent(t.getAttribute(this.onAttributeName)))}subscribeCustomEvent(e){if(e===null||e==="")return;if(he.BUILTIN_EVENT_NAMES.has(e)){m.warn("[Haori]",`data-on="${e}" は組み込みイベントです。data-${e}-* を使用してください(data-on はカスタムイベント専用)。`);return}if(this.customEventHandlers.has(e))return;const t=r=>this.runCustomEventProcedures(e,r);this.customEventHandlers.set(e,t),window.addEventListener(e,t,!0)}runCustomEventProcedures(e,t){if(this.deferred){this.deferredProcedures.push(()=>this.runCustomEventProcedures(e,t));return}this.root.querySelectorAll(`[${this.onAttributeName}]`).forEach(i=>{if(i.getAttribute(this.onAttributeName)!==e)return;const n=N.get(i);n instanceof T&&new ee(n,"on",t).run().catch(s=>{m.error("[Haori]","Procedure execution error:",s)})})}observeCustomEventDeclarations(){if(typeof MutationObserver>"u")return;const e=this.root instanceof Document?this.root:this.root.ownerDocument??document,t=this.root instanceof Document?e.body:this.root;t&&(this.customEventObserver=new MutationObserver(r=>{for(const i of r)i.addedNodes.forEach(n=>{n instanceof HTMLElement&&(n.hasAttribute(this.onAttributeName)&&this.subscribeCustomEvent(n.getAttribute(this.onAttributeName)),n.querySelectorAll(`[${this.onAttributeName}]`).forEach(s=>this.subscribeCustomEvent(s.getAttribute(this.onAttributeName))))})}),this.customEventObserver.observe(t,{childList:!0,subtree:!0}))}delegate(e,t){const r=this.getElementFromTarget(e.target,t);if(r){if(t==="input"){const i=`${u.prefix}input-`;if(!r.getAttributeNames().some(s=>s.startsWith(i))){this.recordUserEdit(r);return}}if(r.hasAttribute(`${u.prefix}${t}-prevent`)&&e.preventDefault(),this.deferred){this.deferredProcedures.push(()=>{r.isConnected&&this.runProcedureFor(r,t,e)});return}this.runProcedureFor(r,t,e)}}runProcedureFor(e,t,r){const i=N.get(e);if(!i)return;(t==="change"||t==="input")&&this.syncUserEdit(e);const n=()=>{new ee(i,t,r).run().catch(s=>{m.error("[Haori]","Procedure execution error:",s)})};if(t==="click"&&e.hasAttribute(`${u.prefix}click-defer`)){typeof requestAnimationFrame<"u"?requestAnimationFrame(()=>n()):setTimeout(n,0);return}n()}recordUserEdit(e){if(!(!(e instanceof HTMLInputElement)&&!(e instanceof HTMLSelectElement)&&!(e instanceof HTMLTextAreaElement))){if(this.deferred){this.deferredProcedures.push(()=>{e.isConnected&&this.markUserEditOnly(e)});return}this.markUserEditOnly(e)}}markUserEditOnly(e){const t=N.get(e);t instanceof T&&t.markUserEdit()}syncUserEdit(e){const t=N.get(e);if(t instanceof T&&(t.syncValue(),t.markUserEdit(),e instanceof HTMLInputElement&&e.type==="radio"&&e.name)){const r=document.getElementsByName(e.name);for(const i of Array.from(r)){if(i===e||!(i instanceof HTMLInputElement)||i.type!=="radio"||i.form!==e.form)continue;const n=N.get(i);n instanceof T&&(n.syncValue(),n.markUserEdit())}}}getElementFromTarget(e,t){if(!e)return null;if(e instanceof HTMLElement)return t==="click"?this.findClickableElement(e):e;if(e instanceof Node){const r=e.parentElement;return r?t==="click"?this.findClickableElement(r):r:null}return null}findClickableElement(e){const t=`${u.prefix}click-`,r=`${u.prefix}click-passive`;let i=e;for(;i;){if(i.getAttributeNames().some(s=>s.startsWith(t)&&s!==r))return i;if(i.hasAttribute(r))return null;i=i.parentElement}return null}};he.HISTORY_STATE_KEY="__haoriHistoryState__",he.BUILTIN_EVENT_NAMES=new Set(["click","change","input","load"]);let Pe=he;const U=class U{static isHtmlElement(e){if(!(e instanceof Element))return!1;const t=e.ownerDocument?.defaultView?.HTMLElement;return typeof t<"u"&&e instanceof t}static syncTree(e){(e instanceof Element||e instanceof DocumentFragment)&&(U.isHtmlElement(e)&&U.syncElement(e),e.querySelectorAll("*").forEach(t=>{U.syncElement(t)}))}static syncElement(e){const t=U.registrations.get(e),r=N.get(e);if(!r||!U.shouldObserve(r)){t&&(t.observer.disconnect(),U.registrations.delete(e));return}if(typeof IntersectionObserver>"u")return;const i=U.resolveRoot(r),n=U.resolveRootMargin(r),s=U.resolveThreshold(r),a=r.hasAttribute(`${u.prefix}intersect-once`);if(t&&t.observer.root===i&&t.observer.rootMargin===n&&U.sameThreshold(t.observer.thresholds,s)&&t.once===a){t.fragment=r;return}t&&(t.observer.disconnect(),U.registrations.delete(e));const o=new IntersectionObserver(l=>{const c=U.registrations.get(e);c&&l.forEach(d=>{!d.isIntersecting||c.running||U.isDisabled(c.fragment)||(c.running=!0,new ee(c.fragment,"intersect").runWithResult().then(h=>{h&&c.once&&(c.observer.disconnect(),U.registrations.delete(e))}).catch(h=>{m.error("[Haori]","Intersect procedure execution error:",h)}).finally(()=>{const h=U.registrations.get(e);h&&(h.running=!1)}))})},{root:i,rootMargin:n,threshold:s});o.observe(e),U.registrations.set(e,{fragment:r,observer:o,once:a,running:!1})}static cleanupTree(e){if(U.isHtmlElement(e)){const t=U.registrations.get(e);t&&(t.observer.disconnect(),U.registrations.delete(e))}(e instanceof Element||e instanceof DocumentFragment)&&e.querySelectorAll("*").forEach(t=>{const r=U.registrations.get(t);r&&(r.observer.disconnect(),U.registrations.delete(t))})}static disconnectAll(){U.registrations.forEach(e=>{e.observer.disconnect()}),U.registrations.clear()}static shouldObserve(e){return e.getAttributeNames().some(t=>{if(!t.startsWith(`${u.prefix}intersect-`))return!1;const r=t.slice(`${u.prefix}intersect-`.length);return!U.CONFIG_KEYS.has(r)})}static resolveRoot(e){const t=`${u.prefix}intersect-root`;if(!e.hasAttribute(t))return null;const r=e.getAttribute(t);if(typeof r!="string"||r.trim()==="")return null;const i=z.query(r,t,document);return U.isHtmlElement(i)?i:(m.error("[Haori]",`Intersect root element not found: ${r}`),null)}static resolveRootMargin(e){const t=`${u.prefix}intersect-root-margin`,r=e.getAttribute(t);return r===null||r===!1||r===""?"0px":String(r)}static resolveThreshold(e){const t=`${u.prefix}intersect-threshold`,r=e.getAttribute(t),i=typeof r=="number"?r:Number.parseFloat(String(r??0));return Number.isNaN(i)?0:Math.min(1,Math.max(0,i))}static isDisabled(e){const t=`${u.prefix}intersect-disabled`,r=e.getAttribute(t);if(r===null||r===!1)return!1;if(typeof r=="boolean")return r;const i=String(r).trim().toLowerCase();return i!==""&&i!=="false"&&i!=="0"}static sameThreshold(e,t){return e.length===1&&e[0]===t}};U.CONFIG_KEYS=new Set(["root","root-margin","threshold","disabled","once"]),U.registrations=new Map;let ce=U;const w=class w{static syncTree(e){(e instanceof Element||e instanceof DocumentFragment)&&(w.isHtmlElement(e)&&w.syncElement(e),e.querySelectorAll("*").forEach(t=>{w.syncElement(t)}))}static syncElement(e){const t=w.registrations.get(e);if(!t&&!w.hasPollAttribute(e))return;const r=N.get(e);if(!(r instanceof T)||!w.shouldObserve(r)){t&&w.teardown(e,t);return}const i=w.buildConfigKey(r);if(t){if(t.configKey===i){t.fragment=r;return}w.teardown(e,t)}w.startPolling(e,r,i)}static cleanupTree(e){if(w.isHtmlElement(e)){const t=w.registrations.get(e);t&&w.teardown(e,t)}(e instanceof Element||e instanceof DocumentFragment)&&e.querySelectorAll("*").forEach(t=>{const r=w.registrations.get(t);r&&w.teardown(t,r)})}static disconnectAll(){w.registrations.forEach(e=>{w.clearTimers(e)}),w.registrations.clear(),w.visibilityListener&&typeof document<"u"&&document.removeEventListener("visibilitychange",w.visibilityListener),w.visibilityListener=null}static isHtmlElement(e){if(!(e instanceof Element))return!1;const t=e.ownerDocument?.defaultView?.HTMLElement;return typeof t<"u"&&e instanceof t}static hasPollAttribute(e){const t=`${u.prefix}poll-`,r=e.attributes;for(let i=0;i<r.length;i+=1)if(r[i].name.startsWith(t))return!0;return!1}static shouldObserve(e){const t=`${u.prefix}poll-`;return e.getAttributeNames().some(r=>r.startsWith(t)?!w.CONFIG_KEYS.has(r.slice(t.length)):!1)}static buildConfigKey(e){const t=`${u.prefix}poll-`;return e.getAttributeNames().filter(r=>r.startsWith(t)).sort().map(r=>`${r}=${e.getRawAttribute(r)??""}`).join(`
|
|
28
|
+
`)}static startPolling(e,t,r){const i={fragment:t,configKey:r,intervalMs:w.resolveInterval(t),timeoutMs:w.resolveTimeout(t),errorLimit:w.resolveErrorLimit(t),startedAt:performance.now(),intervalTimerId:null,timeoutTimerId:null,fetching:!1,paused:!1,stopped:!1,timedOut:!1,stopReason:null,count:0,consecutiveErrors:0};w.registrations.set(e,i),w.ensureVisibilityListener(),i.timeoutMs!==null&&(i.timeoutTimerId=setTimeout(()=>{w.handleTimeout(e)},i.timeoutMs)),w.injectState(i),w.tick(e)}static async tick(e){const t=w.registrations.get(e);if(!t||t.stopped||t.fetching)return;if(t.intervalTimerId=null,!e.isConnected){await w.stop(e,t,"detached");return}const r=w.isHidden(e)||w.isDisabled(t.fragment);if(r!==t.paused&&(t.paused=r,await w.injectState(t)),r){w.schedule(e,t);return}if(w.isUntilSatisfied(t.fragment)){await w.stop(e,t,"until");return}t.fetching=!0,t.count+=1;let i=!1;try{i=await new ee(t.fragment,"poll").runWithResult()}catch(n){m.error("[Haori]","Poll procedure execution error:",n)}finally{t.fetching=!1}if(!(w.registrations.get(e)!==t||t.stopped)){if(i)t.consecutiveErrors=0;else if(t.consecutiveErrors+=1,t.errorLimit!==null&&t.consecutiveErrors>=t.errorLimit){await w.stop(e,t,"error");return}if(await w.restoreStateIfCleared(t),i&&w.isUntilSatisfied(t.fragment)){await w.stop(e,t,"until");return}w.schedule(e,t)}}static schedule(e,t){t.stopped||t.intervalTimerId!==null||(t.intervalTimerId=setTimeout(()=>{w.tick(e)},t.intervalMs))}static async handleTimeout(e){const t=w.registrations.get(e);!t||t.stopped||(t.timeoutTimerId=null,t.timedOut=!0,e.isConnected&&H.pollTimeout(e,t.count,w.elapsed(t)),await w.stop(e,t,"timeout"))}static async stop(e,t,r){if(!t.stopped){if(t.stopped=!0,t.stopReason=r,t.paused=!1,w.clearTimers(t),r==="detached"){w.registrations.delete(e);return}await w.injectState(t),e.isConnected&&H.pollStop(e,r,t.count,w.elapsed(t))}}static teardown(e,t){w.clearTimers(t),w.registrations.delete(e)}static clearTimers(e){e.intervalTimerId!==null&&(clearTimeout(e.intervalTimerId),e.intervalTimerId=null),e.timeoutTimerId!==null&&(clearTimeout(e.timeoutTimerId),e.timeoutTimerId=null)}static elapsed(e){return Math.round(performance.now()-e.startedAt)}static ensureVisibilityListener(){if(w.visibilityListener||typeof document>"u")return;const e=()=>{document.visibilityState==="visible"&&Array.from(w.registrations.entries()).forEach(([t,r])=>{r.stopped||r.fetching||(r.intervalTimerId!==null&&(clearTimeout(r.intervalTimerId),r.intervalTimerId=null),w.tick(t))})};w.visibilityListener=e,document.addEventListener("visibilitychange",e)}static injectState(e){const t=w.resolveStateFragments(e);if(t.length===0)return Promise.resolve();const r={running:!e.stopped,paused:e.paused,stopped:e.stopped,timedOut:e.timedOut,stopReason:e.stopReason,count:e.count,elapsedMs:w.elapsed(e)};return Promise.all(t.map(i=>{const n=i.getTarget(),s={...i.getRawBindingData()??{},_poll:r};return B.setBindingData(n,s,{reflectToAttribute:!1,kind:"nonSupply",sequence:T.nextSequence()})})).then(()=>{})}static async restoreStateIfCleared(e){w.resolveStateFragments(e).some(i=>(i.getRawBindingData()??{})._poll===void 0)&&await w.injectState(e)}static resolveStateFragments(e){const t=`${u.prefix}poll-state`,r=e.fragment;if(!r.hasAttribute(t))return[];const i=r.getAttribute(t);if(typeof i!="string"||i.trim()==="")return r.getTarget().isConnected?[r]:[];const n=z.queryAll(i,t,document);if(n.length===0)return m.error("[Haori]",`Poll state element not found: ${i}`),[];const s=[];return n.forEach(a=>{if(!a.isConnected)return;const o=N.get(a);o instanceof T&&s.push(o)}),s}static resolveInterval(e){const t=`${u.prefix}poll-interval`;if(!e.hasAttribute(t))return w.DEFAULT_INTERVAL_MS;const r=w.toNumber(e.getAttribute(t));return r===null?(m.warn("[Haori]",`${t} は数値で指定してください。既定値 ${w.DEFAULT_INTERVAL_MS}ms を使用します。`),w.DEFAULT_INTERVAL_MS):r<w.MIN_INTERVAL_MS?(m.warn("[Haori]",`${t} の下限は ${w.MIN_INTERVAL_MS}ms です。${r}ms は下限へ切り上げます。`),w.MIN_INTERVAL_MS):r}static resolveTimeout(e){const t=`${u.prefix}poll-timeout`;if(!e.hasAttribute(t))return null;const r=w.toNumber(e.getAttribute(t));return r===null||r<=0?(m.warn("[Haori]",`${t} は正の数値で指定してください。無制限として扱います。`),null):r}static resolveErrorLimit(e){const t=`${u.prefix}poll-error-limit`;if(!e.hasAttribute(t))return null;const r=w.toNumber(e.getAttribute(t));return r===null||r<1?(m.warn("[Haori]",`${t} は 1 以上の数値で指定してください。無制限として扱います。`),null):Math.floor(r)}static toNumber(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e!="string"||e.trim()==="")return null;const t=Number(e.trim());return Number.isFinite(t)?t:null}static isHidden(e){return e.closest(`[${u.prefix}if-false]`)!==null}static isDisabled(e){const t=`${u.prefix}poll-disabled`;return e.hasAttribute(t)?w.isTruthy(e.getAttribute(t)):!1}static isUntilSatisfied(e){const t=`${u.prefix}poll-until`;if(!e.hasAttribute(t))return!1;const r=e.getAttributeEvaluation(t);return r?r.hasUnresolvedReference?(m.warn("[Haori]",`${t} に未解決の参照が含まれています(停止条件は成立扱いにしません):`,e.getRawAttribute(t),e.getTarget()),!1):w.isTruthy(r.value):!1}static isTruthy(e){if(e==null||e===!1)return!1;if(typeof e=="boolean")return e;if(typeof e=="string"){const t=e.trim().toLowerCase();return t!==""&&t!=="false"&&t!=="0"}return!!e}};w.CONFIG_KEYS=new Set(["interval","timeout","until","error-limit","disabled","state"]),w.DEFAULT_INTERVAL_MS=5e3,w.MIN_INTERVAL_MS=100,w.registrations=new Map,w.visibilityListener=null;let de=w;const ht="0.41.3";function Vt(g){typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>g()):Promise.resolve().then(g)}const O=class O{static isHtmlElement(e){if(!(e instanceof Element))return!1;const t=e.ownerDocument?.defaultView?.HTMLElement;return typeof t<"u"&&e instanceof t}static syncTree(e){(e instanceof Element||e instanceof DocumentFragment)&&(O.isHtmlElement(e)&&O.syncElement(e),e.querySelectorAll("*").forEach(t=>{O.syncElement(t)}))}static syncElement(e){const t=O.registrations.get(e),r=N.get(e);if(!(r instanceof T)||!O.shouldObserve(r)){t&&(t.observer.disconnect(),O.registrations.delete(e));return}if(typeof IntersectionObserver>"u")return;const i=O.resolveVarName(r);if(i===""){t&&(t.observer.disconnect(),O.registrations.delete(e)),m.warn("[Haori]",'data-each-visible requires a variable name (e.g. data-each-visible="visibleRange").');return}const n=O.resolveRoot(r),s=O.resolveRootMargin(r);if(t&&t.observer.root===n&&t.observer.rootMargin===s&&t.varName===i){t.fragment=r,O.refreshRows(t);return}t&&(t.observer.disconnect(),O.registrations.delete(e));const a=new IntersectionObserver(l=>{const c=O.registrations.get(e);if(!c)return;let d=!1;l.forEach(h=>{const y=h.target;c.observedRows.has(y)&&(h.isIntersecting?c.visibleRows.has(y)||(c.visibleRows.add(y),d=!0):c.visibleRows.delete(y)&&(d=!0))}),d&&O.scheduleCompute(c)},{root:n,rootMargin:s,threshold:O.THRESHOLD}),o={fragment:r,observer:a,varName:i,root:n,rootMargin:s,observedRows:new Set,visibleRows:new Set,scheduled:!1,lastSnapshot:null};O.registrations.set(e,o),O.refreshRows(o)}static cleanupTree(e){if(O.isHtmlElement(e)){const t=O.registrations.get(e);t&&(t.observer.disconnect(),O.registrations.delete(e))}(e instanceof Element||e instanceof DocumentFragment)&&e.querySelectorAll("*").forEach(t=>{const r=O.registrations.get(t);r&&(r.observer.disconnect(),O.registrations.delete(t))})}static disconnectAll(){O.registrations.forEach(e=>{e.observer.disconnect()}),O.registrations.clear()}static shouldObserve(e){return e.hasAttribute(`${u.prefix}each`)&&e.hasAttribute(`${u.prefix}each-visible`)}static resolveVarName(e){const t=e.getRawAttribute(`${u.prefix}each-visible`);return typeof t=="string"?t.trim():""}static resolveRoot(e){const t=`${u.prefix}each-visible-root`;if(!e.hasAttribute(t))return null;const r=e.getAttribute(t);if(typeof r!="string"||r.trim()==="")return null;const i=z.query(r,t,document);return O.isHtmlElement(i)?i:(m.error("[Haori]",`Visible range root element not found: ${r}`),null)}static resolveRootMargin(e){const t=`${u.prefix}each-visible-margin`,r=e.getAttribute(t);return r===null||r===!1||r===""?O.DEFAULT_ROOT_MARGIN:String(r)}static realRowElements(e){return e.getChildren().filter(t=>t instanceof T&&!t.hasAttribute(`${u.prefix}each-before`)&&!t.hasAttribute(`${u.prefix}each-after`)).map(t=>t.getTarget())}static refreshRows(e){const t=O.realRowElements(e.fragment),r=new Set(t);for(const i of[...e.observedRows])r.has(i)||(e.observer.unobserve(i),e.observedRows.delete(i),e.visibleRows.delete(i));for(const i of t)e.observedRows.has(i)||(e.observer.observe(i),e.observedRows.add(i));O.scheduleCompute(e)}static scheduleCompute(e){e.scheduled||(e.scheduled=!0,Vt(()=>{e.scheduled=!1;const t=e.fragment.getTarget();O.registrations.get(t)===e&&O.computeAndPublish(e)}))}static computeAndPublish(e){const t=O.realRowElements(e.fragment),r=new Map;t.forEach((a,o)=>r.set(a,o));const i=[];for(const a of e.visibleRows){const o=r.get(a);o!==void 0&&i.push(o)}let n;if(i.length===0)n={first:-1,last:-1,firstLabel:0,lastLabel:0,count:0,total:t.length,empty:!0};else{let a=i[0],o=i[0];for(const l of i)l<a&&(a=l),l>o&&(o=l);n={first:a,last:o,firstLabel:a+1,lastLabel:o+1,count:i.length,total:t.length,empty:!1}}const s=JSON.stringify(n);s!==e.lastSnapshot&&(e.lastSnapshot=s,O.publish(e,n))}static publish(e,t){const r=O.resolveBindOwner(e.fragment);if(!r){m.warn("[Haori]","data-each-visible found no ancestor data-bind scope to publish into.");return}const i=r.getTarget(),n={...r.getRawBindingData()??{}};n[e.varName]={...t};const s=e.fragment.getTarget(),a=i===s?new Set:new Set([e.fragment]);B.setBindingData(i,n,{skipFragments:a,reflectToAttribute:!1,kind:"nonSupply",sequence:T.nextSequence()}).catch(o=>{m.error("[Haori]","Failed to publish visible range:",o)})}static resolveBindOwner(e){const t=`${u.prefix}bind`;let r=e.getParent();for(;r;){if(r.hasAttribute(t))return r;r=r.getParent()}return e.hasAttribute(t)?e:null}};O.THRESHOLD=0,O.DEFAULT_ROOT_MARGIN="0px",O.registrations=new Map;let ae=O;const K=class K{static disconnectMutationObservers(){K._mutationObservers.forEach(e=>{e.disconnect()}),K._mutationObservers.length=0}static async init(){if(K._initialized)return;K._initialized=!0,K.disconnectMutationObservers(),T.setPendingMutationFlusher(()=>{K.flushPendingMutations()});const e=new Pe;K._dispatcher=e,e.startDeferred();try{const t=await Promise.allSettled([B.scan(document.head),B.scan(document.body)]),[r,i]=t;r.status!=="fulfilled"&&m.error("[Haori]","Failed to build head fragment:",r.reason),i.status!=="fulfilled"&&m.error("[Haori]","Failed to build body fragment:",i.reason),await V.wait(),document.body.setAttribute("data-haori-ready",""),K.observe(document.head),K.observe(document.body),ce.syncTree(document.body),de.syncTree(document.body),ae.syncTree(document.body)}finally{e.release()}H.ready(ht)}static getDispatcher(){return K._dispatcher}static isExternallyManaged(e){return(e instanceof Element?e:e?.parentElement??null)?.closest(`[${u.prefix}external]`)!=null}static observe(e){const t=new MutationObserver(r=>{K.processMutations(r)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),K._mutationObservers.push(t)}static flushPendingMutations(){for(const e of K._mutationObservers){const t=e.takeRecords();if(t.length===0)continue;const r=t.filter(K.isBindAttributeRecord),i=t.filter(n=>!K.isBindAttributeRecord(n));r.length>0&&K.processMutations(r,T.nextSequence()),i.length>0&&Promise.resolve().then(()=>{K.processMutations(i)})}}static isBindAttributeRecord(e){return e.type==="attributes"&&e.attributeName===`${u.prefix}bind`}static processMutations(e,t){for(const r of e)try{if(K.isExternallyManaged(r.target))continue;switch(r.type){case"attributes":{const i=r.target;if(r.attributeName&&i.hasAttribute("data-haori-click-lock")&&(r.attributeName==="disabled"||r.attributeName==="data-haori-click-lock")||r.attributeName&&i.hasAttribute(pe)&&(r.attributeName==="disabled"||r.attributeName===pe)||r.attributeName&&B.isAliasedAttributeReflection(i,r.attributeName))break;B.setAttribute(i,r.attributeName,i.getAttribute(r.attributeName),!0,t),ce.syncElement(i),de.syncElement(i),ae.syncElement(i);break}case"childList":{Array.from(r.removedNodes).forEach(i=>{ce.cleanupTree(i),de.cleanupTree(i),ae.cleanupTree(i),B.removeNode(i)}),Array.from(r.addedNodes).forEach(i=>{i.parentElement instanceof Element&&(B.addNode(i.parentElement,i),ce.syncTree(i),de.syncTree(i),ae.syncTree(i))}),r.target instanceof Element&&ae.syncElement(r.target);break}case"characterData":{r.target instanceof Text||r.target instanceof Comment?B.changeText(r.target,r.target.textContent):m.warn("[Haori]","Unsupported character data type:",r.target);break}default:m.warn("[Haori]","Unknown mutation type:",r.type);continue}}catch(i){m.error("[Haori]","Error processing mutation:",i)}}};K._initialized=!1,K._mutationObservers=[],K._dispatcher=null;let Re=K;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Re.init):Re.init();const qt=()=>re.waitForRenders(),Wt=re.enhancers,jt=Object.freeze(Object.defineProperty({__proto__:null,Core:B,Enhance:_,Env:u,Form:F,Fragment:N,Haori:re,Log:m,Queue:V,default:re,enhancers:Wt,version:ht,waitForRenders:qt},Symbol.toStringTag,{value:"Module"})),$e=re;for(const[g,e]of Object.entries(jt))g in $e||Object.defineProperty($e,g,{value:e,writable:!0,enumerable:!0,configurable:!0});return $e}();
|
|
29
29
|
//# sourceMappingURL=haori.iife.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1646,10 +1646,13 @@ declare class ElementFragment extends Fragment {
|
|
|
1646
1646
|
/**
|
|
1647
1647
|
* この入力欄がユーザーに編集されたことを記録します。
|
|
1648
1648
|
*
|
|
1649
|
-
* DOM で `change` / `input`
|
|
1650
|
-
*
|
|
1651
|
-
*
|
|
1652
|
-
*
|
|
1649
|
+
* DOM で `change` / `input` が発火した時点に呼び出します。イベントを伴って値を
|
|
1650
|
+
* 反映した場合(`Form.setValues()` など)も、その発火を通じて呼ばれます。
|
|
1651
|
+
* イベントを伴わない反映(`syncBindingValue()` や `Core.setBindingData()` 由来の
|
|
1652
|
+
* 書き戻し)では呼び出しません。
|
|
1653
|
+
*
|
|
1654
|
+
* 内部値の同期(`syncValue()`)とは独立です。手続きを起動しない `input` では
|
|
1655
|
+
* 発番だけを行い、内部値は同期しません(`EventDispatcher.recordUserEdit()`)。
|
|
1653
1656
|
*
|
|
1654
1657
|
* @returns 発番した編集の通番
|
|
1655
1658
|
*/
|
|
@@ -3843,7 +3846,7 @@ declare interface ValueChangeOrigin {
|
|
|
3843
3846
|
* リリース時に `package.json` と揃えて更新します(`tests/version.test.ts` が
|
|
3844
3847
|
* 一致を検査します)。
|
|
3845
3848
|
*/
|
|
3846
|
-
export declare const version = "0.41.
|
|
3849
|
+
export declare const version = "0.41.3";
|
|
3847
3850
|
|
|
3848
3851
|
/**
|
|
3849
3852
|
* すべてのレンダリングタスク(追従投入分を含む)の完了を待ちます。
|