@wcstack/intersection 4.23.0 → 4.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +25 -11
- package/README.md +25 -11
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.esm.js +43 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -76,27 +76,41 @@ npm install @wcstack/intersection
|
|
|
76
76
|
|
|
77
77
|
### 2. 無限スクロール(センチネル)
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
ページを `<wcs-fetch>` で読み込む一覧では、番兵には [`<wcs-infinite-scroll>`](../fetch/README.ja.md#5-wcs-infinite-scroll-による無限スクロール) を使ってください: url を待ち、背の高いウィンドウを埋め、失敗した要求を繰り返しません。`<wcs-intersect target="self">` は、端がほかのものを動かすときや、端の意味をページ自身が決めるとき(両端に伸びる一覧)に使います。
|
|
80
|
+
|
|
81
|
+
リストの末尾に空の `target="self"` マーカーを置き、その**報告**(イベントトークン)で動きます。取っておいたフラグでは動きません: 保存した `intersecting` は、ページがマーカーを動かした時点で古くなります。
|
|
80
82
|
|
|
81
83
|
```html
|
|
82
|
-
<ul
|
|
83
|
-
<
|
|
84
|
+
<ul>
|
|
85
|
+
<template data-wcs="for: items">
|
|
86
|
+
<li data-wcs="textContent: .name"></li>
|
|
87
|
+
</template>
|
|
84
88
|
</ul>
|
|
85
89
|
|
|
86
|
-
<wcs-intersect target="self"
|
|
90
|
+
<wcs-intersect target="self" root-margin="240px 0px"
|
|
91
|
+
data-wcs="eventToken.intersecting: sentinelChanged; command.reobserve: $command.rearm"></wcs-intersect>
|
|
87
92
|
```
|
|
88
93
|
|
|
89
94
|
```js
|
|
90
95
|
export default {
|
|
91
96
|
items: [],
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
$eventTokens: ["sentinelChanged"],
|
|
98
|
+
$commandTokens: ["rearm", "loadPage"],
|
|
99
|
+
$on: {
|
|
100
|
+
sentinelChanged(state, event) {
|
|
101
|
+
if (event.detail.isIntersecting) state.$command.loadPage.emit(); // 入ってきた端で次のページを取りに行く
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
$watch: {
|
|
105
|
+
// observer が報告するのは可視性の変化だけ: マーカーを画面に残したページの後は、今どこにいるかを尋ね直す。
|
|
106
|
+
// 失敗の後には尋ねない —— エラー表示のレイアウトが再試行のループになる。
|
|
107
|
+
items() { this.$command.rearm.emit(); },
|
|
108
|
+
},
|
|
97
109
|
};
|
|
98
110
|
```
|
|
99
111
|
|
|
112
|
+
読み込みはハンドラか `$watch` から始め、getter からは始めないでください: getter は誰かが読んだときにしか評価されず、要求を始めてはいけません。要求・一覧の終わり・再試行まで含めた形は [`examples/state-intersect-fetch`](../../examples/state-intersect-fetch) にあります。
|
|
113
|
+
|
|
100
114
|
### 3. スクロールスパイ(単一セクション)
|
|
101
115
|
|
|
102
116
|
ドキュメント内の別の場所にあるセクションに `target` を向け、`intersecting` をバインドして対応するナビ項目をハイライトします。
|
|
@@ -117,7 +131,7 @@ export default {
|
|
|
117
131
|
| 属性 | 型 | 既定値 | 説明 |
|
|
118
132
|
|----------------|---------|------------|-------------|
|
|
119
133
|
| `target` | string | *(省略)* | 何を観測するか: 省略 → 最初の子、セレクタ → その要素、`self` → この要素。 |
|
|
120
|
-
| `root` | string | *(viewport)* | スクロールルートのセレクタ。 |
|
|
134
|
+
| `root` | string | *(viewport)* | スクロールルートのセレクタ。4.24 から、セレクタとして何にも一致しない値は id として探し(`<wcs-infinite-scroll root>` の書き方)、見つからなければ値ごとに 1 回 `[wcs/intersect-root]` で警告します —— それまでは黙って viewport が使われました。中身を切り取らない root(`root="main"` は `<main>` に一致します)は、中にあるものをすべて交差中として数えます。 |
|
|
121
135
|
| `root-margin` | string | `0px` | ルート周りのマージン(CSS の margin 構文)。 |
|
|
122
136
|
| `threshold` | string | `0` | 単一の比率(`0.5`)またはカンマ区切りリスト(`0,0.5,1`)の `0..1` の閾値。不正 / 範囲外の値は捨てられる。 |
|
|
123
137
|
| `once` | boolean | `false` | 最初の交差した観測の後に切断する。 |
|
|
@@ -246,7 +260,7 @@ Core の構造サーフェスは wcstack I/O ノード横断の規範です([asy
|
|
|
246
260
|
|
|
247
261
|
- **4.8 から、観測は接続の 1 マイクロタスク後に始まる。** そのときの `manual`・`target`・`root`・オプションで観測し、その後のオプションの変化も次のマイクロタスクで 1 回にまとめて観測し直す([タイミング契約](../../docs/timing-and-firing-contract.ja.md) §23)。`@wcstack/router` はパラメータだけの遷移でルートの要素を入れ直し、`@wcstack/state` が次のルートの入力を書くのはその後。同じタスクの `unobserve()` / `disconnect()` はそれを取り消し、`observe()` / `reobserve()` はその場で動く。
|
|
248
262
|
- **単一ターゲット。** 各 `<wcs-intersect>` はちょうど 1 つの要素を観測するので、状態は単一の値面にマップします。多数のターゲットには多数の要素を使ってください。
|
|
249
|
-
- **決して throw しない。** 非対応環境(`IntersectionObserver`
|
|
263
|
+
- **決して throw しない。** 非対応環境(`IntersectionObserver` が無い)や不正なオプションは no-op です。throw せず、`observing` は `false` のままです。ブラウザが拒む `root-margin` —— 単位の無い長さ: `200`、`0 0 900 0`、`0` だけでも。`px` か `%` を付けます —— では何も観測しません。4.24 から、要素が値ごとに 1 回そう知らせます(`[wcs/root-margin-unit]`。lint と同じ code)。4.23 までは無言でした。
|
|
250
264
|
- **パーミッションゲート / セキュアコンテキスト要件は無い**(`@wcstack/geolocation` と異なります)。
|
|
251
265
|
|
|
252
266
|
## ライセンス
|
package/README.md
CHANGED
|
@@ -76,27 +76,41 @@ npm install @wcstack/intersection
|
|
|
76
76
|
|
|
77
77
|
### 2. Infinite scroll (sentinel)
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
For a list that loads its pages with `<wcs-fetch>`, the sentinel to use is [`<wcs-infinite-scroll>`](../fetch/README.md#5-infinite-scroll-with-wcs-infinite-scroll): it waits for the url, fills a tall window and does not repeat a failed request. Use `<wcs-intersect target="self">` when the edge drives something else, or when the page decides itself what an edge means (a list that grows at both ends).
|
|
80
|
+
|
|
81
|
+
Place an empty `target="self"` marker at the bottom of the list and act on its **report** — an event token — not on a flag you keep: a stored `intersecting` is stale as soon as a page has moved the marker.
|
|
80
82
|
|
|
81
83
|
```html
|
|
82
|
-
<ul
|
|
83
|
-
<
|
|
84
|
+
<ul>
|
|
85
|
+
<template data-wcs="for: items">
|
|
86
|
+
<li data-wcs="textContent: .name"></li>
|
|
87
|
+
</template>
|
|
84
88
|
</ul>
|
|
85
89
|
|
|
86
|
-
<wcs-intersect target="self"
|
|
90
|
+
<wcs-intersect target="self" root-margin="240px 0px"
|
|
91
|
+
data-wcs="eventToken.intersecting: sentinelChanged; command.reobserve: $command.rearm"></wcs-intersect>
|
|
87
92
|
```
|
|
88
93
|
|
|
89
94
|
```js
|
|
90
95
|
export default {
|
|
91
96
|
items: [],
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
$eventTokens: ["sentinelChanged"],
|
|
98
|
+
$commandTokens: ["rearm", "loadPage"],
|
|
99
|
+
$on: {
|
|
100
|
+
sentinelChanged(state, event) {
|
|
101
|
+
if (event.detail.isIntersecting) state.$command.loadPage.emit(); // an enter edge asks for the next page
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
$watch: {
|
|
105
|
+
// The observer reports a change of visibility and nothing else: after a page that left the marker on screen,
|
|
106
|
+
// ask it where it is now. Not after a failure — the layout of an error message would retry in a loop.
|
|
107
|
+
items() { this.$command.rearm.emit(); },
|
|
108
|
+
},
|
|
97
109
|
};
|
|
98
110
|
```
|
|
99
111
|
|
|
112
|
+
Load from a handler or a `$watch`, never from a getter: a getter is evaluated only when something reads it, and it must not start a request. The whole pattern — the request, the end of the list, a retry — is [`examples/state-intersect-fetch`](../../examples/state-intersect-fetch).
|
|
113
|
+
|
|
100
114
|
### 3. Scrollspy (single section)
|
|
101
115
|
|
|
102
116
|
Point `target` at a section elsewhere in the document; bind `intersecting` to highlight the matching nav item.
|
|
@@ -117,7 +131,7 @@ Point `target` at a section elsewhere in the document; bind `intersecting` to hi
|
|
|
117
131
|
| Attribute | Type | Default | Description |
|
|
118
132
|
|----------------|---------|------------|-------------|
|
|
119
133
|
| `target` | string | *(omitted)*| What to observe: omitted → first child, a selector → that element, `self` → this element. |
|
|
120
|
-
| `root` | string | *(viewport)* | Selector for the scroll root. |
|
|
134
|
+
| `root` | string | *(viewport)* | Selector for the scroll root. Since 4.24, a value that matches nothing as a selector is tried as an id (the way `<wcs-infinite-scroll root>` spells it), and one that is not found warns `[wcs/intersect-root]` once per value — before, the viewport took its place without a word. A root that does not clip its content (`root="main"` matches `<main>`) counts everything inside it as intersecting. |
|
|
121
135
|
| `root-margin` | string | `0px` | Margin around the root (CSS-margin syntax). |
|
|
122
136
|
| `threshold` | string | `0` | A single ratio (`0.5`) or comma list (`0,0.5,1`) of `0..1` thresholds. Invalid / out-of-range values are dropped. |
|
|
123
137
|
| `once` | boolean | `false` | Disconnect after the first intersecting observation. |
|
|
@@ -250,7 +264,7 @@ The structural Core surface is normative across wcstack IO nodes ([async-io-node
|
|
|
250
264
|
|
|
251
265
|
- **Since 4.8, observing starts one microtask after connect**, with `manual`, `target`, `root` and the options as they are then, and a later option change re-observes in the next microtask, folded into one ([timing contract](../../docs/timing-and-firing-contract.md) §23): `@wcstack/router` puts a route's elements back on a parameter-only navigation before `@wcstack/state` writes the next route's inputs. `unobserve()` / `disconnect()` in the same task cancel it; `observe()` / `reobserve()` act at once.
|
|
252
266
|
- **Single target.** Each `<wcs-intersect>` observes exactly one element so the state maps to a single value surface. For many targets, use many elements.
|
|
253
|
-
- **Never throws.** Unsupported environments (no `IntersectionObserver`) and invalid options
|
|
267
|
+
- **Never throws.** Unsupported environments (no `IntersectionObserver`) and invalid options are no-ops: `observing` stays `false` rather than throwing. A `root-margin` the browser refuses — a length with no unit: `200`, `0 0 900 0`, a bare `0` too; write `px` or `%` — observes nothing; since 4.24 the element says so once per value (`[wcs/root-margin-unit]`, the lint's code). Up to 4.23 it was silent.
|
|
254
268
|
- **No permission gate / secure context requirement** (unlike `@wcstack/geolocation`).
|
|
255
269
|
|
|
256
270
|
## License
|
package/dist/auto.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const t={tagNames:{intersect:"wcs-intersect"}};var e="@wcstack/intersection",s="4.23.0";class n extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"entry",event:"wcs-intersect:change",semantics:"state"},{name:"intersecting",event:"wcs-intersect:change",semantics:"state",getter:t=>t.detail.isIntersecting},{name:"ratio",event:"wcs-intersect:change",semantics:"state",getter:t=>t.detail.intersectionRatio},{name:"visible",event:"wcs-intersect:visible-changed",semantics:"state"},{name:"observing",event:"wcs-intersect:observing-changed",semantics:"state"}],commands:[{name:"observe"},{name:"reobserve"},{name:"unobserve"},{name:"disconnect"},{name:"reset"}]};_target;_observer=null;_observed=null;_options={};_entry=null;_visible=!1;_observing=!1;_gen=0;_ready=Promise.resolve();constructor(t){super(),this._target=t??this}get ready(){return this._ready}get entry(){return this._entry}get intersecting(){return!!this._entry&&this._entry.isIntersecting}get ratio(){return this._entry?this._entry.intersectionRatio:0}get visible(){return this._visible}get observing(){return this._observing}_setEntry(t){this._entry=t,this._target.dispatchEvent(new CustomEvent("wcs-intersect:change",{detail:t,bubbles:!0}))}_setVisible(t){this._visible!==t&&(this._visible=t,this._target.dispatchEvent(new CustomEvent("wcs-intersect:visible-changed",{detail:t,bubbles:!0})))}_setObserving(t){this._observing!==t&&(this._observing=t,this._target.dispatchEvent(new CustomEvent("wcs-intersect:observing-changed",{detail:t,bubbles:!0})))}observe(t,e={}){if(this._observer&&this._observed===t&&this._optionsEqual(this._options,e))return this._ready;this._teardownObserver();const s=this._createObserver(e);return s?(this._observer=s,this._observed=t,this._options=e,s.observe(t),this._setObserving(!0),this._ready):(this._setObserving(!1),this._ready)}reobserve(t,e={}){this._teardownObserver(),this.observe(t,e)}unobserve(t){this._observed===t&&(this._teardownObserver(),this._setObserving(!1))}disconnect(){this._teardownObserver(),this._setObserving(!1)}reset(){this._setVisible(!1)}dispose(){this._gen++,this.disconnect()}_teardownObserver(){this._observer&&(this._observer.disconnect(),this._observer=null),this._observed=null,this._gen++}_createObserver(t){if("undefined"==typeof IntersectionObserver)return null;const e=this._gen;try{return new IntersectionObserver(t=>this._onIntersect(e,t),{root:t.root??null,rootMargin:t.rootMargin??"0px",threshold:t.threshold??0})}catch{return null}}_onIntersect(t,e){if(t===this._gen)for(const t of e){const e=this._normalizeEntry(t);this._setEntry(e),e.isIntersecting&&this._setVisible(!0)}}_normalizeEntry(t){return{isIntersecting:t.isIntersecting,intersectionRatio:t.intersectionRatio,time:t.time,boundingClientRect:this._normalizeRect(t.boundingClientRect),intersectionRect:this._normalizeRect(t.intersectionRect),rootBounds:t.rootBounds?this._normalizeRect(t.rootBounds):null,target:t.target}}_normalizeRect(t){return{x:t.x,y:t.y,width:t.width,height:t.height,top:t.top,right:t.right,bottom:t.bottom,left:t.left}}_optionsEqual(t,e){return(t.root??null)===(e.root??null)&&((t.rootMargin??"0px")===(e.rootMargin??"0px")&&this._thresholdKey(t.threshold)===this._thresholdKey(e.threshold))}_thresholdKey(t){return void 0===t?"0":Array.isArray(t)?t.join(","):String(t)}}function r(t,e){let s=Object.getPrototypeOf(t);for(;null!==s;){const t=Object.getOwnPropertyDescriptor(s,e);if(void 0!==t)return"function"==typeof t.get||"function"==typeof t.set;s=Object.getPrototypeOf(s)}return!1}const i=new WeakSet;function o(t,e,s){if(i.has(t))return;i.add(t);const n=t.localName??"element";console.warn(`[wcs/input-as-attribute] <${n}> has the attribute ${e}="${s}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,t)}const a=new WeakMap;function c(t,e){let s=a.get(t);return void 0===s&&(s=new Map,a.set(t,s)),s.has(e)||s.set(e,t.getAttribute(e)),s.get(e)}function h(t,e,s){null===s?t.removeAttribute(e):t.setAttribute(e,s)}function l(t,e,s){const n=c(t,e);h(t,e,void 0===s?n:null===s?null:String(s))}function g(t,e,s){const n=c(t,e);h(t,e,void 0===s?n:s?"":null)}class u extends HTMLElement{static hasConnectedCallbackPromise=!0;static observedAttributes=["target","root","root-margin","threshold"];static wcBindable={...n.wcBindable,properties:[...n.wcBindable.properties,{name:"trigger",event:"wcs-intersect:trigger-changed",semantics:"state"}],inputs:[{name:"target",attribute:"target"},{name:"root",attribute:"root"},{name:"rootMargin",attribute:"root-margin"},{name:"threshold",attribute:"threshold"},{name:"once",attribute:"once"},{name:"manual",attribute:"manual"},{name:"trigger"}],commands:n.wcBindable.commands};_core;_trigger=!1;_connectedCallbackPromise=Promise.resolve();_internals=null;_observePending=!1;constructor(){super(),this._core=new n(this),this._internals=this._initInternals(),this._wireStates({"wcs-intersect:visible-changed":t=>({visible:!0===t}),"wcs-intersect:observing-changed":t=>({observing:!0===t}),"wcs-intersect:change":t=>({intersecting:!0===t.isIntersecting})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const t=this.attachInternals();return t.states.add("wcs-probe"),t.states.delete("wcs-probe"),t}catch{return null}}_wireStates(t){if(null===this._internals)return;const e=this._internals.states;for(const[s,n]of Object.entries(t))this.addEventListener(s,t=>{const s=this.hasAttribute("debug-states");for(const[r,i]of Object.entries(n(t.detail))){try{i?e.add(r):e.delete(r)}catch{}s&&this.toggleAttribute(`data-wcs-state-${r}`,i)}})}get connectedCallbackPromise(){return this._connectedCallbackPromise}get target(){return this.getAttribute("target")??""}set target(t){l(this,"target",t)}get root(){return this.getAttribute("root")??""}set root(t){l(this,"root",t)}get rootMargin(){const t=this.getAttribute("root-margin");return null===t||""===t.trim()?"0px":t}set rootMargin(t){l(this,"root-margin",t)}get threshold(){return this.getAttribute("threshold")??""}set threshold(t){l(this,"threshold",t)}get once(){return this.hasAttribute("once")}set once(t){g(this,"once",t)}get manual(){return this.hasAttribute("manual")}set manual(t){g(this,"manual",t)}get entry(){return this._core.entry}get intersecting(){return this._core.intersecting}get ratio(){return this._core.ratio}get visible(){return this._core.visible}get observing(){return this._core.observing}get trigger(){return this._trigger}set trigger(t){if(!!t){this._trigger=!0;try{this.observe()}finally{this._trigger=!1,this.dispatchEvent(new CustomEvent("wcs-intersect:trigger-changed",{detail:!1,bubbles:!0}))}}}observe(){const{element:t,display:e}=this._resolveTarget();this.style.display=e,t?this._core.observe(t,this._options()):this._core.disconnect()}reobserve(){const{element:t,display:e}=this._resolveTarget();this.style.display=e,t?this._core.reobserve(t,this._options()):this._core.disconnect()}unobserve(){this._observePending=!1,this._core.disconnect()}disconnect(){this._observePending=!1,this._core.disconnect()}reset(){this._core.reset()}_resolveTarget(){const t=this.target;if("self"===t)return{element:this,display:"block"};if(""!==t){const e=this.getRootNode();return{element:this._safeQuery(e,t),display:"none"}}const e=this.firstElementChild;return e?{element:e,display:"contents"}:{element:this,display:"block"}}_resolveRoot(){const t=this.root;if(""===t)return null;const e=this.getRootNode();return this._safeQuery(e,t)}_safeQuery(t,e){try{return t.querySelector(e)}catch{return null}}_parseThreshold(){const t=this.threshold.trim();if(""===t)return 0;const e=t.split(",").map(t=>t.trim()).filter(t=>""!==t).map(t=>Number(t)).filter(t=>Number.isFinite(t)&&t>=0&&t<=1);return 0===e.length?0:1===e.length?e[0]:e}_options(){return{root:this._resolveRoot(),rootMargin:this.rootMargin,threshold:this._parseThreshold()}}_onChange=t=>{t.target===this&&this.once&&t.detail.isIntersecting&&this._core.disconnect()};_scheduleObserve(){this._observePending||(this._observePending=!0,queueMicrotask(()=>{this._observePending&&(this._observePending=!1,this.isConnected&&!this.manual&&this.observe())}))}connectedCallback(){!function(t){const e=t.constructor?.wcBindable,s=e?.inputs;if(void 0===s)return;const n=t.getAttribute;for(const e of s){const s=e.name,i="function"==typeof n?n.call(t,s.toLowerCase()):null;if(null!==i&&i.startsWith("[object ")&&o(t,s,i),!Object.prototype.hasOwnProperty.call(t,s))continue;if(!r(t,s))continue;const a=t,c=a[s];delete a[s],a[s]=c}}(this),this.addEventListener("wcs-intersect:change",this._onChange),this._scheduleObserve(),this._connectedCallbackPromise=this._core.ready}disconnectedCallback(){this.removeEventListener("wcs-intersect:change",this._onChange),this._core.dispose()}attributeChangedCallback(t,e,s){e!==s&&this.isConnected&&!this.manual&&this._scheduleObserve()}}const d=Symbol.for("wcstack.package"),b=new WeakSet;function _(t,e){Object.defineProperty(t,d,{value:e,configurable:!0})}function v(t,e,s,n,r){if(void 0!==n&&(s===n||s.prototype instanceof n))return;const i=s[d];if(i===r||b.has(t))return;b.add(t);const o=r.slice(0,r.lastIndexOf("@"));console.warn(`[${o}] [wcs/package-twice] <${e}> is already defined by ${i??`another copy of ${o} that does not name its version`}; this copy, ${r}, does nothing. Load each package once.`)}function m(n=customElements){!function(t,e,s){for(const[n,r]of s){const s=t.get(n);void 0===s?(_(r,e),t.define(n,r)):v(t,n,s,r,e)}}(n,`${e}@${s}`,[[t.tagNames.intersect,u]])}var p;m(p);
|
|
1
|
+
const t={tagNames:{intersect:"wcs-intersect"}};var e="@wcstack/intersection",s="4.24.0";class n extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"entry",event:"wcs-intersect:change",semantics:"state"},{name:"intersecting",event:"wcs-intersect:change",semantics:"state",getter:t=>t.detail.isIntersecting},{name:"ratio",event:"wcs-intersect:change",semantics:"state",getter:t=>t.detail.intersectionRatio},{name:"visible",event:"wcs-intersect:visible-changed",semantics:"state"},{name:"observing",event:"wcs-intersect:observing-changed",semantics:"state"}],commands:[{name:"observe"},{name:"reobserve"},{name:"unobserve"},{name:"disconnect"},{name:"reset"}]};_target;_observer=null;_observed=null;_options={};_entry=null;_visible=!1;_observing=!1;_gen=0;_ready=Promise.resolve();constructor(t){super(),this._target=t??this}get ready(){return this._ready}get entry(){return this._entry}get intersecting(){return!!this._entry&&this._entry.isIntersecting}get ratio(){return this._entry?this._entry.intersectionRatio:0}get visible(){return this._visible}get observing(){return this._observing}_setEntry(t){this._entry=t,this._target.dispatchEvent(new CustomEvent("wcs-intersect:change",{detail:t,bubbles:!0}))}_setVisible(t){this._visible!==t&&(this._visible=t,this._target.dispatchEvent(new CustomEvent("wcs-intersect:visible-changed",{detail:t,bubbles:!0})))}_setObserving(t){this._observing!==t&&(this._observing=t,this._target.dispatchEvent(new CustomEvent("wcs-intersect:observing-changed",{detail:t,bubbles:!0})))}observe(t,e={}){if(this._observer&&this._observed===t&&this._optionsEqual(this._options,e))return this._ready;this._teardownObserver();const s=this._createObserver(e);return s?(this._observer=s,this._observed=t,this._options=e,s.observe(t),this._setObserving(!0),this._ready):(this._setObserving(!1),this._ready)}reobserve(t,e={}){this._teardownObserver(),this.observe(t,e)}unobserve(t){this._observed===t&&(this._teardownObserver(),this._setObserving(!1))}disconnect(){this._teardownObserver(),this._setObserving(!1)}reset(){this._setVisible(!1)}dispose(){this._gen++,this.disconnect()}_teardownObserver(){this._observer&&(this._observer.disconnect(),this._observer=null),this._observed=null,this._gen++}_createObserver(t){if("undefined"==typeof IntersectionObserver)return null;const e=this._gen;try{return new IntersectionObserver(t=>this._onIntersect(e,t),{root:t.root??null,rootMargin:t.rootMargin??"0px",threshold:t.threshold??0})}catch{return null}}_onIntersect(t,e){if(t===this._gen)for(const t of e){const e=this._normalizeEntry(t);this._setEntry(e),e.isIntersecting&&this._setVisible(!0)}}_normalizeEntry(t){return{isIntersecting:t.isIntersecting,intersectionRatio:t.intersectionRatio,time:t.time,boundingClientRect:this._normalizeRect(t.boundingClientRect),intersectionRect:this._normalizeRect(t.intersectionRect),rootBounds:t.rootBounds?this._normalizeRect(t.rootBounds):null,target:t.target}}_normalizeRect(t){return{x:t.x,y:t.y,width:t.width,height:t.height,top:t.top,right:t.right,bottom:t.bottom,left:t.left}}_optionsEqual(t,e){return(t.root??null)===(e.root??null)&&((t.rootMargin??"0px")===(e.rootMargin??"0px")&&this._thresholdKey(t.threshold)===this._thresholdKey(e.threshold))}_thresholdKey(t){return void 0===t?"0":Array.isArray(t)?t.join(","):String(t)}}function r(t,e){let s=Object.getPrototypeOf(t);for(;null!==s;){const t=Object.getOwnPropertyDescriptor(s,e);if(void 0!==t)return"function"==typeof t.get||"function"==typeof t.set;s=Object.getPrototypeOf(s)}return!1}const i=new WeakSet;function o(t,e,s){if(i.has(t))return;i.add(t);const n=t.localName??"element";console.warn(`[wcs/input-as-attribute] <${n}> has the attribute ${e}="${s}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,t)}const a=new WeakMap;function c(t,e){let s=a.get(t);return void 0===s&&(s=new Map,a.set(t,s)),s.has(e)||s.set(e,t.getAttribute(e)),s.get(e)}function h(t,e,s){null===s?t.removeAttribute(e):t.setAttribute(e,s)}function l(t,e,s){const n=c(t,e);h(t,e,void 0===s?n:null===s?null:String(s))}function g(t,e,s){const n=c(t,e);h(t,e,void 0===s?n:s?"":null)}class d extends HTMLElement{static hasConnectedCallbackPromise=!0;static observedAttributes=["target","root","root-margin","threshold"];static wcBindable={...n.wcBindable,properties:[...n.wcBindable.properties,{name:"trigger",event:"wcs-intersect:trigger-changed",semantics:"state"}],inputs:[{name:"target",attribute:"target"},{name:"root",attribute:"root"},{name:"rootMargin",attribute:"root-margin"},{name:"threshold",attribute:"threshold"},{name:"once",attribute:"once"},{name:"manual",attribute:"manual"},{name:"trigger"}],commands:n.wcBindable.commands};_core;_trigger=!1;_connectedCallbackPromise=Promise.resolve();_internals=null;_observePending=!1;_warnedRoot=null;_warnedMargin=null;constructor(){super(),this._core=new n(this),this._internals=this._initInternals(),this._wireStates({"wcs-intersect:visible-changed":t=>({visible:!0===t}),"wcs-intersect:observing-changed":t=>({observing:!0===t}),"wcs-intersect:change":t=>({intersecting:!0===t.isIntersecting})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const t=this.attachInternals();return t.states.add("wcs-probe"),t.states.delete("wcs-probe"),t}catch{return null}}_wireStates(t){if(null===this._internals)return;const e=this._internals.states;for(const[s,n]of Object.entries(t))this.addEventListener(s,t=>{const s=this.hasAttribute("debug-states");for(const[r,i]of Object.entries(n(t.detail))){try{i?e.add(r):e.delete(r)}catch{}s&&this.toggleAttribute(`data-wcs-state-${r}`,i)}})}get connectedCallbackPromise(){return this._connectedCallbackPromise}get target(){return this.getAttribute("target")??""}set target(t){l(this,"target",t)}get root(){return this.getAttribute("root")??""}set root(t){l(this,"root",t)}get rootMargin(){const t=this.getAttribute("root-margin");return null===t||""===t.trim()?"0px":t}set rootMargin(t){l(this,"root-margin",t)}get threshold(){return this.getAttribute("threshold")??""}set threshold(t){l(this,"threshold",t)}get once(){return this.hasAttribute("once")}set once(t){g(this,"once",t)}get manual(){return this.hasAttribute("manual")}set manual(t){g(this,"manual",t)}get entry(){return this._core.entry}get intersecting(){return this._core.intersecting}get ratio(){return this._core.ratio}get visible(){return this._core.visible}get observing(){return this._core.observing}get trigger(){return this._trigger}set trigger(t){if(!!t){this._trigger=!0;try{this.observe()}finally{this._trigger=!1,this.dispatchEvent(new CustomEvent("wcs-intersect:trigger-changed",{detail:!1,bubbles:!0}))}}}observe(){const{element:t,display:e}=this._resolveTarget();this.style.display=e,t?(this._core.observe(t,this._options()),this._warnRefused()):this._core.disconnect()}reobserve(){const{element:t,display:e}=this._resolveTarget();this.style.display=e,t?(this._core.reobserve(t,this._options()),this._warnRefused()):this._core.disconnect()}_warnRefused(){if(this._core.observing||"undefined"==typeof IntersectionObserver)return;const t=this.rootMargin;if(this._warnedMargin===t)return;let e="";try{return void new IntersectionObserver(Function.prototype,{rootMargin:t}).disconnect()}catch(t){e=t.message}this._warnedMargin=t,console.warn(`[@wcstack/intersection] [wcs/root-margin-unit] <${this.localName} root-margin="${t}"> is not a margin the browser takes (${e}): write each length with px or %, as "200px 0px". Nothing is observed (observing stays false).`)}unobserve(){this._observePending=!1,this._core.disconnect()}disconnect(){this._observePending=!1,this._core.disconnect()}reset(){this._core.reset()}_resolveTarget(){const t=this.target;if("self"===t)return{element:this,display:"block"};if(""!==t){const e=this.getRootNode();return{element:this._safeQuery(e,t),display:"none"}}const e=this.firstElementChild;return e?{element:e,display:"contents"}:{element:this,display:"block"}}_resolveRoot(){const t=this.root;if(""===t)return null;const e=this.getRootNode(),s=this._safeQuery(e,t)??e.getElementById?.(t)??null;return s||this._warnedRoot===t||(this._warnedRoot=t,console.warn(`[@wcstack/intersection] [wcs/intersect-root] <${this.localName} root="${t}">: no element matches that selector, and none has it as its id, so the viewport is the root.`)),s}_safeQuery(t,e){try{return t.querySelector(e)}catch{return null}}_parseThreshold(){const t=this.threshold.trim();if(""===t)return 0;const e=t.split(",").map(t=>t.trim()).filter(t=>""!==t).map(t=>Number(t)).filter(t=>Number.isFinite(t)&&t>=0&&t<=1);return 0===e.length?0:1===e.length?e[0]:e}_options(){return{root:this._resolveRoot(),rootMargin:this.rootMargin,threshold:this._parseThreshold()}}_onChange=t=>{t.target===this&&this.once&&t.detail.isIntersecting&&this._core.disconnect()};_scheduleObserve(){this._observePending||(this._observePending=!0,queueMicrotask(()=>{this._observePending&&(this._observePending=!1,this.isConnected&&!this.manual&&this.observe())}))}connectedCallback(){!function(t){const e=t.constructor?.wcBindable,s=e?.inputs;if(void 0===s)return;const n=t.getAttribute;for(const e of s){const s=e.name,i="function"==typeof n?n.call(t,s.toLowerCase()):null;if(null!==i&&i.startsWith("[object ")&&o(t,s,i),!Object.prototype.hasOwnProperty.call(t,s))continue;if(!r(t,s))continue;const a=t,c=a[s];delete a[s],a[s]=c}}(this),this.addEventListener("wcs-intersect:change",this._onChange),this._scheduleObserve(),this._connectedCallbackPromise=this._core.ready}disconnectedCallback(){this.removeEventListener("wcs-intersect:change",this._onChange),this._core.dispose()}attributeChangedCallback(t,e,s){e!==s&&this.isConnected&&!this.manual&&this._scheduleObserve()}}const u=Symbol.for("wcstack.package"),b=new WeakSet;function _(t,e){Object.defineProperty(t,u,{value:e,configurable:!0})}function v(t,e,s,n,r){if(void 0!==n&&(s===n||s.prototype instanceof n))return;const i=s[u];if(i===r||b.has(t))return;b.add(t);const o=r.slice(0,r.lastIndexOf("@"));console.warn(`[${o}] [wcs/package-twice] <${e}> is already defined by ${i??`another copy of ${o} that does not name its version`}; this copy, ${r}, does nothing. Load each package once.`)}function m(n=customElements){!function(t,e,s){for(const[n,r]of s){const s=t.get(n);void 0===s?(_(r,e),t.define(n,r)):v(t,n,s,r,e)}}(n,`${e}@${s}`,[[t.tagNames.intersect,d]])}var f;m(f);
|
|
2
2
|
//# sourceMappingURL=auto.min.js.map
|
package/dist/auto.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto.min.js","sources":["../../src/config.ts","../../src/core/IntersectionCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Intersect.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapIntersection.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n intersect: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n intersect: \"wcs-intersect\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapIntersection` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/intersection] bootstrapIntersection: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","import { IWcBindable, IntersectOptions, WcsIntersectEntry, WcsIntersectRect } from \"../types.js\";\n\n/**\n * Headless visibility primitive. A thin, framework-agnostic wrapper around the\n * IntersectionObserver API exposed through the wc-bindable protocol.\n *\n * Unlike the other @wcstack sensors (geolocation / timer / websocket), the thing\n * being observed is a *DOM element* — so `observe()` takes the target node. The\n * Core stays DOM-resolution-agnostic: it observes whatever element it is handed\n * (the Shell resolves `target` / `root` selectors before calling). It is a\n * read-only producer — element/layout → state only, with no element-bound path.\n *\n * Every observer callback is published via the single `wcs-intersect:change`\n * event; `intersecting` / `ratio` are read from it through getters (mirroring how\n * GeolocationCore exposes latitude/longitude from one `wcs-geo:position` event),\n * so an observer that binds any of them is notified on every change.\n *\n * `visible` is a latch: it flips to `true` the first time the target intersects\n * and stays `true` until `reset()` — ideal for one-way lazy-load bindings\n * (`src@visible`). `observing` reflects whether an observation is currently\n * active (like TimerCore's `running`).\n *\n * Single-target by design: the Shell observes exactly one element, so the state\n * reflects that element. Multi-target observation is intentionally out of scope.\n */\nexport class IntersectionCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"entry\", event: \"wcs-intersect:change\", semantics: \"state\" },\n { name: \"intersecting\", event: \"wcs-intersect:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.isIntersecting },\n { name: \"ratio\", event: \"wcs-intersect:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.intersectionRatio },\n { name: \"visible\", event: \"wcs-intersect:visible-changed\", semantics: \"state\" },\n { name: \"observing\", event: \"wcs-intersect:observing-changed\", semantics: \"state\" },\n ],\n commands: [\n { name: \"observe\" },\n { name: \"reobserve\" },\n { name: \"unobserve\" },\n { name: \"disconnect\" },\n { name: \"reset\" },\n ],\n };\n\n private _target: EventTarget;\n\n // The live observer and the single element it observes. Options are kept so a\n // repeated observe() with identical options is a no-op (avoids the create→\n // observe→disconnect churn an autoloader upgrade can otherwise cause).\n private _observer: IntersectionObserver | null = null;\n private _observed: Element | null = null;\n private _options: IntersectOptions = {};\n\n private _entry: WcsIntersectEntry | null = null;\n private _visible: boolean = false;\n private _observing: boolean = false;\n\n // Generation guard (§3.4): bumped on dispose() and on each observe()/reobserve()\n // teardown+rebuild. IntersectionObserver delivers its callback asynchronously off\n // layout, so a callback can fire after the element is disposed or after a rapid\n // disconnect→reconnect rebuilt the observer. Each observer captures the gen live at\n // creation; a callback from a superseded/torn-down observer has a stale gen and\n // MUST NOT write state to a torn-down element. A boolean flag is insufficient\n // (dispose→observe would flip it back and let stale work slip through).\n private _gen = 0;\n\n // SSR (§3.8): IntersectionObserver setup is synchronous (no async probe to await),\n // so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n /** Resolves immediately — there is no asynchronous probe to await (§3.8). */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get entry(): WcsIntersectEntry | null {\n return this._entry;\n }\n\n get intersecting(): boolean {\n return this._entry ? this._entry.isIntersecting : false;\n }\n\n get ratio(): number {\n return this._entry ? this._entry.intersectionRatio : 0;\n }\n\n get visible(): boolean {\n return this._visible;\n }\n\n get observing(): boolean {\n return this._observing;\n }\n\n // --- State setters with event dispatch ---\n\n private _setEntry(entry: WcsIntersectEntry): void {\n // No same-value guard: `change` carries event semantics (every callback is a\n // distinct observation) and `intersecting` / `ratio` are derived getters that\n // must re-fire on each entry, mirroring GeolocationCore's `position`.\n this._entry = entry;\n this._target.dispatchEvent(new CustomEvent(\"wcs-intersect:change\", {\n detail: entry,\n bubbles: true,\n }));\n }\n\n private _setVisible(visible: boolean): void {\n if (this._visible === visible) return;\n this._visible = visible;\n this._target.dispatchEvent(new CustomEvent(\"wcs-intersect:visible-changed\", {\n detail: visible,\n bubbles: true,\n }));\n }\n\n private _setObserving(observing: boolean): void {\n if (this._observing === observing) return;\n this._observing = observing;\n this._target.dispatchEvent(new CustomEvent(\"wcs-intersect:observing-changed\", {\n detail: observing,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing `element`. Idempotent while already observing the same\n * element with the same options. Changing the element or options tears down the\n * current observer and builds a new one (IntersectionObserver options are fixed\n * at construction, so reconfiguring requires a fresh observer).\n *\n * If IntersectionObserver is unavailable (SSR) or the options are invalid (e.g.\n * a malformed `rootMargin`, which the constructor rejects), this is a silent\n * no-op — `observing` stays false, consistent with the never-throw design of\n * the other @wcstack sensors.\n */\n observe(element: Element, options: IntersectOptions = {}): Promise<void> {\n if (this._observer && this._observed === element && this._optionsEqual(this._options, options)) {\n return this._ready;\n }\n this._teardownObserver();\n const observer = this._createObserver(options);\n if (!observer) {\n // Creation failed (unsupported environment or invalid options) *after* we\n // tore down any previous observer. If we were already observing, the\n // observation is now gone, so reflect that — otherwise `observing` would\n // keep reporting true with no live observer behind it (e.g. re-observing an\n // active target with a newly-invalid rootMargin).\n this._setObserving(false);\n return this._ready;\n }\n this._observer = observer;\n this._observed = element;\n this._options = options;\n observer.observe(element);\n this._setObserving(true);\n // SSR (§3.5): observe() returns the readiness promise. Observation establishment\n // is synchronous, so this resolves immediately.\n return this._ready;\n }\n\n /**\n * Force a fresh observation of `element`, even when it matches the currently\n * observed target+options. Unlike observe() — which is idempotent and\n * early-returns for an unchanged target+options *without* re-delivering a\n * callback — this always tears the observer down and rebuilds it, so a new\n * IntersectionObserver delivers an initial callback for the element's CURRENT\n * visibility.\n *\n * This is the way to re-arm an edge-driven consumer (e.g. infinite scroll) after\n * the layout changed without a visibility *transition*: IntersectionObserver only\n * fires on a change, so appending a short page that leaves the sentinel visible\n * yields no new callback — a bare observe() can't help (idempotent), but a\n * reobserve() re-reads the current state. Same never-throw guarantees as\n * observe(); `observing` stays true across a successful re-arm (no false blip).\n */\n reobserve(element: Element, options: IntersectOptions = {}): void {\n this._teardownObserver();\n this.observe(element, options);\n }\n\n /**\n * Stop observing `element`. A no-op if it is not the currently observed\n * element. The observer instance is torn down (single-target Core), so a later\n * observe() rebuilds it.\n */\n unobserve(element: Element): void {\n if (this._observed !== element) return;\n this._teardownObserver();\n this._setObserving(false);\n }\n\n /** Stop all observation and release the observer. */\n disconnect(): void {\n this._teardownObserver();\n this._setObserving(false);\n }\n\n /** Clear the `visible` latch so a later intersection can set it again. */\n reset(): void {\n this._setVisible(false);\n }\n\n // --- Lifecycle (§3.5) ---\n\n /**\n * `observe()` (the IntersectionObserver-style command above) establishes\n * monitoring, so there is no separate idempotent monitoring entry point — only\n * teardown. `dispose()` invalidates any in-flight observer callback (`_gen++`)\n * and releases the observer. A later observe() revives it (the Shell calls this\n * from `disconnectedCallback`).\n */\n dispose(): void {\n this._gen++;\n this.disconnect();\n }\n\n // --- Internal ---\n\n private _teardownObserver(): void {\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n this._observed = null;\n // Invalidate the torn-down observer's generation: its callback can still fire\n // once asynchronously after disconnect(), and must be dropped (§3.4).\n this._gen++;\n }\n\n private _createObserver(options: IntersectOptions): IntersectionObserver | null {\n if (typeof IntersectionObserver === \"undefined\") return null;\n // Capture the generation live at creation. The callback closure below guards\n // against deliveries from this observer after it has been superseded or\n // disposed (a stale callback fired off layout after teardown).\n const gen = this._gen;\n try {\n return new IntersectionObserver(\n (entries) => this._onIntersect(gen, entries),\n {\n root: options.root ?? null,\n rootMargin: options.rootMargin ?? \"0px\",\n threshold: options.threshold ?? 0,\n },\n );\n } catch {\n // Invalid options (e.g. a malformed rootMargin) — surface nothing and leave\n // observing false, rather than letting the constructor throw escape.\n return null;\n }\n }\n\n private _onIntersect(gen: number, entries: IntersectionObserverEntry[]): void {\n // Stale-generation guard (§3.4): drop callbacks from an observer that was torn\n // down or disposed (e.g. a delivery that landed after disconnect/reconnect).\n if (gen !== this._gen) return;\n for (const entry of entries) {\n const normalized = this._normalizeEntry(entry);\n this._setEntry(normalized);\n // Latch on the first (and any) intersecting observation; never auto-clears.\n if (normalized.isIntersecting) {\n this._setVisible(true);\n }\n }\n }\n\n private _normalizeEntry(entry: IntersectionObserverEntry): WcsIntersectEntry {\n return {\n isIntersecting: entry.isIntersecting,\n intersectionRatio: entry.intersectionRatio,\n time: entry.time,\n boundingClientRect: this._normalizeRect(entry.boundingClientRect),\n intersectionRect: this._normalizeRect(entry.intersectionRect),\n rootBounds: entry.rootBounds ? this._normalizeRect(entry.rootBounds) : null,\n target: entry.target,\n };\n }\n\n private _normalizeRect(rect: DOMRectReadOnly): WcsIntersectRect {\n return {\n x: rect.x,\n y: rect.y,\n width: rect.width,\n height: rect.height,\n top: rect.top,\n right: rect.right,\n bottom: rect.bottom,\n left: rect.left,\n };\n }\n\n private _optionsEqual(a: IntersectOptions, b: IntersectOptions): boolean {\n if ((a.root ?? null) !== (b.root ?? null)) return false;\n if ((a.rootMargin ?? \"0px\") !== (b.rootMargin ?? \"0px\")) return false;\n return this._thresholdKey(a.threshold) === this._thresholdKey(b.threshold);\n }\n\n private _thresholdKey(threshold: number | number[] | undefined): string {\n if (threshold === undefined) return \"0\";\n return Array.isArray(threshold) ? threshold.join(\",\") : String(threshold);\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { IWcBindable, IntersectOptions, WcsIntersectEntry } from \"../types.js\";\nimport { IntersectionCore } from \"../core/IntersectionCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-intersect>` — declarative IntersectionObserver.\n *\n * The `target` attribute is the single knob that decides both *what* is observed\n * and how the element renders (it never injects a layout box unless asked):\n *\n * | `target` | observes | display | use case |\n * |-----------------|-----------------------|-------------|-------------------|\n * | omitted | first element child | `contents` | lazy-load wrapper |\n * | `\"#hero\"` / sel | the matched element | `none` | scrollspy (single)|\n * | `\"self\"` | the element itself | `block` | infinite-scroll |\n *\n * `display:contents` means wrapping a child injects no box of its own (so a\n * `<wcs-intersect><img></wcs-intersect>` does not disturb a flex/grid parent);\n * only the explicit `target=\"self\"` sentinel takes a box.\n */\nexport class WcsIntersect extends HTMLElement {\n // SSR (§4.4): the first observation is established in a microtask after connect\n // (timing-and-firing-contract §23) with no async probe, but the Shell still\n // exposes connectedCallbackPromise so the state binder can await it uniformly\n // across all IO nodes before snapshotting.\n static hasConnectedCallbackPromise = true;\n // Only attributes that change *what or how* we observe trigger a re-observe.\n // `once` is intentionally excluded: it is evaluated at intersection fire time\n // (in `_onChange`), so toggling it takes effect without re-observing — and a\n // re-observe on its change would be a pure no-op (same target, same options).\n // `manual` is also excluded: it is a connect-time policy (\"don't auto-observe\n // on connect\"), not a live switch that should start/stop an active observation.\n static observedAttributes = [\"target\", \"root\", \"root-margin\", \"threshold\"];\n\n static wcBindable: IWcBindable = {\n ...IntersectionCore.wcBindable,\n properties: [\n ...IntersectionCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-intersect:trigger-changed\", semantics: \"state\" },\n ],\n // Shell-level settable surface. Each input carries its mirrored `attribute`\n // hint; `trigger` has none — it is a momentary command-property, not a\n // declarative attribute. The observe / reobserve / unobserve / disconnect /\n // reset commands are inherited from the Core via the spread above.\n inputs: [\n { name: \"target\", attribute: \"target\" },\n { name: \"root\", attribute: \"root\" },\n { name: \"rootMargin\", attribute: \"root-margin\" },\n { name: \"threshold\", attribute: \"threshold\" },\n { name: \"once\", attribute: \"once\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。<wcs-sse>/<wcs-broadcast> と同型。\n // spread でも継承されるが、Core に command 追加時の追従漏れを防ぐため明示参照する。\n commands: IntersectionCore.wcBindable.commands,\n };\n\n private _core: IntersectionCore;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n // _scheduleObserve のマイクロタスクが待っている間 true\n private _observePending = false;\n\n constructor() {\n super();\n this._core = new IntersectionCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-intersect:visible-changed\": (d) => ({ visible: d === true }),\n \"wcs-intersect:observing-changed\": (d) => ({ observing: d === true }),\n \"wcs-intersect:change\": (d) => ({ intersecting: d.isIntersecting === true }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n // Input setters never let setAttribute stringify null / undefined (an\n // \"undefined\" target is a selector that matches nothing, which would tear the\n // observation down): `null` removes the attribute (the default), `undefined`\n // restores the attribute the element started with (wc-bindable producer\n // guidance P1; React 19 and a direct assignment deliver it, @wcstack/state\n // does not). A change of target / root / root-margin / threshold re-observes\n // through attributeChangedCallback as before.\n\n get target(): string {\n return this.getAttribute(\"target\") ?? \"\";\n }\n\n set target(value: string | null | undefined) {\n reflectAttribute(this, \"target\", value);\n }\n\n get root(): string {\n return this.getAttribute(\"root\") ?? \"\";\n }\n\n set root(value: string | null | undefined) {\n reflectAttribute(this, \"root\", value);\n }\n\n get rootMargin(): string {\n const attr = this.getAttribute(\"root-margin\");\n return attr === null || attr.trim() === \"\" ? \"0px\" : attr;\n }\n\n set rootMargin(value: string | null | undefined) {\n reflectAttribute(this, \"root-margin\", value);\n }\n\n get threshold(): string {\n return this.getAttribute(\"threshold\") ?? \"\";\n }\n\n set threshold(value: string | null | undefined) {\n reflectAttribute(this, \"threshold\", value);\n }\n\n get once(): boolean {\n return this.hasAttribute(\"once\");\n }\n\n set once(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"once\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"manual\", value);\n }\n\n // --- Core delegated getters ---\n\n get entry(): WcsIntersectEntry | null {\n return this._core.entry;\n }\n\n get intersecting(): boolean {\n return this._core.intersecting;\n }\n\n get ratio(): number {\n return this._core.ratio;\n }\n\n get visible(): boolean {\n return this._core.visible;\n }\n\n get observing(): boolean {\n return this._core.observing;\n }\n\n // --- Command property ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n // Momentary command-property: a false→true write re-runs observe(). Mirrors\n // the trigger flag on <wcs-geo> / <wcs-ws> / <wcs-sse>. Prefer the command-token\n // protocol (`command.observe: $command.start`) for state-driven observation;\n // this exists mainly for simple boolean bindings.\n const v = !!value; // normalize truthy state-bindings, like <wcs-sse>'s setter\n if (v) {\n this._trigger = true;\n // try/finally mirrors <wcs-sse>'s set trigger: observe() is never-throw\n // today, but should a synchronous throw path ever appear, the finally still\n // auto-resets _trigger (no stuck-true latch) and emits the completion notice.\n try {\n this.observe();\n } finally {\n this._trigger = false;\n // Always auto-reset to false after the observe() attempt — this is the\n // *momentary acknowledgement* that the trigger was consumed, NOT a signal\n // that observation succeeded (whether the target resolved is reflected by\n // `observing`, not by this event). Firing unconditionally keeps the bound\n // state's trigger flag from sticking at true regardless of resolution.\n // Read `observing` if you need the actual outcome.\n this.dispatchEvent(new CustomEvent(\"wcs-intersect:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n }\n\n // --- Commands ---\n\n /** Re-resolve the target/root from the DOM and (re)start observing. */\n observe(): void {\n const { element, display } = this._resolveTarget();\n // `display` is derived from the `target` *mode* (self/selector/child), not from\n // whether the selector currently matches — so it is applied unconditionally,\n // before the resolution check. A `target=\"#x\"` whose node is momentarily absent\n // still renders `display:none` (it is a selector pointer, never a box).\n this.style.display = display;\n if (!element) {\n // The target is no longer resolvable (e.g. a `target` selector whose node\n // was removed from the DOM). Tear down any stale observation so `observing`\n // does not keep reporting true against a node that is gone.\n this._core.disconnect();\n return;\n }\n this._core.observe(element, this._options());\n }\n\n /**\n * Force a fresh observation: re-resolve target/root from the DOM and re-observe\n * even when nothing changed. Unlike observe() (idempotent for an unchanged\n * target+options), this rebuilds the observer so a new initial callback fires for\n * the current visibility — the way to re-arm an edge-driven consumer after the\n * layout shifted without a visibility transition (e.g. infinite scroll appended a\n * short page that left this sentinel in view). Resolution/teardown rules match\n * observe(): an unresolvable target tears down any stale observation.\n */\n reobserve(): void {\n const { element, display } = this._resolveTarget();\n this.style.display = display;\n if (!element) {\n this._core.disconnect();\n return;\n }\n this._core.reobserve(element, this._options());\n }\n\n // unobserve / disconnect は、予約中の自動 observe(_scheduleObserve)も取り消す。\n // 同じタスクで接続(や属性の変化)の後に呼ばれたとき、以前の同期の observe を止めたのと\n // 同じく何も監視しない(timing-and-firing-contract §23)。observe / reobserve / trigger は\n // 取り消さない — 予約の observe は同じ target・options なら no-op(冪等)。\n unobserve(): void {\n this._observePending = false;\n // Single-target Shell: \"stop observing my target\" is exactly the Core's\n // teardown. Delegate to the Core's tracked state rather than re-resolving the\n // selector, so a target that has since left the DOM can still be stopped\n // (re-resolving would yield null and silently leave the observer running).\n this._core.disconnect();\n }\n\n disconnect(): void {\n this._observePending = false;\n this._core.disconnect();\n }\n\n reset(): void {\n this._core.reset();\n }\n\n // --- Internal ---\n\n private _resolveTarget(): { element: Element | null; display: string } {\n const target = this.target;\n if (target === \"self\") {\n // Explicit sentinel: observe the element itself as a (typically zero-height)\n // marker, which requires a layout box.\n return { element: this, display: \"block\" };\n }\n if (target !== \"\") {\n // Selector pointer: observe a referenced element in place, staying invisible.\n const scope = this.getRootNode() as Document | ShadowRoot;\n // A user-authored selector can be syntactically invalid (e.g. `#`, `:::`,\n // `[data-*`), which makes querySelector throw a SyntaxError. Swallow it and\n // treat the target as unresolvable — the same \"nothing to observe\" path as a\n // selector matching no element — so a bad attribute never lets the throw\n // escape observe() → connectedCallback / attributeChangedCallback (never-throw).\n return { element: this._safeQuery(scope, target), display: \"none\" };\n }\n // Omitted: observe the first element child without injecting a box of our own.\n const child = this.firstElementChild;\n if (child) {\n return { element: child, display: \"contents\" };\n }\n // No child to wrap (e.g. used as an empty marker) — fall back to self.\n return { element: this, display: \"block\" };\n }\n\n private _resolveRoot(): Element | null {\n const root = this.root;\n if (root === \"\") return null;\n const scope = this.getRootNode() as Document | ShadowRoot;\n // Same never-throw guard as the target selector: an invalid `root` selector\n // falls back to a null root (the viewport) rather than throwing out of observe().\n return this._safeQuery(scope, root);\n }\n\n // Wrap querySelector so a syntactically invalid user-authored selector resolves\n // to null (unresolvable) instead of letting the SyntaxError escape — keeping the\n // sensor never-throw, mirroring worker/src/autoTrigger.ts's resolveText guard.\n private _safeQuery(scope: Document | ShadowRoot, selector: string): Element | null {\n try {\n return scope.querySelector(selector);\n } catch {\n return null;\n }\n }\n\n private _parseThreshold(): number | number[] {\n const raw = this.threshold.trim();\n if (raw === \"\") return 0;\n // Strict parse via Number() (unlike parseFloat, \"0.5px\" -> NaN, not 0.5); drop\n // any non-finite or out-of-range [0,1] value, matching the README note.\n // Drop empty slots first (\"0,,1\" / \"1,\") — Number(\"\") is 0, which would\n // otherwise smuggle a spurious 0 threshold past the finite/range filter.\n const nums = raw\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s !== \"\")\n .map((s) => Number(s))\n .filter((n) => Number.isFinite(n) && n >= 0 && n <= 1);\n if (nums.length === 0) return 0;\n return nums.length === 1 ? nums[0] : nums;\n }\n\n private _options(): IntersectOptions {\n return {\n root: this._resolveRoot(),\n rootMargin: this.rootMargin,\n threshold: this._parseThreshold(),\n };\n }\n\n private _onChange = (event: Event): void => {\n // `wcs-intersect:change` bubbles, so a nested `<wcs-intersect>` descendant's\n // change would otherwise reach this (ancestor) listener and let a *child's*\n // intersection tear down *our* observer. Only act on our own Core's event.\n // (This also avoids reading `.detail` off a foreign event shape.)\n if (event.target !== this) return;\n // `once`: tear down after the first intersecting observation (lazy-load idiom).\n // Gated at fire time so toggling the `once` attribute takes effect live.\n if (this.once && (event as CustomEvent).detail.isIntersecting) {\n this._core.disconnect();\n }\n };\n\n // --- Lifecycle ---\n\n // 自動 observe の判断はマイクロタスクで、そのときの manual / target / root /\n // root-margin / threshold で 1 回だけ行う(timing-and-firing-contract §23)。router は\n // 遷移で同じノードを入れ直し、新しいルートの params から state が入力を書くのは\n // マイクロタスク — その場で observe すると、前の target で observer を張り、前の\n // manual をラッチしていた(docs/seam-apps.md、shift-desk)。接続と属性の変化は\n // ここへまとまり、observer は 1 回だけ作り直す。判断の前に外れた要素は何もしない。\n private _scheduleObserve(): void {\n if (this._observePending) return;\n this._observePending = true;\n queueMicrotask(() => {\n // unobserve / disconnect が予約を取り消していれば何もしない(同じタスクで予約し直して\n // いれば、このマイクロタスクがその判断を受け持ち、後の分は何もしない)\n if (!this._observePending) return;\n this._observePending = false;\n if (this.isConnected && !this.manual) {\n this.observe();\n }\n });\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.addEventListener(\"wcs-intersect:change\", this._onChange);\n this._scheduleObserve();\n // SSR (§4.4): readiness is immediate (the observation itself is decided in the\n // microtask above, which runs before any await on this promise resumes), but\n // expose the Core's ready promise as connectedCallbackPromise so the state\n // binder can await it uniformly. `manual` defers observation but readiness is\n // still immediate.\n this._connectedCallbackPromise = this._core.ready;\n }\n\n disconnectedCallback(): void {\n this.removeEventListener(\"wcs-intersect:change\", this._onChange);\n // dispose() tears down the observer AND bumps the Core's generation so any\n // IntersectionObserver callback still in flight is dropped (§3.4 / §4.1).\n this._core.dispose();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n // Defensive same-value guard. Per spec attributeChangedCallback only fires on\n // an actual value change, so this is effectively a dead branch today — but\n // setAttribute() with an unchanged value (and some test/tooling paths) can\n // still invoke it, and re-observing on an unchanged attribute would be a\n // wasted observer rebuild. Kept intentionally; do not remove.\n if (oldValue === newValue) return;\n // Only react once connected and in automatic mode. The re-observe goes through\n // the same microtask as the connect-time one (_scheduleObserve), so the\n // autoloader upgrade case (attributeChangedCallback + connectedCallback) and\n // several inputs written in one task rebuild the observer once.\n if (!this.isConnected || this.manual) return;\n this._scheduleObserve();\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the\n * page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined\n * by another copy of the package — not its class, not a subclass of it, not the same version — warns\n * `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry\n * `\"<package>@<version>\"` under `Symbol.for(\"wcstack.package\")`; a class without it is named\n * \"another copy of <package> that does not name its version\" (an older copy, or one loaded through\n * an entry that does not stamp).\n */\n\n/** The static a class defined through this helper carries: `\"@wcstack/fetch@<version>\"`. */\nexport const PACKAGE_STAMP: unique symbol = Symbol.for(\"wcstack.package\");\n\ntype Stamped = { [PACKAGE_STAMP]?: string };\n\n/** The registries this copy warned about: one warning per package per registry. */\nconst warned = new WeakSet<CustomElementRegistry>();\n\n/**\n * Marks `cls` as defined by `pkg` (`\"@wcstack/fetch@<version>\"`). A subclass inherits the mark, and\n * `defineProperty` writes it even where a parent's mark is read-only.\n */\nexport function stampPackage(cls: CustomElementConstructor, pkg: string): void {\n Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });\n}\n\n/**\n * Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`\n * is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and\n * carries another version or none. Once per registry.\n */\nexport function warnIfAnotherCopy(\n registry: CustomElementRegistry,\n tag: string,\n existing: CustomElementConstructor,\n own: CustomElementConstructor | undefined,\n pkg: string,\n): void {\n if (own !== undefined && (existing === own || existing.prototype instanceof own)) return;\n const theirs = (existing as Stamped)[PACKAGE_STAMP];\n if (theirs === pkg || warned.has(registry)) return;\n warned.add(registry);\n const name = pkg.slice(0, pkg.lastIndexOf(\"@\"));\n console.warn(\n `[${name}] [wcs/package-twice] <${tag}> is already defined by ` +\n `${theirs ?? `another copy of ${name} that does not name its version`}; ` +\n `this copy, ${pkg}, does nothing. Load each package once.`,\n );\n}\n\n/**\n * Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class\n * with `pkg` (`\"@wcstack/fetch@<version>\"`). A tag another copy of the package defined first is left\n * as it is, with the warning above.\n */\nexport function defineElements(\n registry: CustomElementRegistry,\n pkg: string,\n definitions: readonly (readonly [tag: string, cls: CustomElementConstructor])[],\n): void {\n for (const [tag, cls] of definitions) {\n const existing = registry.get(tag);\n if (existing === undefined) {\n stampPackage(cls, pkg);\n registry.define(tag, cls);\n } else {\n warnIfAnotherCopy(registry, tag, existing, cls, pkg);\n }\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\nimport { WcsIntersect } from \"./components/Intersect.js\";\nimport { config } from \"./config.js\";\nimport { defineElements } from \"./protocol/defineElement.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n defineElements(registry, `${pkg.name}@${pkg.version}`, [\n [config.tagNames.intersect, WcsIntersect],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapIntersection(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":["config","tagNames","intersect","IntersectionCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","isIntersecting","intersectionRatio","commands","_target","_observer","_observed","_options","_entry","_visible","_observing","_gen","_ready","Promise","resolve","constructor","target","super","this","ready","entry","intersecting","ratio","visible","observing","_setEntry","dispatchEvent","CustomEvent","bubbles","_setVisible","_setObserving","observe","element","options","_optionsEqual","_teardownObserver","observer","_createObserver","reobserve","unobserve","disconnect","reset","dispose","IntersectionObserver","gen","entries","_onIntersect","root","rootMargin","threshold","normalized","_normalizeEntry","time","boundingClientRect","_normalizeRect","intersectionRect","rootBounds","rect","x","y","width","height","top","right","bottom","left","a","b","_thresholdKey","undefined","Array","isArray","join","String","hasAccessorOnPrototype","proto","Object","getPrototypeOf","descriptor","getOwnPropertyDescriptor","get","set","toldObjectAttribute","WeakSet","warnObjectAttribute","value","has","add","tag","localName","console","warn","initialAttributes","WeakMap","initialAttribute","el","byName","Map","getAttribute","writeAttribute","removeAttribute","setAttribute","reflectAttribute","initial","reflectBooleanAttribute","WcsIntersect","HTMLElement","wcBindable","inputs","attribute","_core","_trigger","_connectedCallbackPromise","_internals","_observePending","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","delete","map","toStates","addEventListener","debug","hasAttribute","on","toggleAttribute","connectedCallbackPromise","attr","trim","once","manual","trigger","display","_resolveTarget","style","scope","getRootNode","_safeQuery","child","firstElementChild","_resolveRoot","selector","querySelector","_parseThreshold","raw","nums","split","s","filter","Number","n","isFinite","length","_onChange","_scheduleObserve","queueMicrotask","isConnected","connectedCallback","declaration","input","call","toLowerCase","startsWith","prototype","hasOwnProperty","record","upgradeProperties","disconnectedCallback","removeEventListener","attributeChangedCallback","_name","oldValue","newValue","PACKAGE_STAMP","Symbol","for","warned","stampPackage","cls","pkg","defineProperty","configurable","warnIfAnotherCopy","registry","existing","own","theirs","slice","lastIndexOf","registerComponents","customElements","definitions","define","defineElements"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,UAAW,2DC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EAAKoG,EAAUN,EAAKC,EAEpD,CACF,CChEEc,CAAeV,EAAU,GAAGJ,KAAYA,IAAe,CACrD,CAACrM,EAAOC,SAASC,UAAWqH,IAEhC,CCVM,IAA8DkF,EAIlEM,EAAmBN"}
|
|
1
|
+
{"version":3,"file":"auto.min.js","sources":["../../src/config.ts","../../src/core/IntersectionCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Intersect.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapIntersection.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n intersect: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n intersect: \"wcs-intersect\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapIntersection` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/intersection] bootstrapIntersection: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","import { IWcBindable, IntersectOptions, WcsIntersectEntry, WcsIntersectRect } from \"../types.js\";\n\n/**\n * Headless visibility primitive. A thin, framework-agnostic wrapper around the\n * IntersectionObserver API exposed through the wc-bindable protocol.\n *\n * Unlike the other @wcstack sensors (geolocation / timer / websocket), the thing\n * being observed is a *DOM element* — so `observe()` takes the target node. The\n * Core stays DOM-resolution-agnostic: it observes whatever element it is handed\n * (the Shell resolves `target` / `root` selectors before calling). It is a\n * read-only producer — element/layout → state only, with no element-bound path.\n *\n * Every observer callback is published via the single `wcs-intersect:change`\n * event; `intersecting` / `ratio` are read from it through getters (mirroring how\n * GeolocationCore exposes latitude/longitude from one `wcs-geo:position` event),\n * so an observer that binds any of them is notified on every change.\n *\n * `visible` is a latch: it flips to `true` the first time the target intersects\n * and stays `true` until `reset()` — ideal for one-way lazy-load bindings\n * (`src@visible`). `observing` reflects whether an observation is currently\n * active (like TimerCore's `running`).\n *\n * Single-target by design: the Shell observes exactly one element, so the state\n * reflects that element. Multi-target observation is intentionally out of scope.\n */\nexport class IntersectionCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"entry\", event: \"wcs-intersect:change\", semantics: \"state\" },\n { name: \"intersecting\", event: \"wcs-intersect:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.isIntersecting },\n { name: \"ratio\", event: \"wcs-intersect:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.intersectionRatio },\n { name: \"visible\", event: \"wcs-intersect:visible-changed\", semantics: \"state\" },\n { name: \"observing\", event: \"wcs-intersect:observing-changed\", semantics: \"state\" },\n ],\n commands: [\n { name: \"observe\" },\n { name: \"reobserve\" },\n { name: \"unobserve\" },\n { name: \"disconnect\" },\n { name: \"reset\" },\n ],\n };\n\n private _target: EventTarget;\n\n // The live observer and the single element it observes. Options are kept so a\n // repeated observe() with identical options is a no-op (avoids the create→\n // observe→disconnect churn an autoloader upgrade can otherwise cause).\n private _observer: IntersectionObserver | null = null;\n private _observed: Element | null = null;\n private _options: IntersectOptions = {};\n\n private _entry: WcsIntersectEntry | null = null;\n private _visible: boolean = false;\n private _observing: boolean = false;\n\n // Generation guard (§3.4): bumped on dispose() and on each observe()/reobserve()\n // teardown+rebuild. IntersectionObserver delivers its callback asynchronously off\n // layout, so a callback can fire after the element is disposed or after a rapid\n // disconnect→reconnect rebuilt the observer. Each observer captures the gen live at\n // creation; a callback from a superseded/torn-down observer has a stale gen and\n // MUST NOT write state to a torn-down element. A boolean flag is insufficient\n // (dispose→observe would flip it back and let stale work slip through).\n private _gen = 0;\n\n // SSR (§3.8): IntersectionObserver setup is synchronous (no async probe to await),\n // so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n /** Resolves immediately — there is no asynchronous probe to await (§3.8). */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get entry(): WcsIntersectEntry | null {\n return this._entry;\n }\n\n get intersecting(): boolean {\n return this._entry ? this._entry.isIntersecting : false;\n }\n\n get ratio(): number {\n return this._entry ? this._entry.intersectionRatio : 0;\n }\n\n get visible(): boolean {\n return this._visible;\n }\n\n get observing(): boolean {\n return this._observing;\n }\n\n // --- State setters with event dispatch ---\n\n private _setEntry(entry: WcsIntersectEntry): void {\n // No same-value guard: `change` carries event semantics (every callback is a\n // distinct observation) and `intersecting` / `ratio` are derived getters that\n // must re-fire on each entry, mirroring GeolocationCore's `position`.\n this._entry = entry;\n this._target.dispatchEvent(new CustomEvent(\"wcs-intersect:change\", {\n detail: entry,\n bubbles: true,\n }));\n }\n\n private _setVisible(visible: boolean): void {\n if (this._visible === visible) return;\n this._visible = visible;\n this._target.dispatchEvent(new CustomEvent(\"wcs-intersect:visible-changed\", {\n detail: visible,\n bubbles: true,\n }));\n }\n\n private _setObserving(observing: boolean): void {\n if (this._observing === observing) return;\n this._observing = observing;\n this._target.dispatchEvent(new CustomEvent(\"wcs-intersect:observing-changed\", {\n detail: observing,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing `element`. Idempotent while already observing the same\n * element with the same options. Changing the element or options tears down the\n * current observer and builds a new one (IntersectionObserver options are fixed\n * at construction, so reconfiguring requires a fresh observer).\n *\n * If IntersectionObserver is unavailable (SSR) or the options are invalid (e.g.\n * a malformed `rootMargin`, which the constructor rejects), this is a silent\n * no-op — `observing` stays false, consistent with the never-throw design of\n * the other @wcstack sensors.\n */\n observe(element: Element, options: IntersectOptions = {}): Promise<void> {\n if (this._observer && this._observed === element && this._optionsEqual(this._options, options)) {\n return this._ready;\n }\n this._teardownObserver();\n const observer = this._createObserver(options);\n if (!observer) {\n // Creation failed (unsupported environment or invalid options) *after* we\n // tore down any previous observer. If we were already observing, the\n // observation is now gone, so reflect that — otherwise `observing` would\n // keep reporting true with no live observer behind it (e.g. re-observing an\n // active target with a newly-invalid rootMargin).\n this._setObserving(false);\n return this._ready;\n }\n this._observer = observer;\n this._observed = element;\n this._options = options;\n observer.observe(element);\n this._setObserving(true);\n // SSR (§3.5): observe() returns the readiness promise. Observation establishment\n // is synchronous, so this resolves immediately.\n return this._ready;\n }\n\n /**\n * Force a fresh observation of `element`, even when it matches the currently\n * observed target+options. Unlike observe() — which is idempotent and\n * early-returns for an unchanged target+options *without* re-delivering a\n * callback — this always tears the observer down and rebuilds it, so a new\n * IntersectionObserver delivers an initial callback for the element's CURRENT\n * visibility.\n *\n * This is the way to re-arm an edge-driven consumer (e.g. infinite scroll) after\n * the layout changed without a visibility *transition*: IntersectionObserver only\n * fires on a change, so appending a short page that leaves the sentinel visible\n * yields no new callback — a bare observe() can't help (idempotent), but a\n * reobserve() re-reads the current state. Same never-throw guarantees as\n * observe(); `observing` stays true across a successful re-arm (no false blip).\n */\n reobserve(element: Element, options: IntersectOptions = {}): void {\n this._teardownObserver();\n this.observe(element, options);\n }\n\n /**\n * Stop observing `element`. A no-op if it is not the currently observed\n * element. The observer instance is torn down (single-target Core), so a later\n * observe() rebuilds it.\n */\n unobserve(element: Element): void {\n if (this._observed !== element) return;\n this._teardownObserver();\n this._setObserving(false);\n }\n\n /** Stop all observation and release the observer. */\n disconnect(): void {\n this._teardownObserver();\n this._setObserving(false);\n }\n\n /** Clear the `visible` latch so a later intersection can set it again. */\n reset(): void {\n this._setVisible(false);\n }\n\n // --- Lifecycle (§3.5) ---\n\n /**\n * `observe()` (the IntersectionObserver-style command above) establishes\n * monitoring, so there is no separate idempotent monitoring entry point — only\n * teardown. `dispose()` invalidates any in-flight observer callback (`_gen++`)\n * and releases the observer. A later observe() revives it (the Shell calls this\n * from `disconnectedCallback`).\n */\n dispose(): void {\n this._gen++;\n this.disconnect();\n }\n\n // --- Internal ---\n\n private _teardownObserver(): void {\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n this._observed = null;\n // Invalidate the torn-down observer's generation: its callback can still fire\n // once asynchronously after disconnect(), and must be dropped (§3.4).\n this._gen++;\n }\n\n private _createObserver(options: IntersectOptions): IntersectionObserver | null {\n if (typeof IntersectionObserver === \"undefined\") return null;\n // Capture the generation live at creation. The callback closure below guards\n // against deliveries from this observer after it has been superseded or\n // disposed (a stale callback fired off layout after teardown).\n const gen = this._gen;\n try {\n return new IntersectionObserver(\n (entries) => this._onIntersect(gen, entries),\n {\n root: options.root ?? null,\n rootMargin: options.rootMargin ?? \"0px\",\n threshold: options.threshold ?? 0,\n },\n );\n } catch {\n // Invalid options (e.g. a malformed rootMargin) — surface nothing and leave\n // observing false, rather than letting the constructor throw escape.\n return null;\n }\n }\n\n private _onIntersect(gen: number, entries: IntersectionObserverEntry[]): void {\n // Stale-generation guard (§3.4): drop callbacks from an observer that was torn\n // down or disposed (e.g. a delivery that landed after disconnect/reconnect).\n if (gen !== this._gen) return;\n for (const entry of entries) {\n const normalized = this._normalizeEntry(entry);\n this._setEntry(normalized);\n // Latch on the first (and any) intersecting observation; never auto-clears.\n if (normalized.isIntersecting) {\n this._setVisible(true);\n }\n }\n }\n\n private _normalizeEntry(entry: IntersectionObserverEntry): WcsIntersectEntry {\n return {\n isIntersecting: entry.isIntersecting,\n intersectionRatio: entry.intersectionRatio,\n time: entry.time,\n boundingClientRect: this._normalizeRect(entry.boundingClientRect),\n intersectionRect: this._normalizeRect(entry.intersectionRect),\n rootBounds: entry.rootBounds ? this._normalizeRect(entry.rootBounds) : null,\n target: entry.target,\n };\n }\n\n private _normalizeRect(rect: DOMRectReadOnly): WcsIntersectRect {\n return {\n x: rect.x,\n y: rect.y,\n width: rect.width,\n height: rect.height,\n top: rect.top,\n right: rect.right,\n bottom: rect.bottom,\n left: rect.left,\n };\n }\n\n private _optionsEqual(a: IntersectOptions, b: IntersectOptions): boolean {\n if ((a.root ?? null) !== (b.root ?? null)) return false;\n if ((a.rootMargin ?? \"0px\") !== (b.rootMargin ?? \"0px\")) return false;\n return this._thresholdKey(a.threshold) === this._thresholdKey(b.threshold);\n }\n\n private _thresholdKey(threshold: number | number[] | undefined): string {\n if (threshold === undefined) return \"0\";\n return Array.isArray(threshold) ? threshold.join(\",\") : String(threshold);\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { IWcBindable, IntersectOptions, WcsIntersectEntry } from \"../types.js\";\nimport { IntersectionCore } from \"../core/IntersectionCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-intersect>` — declarative IntersectionObserver.\n *\n * The `target` attribute is the single knob that decides both *what* is observed\n * and how the element renders (it never injects a layout box unless asked):\n *\n * | `target` | observes | display | use case |\n * |-----------------|-----------------------|-------------|-------------------|\n * | omitted | first element child | `contents` | lazy-load wrapper |\n * | `\"#hero\"` / sel | the matched element | `none` | scrollspy (single)|\n * | `\"self\"` | the element itself | `block` | infinite-scroll |\n *\n * `display:contents` means wrapping a child injects no box of its own (so a\n * `<wcs-intersect><img></wcs-intersect>` does not disturb a flex/grid parent);\n * only the explicit `target=\"self\"` sentinel takes a box.\n */\nexport class WcsIntersect extends HTMLElement {\n // SSR (§4.4): the first observation is established in a microtask after connect\n // (timing-and-firing-contract §23) with no async probe, but the Shell still\n // exposes connectedCallbackPromise so the state binder can await it uniformly\n // across all IO nodes before snapshotting.\n static hasConnectedCallbackPromise = true;\n // Only attributes that change *what or how* we observe trigger a re-observe.\n // `once` is intentionally excluded: it is evaluated at intersection fire time\n // (in `_onChange`), so toggling it takes effect without re-observing — and a\n // re-observe on its change would be a pure no-op (same target, same options).\n // `manual` is also excluded: it is a connect-time policy (\"don't auto-observe\n // on connect\"), not a live switch that should start/stop an active observation.\n static observedAttributes = [\"target\", \"root\", \"root-margin\", \"threshold\"];\n\n static wcBindable: IWcBindable = {\n ...IntersectionCore.wcBindable,\n properties: [\n ...IntersectionCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-intersect:trigger-changed\", semantics: \"state\" },\n ],\n // Shell-level settable surface. Each input carries its mirrored `attribute`\n // hint; `trigger` has none — it is a momentary command-property, not a\n // declarative attribute. The observe / reobserve / unobserve / disconnect /\n // reset commands are inherited from the Core via the spread above.\n inputs: [\n { name: \"target\", attribute: \"target\" },\n { name: \"root\", attribute: \"root\" },\n { name: \"rootMargin\", attribute: \"root-margin\" },\n { name: \"threshold\", attribute: \"threshold\" },\n { name: \"once\", attribute: \"once\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。<wcs-sse>/<wcs-broadcast> と同型。\n // spread でも継承されるが、Core に command 追加時の追従漏れを防ぐため明示参照する。\n commands: IntersectionCore.wcBindable.commands,\n };\n\n private _core: IntersectionCore;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n // _scheduleObserve のマイクロタスクが待っている間 true\n private _observePending = false;\n // 最後に警告した root と root-margin(値ごとに 1 回)\n private _warnedRoot: string | null = null;\n private _warnedMargin: string | null = null;\n\n constructor() {\n super();\n this._core = new IntersectionCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-intersect:visible-changed\": (d) => ({ visible: d === true }),\n \"wcs-intersect:observing-changed\": (d) => ({ observing: d === true }),\n \"wcs-intersect:change\": (d) => ({ intersecting: d.isIntersecting === true }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n // Input setters never let setAttribute stringify null / undefined (an\n // \"undefined\" target is a selector that matches nothing, which would tear the\n // observation down): `null` removes the attribute (the default), `undefined`\n // restores the attribute the element started with (wc-bindable producer\n // guidance P1; React 19 and a direct assignment deliver it, @wcstack/state\n // does not). A change of target / root / root-margin / threshold re-observes\n // through attributeChangedCallback as before.\n\n get target(): string {\n return this.getAttribute(\"target\") ?? \"\";\n }\n\n set target(value: string | null | undefined) {\n reflectAttribute(this, \"target\", value);\n }\n\n get root(): string {\n return this.getAttribute(\"root\") ?? \"\";\n }\n\n set root(value: string | null | undefined) {\n reflectAttribute(this, \"root\", value);\n }\n\n get rootMargin(): string {\n const attr = this.getAttribute(\"root-margin\");\n return attr === null || attr.trim() === \"\" ? \"0px\" : attr;\n }\n\n set rootMargin(value: string | null | undefined) {\n reflectAttribute(this, \"root-margin\", value);\n }\n\n get threshold(): string {\n return this.getAttribute(\"threshold\") ?? \"\";\n }\n\n set threshold(value: string | null | undefined) {\n reflectAttribute(this, \"threshold\", value);\n }\n\n get once(): boolean {\n return this.hasAttribute(\"once\");\n }\n\n set once(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"once\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"manual\", value);\n }\n\n // --- Core delegated getters ---\n\n get entry(): WcsIntersectEntry | null {\n return this._core.entry;\n }\n\n get intersecting(): boolean {\n return this._core.intersecting;\n }\n\n get ratio(): number {\n return this._core.ratio;\n }\n\n get visible(): boolean {\n return this._core.visible;\n }\n\n get observing(): boolean {\n return this._core.observing;\n }\n\n // --- Command property ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n // Momentary command-property: a false→true write re-runs observe(). Mirrors\n // the trigger flag on <wcs-geo> / <wcs-ws> / <wcs-sse>. Prefer the command-token\n // protocol (`command.observe: $command.start`) for state-driven observation;\n // this exists mainly for simple boolean bindings.\n const v = !!value; // normalize truthy state-bindings, like <wcs-sse>'s setter\n if (v) {\n this._trigger = true;\n // try/finally mirrors <wcs-sse>'s set trigger: observe() is never-throw\n // today, but should a synchronous throw path ever appear, the finally still\n // auto-resets _trigger (no stuck-true latch) and emits the completion notice.\n try {\n this.observe();\n } finally {\n this._trigger = false;\n // Always auto-reset to false after the observe() attempt — this is the\n // *momentary acknowledgement* that the trigger was consumed, NOT a signal\n // that observation succeeded (whether the target resolved is reflected by\n // `observing`, not by this event). Firing unconditionally keeps the bound\n // state's trigger flag from sticking at true regardless of resolution.\n // Read `observing` if you need the actual outcome.\n this.dispatchEvent(new CustomEvent(\"wcs-intersect:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n }\n\n // --- Commands ---\n\n /** Re-resolve the target/root from the DOM and (re)start observing. */\n observe(): void {\n const { element, display } = this._resolveTarget();\n // `display` is derived from the `target` *mode* (self/selector/child), not from\n // whether the selector currently matches — so it is applied unconditionally,\n // before the resolution check. A `target=\"#x\"` whose node is momentarily absent\n // still renders `display:none` (it is a selector pointer, never a box).\n this.style.display = display;\n if (!element) {\n // The target is no longer resolvable (e.g. a `target` selector whose node\n // was removed from the DOM). Tear down any stale observation so `observing`\n // does not keep reporting true against a node that is gone.\n this._core.disconnect();\n return;\n }\n this._core.observe(element, this._options());\n this._warnRefused();\n }\n\n /**\n * Force a fresh observation: re-resolve target/root from the DOM and re-observe\n * even when nothing changed. Unlike observe() (idempotent for an unchanged\n * target+options), this rebuilds the observer so a new initial callback fires for\n * the current visibility — the way to re-arm an edge-driven consumer after the\n * layout shifted without a visibility transition (e.g. infinite scroll appended a\n * short page that left this sentinel in view). Resolution/teardown rules match\n * observe(): an unresolvable target tears down any stale observation.\n */\n reobserve(): void {\n const { element, display } = this._resolveTarget();\n this.style.display = display;\n if (!element) {\n this._core.disconnect();\n return;\n }\n this._core.reobserve(element, this._options());\n this._warnRefused();\n }\n\n /**\n * The observation did not start although there is something to observe: the browser refused the options, and\n * with the threshold cleaned (_parseThreshold) only the margin is left — a length with no unit (`\"200\"`,\n * `\"0 0 900 0\"`). `observing` stays false as before (never-throw); what was silent is said once per value\n * (docs/mistake-catalogue.md, \"root-margin-unit\").\n */\n private _warnRefused(): void {\n if (this._core.observing || typeof IntersectionObserver === \"undefined\") return;\n const margin = this.rootMargin;\n if (this._warnedMargin === margin) return;\n let reason = \"\";\n try {\n // (Function.prototype: a callback that does nothing — this observer observes nothing)\n new IntersectionObserver(Function.prototype as IntersectionObserverCallback, { rootMargin: margin }).disconnect();\n return;\n } catch (error) {\n reason = (error as Error).message;\n }\n this._warnedMargin = margin;\n console.warn(\n `[@wcstack/intersection] [wcs/root-margin-unit] <${this.localName} root-margin=\"${margin}\"> is not a margin the ` +\n `browser takes (${reason}): write each length with px or %, as \"200px 0px\". Nothing is observed ` +\n `(observing stays false).`,\n );\n }\n\n // unobserve / disconnect は、予約中の自動 observe(_scheduleObserve)も取り消す。\n // 同じタスクで接続(や属性の変化)の後に呼ばれたとき、以前の同期の observe を止めたのと\n // 同じく何も監視しない(timing-and-firing-contract §23)。observe / reobserve / trigger は\n // 取り消さない — 予約の observe は同じ target・options なら no-op(冪等)。\n unobserve(): void {\n this._observePending = false;\n // Single-target Shell: \"stop observing my target\" is exactly the Core's\n // teardown. Delegate to the Core's tracked state rather than re-resolving the\n // selector, so a target that has since left the DOM can still be stopped\n // (re-resolving would yield null and silently leave the observer running).\n this._core.disconnect();\n }\n\n disconnect(): void {\n this._observePending = false;\n this._core.disconnect();\n }\n\n reset(): void {\n this._core.reset();\n }\n\n // --- Internal ---\n\n private _resolveTarget(): { element: Element | null; display: string } {\n const target = this.target;\n if (target === \"self\") {\n // Explicit sentinel: observe the element itself as a (typically zero-height)\n // marker, which requires a layout box.\n return { element: this, display: \"block\" };\n }\n if (target !== \"\") {\n // Selector pointer: observe a referenced element in place, staying invisible.\n const scope = this.getRootNode() as Document | ShadowRoot;\n // A user-authored selector can be syntactically invalid (e.g. `#`, `:::`,\n // `[data-*`), which makes querySelector throw a SyntaxError. Swallow it and\n // treat the target as unresolvable — the same \"nothing to observe\" path as a\n // selector matching no element — so a bad attribute never lets the throw\n // escape observe() → connectedCallback / attributeChangedCallback (never-throw).\n return { element: this._safeQuery(scope, target), display: \"none\" };\n }\n // Omitted: observe the first element child without injecting a box of our own.\n const child = this.firstElementChild;\n if (child) {\n return { element: child, display: \"contents\" };\n }\n // No child to wrap (e.g. used as an empty marker) — fall back to self.\n return { element: this, display: \"block\" };\n }\n\n private _resolveRoot(): Element | null {\n const root = this.root;\n if (root === \"\") return null;\n const scope = this.getRootNode() as Document | ShadowRoot;\n // Same never-throw guard as the target selector: an invalid `root` selector\n // falls back to a null root (the viewport) rather than throwing out of observe().\n // A value that matches nothing as a selector is tried as an id — the way\n // `<wcs-infinite-scroll root>` spells it (docs/seam-apps.md, town-archive).\n const found = this._safeQuery(scope, root) ?? scope.getElementById?.(root) ?? null;\n // A root given and not found was the viewport without a word: the margin was then\n // measured against the wrong box. Said once per value.\n if (!found && this._warnedRoot !== root) {\n this._warnedRoot = root;\n console.warn(\n `[@wcstack/intersection] [wcs/intersect-root] <${this.localName} root=\"${root}\">: no element matches that ` +\n `selector, and none has it as its id, so the viewport is the root.`,\n );\n }\n return found;\n }\n\n // Wrap querySelector so a syntactically invalid user-authored selector resolves\n // to null (unresolvable) instead of letting the SyntaxError escape — keeping the\n // sensor never-throw, mirroring worker/src/autoTrigger.ts's resolveText guard.\n private _safeQuery(scope: Document | ShadowRoot, selector: string): Element | null {\n try {\n return scope.querySelector(selector);\n } catch {\n return null;\n }\n }\n\n private _parseThreshold(): number | number[] {\n const raw = this.threshold.trim();\n if (raw === \"\") return 0;\n // Strict parse via Number() (unlike parseFloat, \"0.5px\" -> NaN, not 0.5); drop\n // any non-finite or out-of-range [0,1] value, matching the README note.\n // Drop empty slots first (\"0,,1\" / \"1,\") — Number(\"\") is 0, which would\n // otherwise smuggle a spurious 0 threshold past the finite/range filter.\n const nums = raw\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s !== \"\")\n .map((s) => Number(s))\n .filter((n) => Number.isFinite(n) && n >= 0 && n <= 1);\n if (nums.length === 0) return 0;\n return nums.length === 1 ? nums[0] : nums;\n }\n\n private _options(): IntersectOptions {\n return {\n root: this._resolveRoot(),\n rootMargin: this.rootMargin,\n threshold: this._parseThreshold(),\n };\n }\n\n private _onChange = (event: Event): void => {\n // `wcs-intersect:change` bubbles, so a nested `<wcs-intersect>` descendant's\n // change would otherwise reach this (ancestor) listener and let a *child's*\n // intersection tear down *our* observer. Only act on our own Core's event.\n // (This also avoids reading `.detail` off a foreign event shape.)\n if (event.target !== this) return;\n // `once`: tear down after the first intersecting observation (lazy-load idiom).\n // Gated at fire time so toggling the `once` attribute takes effect live.\n if (this.once && (event as CustomEvent).detail.isIntersecting) {\n this._core.disconnect();\n }\n };\n\n // --- Lifecycle ---\n\n // 自動 observe の判断はマイクロタスクで、そのときの manual / target / root /\n // root-margin / threshold で 1 回だけ行う(timing-and-firing-contract §23)。router は\n // 遷移で同じノードを入れ直し、新しいルートの params から state が入力を書くのは\n // マイクロタスク — その場で observe すると、前の target で observer を張り、前の\n // manual をラッチしていた(docs/seam-apps.md、shift-desk)。接続と属性の変化は\n // ここへまとまり、observer は 1 回だけ作り直す。判断の前に外れた要素は何もしない。\n private _scheduleObserve(): void {\n if (this._observePending) return;\n this._observePending = true;\n queueMicrotask(() => {\n // unobserve / disconnect が予約を取り消していれば何もしない(同じタスクで予約し直して\n // いれば、このマイクロタスクがその判断を受け持ち、後の分は何もしない)\n if (!this._observePending) return;\n this._observePending = false;\n if (this.isConnected && !this.manual) {\n this.observe();\n }\n });\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.addEventListener(\"wcs-intersect:change\", this._onChange);\n this._scheduleObserve();\n // SSR (§4.4): readiness is immediate (the observation itself is decided in the\n // microtask above, which runs before any await on this promise resumes), but\n // expose the Core's ready promise as connectedCallbackPromise so the state\n // binder can await it uniformly. `manual` defers observation but readiness is\n // still immediate.\n this._connectedCallbackPromise = this._core.ready;\n }\n\n disconnectedCallback(): void {\n this.removeEventListener(\"wcs-intersect:change\", this._onChange);\n // dispose() tears down the observer AND bumps the Core's generation so any\n // IntersectionObserver callback still in flight is dropped (§3.4 / §4.1).\n this._core.dispose();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n // Defensive same-value guard. Per spec attributeChangedCallback only fires on\n // an actual value change, so this is effectively a dead branch today — but\n // setAttribute() with an unchanged value (and some test/tooling paths) can\n // still invoke it, and re-observing on an unchanged attribute would be a\n // wasted observer rebuild. Kept intentionally; do not remove.\n if (oldValue === newValue) return;\n // Only react once connected and in automatic mode. The re-observe goes through\n // the same microtask as the connect-time one (_scheduleObserve), so the\n // autoloader upgrade case (attributeChangedCallback + connectedCallback) and\n // several inputs written in one task rebuild the observer once.\n if (!this.isConnected || this.manual) return;\n this._scheduleObserve();\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the\n * page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined\n * by another copy of the package — not its class, not a subclass of it, not the same version — warns\n * `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry\n * `\"<package>@<version>\"` under `Symbol.for(\"wcstack.package\")`; a class without it is named\n * \"another copy of <package> that does not name its version\" (an older copy, or one loaded through\n * an entry that does not stamp).\n */\n\n/** The static a class defined through this helper carries: `\"@wcstack/fetch@<version>\"`. */\nexport const PACKAGE_STAMP: unique symbol = Symbol.for(\"wcstack.package\");\n\ntype Stamped = { [PACKAGE_STAMP]?: string };\n\n/** The registries this copy warned about: one warning per package per registry. */\nconst warned = new WeakSet<CustomElementRegistry>();\n\n/**\n * Marks `cls` as defined by `pkg` (`\"@wcstack/fetch@<version>\"`). A subclass inherits the mark, and\n * `defineProperty` writes it even where a parent's mark is read-only.\n */\nexport function stampPackage(cls: CustomElementConstructor, pkg: string): void {\n Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });\n}\n\n/**\n * Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`\n * is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and\n * carries another version or none. Once per registry.\n */\nexport function warnIfAnotherCopy(\n registry: CustomElementRegistry,\n tag: string,\n existing: CustomElementConstructor,\n own: CustomElementConstructor | undefined,\n pkg: string,\n): void {\n if (own !== undefined && (existing === own || existing.prototype instanceof own)) return;\n const theirs = (existing as Stamped)[PACKAGE_STAMP];\n if (theirs === pkg || warned.has(registry)) return;\n warned.add(registry);\n const name = pkg.slice(0, pkg.lastIndexOf(\"@\"));\n console.warn(\n `[${name}] [wcs/package-twice] <${tag}> is already defined by ` +\n `${theirs ?? `another copy of ${name} that does not name its version`}; ` +\n `this copy, ${pkg}, does nothing. Load each package once.`,\n );\n}\n\n/**\n * Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class\n * with `pkg` (`\"@wcstack/fetch@<version>\"`). A tag another copy of the package defined first is left\n * as it is, with the warning above.\n */\nexport function defineElements(\n registry: CustomElementRegistry,\n pkg: string,\n definitions: readonly (readonly [tag: string, cls: CustomElementConstructor])[],\n): void {\n for (const [tag, cls] of definitions) {\n const existing = registry.get(tag);\n if (existing === undefined) {\n stampPackage(cls, pkg);\n registry.define(tag, cls);\n } else {\n warnIfAnotherCopy(registry, tag, existing, cls, pkg);\n }\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\nimport { WcsIntersect } from \"./components/Intersect.js\";\nimport { config } from \"./config.js\";\nimport { defineElements } from \"./protocol/defineElement.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n defineElements(registry, `${pkg.name}@${pkg.version}`, [\n [config.tagNames.intersect, WcsIntersect],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapIntersection(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":["config","tagNames","intersect","IntersectionCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","isIntersecting","intersectionRatio","commands","_target","_observer","_observed","_options","_entry","_visible","_observing","_gen","_ready","Promise","resolve","constructor","target","super","this","ready","entry","intersecting","ratio","visible","observing","_setEntry","dispatchEvent","CustomEvent","bubbles","_setVisible","_setObserving","observe","element","options","_optionsEqual","_teardownObserver","observer","_createObserver","reobserve","unobserve","disconnect","reset","dispose","IntersectionObserver","gen","entries","_onIntersect","root","rootMargin","threshold","normalized","_normalizeEntry","time","boundingClientRect","_normalizeRect","intersectionRect","rootBounds","rect","x","y","width","height","top","right","bottom","left","a","b","_thresholdKey","undefined","Array","isArray","join","String","hasAccessorOnPrototype","proto","Object","getPrototypeOf","descriptor","getOwnPropertyDescriptor","get","set","toldObjectAttribute","WeakSet","warnObjectAttribute","value","has","add","tag","localName","console","warn","initialAttributes","WeakMap","initialAttribute","el","byName","Map","getAttribute","writeAttribute","removeAttribute","setAttribute","reflectAttribute","initial","reflectBooleanAttribute","WcsIntersect","HTMLElement","wcBindable","inputs","attribute","_core","_trigger","_connectedCallbackPromise","_internals","_observePending","_warnedRoot","_warnedMargin","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","delete","map","toStates","addEventListener","debug","hasAttribute","on","toggleAttribute","connectedCallbackPromise","attr","trim","once","manual","trigger","display","_resolveTarget","style","_warnRefused","margin","reason","Function","prototype","error","message","scope","getRootNode","_safeQuery","child","firstElementChild","_resolveRoot","found","getElementById","selector","querySelector","_parseThreshold","raw","nums","split","s","filter","Number","n","isFinite","length","_onChange","_scheduleObserve","queueMicrotask","isConnected","connectedCallback","declaration","input","call","toLowerCase","startsWith","hasOwnProperty","record","upgradeProperties","disconnectedCallback","removeEventListener","attributeChangedCallback","_name","oldValue","newValue","PACKAGE_STAMP","Symbol","for","warned","stampPackage","cls","pkg","defineProperty","configurable","warnIfAnotherCopy","registry","existing","own","theirs","slice","lastIndexOf","registerComponents","customElements","definitions","define","defineElements"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,UAAW,2DCeT,MAAOC,UAAyBC,YACpCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,QAASC,MAAO,uBAAwBC,UAAW,SAC3D,CAAEF,KAAM,eAAgBC,MAAO,uBAAwBC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOC,gBAC3H,CAAEN,KAAM,QAASC,MAAO,uBAAwBC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOE,mBACpH,CAAEP,KAAM,UAAWC,MAAO,gCAAiCC,UAAW,SACtE,CAAEF,KAAM,YAAaC,MAAO,kCAAmCC,UAAW,UAE5EM,SAAU,CACR,CAAER,KAAM,WACR,CAAEA,KAAM,aACR,CAAEA,KAAM,aACR,CAAEA,KAAM,cACR,CAAEA,KAAM,WAIJS,QAKAC,UAAyC,KACzCC,UAA4B,KAC5BC,SAA6B,CAAA,EAE7BC,OAAmC,KACnCC,UAAoB,EACpBC,YAAsB,EAStBC,KAAO,EAIPC,OAAwBC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,EAAK8G,EAAUN,EAAKC,EAEpD,CACF,CChEEc,CAAeV,EAAU,GAAGJ,KAAYA,IAAe,CACrD,CAAC/M,EAAOC,SAASC,UAAWqH,IAEhC,CCVM,IAA8D4F,EAIlEM,EAAmBN"}
|
package/dist/index.d.ts
CHANGED
|
@@ -290,6 +290,8 @@ declare class WcsIntersect extends HTMLElement {
|
|
|
290
290
|
private _connectedCallbackPromise;
|
|
291
291
|
private _internals;
|
|
292
292
|
private _observePending;
|
|
293
|
+
private _warnedRoot;
|
|
294
|
+
private _warnedMargin;
|
|
293
295
|
constructor();
|
|
294
296
|
get debugStates(): string[];
|
|
295
297
|
private _initInternals;
|
|
@@ -326,6 +328,13 @@ declare class WcsIntersect extends HTMLElement {
|
|
|
326
328
|
* observe(): an unresolvable target tears down any stale observation.
|
|
327
329
|
*/
|
|
328
330
|
reobserve(): void;
|
|
331
|
+
/**
|
|
332
|
+
* The observation did not start although there is something to observe: the browser refused the options, and
|
|
333
|
+
* with the threshold cleaned (_parseThreshold) only the margin is left — a length with no unit (`"200"`,
|
|
334
|
+
* `"0 0 900 0"`). `observing` stays false as before (never-throw); what was silent is said once per value
|
|
335
|
+
* (docs/mistake-catalogue.md, "root-margin-unit").
|
|
336
|
+
*/
|
|
337
|
+
private _warnRefused;
|
|
329
338
|
unobserve(): void;
|
|
330
339
|
disconnect(): void;
|
|
331
340
|
reset(): void;
|
package/dist/index.esm.js
CHANGED
|
@@ -58,7 +58,7 @@ function setConfig(partialConfig) {
|
|
|
58
58
|
frozenConfig = null;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
var pkg = {"name":"@wcstack/intersection","version":"4.
|
|
61
|
+
var pkg = {"name":"@wcstack/intersection","version":"4.24.0"};
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Headless visibility primitive. A thin, framework-agnostic wrapper around the
|
|
@@ -519,6 +519,9 @@ class WcsIntersect extends HTMLElement {
|
|
|
519
519
|
_internals = null;
|
|
520
520
|
// _scheduleObserve のマイクロタスクが待っている間 true
|
|
521
521
|
_observePending = false;
|
|
522
|
+
// 最後に警告した root と root-margin(値ごとに 1 回)
|
|
523
|
+
_warnedRoot = null;
|
|
524
|
+
_warnedMargin = null;
|
|
522
525
|
constructor() {
|
|
523
526
|
super();
|
|
524
527
|
this._core = new IntersectionCore(this);
|
|
@@ -691,6 +694,7 @@ class WcsIntersect extends HTMLElement {
|
|
|
691
694
|
return;
|
|
692
695
|
}
|
|
693
696
|
this._core.observe(element, this._options());
|
|
697
|
+
this._warnRefused();
|
|
694
698
|
}
|
|
695
699
|
/**
|
|
696
700
|
* Force a fresh observation: re-resolve target/root from the DOM and re-observe
|
|
@@ -709,6 +713,33 @@ class WcsIntersect extends HTMLElement {
|
|
|
709
713
|
return;
|
|
710
714
|
}
|
|
711
715
|
this._core.reobserve(element, this._options());
|
|
716
|
+
this._warnRefused();
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* The observation did not start although there is something to observe: the browser refused the options, and
|
|
720
|
+
* with the threshold cleaned (_parseThreshold) only the margin is left — a length with no unit (`"200"`,
|
|
721
|
+
* `"0 0 900 0"`). `observing` stays false as before (never-throw); what was silent is said once per value
|
|
722
|
+
* (docs/mistake-catalogue.md, "root-margin-unit").
|
|
723
|
+
*/
|
|
724
|
+
_warnRefused() {
|
|
725
|
+
if (this._core.observing || typeof IntersectionObserver === "undefined")
|
|
726
|
+
return;
|
|
727
|
+
const margin = this.rootMargin;
|
|
728
|
+
if (this._warnedMargin === margin)
|
|
729
|
+
return;
|
|
730
|
+
let reason = "";
|
|
731
|
+
try {
|
|
732
|
+
// (Function.prototype: a callback that does nothing — this observer observes nothing)
|
|
733
|
+
new IntersectionObserver(Function.prototype, { rootMargin: margin }).disconnect();
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
catch (error) {
|
|
737
|
+
reason = error.message;
|
|
738
|
+
}
|
|
739
|
+
this._warnedMargin = margin;
|
|
740
|
+
console.warn(`[@wcstack/intersection] [wcs/root-margin-unit] <${this.localName} root-margin="${margin}"> is not a margin the ` +
|
|
741
|
+
`browser takes (${reason}): write each length with px or %, as "200px 0px". Nothing is observed ` +
|
|
742
|
+
`(observing stays false).`);
|
|
712
743
|
}
|
|
713
744
|
// unobserve / disconnect は、予約中の自動 observe(_scheduleObserve)も取り消す。
|
|
714
745
|
// 同じタスクで接続(や属性の変化)の後に呼ばれたとき、以前の同期の observe を止めたのと
|
|
@@ -762,7 +793,17 @@ class WcsIntersect extends HTMLElement {
|
|
|
762
793
|
const scope = this.getRootNode();
|
|
763
794
|
// Same never-throw guard as the target selector: an invalid `root` selector
|
|
764
795
|
// falls back to a null root (the viewport) rather than throwing out of observe().
|
|
765
|
-
|
|
796
|
+
// A value that matches nothing as a selector is tried as an id — the way
|
|
797
|
+
// `<wcs-infinite-scroll root>` spells it (docs/seam-apps.md, town-archive).
|
|
798
|
+
const found = this._safeQuery(scope, root) ?? scope.getElementById?.(root) ?? null;
|
|
799
|
+
// A root given and not found was the viewport without a word: the margin was then
|
|
800
|
+
// measured against the wrong box. Said once per value.
|
|
801
|
+
if (!found && this._warnedRoot !== root) {
|
|
802
|
+
this._warnedRoot = root;
|
|
803
|
+
console.warn(`[@wcstack/intersection] [wcs/intersect-root] <${this.localName} root="${root}">: no element matches that ` +
|
|
804
|
+
`selector, and none has it as its id, so the viewport is the root.`);
|
|
805
|
+
}
|
|
806
|
+
return found;
|
|
766
807
|
}
|
|
767
808
|
// Wrap querySelector so a syntactically invalid user-authored selector resolves
|
|
768
809
|
// to null (unresolvable) instead of letting the SyntaxError escape — keeping the
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../src/config.ts","../../src/core/IntersectionCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Intersect.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapIntersection.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n intersect: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n intersect: \"wcs-intersect\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapIntersection` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/intersection] bootstrapIntersection: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","import { IWcBindable, IntersectOptions, WcsIntersectEntry, WcsIntersectRect } from \"../types.js\";\n\n/**\n * Headless visibility primitive. A thin, framework-agnostic wrapper around the\n * IntersectionObserver API exposed through the wc-bindable protocol.\n *\n * Unlike the other @wcstack sensors (geolocation / timer / websocket), the thing\n * being observed is a *DOM element* — so `observe()` takes the target node. The\n * Core stays DOM-resolution-agnostic: it observes whatever element it is handed\n * (the Shell resolves `target` / `root` selectors before calling). It is a\n * read-only producer — element/layout → state only, with no element-bound path.\n *\n * Every observer callback is published via the single `wcs-intersect:change`\n * event; `intersecting` / `ratio` are read from it through getters (mirroring how\n * GeolocationCore exposes latitude/longitude from one `wcs-geo:position` event),\n * so an observer that binds any of them is notified on every change.\n *\n * `visible` is a latch: it flips to `true` the first time the target intersects\n * and stays `true` until `reset()` — ideal for one-way lazy-load bindings\n * (`src@visible`). `observing` reflects whether an observation is currently\n * active (like TimerCore's `running`).\n *\n * Single-target by design: the Shell observes exactly one element, so the state\n * reflects that element. Multi-target observation is intentionally out of scope.\n */\nexport class IntersectionCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"entry\", event: \"wcs-intersect:change\", semantics: \"state\" },\n { name: \"intersecting\", event: \"wcs-intersect:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.isIntersecting },\n { name: \"ratio\", event: \"wcs-intersect:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.intersectionRatio },\n { name: \"visible\", event: \"wcs-intersect:visible-changed\", semantics: \"state\" },\n { name: \"observing\", event: \"wcs-intersect:observing-changed\", semantics: \"state\" },\n ],\n commands: [\n { name: \"observe\" },\n { name: \"reobserve\" },\n { name: \"unobserve\" },\n { name: \"disconnect\" },\n { name: \"reset\" },\n ],\n };\n\n private _target: EventTarget;\n\n // The live observer and the single element it observes. Options are kept so a\n // repeated observe() with identical options is a no-op (avoids the create→\n // observe→disconnect churn an autoloader upgrade can otherwise cause).\n private _observer: IntersectionObserver | null = null;\n private _observed: Element | null = null;\n private _options: IntersectOptions = {};\n\n private _entry: WcsIntersectEntry | null = null;\n private _visible: boolean = false;\n private _observing: boolean = false;\n\n // Generation guard (§3.4): bumped on dispose() and on each observe()/reobserve()\n // teardown+rebuild. IntersectionObserver delivers its callback asynchronously off\n // layout, so a callback can fire after the element is disposed or after a rapid\n // disconnect→reconnect rebuilt the observer. Each observer captures the gen live at\n // creation; a callback from a superseded/torn-down observer has a stale gen and\n // MUST NOT write state to a torn-down element. A boolean flag is insufficient\n // (dispose→observe would flip it back and let stale work slip through).\n private _gen = 0;\n\n // SSR (§3.8): IntersectionObserver setup is synchronous (no async probe to await),\n // so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n /** Resolves immediately — there is no asynchronous probe to await (§3.8). */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get entry(): WcsIntersectEntry | null {\n return this._entry;\n }\n\n get intersecting(): boolean {\n return this._entry ? this._entry.isIntersecting : false;\n }\n\n get ratio(): number {\n return this._entry ? this._entry.intersectionRatio : 0;\n }\n\n get visible(): boolean {\n return this._visible;\n }\n\n get observing(): boolean {\n return this._observing;\n }\n\n // --- State setters with event dispatch ---\n\n private _setEntry(entry: WcsIntersectEntry): void {\n // No same-value guard: `change` carries event semantics (every callback is a\n // distinct observation) and `intersecting` / `ratio` are derived getters that\n // must re-fire on each entry, mirroring GeolocationCore's `position`.\n this._entry = entry;\n this._target.dispatchEvent(new CustomEvent(\"wcs-intersect:change\", {\n detail: entry,\n bubbles: true,\n }));\n }\n\n private _setVisible(visible: boolean): void {\n if (this._visible === visible) return;\n this._visible = visible;\n this._target.dispatchEvent(new CustomEvent(\"wcs-intersect:visible-changed\", {\n detail: visible,\n bubbles: true,\n }));\n }\n\n private _setObserving(observing: boolean): void {\n if (this._observing === observing) return;\n this._observing = observing;\n this._target.dispatchEvent(new CustomEvent(\"wcs-intersect:observing-changed\", {\n detail: observing,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing `element`. Idempotent while already observing the same\n * element with the same options. Changing the element or options tears down the\n * current observer and builds a new one (IntersectionObserver options are fixed\n * at construction, so reconfiguring requires a fresh observer).\n *\n * If IntersectionObserver is unavailable (SSR) or the options are invalid (e.g.\n * a malformed `rootMargin`, which the constructor rejects), this is a silent\n * no-op — `observing` stays false, consistent with the never-throw design of\n * the other @wcstack sensors.\n */\n observe(element: Element, options: IntersectOptions = {}): Promise<void> {\n if (this._observer && this._observed === element && this._optionsEqual(this._options, options)) {\n return this._ready;\n }\n this._teardownObserver();\n const observer = this._createObserver(options);\n if (!observer) {\n // Creation failed (unsupported environment or invalid options) *after* we\n // tore down any previous observer. If we were already observing, the\n // observation is now gone, so reflect that — otherwise `observing` would\n // keep reporting true with no live observer behind it (e.g. re-observing an\n // active target with a newly-invalid rootMargin).\n this._setObserving(false);\n return this._ready;\n }\n this._observer = observer;\n this._observed = element;\n this._options = options;\n observer.observe(element);\n this._setObserving(true);\n // SSR (§3.5): observe() returns the readiness promise. Observation establishment\n // is synchronous, so this resolves immediately.\n return this._ready;\n }\n\n /**\n * Force a fresh observation of `element`, even when it matches the currently\n * observed target+options. Unlike observe() — which is idempotent and\n * early-returns for an unchanged target+options *without* re-delivering a\n * callback — this always tears the observer down and rebuilds it, so a new\n * IntersectionObserver delivers an initial callback for the element's CURRENT\n * visibility.\n *\n * This is the way to re-arm an edge-driven consumer (e.g. infinite scroll) after\n * the layout changed without a visibility *transition*: IntersectionObserver only\n * fires on a change, so appending a short page that leaves the sentinel visible\n * yields no new callback — a bare observe() can't help (idempotent), but a\n * reobserve() re-reads the current state. Same never-throw guarantees as\n * observe(); `observing` stays true across a successful re-arm (no false blip).\n */\n reobserve(element: Element, options: IntersectOptions = {}): void {\n this._teardownObserver();\n this.observe(element, options);\n }\n\n /**\n * Stop observing `element`. A no-op if it is not the currently observed\n * element. The observer instance is torn down (single-target Core), so a later\n * observe() rebuilds it.\n */\n unobserve(element: Element): void {\n if (this._observed !== element) return;\n this._teardownObserver();\n this._setObserving(false);\n }\n\n /** Stop all observation and release the observer. */\n disconnect(): void {\n this._teardownObserver();\n this._setObserving(false);\n }\n\n /** Clear the `visible` latch so a later intersection can set it again. */\n reset(): void {\n this._setVisible(false);\n }\n\n // --- Lifecycle (§3.5) ---\n\n /**\n * `observe()` (the IntersectionObserver-style command above) establishes\n * monitoring, so there is no separate idempotent monitoring entry point — only\n * teardown. `dispose()` invalidates any in-flight observer callback (`_gen++`)\n * and releases the observer. A later observe() revives it (the Shell calls this\n * from `disconnectedCallback`).\n */\n dispose(): void {\n this._gen++;\n this.disconnect();\n }\n\n // --- Internal ---\n\n private _teardownObserver(): void {\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n this._observed = null;\n // Invalidate the torn-down observer's generation: its callback can still fire\n // once asynchronously after disconnect(), and must be dropped (§3.4).\n this._gen++;\n }\n\n private _createObserver(options: IntersectOptions): IntersectionObserver | null {\n if (typeof IntersectionObserver === \"undefined\") return null;\n // Capture the generation live at creation. The callback closure below guards\n // against deliveries from this observer after it has been superseded or\n // disposed (a stale callback fired off layout after teardown).\n const gen = this._gen;\n try {\n return new IntersectionObserver(\n (entries) => this._onIntersect(gen, entries),\n {\n root: options.root ?? null,\n rootMargin: options.rootMargin ?? \"0px\",\n threshold: options.threshold ?? 0,\n },\n );\n } catch {\n // Invalid options (e.g. a malformed rootMargin) — surface nothing and leave\n // observing false, rather than letting the constructor throw escape.\n return null;\n }\n }\n\n private _onIntersect(gen: number, entries: IntersectionObserverEntry[]): void {\n // Stale-generation guard (§3.4): drop callbacks from an observer that was torn\n // down or disposed (e.g. a delivery that landed after disconnect/reconnect).\n if (gen !== this._gen) return;\n for (const entry of entries) {\n const normalized = this._normalizeEntry(entry);\n this._setEntry(normalized);\n // Latch on the first (and any) intersecting observation; never auto-clears.\n if (normalized.isIntersecting) {\n this._setVisible(true);\n }\n }\n }\n\n private _normalizeEntry(entry: IntersectionObserverEntry): WcsIntersectEntry {\n return {\n isIntersecting: entry.isIntersecting,\n intersectionRatio: entry.intersectionRatio,\n time: entry.time,\n boundingClientRect: this._normalizeRect(entry.boundingClientRect),\n intersectionRect: this._normalizeRect(entry.intersectionRect),\n rootBounds: entry.rootBounds ? this._normalizeRect(entry.rootBounds) : null,\n target: entry.target,\n };\n }\n\n private _normalizeRect(rect: DOMRectReadOnly): WcsIntersectRect {\n return {\n x: rect.x,\n y: rect.y,\n width: rect.width,\n height: rect.height,\n top: rect.top,\n right: rect.right,\n bottom: rect.bottom,\n left: rect.left,\n };\n }\n\n private _optionsEqual(a: IntersectOptions, b: IntersectOptions): boolean {\n if ((a.root ?? null) !== (b.root ?? null)) return false;\n if ((a.rootMargin ?? \"0px\") !== (b.rootMargin ?? \"0px\")) return false;\n return this._thresholdKey(a.threshold) === this._thresholdKey(b.threshold);\n }\n\n private _thresholdKey(threshold: number | number[] | undefined): string {\n if (threshold === undefined) return \"0\";\n return Array.isArray(threshold) ? threshold.join(\",\") : String(threshold);\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { IWcBindable, IntersectOptions, WcsIntersectEntry } from \"../types.js\";\nimport { IntersectionCore } from \"../core/IntersectionCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-intersect>` — declarative IntersectionObserver.\n *\n * The `target` attribute is the single knob that decides both *what* is observed\n * and how the element renders (it never injects a layout box unless asked):\n *\n * | `target` | observes | display | use case |\n * |-----------------|-----------------------|-------------|-------------------|\n * | omitted | first element child | `contents` | lazy-load wrapper |\n * | `\"#hero\"` / sel | the matched element | `none` | scrollspy (single)|\n * | `\"self\"` | the element itself | `block` | infinite-scroll |\n *\n * `display:contents` means wrapping a child injects no box of its own (so a\n * `<wcs-intersect><img></wcs-intersect>` does not disturb a flex/grid parent);\n * only the explicit `target=\"self\"` sentinel takes a box.\n */\nexport class WcsIntersect extends HTMLElement {\n // SSR (§4.4): the first observation is established in a microtask after connect\n // (timing-and-firing-contract §23) with no async probe, but the Shell still\n // exposes connectedCallbackPromise so the state binder can await it uniformly\n // across all IO nodes before snapshotting.\n static hasConnectedCallbackPromise = true;\n // Only attributes that change *what or how* we observe trigger a re-observe.\n // `once` is intentionally excluded: it is evaluated at intersection fire time\n // (in `_onChange`), so toggling it takes effect without re-observing — and a\n // re-observe on its change would be a pure no-op (same target, same options).\n // `manual` is also excluded: it is a connect-time policy (\"don't auto-observe\n // on connect\"), not a live switch that should start/stop an active observation.\n static observedAttributes = [\"target\", \"root\", \"root-margin\", \"threshold\"];\n\n static wcBindable: IWcBindable = {\n ...IntersectionCore.wcBindable,\n properties: [\n ...IntersectionCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-intersect:trigger-changed\", semantics: \"state\" },\n ],\n // Shell-level settable surface. Each input carries its mirrored `attribute`\n // hint; `trigger` has none — it is a momentary command-property, not a\n // declarative attribute. The observe / reobserve / unobserve / disconnect /\n // reset commands are inherited from the Core via the spread above.\n inputs: [\n { name: \"target\", attribute: \"target\" },\n { name: \"root\", attribute: \"root\" },\n { name: \"rootMargin\", attribute: \"root-margin\" },\n { name: \"threshold\", attribute: \"threshold\" },\n { name: \"once\", attribute: \"once\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。<wcs-sse>/<wcs-broadcast> と同型。\n // spread でも継承されるが、Core に command 追加時の追従漏れを防ぐため明示参照する。\n commands: IntersectionCore.wcBindable.commands,\n };\n\n private _core: IntersectionCore;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n // _scheduleObserve のマイクロタスクが待っている間 true\n private _observePending = false;\n\n constructor() {\n super();\n this._core = new IntersectionCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-intersect:visible-changed\": (d) => ({ visible: d === true }),\n \"wcs-intersect:observing-changed\": (d) => ({ observing: d === true }),\n \"wcs-intersect:change\": (d) => ({ intersecting: d.isIntersecting === true }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n // Input setters never let setAttribute stringify null / undefined (an\n // \"undefined\" target is a selector that matches nothing, which would tear the\n // observation down): `null` removes the attribute (the default), `undefined`\n // restores the attribute the element started with (wc-bindable producer\n // guidance P1; React 19 and a direct assignment deliver it, @wcstack/state\n // does not). A change of target / root / root-margin / threshold re-observes\n // through attributeChangedCallback as before.\n\n get target(): string {\n return this.getAttribute(\"target\") ?? \"\";\n }\n\n set target(value: string | null | undefined) {\n reflectAttribute(this, \"target\", value);\n }\n\n get root(): string {\n return this.getAttribute(\"root\") ?? \"\";\n }\n\n set root(value: string | null | undefined) {\n reflectAttribute(this, \"root\", value);\n }\n\n get rootMargin(): string {\n const attr = this.getAttribute(\"root-margin\");\n return attr === null || attr.trim() === \"\" ? \"0px\" : attr;\n }\n\n set rootMargin(value: string | null | undefined) {\n reflectAttribute(this, \"root-margin\", value);\n }\n\n get threshold(): string {\n return this.getAttribute(\"threshold\") ?? \"\";\n }\n\n set threshold(value: string | null | undefined) {\n reflectAttribute(this, \"threshold\", value);\n }\n\n get once(): boolean {\n return this.hasAttribute(\"once\");\n }\n\n set once(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"once\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"manual\", value);\n }\n\n // --- Core delegated getters ---\n\n get entry(): WcsIntersectEntry | null {\n return this._core.entry;\n }\n\n get intersecting(): boolean {\n return this._core.intersecting;\n }\n\n get ratio(): number {\n return this._core.ratio;\n }\n\n get visible(): boolean {\n return this._core.visible;\n }\n\n get observing(): boolean {\n return this._core.observing;\n }\n\n // --- Command property ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n // Momentary command-property: a false→true write re-runs observe(). Mirrors\n // the trigger flag on <wcs-geo> / <wcs-ws> / <wcs-sse>. Prefer the command-token\n // protocol (`command.observe: $command.start`) for state-driven observation;\n // this exists mainly for simple boolean bindings.\n const v = !!value; // normalize truthy state-bindings, like <wcs-sse>'s setter\n if (v) {\n this._trigger = true;\n // try/finally mirrors <wcs-sse>'s set trigger: observe() is never-throw\n // today, but should a synchronous throw path ever appear, the finally still\n // auto-resets _trigger (no stuck-true latch) and emits the completion notice.\n try {\n this.observe();\n } finally {\n this._trigger = false;\n // Always auto-reset to false after the observe() attempt — this is the\n // *momentary acknowledgement* that the trigger was consumed, NOT a signal\n // that observation succeeded (whether the target resolved is reflected by\n // `observing`, not by this event). Firing unconditionally keeps the bound\n // state's trigger flag from sticking at true regardless of resolution.\n // Read `observing` if you need the actual outcome.\n this.dispatchEvent(new CustomEvent(\"wcs-intersect:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n }\n\n // --- Commands ---\n\n /** Re-resolve the target/root from the DOM and (re)start observing. */\n observe(): void {\n const { element, display } = this._resolveTarget();\n // `display` is derived from the `target` *mode* (self/selector/child), not from\n // whether the selector currently matches — so it is applied unconditionally,\n // before the resolution check. A `target=\"#x\"` whose node is momentarily absent\n // still renders `display:none` (it is a selector pointer, never a box).\n this.style.display = display;\n if (!element) {\n // The target is no longer resolvable (e.g. a `target` selector whose node\n // was removed from the DOM). Tear down any stale observation so `observing`\n // does not keep reporting true against a node that is gone.\n this._core.disconnect();\n return;\n }\n this._core.observe(element, this._options());\n }\n\n /**\n * Force a fresh observation: re-resolve target/root from the DOM and re-observe\n * even when nothing changed. Unlike observe() (idempotent for an unchanged\n * target+options), this rebuilds the observer so a new initial callback fires for\n * the current visibility — the way to re-arm an edge-driven consumer after the\n * layout shifted without a visibility transition (e.g. infinite scroll appended a\n * short page that left this sentinel in view). Resolution/teardown rules match\n * observe(): an unresolvable target tears down any stale observation.\n */\n reobserve(): void {\n const { element, display } = this._resolveTarget();\n this.style.display = display;\n if (!element) {\n this._core.disconnect();\n return;\n }\n this._core.reobserve(element, this._options());\n }\n\n // unobserve / disconnect は、予約中の自動 observe(_scheduleObserve)も取り消す。\n // 同じタスクで接続(や属性の変化)の後に呼ばれたとき、以前の同期の observe を止めたのと\n // 同じく何も監視しない(timing-and-firing-contract §23)。observe / reobserve / trigger は\n // 取り消さない — 予約の observe は同じ target・options なら no-op(冪等)。\n unobserve(): void {\n this._observePending = false;\n // Single-target Shell: \"stop observing my target\" is exactly the Core's\n // teardown. Delegate to the Core's tracked state rather than re-resolving the\n // selector, so a target that has since left the DOM can still be stopped\n // (re-resolving would yield null and silently leave the observer running).\n this._core.disconnect();\n }\n\n disconnect(): void {\n this._observePending = false;\n this._core.disconnect();\n }\n\n reset(): void {\n this._core.reset();\n }\n\n // --- Internal ---\n\n private _resolveTarget(): { element: Element | null; display: string } {\n const target = this.target;\n if (target === \"self\") {\n // Explicit sentinel: observe the element itself as a (typically zero-height)\n // marker, which requires a layout box.\n return { element: this, display: \"block\" };\n }\n if (target !== \"\") {\n // Selector pointer: observe a referenced element in place, staying invisible.\n const scope = this.getRootNode() as Document | ShadowRoot;\n // A user-authored selector can be syntactically invalid (e.g. `#`, `:::`,\n // `[data-*`), which makes querySelector throw a SyntaxError. Swallow it and\n // treat the target as unresolvable — the same \"nothing to observe\" path as a\n // selector matching no element — so a bad attribute never lets the throw\n // escape observe() → connectedCallback / attributeChangedCallback (never-throw).\n return { element: this._safeQuery(scope, target), display: \"none\" };\n }\n // Omitted: observe the first element child without injecting a box of our own.\n const child = this.firstElementChild;\n if (child) {\n return { element: child, display: \"contents\" };\n }\n // No child to wrap (e.g. used as an empty marker) — fall back to self.\n return { element: this, display: \"block\" };\n }\n\n private _resolveRoot(): Element | null {\n const root = this.root;\n if (root === \"\") return null;\n const scope = this.getRootNode() as Document | ShadowRoot;\n // Same never-throw guard as the target selector: an invalid `root` selector\n // falls back to a null root (the viewport) rather than throwing out of observe().\n return this._safeQuery(scope, root);\n }\n\n // Wrap querySelector so a syntactically invalid user-authored selector resolves\n // to null (unresolvable) instead of letting the SyntaxError escape — keeping the\n // sensor never-throw, mirroring worker/src/autoTrigger.ts's resolveText guard.\n private _safeQuery(scope: Document | ShadowRoot, selector: string): Element | null {\n try {\n return scope.querySelector(selector);\n } catch {\n return null;\n }\n }\n\n private _parseThreshold(): number | number[] {\n const raw = this.threshold.trim();\n if (raw === \"\") return 0;\n // Strict parse via Number() (unlike parseFloat, \"0.5px\" -> NaN, not 0.5); drop\n // any non-finite or out-of-range [0,1] value, matching the README note.\n // Drop empty slots first (\"0,,1\" / \"1,\") — Number(\"\") is 0, which would\n // otherwise smuggle a spurious 0 threshold past the finite/range filter.\n const nums = raw\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s !== \"\")\n .map((s) => Number(s))\n .filter((n) => Number.isFinite(n) && n >= 0 && n <= 1);\n if (nums.length === 0) return 0;\n return nums.length === 1 ? nums[0] : nums;\n }\n\n private _options(): IntersectOptions {\n return {\n root: this._resolveRoot(),\n rootMargin: this.rootMargin,\n threshold: this._parseThreshold(),\n };\n }\n\n private _onChange = (event: Event): void => {\n // `wcs-intersect:change` bubbles, so a nested `<wcs-intersect>` descendant's\n // change would otherwise reach this (ancestor) listener and let a *child's*\n // intersection tear down *our* observer. Only act on our own Core's event.\n // (This also avoids reading `.detail` off a foreign event shape.)\n if (event.target !== this) return;\n // `once`: tear down after the first intersecting observation (lazy-load idiom).\n // Gated at fire time so toggling the `once` attribute takes effect live.\n if (this.once && (event as CustomEvent).detail.isIntersecting) {\n this._core.disconnect();\n }\n };\n\n // --- Lifecycle ---\n\n // 自動 observe の判断はマイクロタスクで、そのときの manual / target / root /\n // root-margin / threshold で 1 回だけ行う(timing-and-firing-contract §23)。router は\n // 遷移で同じノードを入れ直し、新しいルートの params から state が入力を書くのは\n // マイクロタスク — その場で observe すると、前の target で observer を張り、前の\n // manual をラッチしていた(docs/seam-apps.md、shift-desk)。接続と属性の変化は\n // ここへまとまり、observer は 1 回だけ作り直す。判断の前に外れた要素は何もしない。\n private _scheduleObserve(): void {\n if (this._observePending) return;\n this._observePending = true;\n queueMicrotask(() => {\n // unobserve / disconnect が予約を取り消していれば何もしない(同じタスクで予約し直して\n // いれば、このマイクロタスクがその判断を受け持ち、後の分は何もしない)\n if (!this._observePending) return;\n this._observePending = false;\n if (this.isConnected && !this.manual) {\n this.observe();\n }\n });\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.addEventListener(\"wcs-intersect:change\", this._onChange);\n this._scheduleObserve();\n // SSR (§4.4): readiness is immediate (the observation itself is decided in the\n // microtask above, which runs before any await on this promise resumes), but\n // expose the Core's ready promise as connectedCallbackPromise so the state\n // binder can await it uniformly. `manual` defers observation but readiness is\n // still immediate.\n this._connectedCallbackPromise = this._core.ready;\n }\n\n disconnectedCallback(): void {\n this.removeEventListener(\"wcs-intersect:change\", this._onChange);\n // dispose() tears down the observer AND bumps the Core's generation so any\n // IntersectionObserver callback still in flight is dropped (§3.4 / §4.1).\n this._core.dispose();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n // Defensive same-value guard. Per spec attributeChangedCallback only fires on\n // an actual value change, so this is effectively a dead branch today — but\n // setAttribute() with an unchanged value (and some test/tooling paths) can\n // still invoke it, and re-observing on an unchanged attribute would be a\n // wasted observer rebuild. Kept intentionally; do not remove.\n if (oldValue === newValue) return;\n // Only react once connected and in automatic mode. The re-observe goes through\n // the same microtask as the connect-time one (_scheduleObserve), so the\n // autoloader upgrade case (attributeChangedCallback + connectedCallback) and\n // several inputs written in one task rebuild the observer once.\n if (!this.isConnected || this.manual) return;\n this._scheduleObserve();\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the\n * page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined\n * by another copy of the package — not its class, not a subclass of it, not the same version — warns\n * `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry\n * `\"<package>@<version>\"` under `Symbol.for(\"wcstack.package\")`; a class without it is named\n * \"another copy of <package> that does not name its version\" (an older copy, or one loaded through\n * an entry that does not stamp).\n */\n\n/** The static a class defined through this helper carries: `\"@wcstack/fetch@<version>\"`. */\nexport const PACKAGE_STAMP: unique symbol = Symbol.for(\"wcstack.package\");\n\ntype Stamped = { [PACKAGE_STAMP]?: string };\n\n/** The registries this copy warned about: one warning per package per registry. */\nconst warned = new WeakSet<CustomElementRegistry>();\n\n/**\n * Marks `cls` as defined by `pkg` (`\"@wcstack/fetch@<version>\"`). A subclass inherits the mark, and\n * `defineProperty` writes it even where a parent's mark is read-only.\n */\nexport function stampPackage(cls: CustomElementConstructor, pkg: string): void {\n Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });\n}\n\n/**\n * Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`\n * is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and\n * carries another version or none. Once per registry.\n */\nexport function warnIfAnotherCopy(\n registry: CustomElementRegistry,\n tag: string,\n existing: CustomElementConstructor,\n own: CustomElementConstructor | undefined,\n pkg: string,\n): void {\n if (own !== undefined && (existing === own || existing.prototype instanceof own)) return;\n const theirs = (existing as Stamped)[PACKAGE_STAMP];\n if (theirs === pkg || warned.has(registry)) return;\n warned.add(registry);\n const name = pkg.slice(0, pkg.lastIndexOf(\"@\"));\n console.warn(\n `[${name}] [wcs/package-twice] <${tag}> is already defined by ` +\n `${theirs ?? `another copy of ${name} that does not name its version`}; ` +\n `this copy, ${pkg}, does nothing. Load each package once.`,\n );\n}\n\n/**\n * Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class\n * with `pkg` (`\"@wcstack/fetch@<version>\"`). A tag another copy of the package defined first is left\n * as it is, with the warning above.\n */\nexport function defineElements(\n registry: CustomElementRegistry,\n pkg: string,\n definitions: readonly (readonly [tag: string, cls: CustomElementConstructor])[],\n): void {\n for (const [tag, cls] of definitions) {\n const existing = registry.get(tag);\n if (existing === undefined) {\n stampPackage(cls, pkg);\n registry.define(tag, cls);\n } else {\n warnIfAnotherCopy(registry, tag, existing, cls, pkg);\n }\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\nimport { WcsIntersect } from \"./components/Intersect.js\";\nimport { config } from \"./config.js\";\nimport { defineElements } from \"./protocol/defineElement.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n defineElements(registry, `${pkg.name}@${pkg.version}`, [\n [config.tagNames.intersect, WcsIntersect],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapIntersection(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":[],"mappings":"AAQA,MAAM,OAAO,GAAoB;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,SAAS,EAAE,eAAe;AAC3B,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IAC/D;AACA,IAAA,OAAO,KAAU;A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I,iCAAiC,CAAA,EAAA,CAAI;QACzE,CAAA,WAAA,EAAc,GAAG,CAAA,uCAAA,CAAyC,CAC3D;AACH;AAEA;;;;AAIG;SACa,cAAc,CAC5B,QAA+B,EAC/B,GAAW,EACX,WAA+E,EAAA;IAE/E,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,WAAW,EAAE;QACpC,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;AAClC,QAAA,IAAI,QAAQ,KAAK,SAAS,EAAE;AAC1B,YAAA,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC;AACtB,YAAA,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC;QAC3B;aAAO;YACL,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC;QACtD;IACF;AACF;;ACtEA;;;;AAIG;AACG,SAAU,kBAAkB,CAAC,QAAA,GAAkC,cAAc,EAAA;AACjF,IAAA,cAAc,CAAC,QAAQ,EAAE,CAAA,EAAG,GAAG,CAAC,IAAI,CAAA,CAAA,EAAI,GAAG,CAAC,OAAO,CAAA,CAAE,EAAE;AACrD,QAAA,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;AAC1C,KAAA,CAAC;AACJ;;ACVM,SAAU,qBAAqB,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAClG,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;IACA,kBAAkB,CAAC,QAAQ,CAAC;AAC9B;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../src/config.ts","../../src/core/IntersectionCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Intersect.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapIntersection.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n intersect: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n intersect: \"wcs-intersect\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapIntersection` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/intersection] bootstrapIntersection: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","import { IWcBindable, IntersectOptions, WcsIntersectEntry, WcsIntersectRect } from \"../types.js\";\n\n/**\n * Headless visibility primitive. A thin, framework-agnostic wrapper around the\n * IntersectionObserver API exposed through the wc-bindable protocol.\n *\n * Unlike the other @wcstack sensors (geolocation / timer / websocket), the thing\n * being observed is a *DOM element* — so `observe()` takes the target node. The\n * Core stays DOM-resolution-agnostic: it observes whatever element it is handed\n * (the Shell resolves `target` / `root` selectors before calling). It is a\n * read-only producer — element/layout → state only, with no element-bound path.\n *\n * Every observer callback is published via the single `wcs-intersect:change`\n * event; `intersecting` / `ratio` are read from it through getters (mirroring how\n * GeolocationCore exposes latitude/longitude from one `wcs-geo:position` event),\n * so an observer that binds any of them is notified on every change.\n *\n * `visible` is a latch: it flips to `true` the first time the target intersects\n * and stays `true` until `reset()` — ideal for one-way lazy-load bindings\n * (`src@visible`). `observing` reflects whether an observation is currently\n * active (like TimerCore's `running`).\n *\n * Single-target by design: the Shell observes exactly one element, so the state\n * reflects that element. Multi-target observation is intentionally out of scope.\n */\nexport class IntersectionCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"entry\", event: \"wcs-intersect:change\", semantics: \"state\" },\n { name: \"intersecting\", event: \"wcs-intersect:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.isIntersecting },\n { name: \"ratio\", event: \"wcs-intersect:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.intersectionRatio },\n { name: \"visible\", event: \"wcs-intersect:visible-changed\", semantics: \"state\" },\n { name: \"observing\", event: \"wcs-intersect:observing-changed\", semantics: \"state\" },\n ],\n commands: [\n { name: \"observe\" },\n { name: \"reobserve\" },\n { name: \"unobserve\" },\n { name: \"disconnect\" },\n { name: \"reset\" },\n ],\n };\n\n private _target: EventTarget;\n\n // The live observer and the single element it observes. Options are kept so a\n // repeated observe() with identical options is a no-op (avoids the create→\n // observe→disconnect churn an autoloader upgrade can otherwise cause).\n private _observer: IntersectionObserver | null = null;\n private _observed: Element | null = null;\n private _options: IntersectOptions = {};\n\n private _entry: WcsIntersectEntry | null = null;\n private _visible: boolean = false;\n private _observing: boolean = false;\n\n // Generation guard (§3.4): bumped on dispose() and on each observe()/reobserve()\n // teardown+rebuild. IntersectionObserver delivers its callback asynchronously off\n // layout, so a callback can fire after the element is disposed or after a rapid\n // disconnect→reconnect rebuilt the observer. Each observer captures the gen live at\n // creation; a callback from a superseded/torn-down observer has a stale gen and\n // MUST NOT write state to a torn-down element. A boolean flag is insufficient\n // (dispose→observe would flip it back and let stale work slip through).\n private _gen = 0;\n\n // SSR (§3.8): IntersectionObserver setup is synchronous (no async probe to await),\n // so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n /** Resolves immediately — there is no asynchronous probe to await (§3.8). */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get entry(): WcsIntersectEntry | null {\n return this._entry;\n }\n\n get intersecting(): boolean {\n return this._entry ? this._entry.isIntersecting : false;\n }\n\n get ratio(): number {\n return this._entry ? this._entry.intersectionRatio : 0;\n }\n\n get visible(): boolean {\n return this._visible;\n }\n\n get observing(): boolean {\n return this._observing;\n }\n\n // --- State setters with event dispatch ---\n\n private _setEntry(entry: WcsIntersectEntry): void {\n // No same-value guard: `change` carries event semantics (every callback is a\n // distinct observation) and `intersecting` / `ratio` are derived getters that\n // must re-fire on each entry, mirroring GeolocationCore's `position`.\n this._entry = entry;\n this._target.dispatchEvent(new CustomEvent(\"wcs-intersect:change\", {\n detail: entry,\n bubbles: true,\n }));\n }\n\n private _setVisible(visible: boolean): void {\n if (this._visible === visible) return;\n this._visible = visible;\n this._target.dispatchEvent(new CustomEvent(\"wcs-intersect:visible-changed\", {\n detail: visible,\n bubbles: true,\n }));\n }\n\n private _setObserving(observing: boolean): void {\n if (this._observing === observing) return;\n this._observing = observing;\n this._target.dispatchEvent(new CustomEvent(\"wcs-intersect:observing-changed\", {\n detail: observing,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing `element`. Idempotent while already observing the same\n * element with the same options. Changing the element or options tears down the\n * current observer and builds a new one (IntersectionObserver options are fixed\n * at construction, so reconfiguring requires a fresh observer).\n *\n * If IntersectionObserver is unavailable (SSR) or the options are invalid (e.g.\n * a malformed `rootMargin`, which the constructor rejects), this is a silent\n * no-op — `observing` stays false, consistent with the never-throw design of\n * the other @wcstack sensors.\n */\n observe(element: Element, options: IntersectOptions = {}): Promise<void> {\n if (this._observer && this._observed === element && this._optionsEqual(this._options, options)) {\n return this._ready;\n }\n this._teardownObserver();\n const observer = this._createObserver(options);\n if (!observer) {\n // Creation failed (unsupported environment or invalid options) *after* we\n // tore down any previous observer. If we were already observing, the\n // observation is now gone, so reflect that — otherwise `observing` would\n // keep reporting true with no live observer behind it (e.g. re-observing an\n // active target with a newly-invalid rootMargin).\n this._setObserving(false);\n return this._ready;\n }\n this._observer = observer;\n this._observed = element;\n this._options = options;\n observer.observe(element);\n this._setObserving(true);\n // SSR (§3.5): observe() returns the readiness promise. Observation establishment\n // is synchronous, so this resolves immediately.\n return this._ready;\n }\n\n /**\n * Force a fresh observation of `element`, even when it matches the currently\n * observed target+options. Unlike observe() — which is idempotent and\n * early-returns for an unchanged target+options *without* re-delivering a\n * callback — this always tears the observer down and rebuilds it, so a new\n * IntersectionObserver delivers an initial callback for the element's CURRENT\n * visibility.\n *\n * This is the way to re-arm an edge-driven consumer (e.g. infinite scroll) after\n * the layout changed without a visibility *transition*: IntersectionObserver only\n * fires on a change, so appending a short page that leaves the sentinel visible\n * yields no new callback — a bare observe() can't help (idempotent), but a\n * reobserve() re-reads the current state. Same never-throw guarantees as\n * observe(); `observing` stays true across a successful re-arm (no false blip).\n */\n reobserve(element: Element, options: IntersectOptions = {}): void {\n this._teardownObserver();\n this.observe(element, options);\n }\n\n /**\n * Stop observing `element`. A no-op if it is not the currently observed\n * element. The observer instance is torn down (single-target Core), so a later\n * observe() rebuilds it.\n */\n unobserve(element: Element): void {\n if (this._observed !== element) return;\n this._teardownObserver();\n this._setObserving(false);\n }\n\n /** Stop all observation and release the observer. */\n disconnect(): void {\n this._teardownObserver();\n this._setObserving(false);\n }\n\n /** Clear the `visible` latch so a later intersection can set it again. */\n reset(): void {\n this._setVisible(false);\n }\n\n // --- Lifecycle (§3.5) ---\n\n /**\n * `observe()` (the IntersectionObserver-style command above) establishes\n * monitoring, so there is no separate idempotent monitoring entry point — only\n * teardown. `dispose()` invalidates any in-flight observer callback (`_gen++`)\n * and releases the observer. A later observe() revives it (the Shell calls this\n * from `disconnectedCallback`).\n */\n dispose(): void {\n this._gen++;\n this.disconnect();\n }\n\n // --- Internal ---\n\n private _teardownObserver(): void {\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n this._observed = null;\n // Invalidate the torn-down observer's generation: its callback can still fire\n // once asynchronously after disconnect(), and must be dropped (§3.4).\n this._gen++;\n }\n\n private _createObserver(options: IntersectOptions): IntersectionObserver | null {\n if (typeof IntersectionObserver === \"undefined\") return null;\n // Capture the generation live at creation. The callback closure below guards\n // against deliveries from this observer after it has been superseded or\n // disposed (a stale callback fired off layout after teardown).\n const gen = this._gen;\n try {\n return new IntersectionObserver(\n (entries) => this._onIntersect(gen, entries),\n {\n root: options.root ?? null,\n rootMargin: options.rootMargin ?? \"0px\",\n threshold: options.threshold ?? 0,\n },\n );\n } catch {\n // Invalid options (e.g. a malformed rootMargin) — surface nothing and leave\n // observing false, rather than letting the constructor throw escape.\n return null;\n }\n }\n\n private _onIntersect(gen: number, entries: IntersectionObserverEntry[]): void {\n // Stale-generation guard (§3.4): drop callbacks from an observer that was torn\n // down or disposed (e.g. a delivery that landed after disconnect/reconnect).\n if (gen !== this._gen) return;\n for (const entry of entries) {\n const normalized = this._normalizeEntry(entry);\n this._setEntry(normalized);\n // Latch on the first (and any) intersecting observation; never auto-clears.\n if (normalized.isIntersecting) {\n this._setVisible(true);\n }\n }\n }\n\n private _normalizeEntry(entry: IntersectionObserverEntry): WcsIntersectEntry {\n return {\n isIntersecting: entry.isIntersecting,\n intersectionRatio: entry.intersectionRatio,\n time: entry.time,\n boundingClientRect: this._normalizeRect(entry.boundingClientRect),\n intersectionRect: this._normalizeRect(entry.intersectionRect),\n rootBounds: entry.rootBounds ? this._normalizeRect(entry.rootBounds) : null,\n target: entry.target,\n };\n }\n\n private _normalizeRect(rect: DOMRectReadOnly): WcsIntersectRect {\n return {\n x: rect.x,\n y: rect.y,\n width: rect.width,\n height: rect.height,\n top: rect.top,\n right: rect.right,\n bottom: rect.bottom,\n left: rect.left,\n };\n }\n\n private _optionsEqual(a: IntersectOptions, b: IntersectOptions): boolean {\n if ((a.root ?? null) !== (b.root ?? null)) return false;\n if ((a.rootMargin ?? \"0px\") !== (b.rootMargin ?? \"0px\")) return false;\n return this._thresholdKey(a.threshold) === this._thresholdKey(b.threshold);\n }\n\n private _thresholdKey(threshold: number | number[] | undefined): string {\n if (threshold === undefined) return \"0\";\n return Array.isArray(threshold) ? threshold.join(\",\") : String(threshold);\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { IWcBindable, IntersectOptions, WcsIntersectEntry } from \"../types.js\";\nimport { IntersectionCore } from \"../core/IntersectionCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-intersect>` — declarative IntersectionObserver.\n *\n * The `target` attribute is the single knob that decides both *what* is observed\n * and how the element renders (it never injects a layout box unless asked):\n *\n * | `target` | observes | display | use case |\n * |-----------------|-----------------------|-------------|-------------------|\n * | omitted | first element child | `contents` | lazy-load wrapper |\n * | `\"#hero\"` / sel | the matched element | `none` | scrollspy (single)|\n * | `\"self\"` | the element itself | `block` | infinite-scroll |\n *\n * `display:contents` means wrapping a child injects no box of its own (so a\n * `<wcs-intersect><img></wcs-intersect>` does not disturb a flex/grid parent);\n * only the explicit `target=\"self\"` sentinel takes a box.\n */\nexport class WcsIntersect extends HTMLElement {\n // SSR (§4.4): the first observation is established in a microtask after connect\n // (timing-and-firing-contract §23) with no async probe, but the Shell still\n // exposes connectedCallbackPromise so the state binder can await it uniformly\n // across all IO nodes before snapshotting.\n static hasConnectedCallbackPromise = true;\n // Only attributes that change *what or how* we observe trigger a re-observe.\n // `once` is intentionally excluded: it is evaluated at intersection fire time\n // (in `_onChange`), so toggling it takes effect without re-observing — and a\n // re-observe on its change would be a pure no-op (same target, same options).\n // `manual` is also excluded: it is a connect-time policy (\"don't auto-observe\n // on connect\"), not a live switch that should start/stop an active observation.\n static observedAttributes = [\"target\", \"root\", \"root-margin\", \"threshold\"];\n\n static wcBindable: IWcBindable = {\n ...IntersectionCore.wcBindable,\n properties: [\n ...IntersectionCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-intersect:trigger-changed\", semantics: \"state\" },\n ],\n // Shell-level settable surface. Each input carries its mirrored `attribute`\n // hint; `trigger` has none — it is a momentary command-property, not a\n // declarative attribute. The observe / reobserve / unobserve / disconnect /\n // reset commands are inherited from the Core via the spread above.\n inputs: [\n { name: \"target\", attribute: \"target\" },\n { name: \"root\", attribute: \"root\" },\n { name: \"rootMargin\", attribute: \"root-margin\" },\n { name: \"threshold\", attribute: \"threshold\" },\n { name: \"once\", attribute: \"once\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。<wcs-sse>/<wcs-broadcast> と同型。\n // spread でも継承されるが、Core に command 追加時の追従漏れを防ぐため明示参照する。\n commands: IntersectionCore.wcBindable.commands,\n };\n\n private _core: IntersectionCore;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n // _scheduleObserve のマイクロタスクが待っている間 true\n private _observePending = false;\n // 最後に警告した root と root-margin(値ごとに 1 回)\n private _warnedRoot: string | null = null;\n private _warnedMargin: string | null = null;\n\n constructor() {\n super();\n this._core = new IntersectionCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-intersect:visible-changed\": (d) => ({ visible: d === true }),\n \"wcs-intersect:observing-changed\": (d) => ({ observing: d === true }),\n \"wcs-intersect:change\": (d) => ({ intersecting: d.isIntersecting === true }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n // Input setters never let setAttribute stringify null / undefined (an\n // \"undefined\" target is a selector that matches nothing, which would tear the\n // observation down): `null` removes the attribute (the default), `undefined`\n // restores the attribute the element started with (wc-bindable producer\n // guidance P1; React 19 and a direct assignment deliver it, @wcstack/state\n // does not). A change of target / root / root-margin / threshold re-observes\n // through attributeChangedCallback as before.\n\n get target(): string {\n return this.getAttribute(\"target\") ?? \"\";\n }\n\n set target(value: string | null | undefined) {\n reflectAttribute(this, \"target\", value);\n }\n\n get root(): string {\n return this.getAttribute(\"root\") ?? \"\";\n }\n\n set root(value: string | null | undefined) {\n reflectAttribute(this, \"root\", value);\n }\n\n get rootMargin(): string {\n const attr = this.getAttribute(\"root-margin\");\n return attr === null || attr.trim() === \"\" ? \"0px\" : attr;\n }\n\n set rootMargin(value: string | null | undefined) {\n reflectAttribute(this, \"root-margin\", value);\n }\n\n get threshold(): string {\n return this.getAttribute(\"threshold\") ?? \"\";\n }\n\n set threshold(value: string | null | undefined) {\n reflectAttribute(this, \"threshold\", value);\n }\n\n get once(): boolean {\n return this.hasAttribute(\"once\");\n }\n\n set once(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"once\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"manual\", value);\n }\n\n // --- Core delegated getters ---\n\n get entry(): WcsIntersectEntry | null {\n return this._core.entry;\n }\n\n get intersecting(): boolean {\n return this._core.intersecting;\n }\n\n get ratio(): number {\n return this._core.ratio;\n }\n\n get visible(): boolean {\n return this._core.visible;\n }\n\n get observing(): boolean {\n return this._core.observing;\n }\n\n // --- Command property ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n // Momentary command-property: a false→true write re-runs observe(). Mirrors\n // the trigger flag on <wcs-geo> / <wcs-ws> / <wcs-sse>. Prefer the command-token\n // protocol (`command.observe: $command.start`) for state-driven observation;\n // this exists mainly for simple boolean bindings.\n const v = !!value; // normalize truthy state-bindings, like <wcs-sse>'s setter\n if (v) {\n this._trigger = true;\n // try/finally mirrors <wcs-sse>'s set trigger: observe() is never-throw\n // today, but should a synchronous throw path ever appear, the finally still\n // auto-resets _trigger (no stuck-true latch) and emits the completion notice.\n try {\n this.observe();\n } finally {\n this._trigger = false;\n // Always auto-reset to false after the observe() attempt — this is the\n // *momentary acknowledgement* that the trigger was consumed, NOT a signal\n // that observation succeeded (whether the target resolved is reflected by\n // `observing`, not by this event). Firing unconditionally keeps the bound\n // state's trigger flag from sticking at true regardless of resolution.\n // Read `observing` if you need the actual outcome.\n this.dispatchEvent(new CustomEvent(\"wcs-intersect:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n }\n\n // --- Commands ---\n\n /** Re-resolve the target/root from the DOM and (re)start observing. */\n observe(): void {\n const { element, display } = this._resolveTarget();\n // `display` is derived from the `target` *mode* (self/selector/child), not from\n // whether the selector currently matches — so it is applied unconditionally,\n // before the resolution check. A `target=\"#x\"` whose node is momentarily absent\n // still renders `display:none` (it is a selector pointer, never a box).\n this.style.display = display;\n if (!element) {\n // The target is no longer resolvable (e.g. a `target` selector whose node\n // was removed from the DOM). Tear down any stale observation so `observing`\n // does not keep reporting true against a node that is gone.\n this._core.disconnect();\n return;\n }\n this._core.observe(element, this._options());\n this._warnRefused();\n }\n\n /**\n * Force a fresh observation: re-resolve target/root from the DOM and re-observe\n * even when nothing changed. Unlike observe() (idempotent for an unchanged\n * target+options), this rebuilds the observer so a new initial callback fires for\n * the current visibility — the way to re-arm an edge-driven consumer after the\n * layout shifted without a visibility transition (e.g. infinite scroll appended a\n * short page that left this sentinel in view). Resolution/teardown rules match\n * observe(): an unresolvable target tears down any stale observation.\n */\n reobserve(): void {\n const { element, display } = this._resolveTarget();\n this.style.display = display;\n if (!element) {\n this._core.disconnect();\n return;\n }\n this._core.reobserve(element, this._options());\n this._warnRefused();\n }\n\n /**\n * The observation did not start although there is something to observe: the browser refused the options, and\n * with the threshold cleaned (_parseThreshold) only the margin is left — a length with no unit (`\"200\"`,\n * `\"0 0 900 0\"`). `observing` stays false as before (never-throw); what was silent is said once per value\n * (docs/mistake-catalogue.md, \"root-margin-unit\").\n */\n private _warnRefused(): void {\n if (this._core.observing || typeof IntersectionObserver === \"undefined\") return;\n const margin = this.rootMargin;\n if (this._warnedMargin === margin) return;\n let reason = \"\";\n try {\n // (Function.prototype: a callback that does nothing — this observer observes nothing)\n new IntersectionObserver(Function.prototype as IntersectionObserverCallback, { rootMargin: margin }).disconnect();\n return;\n } catch (error) {\n reason = (error as Error).message;\n }\n this._warnedMargin = margin;\n console.warn(\n `[@wcstack/intersection] [wcs/root-margin-unit] <${this.localName} root-margin=\"${margin}\"> is not a margin the ` +\n `browser takes (${reason}): write each length with px or %, as \"200px 0px\". Nothing is observed ` +\n `(observing stays false).`,\n );\n }\n\n // unobserve / disconnect は、予約中の自動 observe(_scheduleObserve)も取り消す。\n // 同じタスクで接続(や属性の変化)の後に呼ばれたとき、以前の同期の observe を止めたのと\n // 同じく何も監視しない(timing-and-firing-contract §23)。observe / reobserve / trigger は\n // 取り消さない — 予約の observe は同じ target・options なら no-op(冪等)。\n unobserve(): void {\n this._observePending = false;\n // Single-target Shell: \"stop observing my target\" is exactly the Core's\n // teardown. Delegate to the Core's tracked state rather than re-resolving the\n // selector, so a target that has since left the DOM can still be stopped\n // (re-resolving would yield null and silently leave the observer running).\n this._core.disconnect();\n }\n\n disconnect(): void {\n this._observePending = false;\n this._core.disconnect();\n }\n\n reset(): void {\n this._core.reset();\n }\n\n // --- Internal ---\n\n private _resolveTarget(): { element: Element | null; display: string } {\n const target = this.target;\n if (target === \"self\") {\n // Explicit sentinel: observe the element itself as a (typically zero-height)\n // marker, which requires a layout box.\n return { element: this, display: \"block\" };\n }\n if (target !== \"\") {\n // Selector pointer: observe a referenced element in place, staying invisible.\n const scope = this.getRootNode() as Document | ShadowRoot;\n // A user-authored selector can be syntactically invalid (e.g. `#`, `:::`,\n // `[data-*`), which makes querySelector throw a SyntaxError. Swallow it and\n // treat the target as unresolvable — the same \"nothing to observe\" path as a\n // selector matching no element — so a bad attribute never lets the throw\n // escape observe() → connectedCallback / attributeChangedCallback (never-throw).\n return { element: this._safeQuery(scope, target), display: \"none\" };\n }\n // Omitted: observe the first element child without injecting a box of our own.\n const child = this.firstElementChild;\n if (child) {\n return { element: child, display: \"contents\" };\n }\n // No child to wrap (e.g. used as an empty marker) — fall back to self.\n return { element: this, display: \"block\" };\n }\n\n private _resolveRoot(): Element | null {\n const root = this.root;\n if (root === \"\") return null;\n const scope = this.getRootNode() as Document | ShadowRoot;\n // Same never-throw guard as the target selector: an invalid `root` selector\n // falls back to a null root (the viewport) rather than throwing out of observe().\n // A value that matches nothing as a selector is tried as an id — the way\n // `<wcs-infinite-scroll root>` spells it (docs/seam-apps.md, town-archive).\n const found = this._safeQuery(scope, root) ?? scope.getElementById?.(root) ?? null;\n // A root given and not found was the viewport without a word: the margin was then\n // measured against the wrong box. Said once per value.\n if (!found && this._warnedRoot !== root) {\n this._warnedRoot = root;\n console.warn(\n `[@wcstack/intersection] [wcs/intersect-root] <${this.localName} root=\"${root}\">: no element matches that ` +\n `selector, and none has it as its id, so the viewport is the root.`,\n );\n }\n return found;\n }\n\n // Wrap querySelector so a syntactically invalid user-authored selector resolves\n // to null (unresolvable) instead of letting the SyntaxError escape — keeping the\n // sensor never-throw, mirroring worker/src/autoTrigger.ts's resolveText guard.\n private _safeQuery(scope: Document | ShadowRoot, selector: string): Element | null {\n try {\n return scope.querySelector(selector);\n } catch {\n return null;\n }\n }\n\n private _parseThreshold(): number | number[] {\n const raw = this.threshold.trim();\n if (raw === \"\") return 0;\n // Strict parse via Number() (unlike parseFloat, \"0.5px\" -> NaN, not 0.5); drop\n // any non-finite or out-of-range [0,1] value, matching the README note.\n // Drop empty slots first (\"0,,1\" / \"1,\") — Number(\"\") is 0, which would\n // otherwise smuggle a spurious 0 threshold past the finite/range filter.\n const nums = raw\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s !== \"\")\n .map((s) => Number(s))\n .filter((n) => Number.isFinite(n) && n >= 0 && n <= 1);\n if (nums.length === 0) return 0;\n return nums.length === 1 ? nums[0] : nums;\n }\n\n private _options(): IntersectOptions {\n return {\n root: this._resolveRoot(),\n rootMargin: this.rootMargin,\n threshold: this._parseThreshold(),\n };\n }\n\n private _onChange = (event: Event): void => {\n // `wcs-intersect:change` bubbles, so a nested `<wcs-intersect>` descendant's\n // change would otherwise reach this (ancestor) listener and let a *child's*\n // intersection tear down *our* observer. Only act on our own Core's event.\n // (This also avoids reading `.detail` off a foreign event shape.)\n if (event.target !== this) return;\n // `once`: tear down after the first intersecting observation (lazy-load idiom).\n // Gated at fire time so toggling the `once` attribute takes effect live.\n if (this.once && (event as CustomEvent).detail.isIntersecting) {\n this._core.disconnect();\n }\n };\n\n // --- Lifecycle ---\n\n // 自動 observe の判断はマイクロタスクで、そのときの manual / target / root /\n // root-margin / threshold で 1 回だけ行う(timing-and-firing-contract §23)。router は\n // 遷移で同じノードを入れ直し、新しいルートの params から state が入力を書くのは\n // マイクロタスク — その場で observe すると、前の target で observer を張り、前の\n // manual をラッチしていた(docs/seam-apps.md、shift-desk)。接続と属性の変化は\n // ここへまとまり、observer は 1 回だけ作り直す。判断の前に外れた要素は何もしない。\n private _scheduleObserve(): void {\n if (this._observePending) return;\n this._observePending = true;\n queueMicrotask(() => {\n // unobserve / disconnect が予約を取り消していれば何もしない(同じタスクで予約し直して\n // いれば、このマイクロタスクがその判断を受け持ち、後の分は何もしない)\n if (!this._observePending) return;\n this._observePending = false;\n if (this.isConnected && !this.manual) {\n this.observe();\n }\n });\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.addEventListener(\"wcs-intersect:change\", this._onChange);\n this._scheduleObserve();\n // SSR (§4.4): readiness is immediate (the observation itself is decided in the\n // microtask above, which runs before any await on this promise resumes), but\n // expose the Core's ready promise as connectedCallbackPromise so the state\n // binder can await it uniformly. `manual` defers observation but readiness is\n // still immediate.\n this._connectedCallbackPromise = this._core.ready;\n }\n\n disconnectedCallback(): void {\n this.removeEventListener(\"wcs-intersect:change\", this._onChange);\n // dispose() tears down the observer AND bumps the Core's generation so any\n // IntersectionObserver callback still in flight is dropped (§3.4 / §4.1).\n this._core.dispose();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n // Defensive same-value guard. Per spec attributeChangedCallback only fires on\n // an actual value change, so this is effectively a dead branch today — but\n // setAttribute() with an unchanged value (and some test/tooling paths) can\n // still invoke it, and re-observing on an unchanged attribute would be a\n // wasted observer rebuild. Kept intentionally; do not remove.\n if (oldValue === newValue) return;\n // Only react once connected and in automatic mode. The re-observe goes through\n // the same microtask as the connect-time one (_scheduleObserve), so the\n // autoloader upgrade case (attributeChangedCallback + connectedCallback) and\n // several inputs written in one task rebuild the observer once.\n if (!this.isConnected || this.manual) return;\n this._scheduleObserve();\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the\n * page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined\n * by another copy of the package — not its class, not a subclass of it, not the same version — warns\n * `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry\n * `\"<package>@<version>\"` under `Symbol.for(\"wcstack.package\")`; a class without it is named\n * \"another copy of <package> that does not name its version\" (an older copy, or one loaded through\n * an entry that does not stamp).\n */\n\n/** The static a class defined through this helper carries: `\"@wcstack/fetch@<version>\"`. */\nexport const PACKAGE_STAMP: unique symbol = Symbol.for(\"wcstack.package\");\n\ntype Stamped = { [PACKAGE_STAMP]?: string };\n\n/** The registries this copy warned about: one warning per package per registry. */\nconst warned = new WeakSet<CustomElementRegistry>();\n\n/**\n * Marks `cls` as defined by `pkg` (`\"@wcstack/fetch@<version>\"`). A subclass inherits the mark, and\n * `defineProperty` writes it even where a parent's mark is read-only.\n */\nexport function stampPackage(cls: CustomElementConstructor, pkg: string): void {\n Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });\n}\n\n/**\n * Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`\n * is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and\n * carries another version or none. Once per registry.\n */\nexport function warnIfAnotherCopy(\n registry: CustomElementRegistry,\n tag: string,\n existing: CustomElementConstructor,\n own: CustomElementConstructor | undefined,\n pkg: string,\n): void {\n if (own !== undefined && (existing === own || existing.prototype instanceof own)) return;\n const theirs = (existing as Stamped)[PACKAGE_STAMP];\n if (theirs === pkg || warned.has(registry)) return;\n warned.add(registry);\n const name = pkg.slice(0, pkg.lastIndexOf(\"@\"));\n console.warn(\n `[${name}] [wcs/package-twice] <${tag}> is already defined by ` +\n `${theirs ?? `another copy of ${name} that does not name its version`}; ` +\n `this copy, ${pkg}, does nothing. Load each package once.`,\n );\n}\n\n/**\n * Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class\n * with `pkg` (`\"@wcstack/fetch@<version>\"`). A tag another copy of the package defined first is left\n * as it is, with the warning above.\n */\nexport function defineElements(\n registry: CustomElementRegistry,\n pkg: string,\n definitions: readonly (readonly [tag: string, cls: CustomElementConstructor])[],\n): void {\n for (const [tag, cls] of definitions) {\n const existing = registry.get(tag);\n if (existing === undefined) {\n stampPackage(cls, pkg);\n registry.define(tag, cls);\n } else {\n warnIfAnotherCopy(registry, tag, existing, cls, pkg);\n }\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\nimport { WcsIntersect } from \"./components/Intersect.js\";\nimport { config } from \"./config.js\";\nimport { defineElements } from \"./protocol/defineElement.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n defineElements(registry, `${pkg.name}@${pkg.version}`, [\n [config.tagNames.intersect, WcsIntersect],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapIntersection(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":[],"mappings":"AAQA,MAAM,OAAO,GAAoB;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,SAAS,EAAE,eAAe;AAC3B,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IAC/D;AACA,IAAA,OAAO,KAAU;AACnB;AAEA,IAAI,YAAY,GAAmB,IAAI;AAEhC,MAAM,MAAM,GAAY,OAAkB;SAEjC,SAAS,GAAA;IACvB,IAAI,CAAC,YAAY,EAAE;QACjB,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/C;AACA,IAAA,OAAO,YAAY;AACrB;AAEA;AACA,SAAS,OAAO,CAAC,GAAW,EAAA;AAC1B,IAAA,MAAM,IAAI,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AK,SAAS,EAAE;AAC1B,YAAA,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC;AACtB,YAAA,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC;QAC3B;aAAO;YACL,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC;QACtD;IACF;AACF;;ACtEA;;;;AAIG;AACG,SAAU,kBAAkB,CAAC,QAAA,GAAkC,cAAc,EAAA;AACjF,IAAA,cAAc,CAAC,QAAQ,EAAE,CAAA,EAAG,GAAG,CAAC,IAAI,CAAA,CAAA,EAAI,GAAG,CAAC,OAAO,CAAA,CAAE,EAAE;AACrD,QAAA,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;AAC1C,KAAA,CAAC;AACJ;;ACVM,SAAU,qBAAqB,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAClG,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;IACA,kBAAkB,CAAC,QAAQ,CAAC;AAC9B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/intersection",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.24.0",
|
|
4
4
|
"description": "Declarative IntersectionObserver component for Web Components. Framework-agnostic visibility primitive via wc-bindable-protocol.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.esm.js",
|