@wcstack/fetch 1.15.0 → 1.17.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 CHANGED
@@ -8,7 +8,7 @@ HTTP リクエストとリアクティブな状態をつなぐ **I/O ノード**
8
8
  `@wcstack/state` と組み合わせると、`<wcs-fetch>` はパス契約を通じて直接バインドできます:
9
9
 
10
10
  - **入力 / コマンドサーフェス**: `url`, `body`, `trigger`
11
- - **出力ステートサーフェス**: `value`, `loading`, `error`, `status`
11
+ - **出力ステートサーフェス**: `value`, `loading`, `error`, `status`, `objectURL`
12
12
 
13
13
  つまり、非同期通信を HTML 内で宣言的に表現できます。UI レイヤーに `fetch()`、`async/await`、loading/error のグルーコードを書く必要はありません。
14
14
 
@@ -275,6 +275,7 @@ npm install @wcstack/fetch
275
275
  | `loading` | `boolean` | リクエスト実行中は `true` |
276
276
  | `error` | `WcsFetchHttpError \| Error \| null` | HTTP またはネットワークエラー |
277
277
  | `status` | `number` | HTTP ステータスコード |
278
+ | `objectURL` | `string \| null` | `response-type="blob"` のレスポンスに対する管理された object URL。それ以外は `null`。Core が新しいレスポンスごとと dispose 時に前の URL を revoke するため、ライフサイクル管理なしで `<img src>` に直接バインドできる |
278
279
 
279
280
  > **注意:** HTTP エラー時は `value` が `null` にリセットされ、`status` にエラーコードが
280
281
  > 入ります。`error` を観測せず `value` のみをバインドしている場合、リクエスト失敗時に
@@ -291,6 +292,57 @@ HTML、JS、または `@wcstack/state` バインディングからリクエス
291
292
  | `trigger` | `boolean` | 単方向の実行トリガー |
292
293
  | `manual` | `boolean` | 接続時 / URL 変更時の自動実行を無効化 |
293
294
 
295
+ ## `:state()` による CSS スタイリング
296
+
297
+ `<wcs-fetch>` は 2 つの boolean 出力ステートを
298
+ [`ElementInternals` の `CustomStateSet`](https://developer.mozilla.org/ja/docs/Web/API/CustomStateSet)
299
+ に反映します。そのため `data-wcs` バインディングやクラスの手動トグルなしに、CSS の
300
+ `:state()` 疑似クラスで直接スタイリングできます。
301
+
302
+ | ステート | on になる条件 |
303
+ |----------|----------------|
304
+ | `loading` | `wcs-fetch:loading-changed` が `true` で発火(`false` でクリア) |
305
+ | `error` | `wcs-fetch:error` が非 `null` の detail で発火(`null` でクリア) |
306
+
307
+ ```css
308
+ wcs-fetch:state(loading) ~ .spinner { display: block; }
309
+ wcs-fetch:state(loading) ~ .spinner { display: none; } /* デフォルト */
310
+
311
+ form:has(wcs-fetch:state(error)) .banner { display: block; }
312
+ ```
313
+
314
+ 属性やクラスと異なり `:state()` は要素の外部から書き込めないため、この出力ステートが
315
+ 入力と混同される心配がありません。
316
+
317
+ **対応ブラウザ**(新構文 `:state(x)`): Chrome/Edge 125+、Safari 17.4+、Firefox 126+。
318
+ 非対応の環境ではステートが一切 set されないだけです — `:state()` セレクタがマッチしなく
319
+ なりますが、`<wcs-fetch>` 自体は通常どおり動作し続けます(graceful degradation・never-throw)。
320
+
321
+ **SSR:** `:state()` は HTML にシリアライズできないため、サーバーレンダリングされた
322
+ マークアップの初期ペイントにはこれらのステートは乗りません(`@wcstack/server` は無改変)。
323
+ ハイドレーション前の見た目を制御したい場合は、代わりに `wcs-fetch:not(:defined)` と組み合わせてください。
324
+
325
+ ### デバッグ
326
+
327
+ カスタムステートは DevTools の Elements パネルには表示されず、`attachInternals()`
328
+ は同一要素に 2 回呼べないため、コンソールから直接覗く手段がありません。そのための
329
+ デバッグ専用の補助を 2 つ用意しています:
330
+
331
+ - `el.debugStates` — 現在 on になっているステート名の**スナップショット**配列
332
+ (例: `["loading"]`)。`wc-bindable` の一部ではなく(バインド対象ではない)、
333
+ 形状も契約として保証されません — デバッグ用途にのみ使ってください。
334
+ - `debug-states` 属性(opt-in・既定 OFF)は、ステート変化を要素の
335
+ `data-wcs-state-loading` / `data-wcs-state-error` 属性にミラーします。
336
+ Elements パネルを開いておけば、トグルのたびにハイライトされます:
337
+
338
+ ```html
339
+ <wcs-fetch url="/api/users" debug-states></wcs-fetch>
340
+ ```
341
+
342
+ **CSS は `data-wcs-state-*` ではなく `:state()` に書いてください。** ミラーされた
343
+ 属性は、DevTools を開いた状態でステート変化を可視化するためだけのものであり、
344
+ スタイリング用の正式なフックではありません。
345
+
294
346
  ## アーキテクチャ
295
347
 
296
348
  `@wcstack/fetch` は CSBC アーキテクチャに従います。
@@ -427,6 +479,7 @@ wcstack アプリケーションでは、**`trigger` によるステート駆動
427
479
  | `method` | `string` | `GET` | HTTP メソッド |
428
480
  | `target` | `string` | — | HTML リプレース対象の DOM 要素 id |
429
481
  | `manual` | `boolean` | `false` | 自動実行を無効化 |
482
+ | `response-type` | `"auto" \| "json" \| "text" \| "blob" \| "arrayBuffer"` | `auto` | レスポンスボディの読み取り方。`auto` は Content-Type を推測し、`blob` は加えて管理された `objectURL` を発行する。`target`(HTML リプレース)が優先される |
430
483
 
431
484
  | プロパティ | 型 | 説明 |
432
485
  |------------|------|------|
@@ -434,6 +487,8 @@ wcstack アプリケーションでは、**`trigger` によるステート駆動
434
487
  | `loading` | `boolean` | リクエスト実行中は `true` |
435
488
  | `error` | `WcsFetchHttpError \| Error \| null` | エラー情報 |
436
489
  | `status` | `number` | HTTP ステータスコード |
490
+ | `objectURL` | `string \| null` | `response-type="blob"` のレスポンスに対する管理された object URL。それ以外は `null` |
491
+ | `responseType` | `"auto" \| "json" \| "text" \| "blob" \| "arrayBuffer"` | レスポンスボディの解釈(`response-type` 属性を背後に持つ) |
437
492
  | `body` | `any` | リクエストボディ(`fetch()` 後に `null` にリセット) |
438
493
  | `trigger` | `boolean` | `true` を設定すると fetch を実行 |
439
494
  | `manual` | `boolean` | 明示的実行モード |
@@ -480,7 +535,7 @@ wcstack アプリケーションでは、**`trigger` によるステート駆動
480
535
 
481
536
  宣言は wc-bindable インターフェースモデルの全体に従い、3 つの独立したサーフェスを持ちます:
482
537
 
483
- - **`properties`** — `bind()` がサブスクライブする観測可能な出力(`value`, `loading`, `error`, `status`、および Shell の `trigger`)
538
+ - **`properties`** — `bind()` がサブスクライブする観測可能な出力(`value`, `loading`, `error`, `status`, `objectURL`、および Shell の `trigger`)
484
539
  - **`inputs`** — 設定可能なサーフェス(`url`, `method`, …)。ツールやコード生成、リモートプロキシが読み取る宣言的メタデータ
485
540
  - **`commands`** — 呼び出し可能なメソッド(`fetch`, `abort`)。`@wcstack/state` のようなバインディングシステムが名前で呼び出せる
486
541
 
@@ -501,6 +556,8 @@ static wcBindable = {
501
556
  { name: "error", event: "wcs-fetch:error" },
502
557
  { name: "status", event: "wcs-fetch:response",
503
558
  getter: (e) => e.detail.status },
559
+ { name: "objectURL", event: "wcs-fetch:response",
560
+ getter: (e) => e.detail.objectURL },
504
561
  ],
505
562
  inputs: [
506
563
  { name: "url" },
@@ -532,12 +589,13 @@ static wcBindable = {
532
589
  { name: "target" },
533
590
  { name: "manual" },
534
591
  { name: "body" },
592
+ { name: "responseType" },
535
593
  { name: "trigger" },
536
594
  ],
537
595
  };
538
596
  ```
539
597
 
540
- Shell の inputs は意図的に `attribute` ヒントを持ちません。各セッター(`url`, `method`, `target`, `manual`)はすでに対応する属性へ反映されるため、`inputs[].attribute` をミラーするバインディングシステムでは属性が二重に設定されてしまうからです。
598
+ Shell の inputs は意図的に `attribute` ヒントを持ちません。各セッター(`url`, `method`, `target`, `manual`, `responseType`)はすでに対応する属性へ反映されるため、`inputs[].attribute` をミラーするバインディングシステムでは属性が二重に設定されてしまうからです。
541
599
 
542
600
  ## TypeScript 型
543
601
 
@@ -555,13 +613,14 @@ interface WcsFetchHttpError {
555
613
  body: string;
556
614
  }
557
615
 
558
- // Core(ヘッドレス)— 4 つの非同期状態プロパティ
616
+ // Core(ヘッドレス)— 5 つの非同期状態プロパティ
559
617
  // T のデフォルトは unknown。型引数を渡すと value が型付けされる
560
618
  interface WcsFetchCoreValues<T = unknown> {
561
619
  value: T;
562
620
  loading: boolean;
563
621
  error: WcsFetchHttpError | Error | null;
564
622
  status: number;
623
+ objectURL: string | null; // responseType:"blob" のレスポンスに対する管理された object URL。それ以外は null
565
624
  }
566
625
 
567
626
  // Shell(<wcs-fetch>)— Core を拡張し trigger を追加
@@ -716,8 +775,9 @@ bootstrapFetch({
716
775
 
717
776
  ## 設計メモ
718
777
 
719
- - `value`、`loading`、`error`、`status` は **出力ステート**
720
- - `url`、`body`、`trigger` は **入力 / コマンドサーフェス**
778
+ - `value`、`loading`、`error`、`status`、`objectURL` は **出力ステート**
779
+ - `url`、`body`、`response-type`、`trigger` は **入力 / コマンドサーフェス**
780
+ - `response-type`(既定 `auto`)はレスポンスボディの読み取り方を選ぶ。`blob` は加えて管理された `objectURL`(新しいレスポンスごと / dispose 時に revoke)を発行する。`target`(HTML リプレースモード)が優先される
721
781
  - `trigger` は意図的に単方向: `true` を書き込むと実行、リセットで完了を通知。`url` が空のまま `true` を書き込んだ場合は黙って無視される(fetch なし・イベントなし・フラグは `false` のまま)
722
782
  - HTTP エラー時(status >= 400)は `value` が `null` にリセットされ、`status` にエラーコードが入る — `value` のみのバインドでは直前の値が消えるため、失敗検知には `error` をバインドする
723
783
  - ネットワークエラー時(HTTP レスポンスなし — DNS 失敗・オフライン・CORS など)は `value` が `null`、`status` が `0` にリセットされ、`error` に投げられた `Error` が入る。HTTP エラーと同様、直前の成功時の value/status は残らない
package/README.md CHANGED
@@ -275,6 +275,7 @@ These properties represent the result of the current request and are the main ob
275
275
  | `loading` | `boolean` | `true` while a request is in flight |
276
276
  | `error` | `WcsFetchHttpError \| Error \| null` | HTTP or network error |
277
277
  | `status` | `number` | HTTP status code |
278
+ | `objectURL` | `string \| null` | Managed object URL for a `response-type="blob"` response; `null` otherwise. The Core revokes the previous URL on each new response and on dispose, so it can be bound straight into `<img src>` |
278
279
 
279
280
  > **Note:** On an HTTP error, `value` is reset to `null` and `status` carries the
280
281
  > error code. If you bind only `value` (without observing `error`), the previous
@@ -292,6 +293,59 @@ These properties control request execution from HTML, JS, or `@wcstack/state` bi
292
293
  | `trigger` | `boolean` | One-way execution trigger |
293
294
  | `manual` | `boolean` | Disables auto-fetch on connect / URL change |
294
295
 
296
+ ## CSS styling with `:state()`
297
+
298
+ `<wcs-fetch>` reflects two boolean output states onto its
299
+ [`ElementInternals` `CustomStateSet`](https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet),
300
+ so you can style it directly from CSS with the `:state()` pseudo-class — no
301
+ `data-wcs` binding or extra class toggling required.
302
+
303
+ | State | On when |
304
+ |-------|---------|
305
+ | `loading` | `wcs-fetch:loading-changed` fires with `true` (cleared on `false`) |
306
+ | `error` | `wcs-fetch:error` fires with a non-`null` detail (cleared on `null`) |
307
+
308
+ ```css
309
+ wcs-fetch:state(loading) ~ .spinner { display: block; }
310
+ wcs-fetch:state(loading) ~ .spinner { display: none; } /* default */
311
+
312
+ form:has(wcs-fetch:state(error)) .banner { display: block; }
313
+ ```
314
+
315
+ Unlike attributes or classes, `:state()` cannot be written from outside the
316
+ element, so there is no risk of confusing this output state with an input.
317
+
318
+ **Browser support** (`:state(x)` syntax): Chrome/Edge 125+, Safari 17.4+,
319
+ Firefox 126+. In older browsers the states are simply never set — `:state()`
320
+ selectors never match, but `<wcs-fetch>` itself keeps working normally
321
+ (graceful degradation, never-throw).
322
+
323
+ **SSR**: `:state()` cannot be serialized into HTML, so server-rendered markup
324
+ never carries these states on first paint (`@wcstack/server` is unaffected).
325
+ If you need to style the pre-hydration gap, pair your rule with
326
+ `wcs-fetch:not(:defined)` instead.
327
+
328
+ ### Debugging
329
+
330
+ Custom states are invisible in DevTools' Elements panel and `attachInternals()`
331
+ cannot be called twice, so there is no console way to inspect them directly.
332
+ Two debug-only aids are provided for that:
333
+
334
+ - `el.debugStates` — a **snapshot** array of the currently-on state names
335
+ (e.g. `["loading"]`). It is not part of `wc-bindable` (not a bind target)
336
+ and its shape is not a guaranteed contract — use it for debugging only.
337
+ - The `debug-states` attribute (opt-in, default off) mirrors state changes
338
+ onto `data-wcs-state-loading` / `data-wcs-state-error` attributes on the
339
+ element, so the Elements panel highlights them as they toggle:
340
+
341
+ ```html
342
+ <wcs-fetch url="/api/users" debug-states></wcs-fetch>
343
+ ```
344
+
345
+ **Write your CSS against `:state()`, not `data-wcs-state-*`.** The mirrored
346
+ attributes exist purely to make state changes visible while debugging with
347
+ DevTools open; they are not a supported styling hook.
348
+
295
349
  ## Architecture
296
350
 
297
351
  `@wcstack/fetch` follows the CSBC architecture.
@@ -432,6 +486,7 @@ In wcstack applications, **state-driven triggering via `trigger`** is usually th
432
486
  | `method` | `string` | `GET` | HTTP method |
433
487
  | `target` | `string` | — | DOM element id for HTML replace mode |
434
488
  | `manual` | `boolean` | `false` | Disable auto-fetch |
489
+ | `response-type` | `"auto" \| "json" \| "text" \| "blob" \| "arrayBuffer"` | `auto` | How to read the response body. `auto` sniffs Content-Type; `blob` additionally publishes a managed `objectURL`. `target` (HTML-replace) overrides this |
435
490
 
436
491
  | Property | Type | Description |
437
492
  |----------|------|-------------|
@@ -439,6 +494,8 @@ In wcstack applications, **state-driven triggering via `trigger`** is usually th
439
494
  | `loading` | `boolean` | `true` while request is in flight |
440
495
  | `error` | `WcsFetchHttpError \| Error \| null` | Error info |
441
496
  | `status` | `number` | HTTP status code |
497
+ | `objectURL` | `string \| null` | Managed object URL for a `response-type="blob"` response; `null` otherwise |
498
+ | `responseType` | `"auto" \| "json" \| "text" \| "blob" \| "arrayBuffer"` | Response body interpretation (backs the `response-type` attribute) |
442
499
  | `body` | `any` | Request body (resets to `null` after `fetch()`) |
443
500
  | `trigger` | `boolean` | Set to `true` to execute fetch |
444
501
  | `manual` | `boolean` | Explicit execution mode |
@@ -485,7 +542,7 @@ Both `FetchCore` and `<wcs-fetch>` declare `wc-bindable-protocol` compliance, ma
485
542
 
486
543
  The declaration follows the full wc-bindable interface model — three independent surfaces:
487
544
 
488
- - **`properties`** — observable outputs that `bind()` subscribes to (`value`, `loading`, `error`, `status`, and the Shell's `trigger`)
545
+ - **`properties`** — observable outputs that `bind()` subscribes to (`value`, `loading`, `error`, `status`, `objectURL`, and the Shell's `trigger`)
489
546
  - **`inputs`** — the settable surface (`url`, `method`, …); declarative metadata that tooling, codegen, and remote proxying read
490
547
  - **`commands`** — invocable methods (`fetch`, `abort`); a binding system such as `@wcstack/state` can invoke them by name
491
548
 
@@ -506,6 +563,8 @@ static wcBindable = {
506
563
  { name: "error", event: "wcs-fetch:error" },
507
564
  { name: "status", event: "wcs-fetch:response",
508
565
  getter: (e) => e.detail.status },
566
+ { name: "objectURL", event: "wcs-fetch:response",
567
+ getter: (e) => e.detail.objectURL },
509
568
  ],
510
569
  inputs: [
511
570
  { name: "url" },
@@ -537,12 +596,13 @@ static wcBindable = {
537
596
  { name: "target" },
538
597
  { name: "manual" },
539
598
  { name: "body" },
599
+ { name: "responseType" },
540
600
  { name: "trigger" },
541
601
  ],
542
602
  };
543
603
  ```
544
604
 
545
- The Shell's inputs intentionally carry no `attribute` hint: each setter (`url`, `method`, `target`, `manual`) already reflects to its attribute, so a binding system that mirrors `inputs[].attribute` would set the attribute twice.
605
+ The Shell's inputs intentionally carry no `attribute` hint: each setter (`url`, `method`, `target`, `manual`, `responseType`) already reflects to its attribute, so a binding system that mirrors `inputs[].attribute` would set the attribute twice.
546
606
 
547
607
  ## TypeScript Types
548
608
 
@@ -560,13 +620,14 @@ interface WcsFetchHttpError {
560
620
  body: string;
561
621
  }
562
622
 
563
- // Core (headless) — 4 async state properties
623
+ // Core (headless) — 5 async state properties
564
624
  // T defaults to unknown; pass a type argument for typed `value`
565
625
  interface WcsFetchCoreValues<T = unknown> {
566
626
  value: T;
567
627
  loading: boolean;
568
628
  error: WcsFetchHttpError | Error | null;
569
629
  status: number;
630
+ objectURL: string | null; // managed object URL for a responseType:"blob" response, else null
570
631
  }
571
632
 
572
633
  // Shell (<wcs-fetch>) — extends Core with trigger
@@ -721,8 +782,9 @@ bootstrapFetch({
721
782
 
722
783
  ## Design Notes
723
784
 
724
- - `value`, `loading`, `error`, and `status` are **output state**
725
- - `url`, `body`, and `trigger` are **input / command surface**
785
+ - `value`, `loading`, `error`, `status`, and `objectURL` are **output state**
786
+ - `url`, `body`, `response-type`, and `trigger` are **input / command surface**
787
+ - `response-type` (default `auto`) selects how the response body is read; `blob` additionally publishes a managed `objectURL` (revoked on each new response / dispose). `target` (HTML-replace mode) overrides it
726
788
  - `trigger` is intentionally one-way: writing `true` executes, reset emits completion. Writing `true` while `url` is empty is silently ignored (no fetch, no event, flag stays `false`)
727
789
  - on an HTTP error (status >= 400), `value` is reset to `null` while `status` carries the error code — a `value`-only binding loses its previous value, so bind `error` to detect failures
728
790
  - on a network error (no HTTP response — DNS failure, offline, CORS, etc.), `value` is reset to `null` and `status` to `0`; `error` holds the thrown `Error`. Like HTTP errors, a previous successful value/status does not linger
package/dist/index.d.ts CHANGED
@@ -51,7 +51,7 @@ interface WcsFetchHttpError {
51
51
  body: string;
52
52
  }
53
53
  /**
54
- * Value types for FetchCore (headless) — the 4 async state properties.
54
+ * Value types for FetchCore (headless) — the 5 async state properties.
55
55
  * Use with `bind()` from `a wc-bindable binding core` for compile-time type checking.
56
56
  *
57
57
  * @example
@@ -142,7 +142,11 @@ declare class Fetch extends HTMLElement {
142
142
  private _autoPending;
143
143
  private _connectResolve;
144
144
  private _lastFetchedUrl;
145
+ private _internals;
145
146
  constructor();
147
+ get debugStates(): string[];
148
+ private _initInternals;
149
+ private _wireStates;
146
150
  get url(): string;
147
151
  set url(value: string | null);
148
152
  get method(): string;
package/dist/index.esm.js CHANGED
@@ -134,6 +134,13 @@ class FetchCore extends EventTarget {
134
134
  }));
135
135
  }
136
136
  _setError(error) {
137
+ // Same-value guard (async-io-node-guidelines.md §3.3). `error` is state-ish,
138
+ // so suppressing redundant null→null dispatches (every fetch start clears a
139
+ // usually-already-null error) avoids a spurious wcs-fetch:error per successful
140
+ // request. Reference identity is sufficient: each failure builds a fresh
141
+ // object, and the clear path always passes null.
142
+ if (this._error === error)
143
+ return;
137
144
  this._error = error;
138
145
  this._target.dispatchEvent(new CustomEvent("wcs-fetch:error", {
139
146
  detail: error,
@@ -392,10 +399,69 @@ class Fetch extends HTMLElement {
392
399
  _autoPending = false;
393
400
  _connectResolve = null;
394
401
  _lastFetchedUrl = null;
402
+ _internals = null;
395
403
  constructor() {
396
404
  super();
405
+ // State reflection is wired BEFORE the Core is constructed (canonical
406
+ // order): a Core that dispatches synchronously from its constructor
407
+ // (e.g. speech's unsupported-changed) would otherwise fire before the
408
+ // listeners exist. FetchCore doesn't do that, so this is equivalent here,
409
+ // but every Shell keeps the same order.
410
+ this._internals = this._initInternals();
411
+ this._wireStates({
412
+ "wcs-fetch:loading-changed": (d) => ({ loading: d === true }),
413
+ "wcs-fetch:error": (d) => ({ error: d != null }),
414
+ });
397
415
  this._core = new FetchCore(this);
398
416
  }
417
+ // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of
418
+ // wc-bindable (not a bind target); see README "CSS styling with :state()".
419
+ // MUST NOT return the live CustomStateSet (that would let callers write
420
+ // states from outside, defeating the point of :state() being read-only).
421
+ get debugStates() {
422
+ return this._internals ? [...this._internals.states] : [];
423
+ }
424
+ _initInternals() {
425
+ // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent
426
+ // in happy-dom / older environments, and pre-125 Chromium rejects
427
+ // non-dashed state names from states.add() (probed and discarded here).
428
+ // Either case silently disables reflection — the component still works,
429
+ // it just doesn't expose :state() selectors.
430
+ try {
431
+ if (typeof this.attachInternals !== "function")
432
+ return null;
433
+ const internals = this.attachInternals();
434
+ internals.states.add("wcs-probe");
435
+ internals.states.delete("wcs-probe");
436
+ return internals;
437
+ }
438
+ catch {
439
+ return null;
440
+ }
441
+ }
442
+ _wireStates(map) {
443
+ if (this._internals === null)
444
+ return;
445
+ const states = this._internals.states;
446
+ for (const [event, toStates] of Object.entries(map)) {
447
+ this.addEventListener(event, (e) => {
448
+ const debug = this.hasAttribute("debug-states");
449
+ for (const [name, on] of Object.entries(toStates(e.detail))) {
450
+ try {
451
+ if (on) {
452
+ states.add(name);
453
+ }
454
+ else {
455
+ states.delete(name);
456
+ }
457
+ }
458
+ catch { /* never-throw */ }
459
+ if (debug)
460
+ this.toggleAttribute(`data-wcs-state-${name}`, on);
461
+ }
462
+ });
463
+ }
464
+ }
399
465
  // Input setters normalize null/undefined to attribute removal instead of
400
466
  // letting setAttribute stringify them ("undefined" url would auto-fetch
401
467
  // /undefined, "undefined" method is an invalid HTTP method). The binder
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/FetchCore.ts","../src/autoTrigger.ts","../src/components/Fetch.ts","../src/components/FetchHeader.ts","../src/components/FetchBody.ts","../src/components/InfiniteScroll.ts","../src/registerComponents.ts","../src/bootstrapFetch.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n fetch: string;\n fetchHeader: string;\n fetchBody: string;\n infiniteScroll: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-fetchtarget\",\n tagNames: {\n fetch: \"wcs-fetch\",\n fetchHeader: \"wcs-fetch-header\",\n fetchBody: \"wcs-fetch-body\",\n infiniteScroll: \"wcs-infinite-scroll\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import { IWcBindable } from \"../types.js\";\n\nexport type FetchResponseType = \"auto\" | \"json\" | \"text\" | \"blob\" | \"arrayBuffer\";\n\nexport interface FetchRequestOptions {\n method?: string;\n headers?: Record<string, string>;\n body?: BodyInit | null;\n contentType?: string | null;\n forceText?: boolean;\n // How to read the response body. \"auto\" (default) sniffs Content-Type (JSON or\n // text). \"blob\"/\"arrayBuffer\" enable binary downloads; \"blob\" additionally\n // publishes a managed `objectURL`. `forceText` (HTML-replace mode) takes\n // priority over this.\n responseType?: FetchResponseType;\n}\n\nexport class FetchCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"value\", event: \"wcs-fetch:response\", getter: (e: Event) => (e as CustomEvent).detail.value },\n { name: \"loading\", event: \"wcs-fetch:loading-changed\" },\n { name: \"error\", event: \"wcs-fetch:error\" },\n { name: \"status\", event: \"wcs-fetch:response\", getter: (e: Event) => (e as CustomEvent).detail.status },\n // Managed object URL for a `responseType: \"blob\"` response (null otherwise).\n // The Core revokes the previous URL on each new response and on dispose, so\n // a consumer can bind it straight into <img src> without lifecycle glue.\n { name: \"objectURL\", event: \"wcs-fetch:response\", getter: (e: Event) => (e as CustomEvent).detail.objectURL },\n ],\n inputs: [\n { name: \"url\" },\n { name: \"method\" },\n ],\n commands: [\n { name: \"fetch\", async: true },\n { name: \"abort\" },\n ],\n };\n\n private _target: EventTarget;\n private _value: any = null;\n private _loading: boolean = false;\n private _error: any = null;\n private _status: number = 0;\n private _objectURL: string | null = null;\n private _abortController: AbortController | null = null;\n private _promise: Promise<any> = Promise.resolve(null);\n // Generation guard (§3.4): bumped on dispose() (and each fetch start). An\n // in-flight request that settles after dispose / a superseding start has a\n // stale `gen` and MUST NOT write state to a torn-down element. A boolean flag\n // is insufficient (dispose→observe would let stale work slip through).\n private _gen = 0;\n // SSR (§3.8): no asynchronous probe to await, 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 get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). Fetch is command-driven with no subscription to\n // establish, so observe() is an idempotent no-op that resolves once ready;\n // dispose() invalidates any in-flight request and aborts it.\n observe(): Promise<void> {\n return this._ready;\n }\n\n dispose(): void {\n this._gen++;\n this.abort();\n // Release any outstanding blob object URL on teardown (the other revoke point\n // is _setResponse, which drops the previous URL when a new response arrives).\n if (this._objectURL !== null) {\n this._revokeObjectURL(this._objectURL);\n this._objectURL = null;\n }\n }\n\n get value(): any {\n return this._value;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): any {\n return this._error;\n }\n\n get status(): number {\n return this._status;\n }\n\n get objectURL(): string | null {\n return this._objectURL;\n }\n\n get promise(): Promise<any> {\n return this._promise;\n }\n\n private _setLoading(loading: boolean): void {\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-fetch:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: any): void {\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-fetch:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _setResponse(value: any, status: number, objectURL: string | null = null): void {\n // Revoke the previous blob object URL before replacing it. Any new response\n // (success, HTTP error, or network error all funnel through here) supersedes\n // the prior one, so the old URL is no longer needed; this plus dispose()\n // revocation keeps blob downloads leak-free.\n if (this._objectURL !== null) {\n this._revokeObjectURL(this._objectURL);\n }\n this._objectURL = objectURL;\n this._value = value;\n this._status = status;\n this._target.dispatchEvent(new CustomEvent(\"wcs-fetch:response\", {\n detail: { value, status, objectURL },\n bubbles: true,\n }));\n }\n\n // Object URL lifecycle for responseType: \"blob\". The Core owns the blob's\n // object URL (mirrors RecorderCore) so a consumer can bind `objectURL` straight\n // into <img src>/<a href> without managing createObjectURL/revokeObjectURL. Both\n // helpers tolerate environments without URL.createObjectURL (SSR / headless).\n private _createObjectURL(blob: Blob): string | null {\n if (typeof URL !== \"undefined\" && typeof URL.createObjectURL === \"function\") {\n return URL.createObjectURL(blob);\n }\n return null;\n }\n\n private _revokeObjectURL(url: string): void {\n if (typeof URL !== \"undefined\" && typeof URL.revokeObjectURL === \"function\") {\n URL.revokeObjectURL(url);\n }\n }\n\n abort(): void {\n if (this._abortController) {\n this._abortController.abort();\n this._abortController = null;\n }\n }\n\n async fetch(url: string, options: FetchRequestOptions = {}): Promise<any> {\n // never-throw (§3.6): 引数バリデーション失敗は例外ではなく error プロパティに\n // 流し、サニタイズ値(null)を返す。command-token 経路からの呼び出しが unhandled\n // rejection にならず、「fetch() は全終了ケースで resolve」契約とも整合する。\n if (!url) {\n this._setError({ message: \"url attribute is required.\" });\n return null;\n }\n\n const p = this._doFetch(url, options);\n this._promise = p;\n return p;\n }\n\n private async _doFetch(url: string, options: FetchRequestOptions): Promise<any> {\n // 進行中のリクエストをキャンセル\n this.abort();\n\n // Hold the controller in a local so the finally block (which can run after a\n // subsequent fetch has already replaced this._abortController) only clears the\n // field when it still owns it. Without the identity check, an aborted earlier\n // request's finally would null out the controller of the request that superseded\n // it, leaving the later request un-abortable.\n const ac = new AbortController();\n this._abortController = ac;\n const { signal } = ac;\n\n // Capture the generation at async start (§3.4). A completion that runs after\n // dispose() (which bumps _gen) is stale and must not write state.\n const gen = ++this._gen;\n\n this._setLoading(true);\n this._setError(null);\n\n const {\n method = \"GET\",\n body = null,\n contentType = null,\n forceText = false,\n responseType = \"auto\",\n } = options;\n\n // Copy the caller's headers so the contentType injection below never mutates\n // the object passed in by a headless consumer (the Shell already builds a\n // fresh object, but direct FetchCore users may reuse theirs).\n const headers: Record<string, string> = { ...(options.headers ?? {}) };\n\n try {\n if (contentType && !headers[\"Content-Type\"]) {\n headers[\"Content-Type\"] = contentType;\n }\n\n const requestInit: RequestInit = {\n method,\n headers,\n signal,\n };\n\n if (method !== \"GET\" && method !== \"HEAD\" && body !== null) {\n requestInit.body = body;\n }\n\n const response = await globalThis.fetch(url, requestInit);\n\n // A stale generation means dispose() (or a superseding fetch) ran while the\n // request was in flight. Drop the result without touching torn-down state.\n if (gen !== this._gen) {\n return null;\n }\n\n if (!response.ok) {\n const errorBody = await response.text().catch(() => \"\");\n const error = { status: response.status, statusText: response.statusText, body: errorBody };\n this._setError(error);\n // Notify `status` observers on HTTP errors too. The `status` property is\n // surfaced via the `wcs-fetch:response` event (getter reads detail.status),\n // so without dispatching it here a bind() subscriber would never see the\n // error status (404, 500, ...). `value` is reset to null on error.\n this._setResponse(null, response.status);\n this._setLoading(false);\n return null;\n }\n\n if (method === \"HEAD\") {\n // HEAD responses carry no body by spec. Reading it as JSON would throw a\n // parse error on the empty body (and end up as a spurious `error`), so skip\n // body reading entirely and surface only the status with a null value.\n this._setResponse(null, response.status);\n } else if (forceText) {\n // HTML-replace mode (the Shell sets forceText when `target` is present)\n // always reads text and takes priority over responseType.\n const text = await response.text();\n this._setResponse(text, response.status);\n } else if (responseType === \"blob\") {\n const blob = await response.blob();\n // Publish a managed object URL alongside the Blob so consumers can bind it\n // directly into <img src> etc.\n this._setResponse(blob, response.status, this._createObjectURL(blob));\n } else if (responseType === \"arrayBuffer\") {\n const buffer = await response.arrayBuffer();\n this._setResponse(buffer, response.status);\n } else if (responseType === \"text\") {\n const text = await response.text();\n this._setResponse(text, response.status);\n } else if (responseType === \"json\") {\n const data = await response.json();\n this._setResponse(data, response.status);\n } else {\n // \"auto\" (default): sniff Content-Type — JSON when it says so, else text.\n const responseContentType = response.headers.get(\"Content-Type\") || \"\";\n if (responseContentType.includes(\"application/json\")) {\n const data = await response.json();\n this._setResponse(data, response.status);\n } else {\n const text = await response.text();\n this._setResponse(text, response.status);\n }\n }\n\n this._setLoading(false);\n return this._value;\n } catch (e: any) {\n // Stale completion (dispose / superseding fetch ran during a later await\n // such as response.json()). Drop the result without writing state.\n if (gen !== this._gen) {\n return null;\n }\n if (e.name === \"AbortError\") {\n // A matching generation means this is an explicit abort() of the current\n // request (a superseding fetch bumps _gen and is caught by the stale guard\n // above; dispose() likewise bumps _gen). Explicit abort clears loading so\n // observers leave the in-flight state.\n this._setLoading(false);\n return null;\n }\n this._setError(e);\n // Reset value/status on network errors too, mirroring the HTTP-error path\n // (`_setResponse(null, response.status)`). Without this, a prior successful\n // request's value/status would linger while `error` is non-null, showing\n // observers an inconsistent state (e.g. status=200 alongside a network\n // error). status=0 is the web-platform convention for \"no HTTP response\"\n // (matches XMLHttpRequest.status on network failure) and the initial value.\n this._setResponse(null, 0);\n this._setLoading(false);\n return null;\n } finally {\n if (this._abortController === ac) {\n this._abortController = null;\n }\n }\n }\n}\n","import { config } from \"./config.js\";\nimport type { Fetch } from \"./components/Fetch.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const fetchId = triggerElement.getAttribute(config.triggerAttribute);\n if (!fetchId) return;\n\n // Resolve the registered constructor at call time instead of importing Fetch\n // as a value. The value import created a components/Fetch.ts ⇄ autoTrigger.ts\n // cycle (Fetch.connectedCallback() calls registerAutoTrigger()). instanceof\n // against the customElements registry keeps the exact same identity guarantee\n // — only the registered <wcs-fetch> class matches — without the import cycle.\n const FetchCtor = customElements.get(config.tagNames.fetch);\n const el = document.getElementById(fetchId);\n if (!FetchCtor || !(el instanceof FetchCtor)) return;\n const fetchElement = el as Fetch;\n\n // Skip when the target has no url. fetch() is fire-and-forget here (its returned\n // promise is intentionally not awaited), and FetchCore.fetch() rejects synchronously\n // on an empty url. Without this guard that rejection would surface as an unhandled\n // promise rejection. Treat a url-less target as \"nothing to do\", consistent with the\n // other early returns above.\n if (!fetchElement.url) return;\n\n // Suppress the element's default action so a fetch can fire without navigating.\n // Intentional: do not attach data-fetchtarget to an element whose default action\n // you also want (real <a href> link, form-submit button) — it will be cancelled.\n // See README \"Optional DOM Triggering\".\n event.preventDefault();\n fetchElement.fetch();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport { IWcBindable } from \"../types.js\";\nimport { FetchCore, FetchResponseType } from \"../core/FetchCore.js\";\nimport { FetchHeader } from \"./FetchHeader.js\";\nimport { FetchBody } from \"./FetchBody.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\nexport class Fetch extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...FetchCore.wcBindable,\n properties: [\n ...FetchCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-fetch:trigger-changed\" },\n ],\n // Shell-level input surface. The Core declares only the portable `url` / `method`;\n // the Shell adds the DOM-driven settable surface. No `attribute` hints are given:\n // these setters already reflect to their attributes themselves, so a binding system\n // that mirrors inputs[].attribute would set the attribute twice. `commands`\n // (fetch / abort) are inherited unchanged from the Core via the spread above.\n inputs: [\n { name: \"url\" },\n { name: \"method\" },\n { name: \"target\" },\n { name: \"manual\" },\n { name: \"body\" },\n { name: \"responseType\" },\n { name: \"trigger\" },\n ],\n };\n static get observedAttributes(): string[] { return [\"url\"]; }\n\n private _core: FetchCore;\n private _body: any = null;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n // Auto-fetch coalescing state (see _scheduleAutoFetch).\n private _autoPending: boolean = false;\n private _connectResolve: (() => void) | null = null;\n private _lastFetchedUrl: string | null = null;\n\n constructor() {\n super();\n this._core = new FetchCore(this);\n }\n\n // Input setters normalize null/undefined to attribute removal instead of\n // letting setAttribute stringify them (\"undefined\" url would auto-fetch\n // /undefined, \"undefined\" method is an invalid HTTP method). The binder\n // already skips undefined writes; this guards direct JS assignment too.\n get url(): string {\n return this.getAttribute(\"url\") || \"\";\n }\n\n set url(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"url\");\n } else {\n this.setAttribute(\"url\", value);\n }\n }\n\n get method(): string {\n return (this.getAttribute(\"method\") || \"GET\").toUpperCase();\n }\n\n set method(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"method\");\n } else {\n this.setAttribute(\"method\", value);\n }\n }\n\n get target(): string | null {\n return this.getAttribute(\"target\");\n }\n\n set target(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"target\");\n } else {\n this.setAttribute(\"target\", value);\n }\n }\n\n // Response body interpretation. Backed by the `response-type` attribute so it is\n // settable from HTML, JS, or a binding. An unknown value falls through to the\n // Core's \"auto\" branch. `target` (HTML-replace mode) overrides this.\n get responseType(): FetchResponseType {\n return (this.getAttribute(\"response-type\") as FetchResponseType) || \"auto\";\n }\n\n set responseType(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"response-type\");\n } else {\n this.setAttribute(\"response-type\", value);\n }\n }\n\n get value(): any {\n return this._core.value;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get status(): number {\n return this._core.status;\n }\n\n get objectURL(): string | null {\n return this._core.objectURL;\n }\n\n get promise(): Promise<any> {\n return this._core.promise;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n if (value) {\n this.setAttribute(\"manual\", \"\");\n } else {\n this.removeAttribute(\"manual\");\n }\n }\n\n get body(): any {\n return this._body;\n }\n\n set body(value: any) {\n // Normalize undefined to null: _collectBody treats \"!== null\" as \"body was\n // provided\", so a raw undefined would serialize as a JSON request body.\n this._body = value ?? null;\n }\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n const v = !!value;\n if (v) {\n // Skip when url is empty. fetch() is fire-and-forget here (its returned\n // promise is intentionally only chained with .finally() to reset the flag,\n // never .catch()'d), and FetchCore.fetch() rejects on an empty url. Without\n // this guard that rejection — re-thrown by .finally() — surfaces as an\n // unhandled promise rejection. Mirrors the url-less guard in autoTrigger.\n //\n // Leave `_trigger` false (do not set it) and emit no event: nothing ran, so\n // surfacing a `wcs-fetch:trigger-changed` \"completion\" would lie to observers.\n // Keeping the flag false also avoids stalling — once url is provided, writing\n // `true` again is a real false→true transition that triggers the fetch.\n if (!this.url) return;\n this._trigger = true;\n this.fetch().finally(() => {\n this._trigger = false;\n this.dispatchEvent(new CustomEvent(\"wcs-fetch:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n });\n }\n }\n\n private _collectHeaders(): Record<string, string> {\n const headers: Record<string, string> = {};\n const headerElements = this.querySelectorAll<FetchHeader>(config.tagNames.fetchHeader);\n for (const el of headerElements) {\n const name = el.headerName;\n const value = el.headerValue;\n if (name) {\n headers[name] = value;\n }\n }\n return headers;\n }\n\n // fetch がネイティブに扱える BodyInit か判定する。これらは JSON.stringify せず\n // 素通しし、Content-Type をブラウザに委ねる (FormData の multipart boundary、\n // Blob の type、URLSearchParams の application/x-www-form-urlencoded を自動付与\n // させるため、_collectBody は contentType に null を返す)。ReadableStream は\n // RequestInit.duplex: 'half' を要するため初版では対象外とし、従来どおり扱う。\n private _isNativeBodyInit(value: unknown): value is BodyInit {\n return value instanceof Blob // File は Blob のサブクラス\n || value instanceof FormData\n || value instanceof URLSearchParams\n || value instanceof ArrayBuffer\n || ArrayBuffer.isView(value); // TypedArray / DataView\n }\n\n private _collectBody(bodySnapshot: any): { body: BodyInit | null; contentType: string | null } {\n // JS API経由のbodyが優先\n if (bodySnapshot !== null) {\n // 文字列はそのまま。Content-Type はユーザーのヘッダ指定に委ねる。\n if (typeof bodySnapshot === \"string\") {\n return { body: bodySnapshot, contentType: null };\n }\n // ネイティブ BodyInit (Blob/File/FormData/URLSearchParams/ArrayBuffer/TypedArray)\n // は素通し。Content-Type はブラウザに委ねるため null を返す。\n if (this._isNativeBodyInit(bodySnapshot)) {\n return { body: bodySnapshot, contentType: null };\n }\n // それ以外のオブジェクトは JSON 化する。\n return { body: JSON.stringify(bodySnapshot), contentType: \"application/json\" };\n }\n\n // サブタグからbodyを取得\n const bodyElement = this.querySelector<FetchBody>(config.tagNames.fetchBody);\n if (bodyElement) {\n return {\n body: bodyElement.bodyContent || null,\n contentType: bodyElement.contentType,\n };\n }\n\n return { body: null, contentType: null };\n }\n\n abort(): void {\n this._core.abort();\n }\n\n /**\n * Coalesce auto-fetch requests in the current task into a single microtask.\n *\n * Multiple synchronous input writes in the same tick — e.g. a `...` spread\n * writing `url` before `manual` — collapse into one decision made against the\n * FINAL element state, so the spread application order can no longer trigger a\n * stray fetch. The microtask re-reads `isConnected` / `manual` / `url` at fire\n * time; whatever was written last wins.\n *\n * Only the implicit auto-fetch (url attribute change, connect-time) is routed\n * here. Explicit triggers — the `trigger` setter, the `fetch` command, and\n * autoTrigger (data-fetchtarget clicks) — must fire immediately and stay on\n * their own synchronous paths.\n *\n * The connect-time promise (connectedCallbackPromise) is resolved here in\n * EVERY exit path, including the no-fetch branch, so awaiting it never hangs\n * when the final state turns out to be manual / url-less / disconnected.\n */\n private _scheduleAutoFetch(): void {\n if (this._autoPending) {\n return;\n }\n this._autoPending = true;\n queueMicrotask(() => {\n this._autoPending = false;\n const resolveConnect = this._connectResolve;\n this._connectResolve = null;\n const url = this.url;\n // Same-value guard (Phase 4): skip a redundant auto-fetch for the url we\n // last fetched. A spread re-evaluation rewrites every input each cycle, so\n // the `url` setter calls setAttribute with an unchanged value and fires\n // attributeChangedCallback again; without this guard an unrelated state\n // change would refetch. Auto-path only — explicit fetch()/trigger/command\n // stay unconditional (a manual refresh of the same url must work), and\n // `_lastFetchedUrl` is reset on disconnect so a remount refetches.\n if (this.isConnected && !this.manual && url && url !== this._lastFetchedUrl) {\n // fetch() cannot reject here: FetchCore swallows network/HTTP errors and\n // only rejects on an empty url, which the `url` guard above rules out.\n this.fetch().finally(() => resolveConnect?.());\n } else {\n resolveConnect?.();\n }\n });\n }\n\n async fetch(): Promise<any> {\n // Record the url for the auto-fetch same-value guard. Every fetch (explicit\n // included) updates it so a later auto-write of the same url is treated as a\n // no-op rather than a duplicate request.\n this._lastFetchedUrl = this.url;\n const headers = this._collectHeaders();\n\n // Snapshot and reset `body` synchronously, before any await. The body is a\n // one-shot input; resetting it after the await (when another caller may have\n // already set a new body for the next request) would silently drop that value.\n const bodySnapshot = this._body;\n this._body = null;\n const { body, contentType } = this._collectBody(bodySnapshot);\n\n // FormData に手動で Content-Type を付けると、ブラウザが付与するはずの multipart\n // boundary が失われてサーバー側でパースできなくなる。ヘッダはユーザー指定を\n // 尊重して素通しするが、この典型的な誤設定は警告する。\n if (body instanceof FormData &&\n Object.keys(headers).some((name) => name.toLowerCase() === \"content-type\")) {\n console.warn(\n \"[@wcstack/fetch] A manual Content-Type header was set alongside a FormData body. \" +\n \"This drops the multipart boundary the browser adds automatically; remove the \" +\n \"Content-Type header (e.g. the <wcs-fetch-header>) to fix multipart uploads.\",\n );\n }\n\n const result = await this._core.fetch(this.url, {\n method: this.method,\n headers,\n body,\n contentType,\n forceText: !!this.target,\n responseType: this.responseType,\n });\n\n // HTML置換モード\n // Security: the response is injected as raw innerHTML without sanitization.\n // This is an opt-in convenience for trusted fragments only; the primary,\n // recommended path is state-driven binding via @wcstack/state. Do not point\n // `target` at an untrusted endpoint (XSS risk). See README \"HTML Replace Mode\".\n if (this.target && result !== null) {\n const targetElement = document.getElementById(this.target);\n if (targetElement) {\n targetElement.innerHTML = result;\n }\n }\n\n return result;\n }\n\n attributeChangedCallback(name: string, _oldValue: string | null, _newValue: string | null): void {\n // Re-fetch on url changes, but intentionally do NOT update\n // `_connectedCallbackPromise`. Per the wc-bindable connectedCallbackPromise\n // protocol that promise represents the one-shot \"connect-time initialization\n // is done\" signal; it resolves once and is not re-armed for later url-driven\n // requests. Await `promise` if you need to track a specific re-fetch.\n //\n // Defer the decision to a microtask (see _scheduleAutoFetch) instead of\n // fetching synchronously here: a `...` spread writes `url` before `manual`,\n // so a synchronous fetch would fire before `manual` is applied. The final\n // state (isConnected / manual / url) is re-read at microtask time.\n if (name === \"url\") {\n this._scheduleAutoFetch();\n }\n }\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // Only the initial connect-time fetch is tracked by connectedCallbackPromise.\n // Arm a deferred here when an auto-fetch looks likely; the scheduled\n // microtask resolves it (in every exit path, so awaiting never hangs). The\n // actual fetch decision is re-evaluated at microtask time against the final\n // state, so a spread that sets `manual` after `url` still suppresses it.\n if (!this.manual && this.url) {\n this._connectedCallbackPromise = new Promise<void>((resolve) => {\n this._connectResolve = resolve;\n });\n }\n this._scheduleAutoFetch();\n }\n\n disconnectedCallback(): void {\n this.abort();\n // Reset the same-value guard so a remount (reconnect with the same url)\n // refetches rather than being skipped as a duplicate.\n this._lastFetchedUrl = null;\n // Resolve any armed connect-time deferred before detaching. A synchronous\n // remove()→append() before the scheduled microtask fires would otherwise let\n // the second connectedCallback overwrite _connectResolve, orphaning the first\n // deferred and hanging any caller that already awaited connectedCallbackPromise.\n // Disconnection makes connect-time init moot, so resolving (never hanging) is\n // correct; the pending microtask then sees _connectResolve === null and no-ops.\n this._connectResolve?.();\n this._connectResolve = null;\n }\n}\n","export class FetchHeader extends HTMLElement {\n connectedCallback(): void {\n this.style.display = \"none\";\n }\n\n get headerName(): string {\n return this.getAttribute(\"name\") || \"\";\n }\n\n get headerValue(): string {\n return this.getAttribute(\"value\") || \"\";\n }\n}\n","export class FetchBody extends HTMLElement {\n constructor() {\n super();\n // スロットなしのShadow DOMでlight DOM(bodyテキスト)の描画を抑制\n this.attachShadow({ mode: \"open\" });\n }\n\n get contentType(): string {\n return this.getAttribute(\"type\") || \"application/json\";\n }\n\n get bodyContent(): string {\n return this.textContent?.trim() || \"\";\n }\n}\n","import { Fetch } from \"./Fetch.js\";\n\nexport class InfiniteScroll extends HTMLElement {\n static get observedAttributes(): string[] {\n return [\"target\", \"root\", \"root-margin\", \"threshold\", \"disabled\"];\n }\n\n private _observer: IntersectionObserver | null = null;\n private _done: boolean = false;\n\n get target(): string {\n return this.getAttribute(\"target\") || \"\";\n }\n\n set target(value: string) {\n this.setAttribute(\"target\", value);\n }\n\n get root(): string | null {\n return this.getAttribute(\"root\");\n }\n\n set root(value: string | null) {\n if (value === null) {\n this.removeAttribute(\"root\");\n } else {\n this.setAttribute(\"root\", value);\n }\n }\n\n get rootMargin(): string {\n return this.getAttribute(\"root-margin\") || \"0px\";\n }\n\n set rootMargin(value: string) {\n this.setAttribute(\"root-margin\", value);\n }\n\n get threshold(): number {\n const value = Number(this.getAttribute(\"threshold\") ?? \"0\");\n return Number.isFinite(value) ? value : 0;\n }\n\n set threshold(value: number) {\n this.setAttribute(\"threshold\", String(value));\n }\n\n get disabled(): boolean {\n return this.hasAttribute(\"disabled\");\n }\n\n set disabled(value: boolean) {\n if (value) {\n this.setAttribute(\"disabled\", \"\");\n } else {\n this.removeAttribute(\"disabled\");\n }\n }\n\n get once(): boolean {\n return this.hasAttribute(\"once\");\n }\n\n set once(value: boolean) {\n if (value) {\n this.setAttribute(\"once\", \"\");\n } else {\n this.removeAttribute(\"once\");\n }\n }\n\n connectedCallback(): void {\n this._observe();\n }\n\n disconnectedCallback(): void {\n this._disconnectObserver();\n }\n\n attributeChangedCallback(): void {\n if (this.isConnected) {\n this._observe();\n }\n }\n\n private _observe(): void {\n this._disconnectObserver();\n\n if (this._done || this.disabled || !this.target || typeof IntersectionObserver === \"undefined\") {\n return;\n }\n\n this._observer = new IntersectionObserver((entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n this._triggerFetch();\n }\n }, {\n root: this._resolveRoot(),\n rootMargin: this.rootMargin,\n threshold: this.threshold,\n });\n this._observer.observe(this);\n }\n\n private _disconnectObserver(): void {\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n }\n\n private _resolveRoot(): Element | Document | null {\n if (!this.root) return null;\n return document.getElementById(this.root) || null;\n }\n\n private _triggerFetch(): void {\n const target = document.getElementById(this.target);\n if (!(target instanceof Fetch)) {\n return;\n }\n\n if (target.loading) {\n return;\n }\n\n target.trigger = true;\n\n if (this.once) {\n this._done = true;\n this._disconnectObserver();\n }\n }\n}","import { Fetch } from \"./components/Fetch.js\";\nimport { FetchHeader } from \"./components/FetchHeader.js\";\nimport { FetchBody } from \"./components/FetchBody.js\";\nimport { InfiniteScroll } from \"./components/InfiniteScroll.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.fetch)) {\n customElements.define(config.tagNames.fetch, Fetch);\n }\n if (!customElements.get(config.tagNames.fetchHeader)) {\n customElements.define(config.tagNames.fetchHeader, FetchHeader);\n }\n if (!customElements.get(config.tagNames.fetchBody)) {\n customElements.define(config.tagNames.fetchBody, FetchBody);\n }\n if (!customElements.get(config.tagNames.infiniteScroll)) {\n customElements.define(config.tagNames.infiniteScroll, InfiniteScroll);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapFetch(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n"],"names":[],"mappings":"AAaA,MAAM,OAAO,GAAoB;AAC/B,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,gBAAgB,EAAE,kBAAkB;AACpC,IAAA,QAAQ,EAAE;AACR,QAAA,KAAK,EAAE,WAAW;AAClB,QAAA,WAAW,EAAE,kBAAkB;AAC/B,QAAA,SAAS,EAAE,gBAAgB;AAC3B,QAAA,cAAc,EAAE,qBAAqB;AACtC,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI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G,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACpD,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IACjE;AACA,IAAA,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QAClD,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC7D;AACA,IAAA,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;QACvD,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACvE;AACF;;ACfM,SAAU,cAAc,CAAC,UAA4B,EAAA;IACzD,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;AACA,IAAA,kBAAkB,EAAE;AACtB;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/FetchCore.ts","../src/autoTrigger.ts","../src/components/Fetch.ts","../src/components/FetchHeader.ts","../src/components/FetchBody.ts","../src/components/InfiniteScroll.ts","../src/registerComponents.ts","../src/bootstrapFetch.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n fetch: string;\n fetchHeader: string;\n fetchBody: string;\n infiniteScroll: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-fetchtarget\",\n tagNames: {\n fetch: \"wcs-fetch\",\n fetchHeader: \"wcs-fetch-header\",\n fetchBody: \"wcs-fetch-body\",\n infiniteScroll: \"wcs-infinite-scroll\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import { IWcBindable } from \"../types.js\";\n\nexport type FetchResponseType = \"auto\" | \"json\" | \"text\" | \"blob\" | \"arrayBuffer\";\n\nexport interface FetchRequestOptions {\n method?: string;\n headers?: Record<string, string>;\n body?: BodyInit | null;\n contentType?: string | null;\n forceText?: boolean;\n // How to read the response body. \"auto\" (default) sniffs Content-Type (JSON or\n // text). \"blob\"/\"arrayBuffer\" enable binary downloads; \"blob\" additionally\n // publishes a managed `objectURL`. `forceText` (HTML-replace mode) takes\n // priority over this.\n responseType?: FetchResponseType;\n}\n\nexport class FetchCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"value\", event: \"wcs-fetch:response\", getter: (e: Event) => (e as CustomEvent).detail.value },\n { name: \"loading\", event: \"wcs-fetch:loading-changed\" },\n { name: \"error\", event: \"wcs-fetch:error\" },\n { name: \"status\", event: \"wcs-fetch:response\", getter: (e: Event) => (e as CustomEvent).detail.status },\n // Managed object URL for a `responseType: \"blob\"` response (null otherwise).\n // The Core revokes the previous URL on each new response and on dispose, so\n // a consumer can bind it straight into <img src> without lifecycle glue.\n { name: \"objectURL\", event: \"wcs-fetch:response\", getter: (e: Event) => (e as CustomEvent).detail.objectURL },\n ],\n inputs: [\n { name: \"url\" },\n { name: \"method\" },\n ],\n commands: [\n { name: \"fetch\", async: true },\n { name: \"abort\" },\n ],\n };\n\n private _target: EventTarget;\n private _value: any = null;\n private _loading: boolean = false;\n private _error: any = null;\n private _status: number = 0;\n private _objectURL: string | null = null;\n private _abortController: AbortController | null = null;\n private _promise: Promise<any> = Promise.resolve(null);\n // Generation guard (§3.4): bumped on dispose() (and each fetch start). An\n // in-flight request that settles after dispose / a superseding start has a\n // stale `gen` and MUST NOT write state to a torn-down element. A boolean flag\n // is insufficient (dispose→observe would let stale work slip through).\n private _gen = 0;\n // SSR (§3.8): no asynchronous probe to await, 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 get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). Fetch is command-driven with no subscription to\n // establish, so observe() is an idempotent no-op that resolves once ready;\n // dispose() invalidates any in-flight request and aborts it.\n observe(): Promise<void> {\n return this._ready;\n }\n\n dispose(): void {\n this._gen++;\n this.abort();\n // Release any outstanding blob object URL on teardown (the other revoke point\n // is _setResponse, which drops the previous URL when a new response arrives).\n if (this._objectURL !== null) {\n this._revokeObjectURL(this._objectURL);\n this._objectURL = null;\n }\n }\n\n get value(): any {\n return this._value;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): any {\n return this._error;\n }\n\n get status(): number {\n return this._status;\n }\n\n get objectURL(): string | null {\n return this._objectURL;\n }\n\n get promise(): Promise<any> {\n return this._promise;\n }\n\n private _setLoading(loading: boolean): void {\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-fetch:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: any): void {\n // Same-value guard (async-io-node-guidelines.md §3.3). `error` is state-ish,\n // so suppressing redundant null→null dispatches (every fetch start clears a\n // usually-already-null error) avoids a spurious wcs-fetch:error per successful\n // request. Reference identity is sufficient: each failure builds a fresh\n // object, and the clear path always passes null.\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-fetch:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _setResponse(value: any, status: number, objectURL: string | null = null): void {\n // Revoke the previous blob object URL before replacing it. Any new response\n // (success, HTTP error, or network error all funnel through here) supersedes\n // the prior one, so the old URL is no longer needed; this plus dispose()\n // revocation keeps blob downloads leak-free.\n if (this._objectURL !== null) {\n this._revokeObjectURL(this._objectURL);\n }\n this._objectURL = objectURL;\n this._value = value;\n this._status = status;\n this._target.dispatchEvent(new CustomEvent(\"wcs-fetch:response\", {\n detail: { value, status, objectURL },\n bubbles: true,\n }));\n }\n\n // Object URL lifecycle for responseType: \"blob\". The Core owns the blob's\n // object URL (mirrors RecorderCore) so a consumer can bind `objectURL` straight\n // into <img src>/<a href> without managing createObjectURL/revokeObjectURL. Both\n // helpers tolerate environments without URL.createObjectURL (SSR / headless).\n private _createObjectURL(blob: Blob): string | null {\n if (typeof URL !== \"undefined\" && typeof URL.createObjectURL === \"function\") {\n return URL.createObjectURL(blob);\n }\n return null;\n }\n\n private _revokeObjectURL(url: string): void {\n if (typeof URL !== \"undefined\" && typeof URL.revokeObjectURL === \"function\") {\n URL.revokeObjectURL(url);\n }\n }\n\n abort(): void {\n if (this._abortController) {\n this._abortController.abort();\n this._abortController = null;\n }\n }\n\n async fetch(url: string, options: FetchRequestOptions = {}): Promise<any> {\n // never-throw (§3.6): 引数バリデーション失敗は例外ではなく error プロパティに\n // 流し、サニタイズ値(null)を返す。command-token 経路からの呼び出しが unhandled\n // rejection にならず、「fetch() は全終了ケースで resolve」契約とも整合する。\n if (!url) {\n this._setError({ message: \"url attribute is required.\" });\n return null;\n }\n\n const p = this._doFetch(url, options);\n this._promise = p;\n return p;\n }\n\n private async _doFetch(url: string, options: FetchRequestOptions): Promise<any> {\n // 進行中のリクエストをキャンセル\n this.abort();\n\n // Hold the controller in a local so the finally block (which can run after a\n // subsequent fetch has already replaced this._abortController) only clears the\n // field when it still owns it. Without the identity check, an aborted earlier\n // request's finally would null out the controller of the request that superseded\n // it, leaving the later request un-abortable.\n const ac = new AbortController();\n this._abortController = ac;\n const { signal } = ac;\n\n // Capture the generation at async start (§3.4). A completion that runs after\n // dispose() (which bumps _gen) is stale and must not write state.\n const gen = ++this._gen;\n\n this._setLoading(true);\n this._setError(null);\n\n const {\n method = \"GET\",\n body = null,\n contentType = null,\n forceText = false,\n responseType = \"auto\",\n } = options;\n\n // Copy the caller's headers so the contentType injection below never mutates\n // the object passed in by a headless consumer (the Shell already builds a\n // fresh object, but direct FetchCore users may reuse theirs).\n const headers: Record<string, string> = { ...(options.headers ?? {}) };\n\n try {\n if (contentType && !headers[\"Content-Type\"]) {\n headers[\"Content-Type\"] = contentType;\n }\n\n const requestInit: RequestInit = {\n method,\n headers,\n signal,\n };\n\n if (method !== \"GET\" && method !== \"HEAD\" && body !== null) {\n requestInit.body = body;\n }\n\n const response = await globalThis.fetch(url, requestInit);\n\n // A stale generation means dispose() (or a superseding fetch) ran while the\n // request was in flight. Drop the result without touching torn-down state.\n if (gen !== this._gen) {\n return null;\n }\n\n if (!response.ok) {\n const errorBody = await response.text().catch(() => \"\");\n const error = { status: response.status, statusText: response.statusText, body: errorBody };\n this._setError(error);\n // Notify `status` observers on HTTP errors too. The `status` property is\n // surfaced via the `wcs-fetch:response` event (getter reads detail.status),\n // so without dispatching it here a bind() subscriber would never see the\n // error status (404, 500, ...). `value` is reset to null on error.\n this._setResponse(null, response.status);\n this._setLoading(false);\n return null;\n }\n\n if (method === \"HEAD\") {\n // HEAD responses carry no body by spec. Reading it as JSON would throw a\n // parse error on the empty body (and end up as a spurious `error`), so skip\n // body reading entirely and surface only the status with a null value.\n this._setResponse(null, response.status);\n } else if (forceText) {\n // HTML-replace mode (the Shell sets forceText when `target` is present)\n // always reads text and takes priority over responseType.\n const text = await response.text();\n this._setResponse(text, response.status);\n } else if (responseType === \"blob\") {\n const blob = await response.blob();\n // Publish a managed object URL alongside the Blob so consumers can bind it\n // directly into <img src> etc.\n this._setResponse(blob, response.status, this._createObjectURL(blob));\n } else if (responseType === \"arrayBuffer\") {\n const buffer = await response.arrayBuffer();\n this._setResponse(buffer, response.status);\n } else if (responseType === \"text\") {\n const text = await response.text();\n this._setResponse(text, response.status);\n } else if (responseType === \"json\") {\n const data = await response.json();\n this._setResponse(data, response.status);\n } else {\n // \"auto\" (default): sniff Content-Type — JSON when it says so, else text.\n const responseContentType = response.headers.get(\"Content-Type\") || \"\";\n if (responseContentType.includes(\"application/json\")) {\n const data = await response.json();\n this._setResponse(data, response.status);\n } else {\n const text = await response.text();\n this._setResponse(text, response.status);\n }\n }\n\n this._setLoading(false);\n return this._value;\n } catch (e: any) {\n // Stale completion (dispose / superseding fetch ran during a later await\n // such as response.json()). Drop the result without writing state.\n if (gen !== this._gen) {\n return null;\n }\n if (e.name === \"AbortError\") {\n // A matching generation means this is an explicit abort() of the current\n // request (a superseding fetch bumps _gen and is caught by the stale guard\n // above; dispose() likewise bumps _gen). Explicit abort clears loading so\n // observers leave the in-flight state.\n this._setLoading(false);\n return null;\n }\n this._setError(e);\n // Reset value/status on network errors too, mirroring the HTTP-error path\n // (`_setResponse(null, response.status)`). Without this, a prior successful\n // request's value/status would linger while `error` is non-null, showing\n // observers an inconsistent state (e.g. status=200 alongside a network\n // error). status=0 is the web-platform convention for \"no HTTP response\"\n // (matches XMLHttpRequest.status on network failure) and the initial value.\n this._setResponse(null, 0);\n this._setLoading(false);\n return null;\n } finally {\n if (this._abortController === ac) {\n this._abortController = null;\n }\n }\n }\n}\n","import { config } from \"./config.js\";\nimport type { Fetch } from \"./components/Fetch.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const fetchId = triggerElement.getAttribute(config.triggerAttribute);\n if (!fetchId) return;\n\n // Resolve the registered constructor at call time instead of importing Fetch\n // as a value. The value import created a components/Fetch.ts ⇄ autoTrigger.ts\n // cycle (Fetch.connectedCallback() calls registerAutoTrigger()). instanceof\n // against the customElements registry keeps the exact same identity guarantee\n // — only the registered <wcs-fetch> class matches — without the import cycle.\n const FetchCtor = customElements.get(config.tagNames.fetch);\n const el = document.getElementById(fetchId);\n if (!FetchCtor || !(el instanceof FetchCtor)) return;\n const fetchElement = el as Fetch;\n\n // Skip when the target has no url. fetch() is fire-and-forget here (its returned\n // promise is intentionally not awaited), and FetchCore.fetch() rejects synchronously\n // on an empty url. Without this guard that rejection would surface as an unhandled\n // promise rejection. Treat a url-less target as \"nothing to do\", consistent with the\n // other early returns above.\n if (!fetchElement.url) return;\n\n // Suppress the element's default action so a fetch can fire without navigating.\n // Intentional: do not attach data-fetchtarget to an element whose default action\n // you also want (real <a href> link, form-submit button) — it will be cancelled.\n // See README \"Optional DOM Triggering\".\n event.preventDefault();\n fetchElement.fetch();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport { IWcBindable } from \"../types.js\";\nimport { FetchCore, FetchResponseType } from \"../core/FetchCore.js\";\nimport { FetchHeader } from \"./FetchHeader.js\";\nimport { FetchBody } from \"./FetchBody.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\nexport class Fetch extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...FetchCore.wcBindable,\n properties: [\n ...FetchCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-fetch:trigger-changed\" },\n ],\n // Shell-level input surface. The Core declares only the portable `url` / `method`;\n // the Shell adds the DOM-driven settable surface. No `attribute` hints are given:\n // these setters already reflect to their attributes themselves, so a binding system\n // that mirrors inputs[].attribute would set the attribute twice. `commands`\n // (fetch / abort) are inherited unchanged from the Core via the spread above.\n inputs: [\n { name: \"url\" },\n { name: \"method\" },\n { name: \"target\" },\n { name: \"manual\" },\n { name: \"body\" },\n { name: \"responseType\" },\n { name: \"trigger\" },\n ],\n };\n static get observedAttributes(): string[] { return [\"url\"]; }\n\n private _core: FetchCore;\n private _body: any = null;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n // Auto-fetch coalescing state (see _scheduleAutoFetch).\n private _autoPending: boolean = false;\n private _connectResolve: (() => void) | null = null;\n private _lastFetchedUrl: string | null = null;\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n // State reflection is wired BEFORE the Core is constructed (canonical\n // order): a Core that dispatches synchronously from its constructor\n // (e.g. speech's unsupported-changed) would otherwise fire before the\n // listeners exist. FetchCore doesn't do that, so this is equivalent here,\n // but every Shell keeps the same order.\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-fetch:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-fetch:error\": (d) => ({ error: d != null }),\n });\n this._core = new FetchCore(this);\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 // Input setters normalize null/undefined to attribute removal instead of\n // letting setAttribute stringify them (\"undefined\" url would auto-fetch\n // /undefined, \"undefined\" method is an invalid HTTP method). The binder\n // already skips undefined writes; this guards direct JS assignment too.\n get url(): string {\n return this.getAttribute(\"url\") || \"\";\n }\n\n set url(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"url\");\n } else {\n this.setAttribute(\"url\", value);\n }\n }\n\n get method(): string {\n return (this.getAttribute(\"method\") || \"GET\").toUpperCase();\n }\n\n set method(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"method\");\n } else {\n this.setAttribute(\"method\", value);\n }\n }\n\n get target(): string | null {\n return this.getAttribute(\"target\");\n }\n\n set target(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"target\");\n } else {\n this.setAttribute(\"target\", value);\n }\n }\n\n // Response body interpretation. Backed by the `response-type` attribute so it is\n // settable from HTML, JS, or a binding. An unknown value falls through to the\n // Core's \"auto\" branch. `target` (HTML-replace mode) overrides this.\n get responseType(): FetchResponseType {\n return (this.getAttribute(\"response-type\") as FetchResponseType) || \"auto\";\n }\n\n set responseType(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"response-type\");\n } else {\n this.setAttribute(\"response-type\", value);\n }\n }\n\n get value(): any {\n return this._core.value;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get status(): number {\n return this._core.status;\n }\n\n get objectURL(): string | null {\n return this._core.objectURL;\n }\n\n get promise(): Promise<any> {\n return this._core.promise;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n if (value) {\n this.setAttribute(\"manual\", \"\");\n } else {\n this.removeAttribute(\"manual\");\n }\n }\n\n get body(): any {\n return this._body;\n }\n\n set body(value: any) {\n // Normalize undefined to null: _collectBody treats \"!== null\" as \"body was\n // provided\", so a raw undefined would serialize as a JSON request body.\n this._body = value ?? null;\n }\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n const v = !!value;\n if (v) {\n // Skip when url is empty. fetch() is fire-and-forget here (its returned\n // promise is intentionally only chained with .finally() to reset the flag,\n // never .catch()'d), and FetchCore.fetch() rejects on an empty url. Without\n // this guard that rejection — re-thrown by .finally() — surfaces as an\n // unhandled promise rejection. Mirrors the url-less guard in autoTrigger.\n //\n // Leave `_trigger` false (do not set it) and emit no event: nothing ran, so\n // surfacing a `wcs-fetch:trigger-changed` \"completion\" would lie to observers.\n // Keeping the flag false also avoids stalling — once url is provided, writing\n // `true` again is a real false→true transition that triggers the fetch.\n if (!this.url) return;\n this._trigger = true;\n this.fetch().finally(() => {\n this._trigger = false;\n this.dispatchEvent(new CustomEvent(\"wcs-fetch:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n });\n }\n }\n\n private _collectHeaders(): Record<string, string> {\n const headers: Record<string, string> = {};\n const headerElements = this.querySelectorAll<FetchHeader>(config.tagNames.fetchHeader);\n for (const el of headerElements) {\n const name = el.headerName;\n const value = el.headerValue;\n if (name) {\n headers[name] = value;\n }\n }\n return headers;\n }\n\n // fetch がネイティブに扱える BodyInit か判定する。これらは JSON.stringify せず\n // 素通しし、Content-Type をブラウザに委ねる (FormData の multipart boundary、\n // Blob の type、URLSearchParams の application/x-www-form-urlencoded を自動付与\n // させるため、_collectBody は contentType に null を返す)。ReadableStream は\n // RequestInit.duplex: 'half' を要するため初版では対象外とし、従来どおり扱う。\n private _isNativeBodyInit(value: unknown): value is BodyInit {\n return value instanceof Blob // File は Blob のサブクラス\n || value instanceof FormData\n || value instanceof URLSearchParams\n || value instanceof ArrayBuffer\n || ArrayBuffer.isView(value); // TypedArray / DataView\n }\n\n private _collectBody(bodySnapshot: any): { body: BodyInit | null; contentType: string | null } {\n // JS API経由のbodyが優先\n if (bodySnapshot !== null) {\n // 文字列はそのまま。Content-Type はユーザーのヘッダ指定に委ねる。\n if (typeof bodySnapshot === \"string\") {\n return { body: bodySnapshot, contentType: null };\n }\n // ネイティブ BodyInit (Blob/File/FormData/URLSearchParams/ArrayBuffer/TypedArray)\n // は素通し。Content-Type はブラウザに委ねるため null を返す。\n if (this._isNativeBodyInit(bodySnapshot)) {\n return { body: bodySnapshot, contentType: null };\n }\n // それ以外のオブジェクトは JSON 化する。\n return { body: JSON.stringify(bodySnapshot), contentType: \"application/json\" };\n }\n\n // サブタグからbodyを取得\n const bodyElement = this.querySelector<FetchBody>(config.tagNames.fetchBody);\n if (bodyElement) {\n return {\n body: bodyElement.bodyContent || null,\n contentType: bodyElement.contentType,\n };\n }\n\n return { body: null, contentType: null };\n }\n\n abort(): void {\n this._core.abort();\n }\n\n /**\n * Coalesce auto-fetch requests in the current task into a single microtask.\n *\n * Multiple synchronous input writes in the same tick — e.g. a `...` spread\n * writing `url` before `manual` — collapse into one decision made against the\n * FINAL element state, so the spread application order can no longer trigger a\n * stray fetch. The microtask re-reads `isConnected` / `manual` / `url` at fire\n * time; whatever was written last wins.\n *\n * Only the implicit auto-fetch (url attribute change, connect-time) is routed\n * here. Explicit triggers — the `trigger` setter, the `fetch` command, and\n * autoTrigger (data-fetchtarget clicks) — must fire immediately and stay on\n * their own synchronous paths.\n *\n * The connect-time promise (connectedCallbackPromise) is resolved here in\n * EVERY exit path, including the no-fetch branch, so awaiting it never hangs\n * when the final state turns out to be manual / url-less / disconnected.\n */\n private _scheduleAutoFetch(): void {\n if (this._autoPending) {\n return;\n }\n this._autoPending = true;\n queueMicrotask(() => {\n this._autoPending = false;\n const resolveConnect = this._connectResolve;\n this._connectResolve = null;\n const url = this.url;\n // Same-value guard (Phase 4): skip a redundant auto-fetch for the url we\n // last fetched. A spread re-evaluation rewrites every input each cycle, so\n // the `url` setter calls setAttribute with an unchanged value and fires\n // attributeChangedCallback again; without this guard an unrelated state\n // change would refetch. Auto-path only — explicit fetch()/trigger/command\n // stay unconditional (a manual refresh of the same url must work), and\n // `_lastFetchedUrl` is reset on disconnect so a remount refetches.\n if (this.isConnected && !this.manual && url && url !== this._lastFetchedUrl) {\n // fetch() cannot reject here: FetchCore swallows network/HTTP errors and\n // only rejects on an empty url, which the `url` guard above rules out.\n this.fetch().finally(() => resolveConnect?.());\n } else {\n resolveConnect?.();\n }\n });\n }\n\n async fetch(): Promise<any> {\n // Record the url for the auto-fetch same-value guard. Every fetch (explicit\n // included) updates it so a later auto-write of the same url is treated as a\n // no-op rather than a duplicate request.\n this._lastFetchedUrl = this.url;\n const headers = this._collectHeaders();\n\n // Snapshot and reset `body` synchronously, before any await. The body is a\n // one-shot input; resetting it after the await (when another caller may have\n // already set a new body for the next request) would silently drop that value.\n const bodySnapshot = this._body;\n this._body = null;\n const { body, contentType } = this._collectBody(bodySnapshot);\n\n // FormData に手動で Content-Type を付けると、ブラウザが付与するはずの multipart\n // boundary が失われてサーバー側でパースできなくなる。ヘッダはユーザー指定を\n // 尊重して素通しするが、この典型的な誤設定は警告する。\n if (body instanceof FormData &&\n Object.keys(headers).some((name) => name.toLowerCase() === \"content-type\")) {\n console.warn(\n \"[@wcstack/fetch] A manual Content-Type header was set alongside a FormData body. \" +\n \"This drops the multipart boundary the browser adds automatically; remove the \" +\n \"Content-Type header (e.g. the <wcs-fetch-header>) to fix multipart uploads.\",\n );\n }\n\n const result = await this._core.fetch(this.url, {\n method: this.method,\n headers,\n body,\n contentType,\n forceText: !!this.target,\n responseType: this.responseType,\n });\n\n // HTML置換モード\n // Security: the response is injected as raw innerHTML without sanitization.\n // This is an opt-in convenience for trusted fragments only; the primary,\n // recommended path is state-driven binding via @wcstack/state. Do not point\n // `target` at an untrusted endpoint (XSS risk). See README \"HTML Replace Mode\".\n if (this.target && result !== null) {\n const targetElement = document.getElementById(this.target);\n if (targetElement) {\n targetElement.innerHTML = result;\n }\n }\n\n return result;\n }\n\n attributeChangedCallback(name: string, _oldValue: string | null, _newValue: string | null): void {\n // Re-fetch on url changes, but intentionally do NOT update\n // `_connectedCallbackPromise`. Per the wc-bindable connectedCallbackPromise\n // protocol that promise represents the one-shot \"connect-time initialization\n // is done\" signal; it resolves once and is not re-armed for later url-driven\n // requests. Await `promise` if you need to track a specific re-fetch.\n //\n // Defer the decision to a microtask (see _scheduleAutoFetch) instead of\n // fetching synchronously here: a `...` spread writes `url` before `manual`,\n // so a synchronous fetch would fire before `manual` is applied. The final\n // state (isConnected / manual / url) is re-read at microtask time.\n if (name === \"url\") {\n this._scheduleAutoFetch();\n }\n }\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // Only the initial connect-time fetch is tracked by connectedCallbackPromise.\n // Arm a deferred here when an auto-fetch looks likely; the scheduled\n // microtask resolves it (in every exit path, so awaiting never hangs). The\n // actual fetch decision is re-evaluated at microtask time against the final\n // state, so a spread that sets `manual` after `url` still suppresses it.\n if (!this.manual && this.url) {\n this._connectedCallbackPromise = new Promise<void>((resolve) => {\n this._connectResolve = resolve;\n });\n }\n this._scheduleAutoFetch();\n }\n\n disconnectedCallback(): void {\n this.abort();\n // Reset the same-value guard so a remount (reconnect with the same url)\n // refetches rather than being skipped as a duplicate.\n this._lastFetchedUrl = null;\n // Resolve any armed connect-time deferred before detaching. A synchronous\n // remove()→append() before the scheduled microtask fires would otherwise let\n // the second connectedCallback overwrite _connectResolve, orphaning the first\n // deferred and hanging any caller that already awaited connectedCallbackPromise.\n // Disconnection makes connect-time init moot, so resolving (never hanging) is\n // correct; the pending microtask then sees _connectResolve === null and no-ops.\n this._connectResolve?.();\n this._connectResolve = null;\n }\n}\n","export class FetchHeader extends HTMLElement {\n connectedCallback(): void {\n this.style.display = \"none\";\n }\n\n get headerName(): string {\n return this.getAttribute(\"name\") || \"\";\n }\n\n get headerValue(): string {\n return this.getAttribute(\"value\") || \"\";\n }\n}\n","export class FetchBody extends HTMLElement {\n constructor() {\n super();\n // スロットなしのShadow DOMでlight DOM(bodyテキスト)の描画を抑制\n this.attachShadow({ mode: \"open\" });\n }\n\n get contentType(): string {\n return this.getAttribute(\"type\") || \"application/json\";\n }\n\n get bodyContent(): string {\n return this.textContent?.trim() || \"\";\n }\n}\n","import { Fetch } from \"./Fetch.js\";\n\nexport class InfiniteScroll extends HTMLElement {\n static get observedAttributes(): string[] {\n return [\"target\", \"root\", \"root-margin\", \"threshold\", \"disabled\"];\n }\n\n private _observer: IntersectionObserver | null = null;\n private _done: boolean = false;\n\n get target(): string {\n return this.getAttribute(\"target\") || \"\";\n }\n\n set target(value: string) {\n this.setAttribute(\"target\", value);\n }\n\n get root(): string | null {\n return this.getAttribute(\"root\");\n }\n\n set root(value: string | null) {\n if (value === null) {\n this.removeAttribute(\"root\");\n } else {\n this.setAttribute(\"root\", value);\n }\n }\n\n get rootMargin(): string {\n return this.getAttribute(\"root-margin\") || \"0px\";\n }\n\n set rootMargin(value: string) {\n this.setAttribute(\"root-margin\", value);\n }\n\n get threshold(): number {\n const value = Number(this.getAttribute(\"threshold\") ?? \"0\");\n return Number.isFinite(value) ? value : 0;\n }\n\n set threshold(value: number) {\n this.setAttribute(\"threshold\", String(value));\n }\n\n get disabled(): boolean {\n return this.hasAttribute(\"disabled\");\n }\n\n set disabled(value: boolean) {\n if (value) {\n this.setAttribute(\"disabled\", \"\");\n } else {\n this.removeAttribute(\"disabled\");\n }\n }\n\n get once(): boolean {\n return this.hasAttribute(\"once\");\n }\n\n set once(value: boolean) {\n if (value) {\n this.setAttribute(\"once\", \"\");\n } else {\n this.removeAttribute(\"once\");\n }\n }\n\n connectedCallback(): void {\n this._observe();\n }\n\n disconnectedCallback(): void {\n this._disconnectObserver();\n }\n\n attributeChangedCallback(): void {\n if (this.isConnected) {\n this._observe();\n }\n }\n\n private _observe(): void {\n this._disconnectObserver();\n\n if (this._done || this.disabled || !this.target || typeof IntersectionObserver === \"undefined\") {\n return;\n }\n\n this._observer = new IntersectionObserver((entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n this._triggerFetch();\n }\n }, {\n root: this._resolveRoot(),\n rootMargin: this.rootMargin,\n threshold: this.threshold,\n });\n this._observer.observe(this);\n }\n\n private _disconnectObserver(): void {\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n }\n\n private _resolveRoot(): Element | Document | null {\n if (!this.root) return null;\n return document.getElementById(this.root) || null;\n }\n\n private _triggerFetch(): void {\n const target = document.getElementById(this.target);\n if (!(target instanceof Fetch)) {\n return;\n }\n\n if (target.loading) {\n return;\n }\n\n target.trigger = true;\n\n if (this.once) {\n this._done = true;\n this._disconnectObserver();\n }\n }\n}","import { Fetch } from \"./components/Fetch.js\";\nimport { FetchHeader } from \"./components/FetchHeader.js\";\nimport { FetchBody } from \"./components/FetchBody.js\";\nimport { InfiniteScroll } from \"./components/InfiniteScroll.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.fetch)) {\n customElements.define(config.tagNames.fetch, Fetch);\n }\n if (!customElements.get(config.tagNames.fetchHeader)) {\n customElements.define(config.tagNames.fetchHeader, FetchHeader);\n }\n if (!customElements.get(config.tagNames.fetchBody)) {\n customElements.define(config.tagNames.fetchBody, FetchBody);\n }\n if (!customElements.get(config.tagNames.infiniteScroll)) {\n customElements.define(config.tagNames.infiniteScroll, InfiniteScroll);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapFetch(userConfig?: IWritableConfig):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AAC,SAAS,EAAE,SAAS,CAAC;IAC7D;AACA,IAAA,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;QACvD,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACvE;AACF;;ACfM,SAAU,cAAc,CAAC,UAA4B,EAAA;IACzD,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;AACA,IAAA,kBAAkB,EAAE;AACtB;;;;"}
@@ -1,2 +1,2 @@
1
- const t={autoTrigger:!0,triggerAttribute:"data-fetchtarget",tagNames:{fetch:"wcs-fetch",fetchHeader:"wcs-fetch-header",fetchBody:"wcs-fetch-body",infiniteScroll:"wcs-infinite-scroll"}};function e(t){if(null===t||"object"!=typeof t)return t;Object.freeze(t);for(const s of Object.keys(t))e(t[s]);return t}function s(t){if(null===t||"object"!=typeof t)return t;const e={};for(const r of Object.keys(t))e[r]=s(t[r]);return e}let r=null;const n=t;function o(){return r||(r=e(s(t))),r}class i extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"value",event:"wcs-fetch:response",getter:t=>t.detail.value},{name:"loading",event:"wcs-fetch:loading-changed"},{name:"error",event:"wcs-fetch:error"},{name:"status",event:"wcs-fetch:response",getter:t=>t.detail.status},{name:"objectURL",event:"wcs-fetch:response",getter:t=>t.detail.objectURL}],inputs:[{name:"url"},{name:"method"}],commands:[{name:"fetch",async:!0},{name:"abort"}]};_target;_value=null;_loading=!1;_error=null;_status=0;_objectURL=null;_abortController=null;_promise=Promise.resolve(null);_gen=0;_ready=Promise.resolve();constructor(t){super(),this._target=t??this}get ready(){return this._ready}observe(){return this._ready}dispose(){this._gen++,this.abort(),null!==this._objectURL&&(this._revokeObjectURL(this._objectURL),this._objectURL=null)}get value(){return this._value}get loading(){return this._loading}get error(){return this._error}get status(){return this._status}get objectURL(){return this._objectURL}get promise(){return this._promise}_setLoading(t){this._loading=t,this._target.dispatchEvent(new CustomEvent("wcs-fetch:loading-changed",{detail:t,bubbles:!0}))}_setError(t){this._error=t,this._target.dispatchEvent(new CustomEvent("wcs-fetch:error",{detail:t,bubbles:!0}))}_setResponse(t,e,s=null){null!==this._objectURL&&this._revokeObjectURL(this._objectURL),this._objectURL=s,this._value=t,this._status=e,this._target.dispatchEvent(new CustomEvent("wcs-fetch:response",{detail:{value:t,status:e,objectURL:s},bubbles:!0}))}_createObjectURL(t){return"undefined"!=typeof URL&&"function"==typeof URL.createObjectURL?URL.createObjectURL(t):null}_revokeObjectURL(t){"undefined"!=typeof URL&&"function"==typeof URL.revokeObjectURL&&URL.revokeObjectURL(t)}abort(){this._abortController&&(this._abortController.abort(),this._abortController=null)}async fetch(t,e={}){if(!t)return this._setError({message:"url attribute is required."}),null;const s=this._doFetch(t,e);return this._promise=s,s}async _doFetch(t,e){this.abort();const s=new AbortController;this._abortController=s;const{signal:r}=s,n=++this._gen;this._setLoading(!0),this._setError(null);const{method:o="GET",body:i=null,contentType:a=null,forceText:l=!1,responseType:c="auto"}=e,h={...e.headers??{}};try{a&&!h["Content-Type"]&&(h["Content-Type"]=a);const e={method:o,headers:h,signal:r};"GET"!==o&&"HEAD"!==o&&null!==i&&(e.body=i);const s=await globalThis.fetch(t,e);if(n!==this._gen)return null;if(!s.ok){const t=await s.text().catch(()=>""),e={status:s.status,statusText:s.statusText,body:t};return this._setError(e),this._setResponse(null,s.status),this._setLoading(!1),null}if("HEAD"===o)this._setResponse(null,s.status);else if(l){const t=await s.text();this._setResponse(t,s.status)}else if("blob"===c){const t=await s.blob();this._setResponse(t,s.status,this._createObjectURL(t))}else if("arrayBuffer"===c){const t=await s.arrayBuffer();this._setResponse(t,s.status)}else if("text"===c){const t=await s.text();this._setResponse(t,s.status)}else if("json"===c){const t=await s.json();this._setResponse(t,s.status)}else{if((s.headers.get("Content-Type")||"").includes("application/json")){const t=await s.json();this._setResponse(t,s.status)}else{const t=await s.text();this._setResponse(t,s.status)}}return this._setLoading(!1),this._value}catch(t){return n!==this._gen?null:"AbortError"===t.name?(this._setLoading(!1),null):(this._setError(t),this._setResponse(null,0),this._setLoading(!1),null)}finally{this._abortController===s&&(this._abortController=null)}}}let a=!1;function l(t){const e=t.target;if(!(e instanceof Element))return;const s=e.closest(`[${n.triggerAttribute}]`);if(!s)return;const r=s.getAttribute(n.triggerAttribute);if(!r)return;const o=customElements.get(n.tagNames.fetch),i=document.getElementById(r);if(!(o&&i instanceof o))return;const a=i;a.url&&(t.preventDefault(),a.fetch())}class c extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...i.wcBindable,properties:[...i.wcBindable.properties,{name:"trigger",event:"wcs-fetch:trigger-changed"}],inputs:[{name:"url"},{name:"method"},{name:"target"},{name:"manual"},{name:"body"},{name:"responseType"},{name:"trigger"}]};static get observedAttributes(){return["url"]}_core;_body=null;_trigger=!1;_connectedCallbackPromise=Promise.resolve();_autoPending=!1;_connectResolve=null;_lastFetchedUrl=null;constructor(){super(),this._core=new i(this)}get url(){return this.getAttribute("url")||""}set url(t){null==t?this.removeAttribute("url"):this.setAttribute("url",t)}get method(){return(this.getAttribute("method")||"GET").toUpperCase()}set method(t){null==t?this.removeAttribute("method"):this.setAttribute("method",t)}get target(){return this.getAttribute("target")}set target(t){null==t?this.removeAttribute("target"):this.setAttribute("target",t)}get responseType(){return this.getAttribute("response-type")||"auto"}set responseType(t){null==t?this.removeAttribute("response-type"):this.setAttribute("response-type",t)}get value(){return this._core.value}get loading(){return this._core.loading}get error(){return this._core.error}get status(){return this._core.status}get objectURL(){return this._core.objectURL}get promise(){return this._core.promise}get connectedCallbackPromise(){return this._connectedCallbackPromise}get manual(){return this.hasAttribute("manual")}set manual(t){t?this.setAttribute("manual",""):this.removeAttribute("manual")}get body(){return this._body}set body(t){this._body=t??null}get trigger(){return this._trigger}set trigger(t){if(!!t){if(!this.url)return;this._trigger=!0,this.fetch().finally(()=>{this._trigger=!1,this.dispatchEvent(new CustomEvent("wcs-fetch:trigger-changed",{detail:!1,bubbles:!0}))})}}_collectHeaders(){const t={},e=this.querySelectorAll(n.tagNames.fetchHeader);for(const s of e){const e=s.headerName,r=s.headerValue;e&&(t[e]=r)}return t}_isNativeBodyInit(t){return t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ArrayBuffer||ArrayBuffer.isView(t)}_collectBody(t){if(null!==t)return"string"==typeof t||this._isNativeBodyInit(t)?{body:t,contentType:null}:{body:JSON.stringify(t),contentType:"application/json"};const e=this.querySelector(n.tagNames.fetchBody);return e?{body:e.bodyContent||null,contentType:e.contentType}:{body:null,contentType:null}}abort(){this._core.abort()}_scheduleAutoFetch(){this._autoPending||(this._autoPending=!0,queueMicrotask(()=>{this._autoPending=!1;const t=this._connectResolve;this._connectResolve=null;const e=this.url;this.isConnected&&!this.manual&&e&&e!==this._lastFetchedUrl?this.fetch().finally(()=>t?.()):t?.()}))}async fetch(){this._lastFetchedUrl=this.url;const t=this._collectHeaders(),e=this._body;this._body=null;const{body:s,contentType:r}=this._collectBody(e);s instanceof FormData&&Object.keys(t).some(t=>"content-type"===t.toLowerCase())&&console.warn("[@wcstack/fetch] A manual Content-Type header was set alongside a FormData body. This drops the multipart boundary the browser adds automatically; remove the Content-Type header (e.g. the <wcs-fetch-header>) to fix multipart uploads.");const n=await this._core.fetch(this.url,{method:this.method,headers:t,body:s,contentType:r,forceText:!!this.target,responseType:this.responseType});if(this.target&&null!==n){const t=document.getElementById(this.target);t&&(t.innerHTML=n)}return n}attributeChangedCallback(t,e,s){"url"===t&&this._scheduleAutoFetch()}connectedCallback(){this.style.display="none",n.autoTrigger&&(a||(a=!0,document.addEventListener("click",l))),!this.manual&&this.url&&(this._connectedCallbackPromise=new Promise(t=>{this._connectResolve=t})),this._scheduleAutoFetch()}disconnectedCallback(){this.abort(),this._lastFetchedUrl=null,this._connectResolve?.(),this._connectResolve=null}}class h extends HTMLElement{connectedCallback(){this.style.display="none"}get headerName(){return this.getAttribute("name")||""}get headerValue(){return this.getAttribute("value")||""}}class u extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}get contentType(){return this.getAttribute("type")||"application/json"}get bodyContent(){return this.textContent?.trim()||""}}class d extends HTMLElement{static get observedAttributes(){return["target","root","root-margin","threshold","disabled"]}_observer=null;_done=!1;get target(){return this.getAttribute("target")||""}set target(t){this.setAttribute("target",t)}get root(){return this.getAttribute("root")}set root(t){null===t?this.removeAttribute("root"):this.setAttribute("root",t)}get rootMargin(){return this.getAttribute("root-margin")||"0px"}set rootMargin(t){this.setAttribute("root-margin",t)}get threshold(){const t=Number(this.getAttribute("threshold")??"0");return Number.isFinite(t)?t:0}set threshold(t){this.setAttribute("threshold",String(t))}get disabled(){return this.hasAttribute("disabled")}set disabled(t){t?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get once(){return this.hasAttribute("once")}set once(t){t?this.setAttribute("once",""):this.removeAttribute("once")}connectedCallback(){this._observe()}disconnectedCallback(){this._disconnectObserver()}attributeChangedCallback(){this.isConnected&&this._observe()}_observe(){this._disconnectObserver(),this._done||this.disabled||!this.target||"undefined"==typeof IntersectionObserver||(this._observer=new IntersectionObserver(t=>{t.some(t=>t.isIntersecting)&&this._triggerFetch()},{root:this._resolveRoot(),rootMargin:this.rootMargin,threshold:this.threshold}),this._observer.observe(this))}_disconnectObserver(){this._observer&&(this._observer.disconnect(),this._observer=null)}_resolveRoot(){return this.root&&document.getElementById(this.root)||null}_triggerFetch(){const t=document.getElementById(this.target);t instanceof c&&(t.loading||(t.trigger=!0,this.once&&(this._done=!0,this._disconnectObserver())))}}function g(e){var s;e&&("boolean"==typeof(s=e).autoTrigger&&(t.autoTrigger=s.autoTrigger),"string"==typeof s.triggerAttribute&&(t.triggerAttribute=s.triggerAttribute),s.tagNames&&Object.assign(t.tagNames,s.tagNames),r=null),customElements.get(n.tagNames.fetch)||customElements.define(n.tagNames.fetch,c),customElements.get(n.tagNames.fetchHeader)||customElements.define(n.tagNames.fetchHeader,h),customElements.get(n.tagNames.fetchBody)||customElements.define(n.tagNames.fetchBody,u),customElements.get(n.tagNames.infiniteScroll)||customElements.define(n.tagNames.infiniteScroll,d)}export{i as FetchCore,c as WcsFetch,d as WcsInfiniteScroll,g as bootstrapFetch,o as getConfig};
1
+ const t={autoTrigger:!0,triggerAttribute:"data-fetchtarget",tagNames:{fetch:"wcs-fetch",fetchHeader:"wcs-fetch-header",fetchBody:"wcs-fetch-body",infiniteScroll:"wcs-infinite-scroll"}};function e(t){if(null===t||"object"!=typeof t)return t;Object.freeze(t);for(const s of Object.keys(t))e(t[s]);return t}function s(t){if(null===t||"object"!=typeof t)return t;const e={};for(const r of Object.keys(t))e[r]=s(t[r]);return e}let r=null;const n=t;function o(){return r||(r=e(s(t))),r}class i extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"value",event:"wcs-fetch:response",getter:t=>t.detail.value},{name:"loading",event:"wcs-fetch:loading-changed"},{name:"error",event:"wcs-fetch:error"},{name:"status",event:"wcs-fetch:response",getter:t=>t.detail.status},{name:"objectURL",event:"wcs-fetch:response",getter:t=>t.detail.objectURL}],inputs:[{name:"url"},{name:"method"}],commands:[{name:"fetch",async:!0},{name:"abort"}]};_target;_value=null;_loading=!1;_error=null;_status=0;_objectURL=null;_abortController=null;_promise=Promise.resolve(null);_gen=0;_ready=Promise.resolve();constructor(t){super(),this._target=t??this}get ready(){return this._ready}observe(){return this._ready}dispose(){this._gen++,this.abort(),null!==this._objectURL&&(this._revokeObjectURL(this._objectURL),this._objectURL=null)}get value(){return this._value}get loading(){return this._loading}get error(){return this._error}get status(){return this._status}get objectURL(){return this._objectURL}get promise(){return this._promise}_setLoading(t){this._loading=t,this._target.dispatchEvent(new CustomEvent("wcs-fetch:loading-changed",{detail:t,bubbles:!0}))}_setError(t){this._error!==t&&(this._error=t,this._target.dispatchEvent(new CustomEvent("wcs-fetch:error",{detail:t,bubbles:!0})))}_setResponse(t,e,s=null){null!==this._objectURL&&this._revokeObjectURL(this._objectURL),this._objectURL=s,this._value=t,this._status=e,this._target.dispatchEvent(new CustomEvent("wcs-fetch:response",{detail:{value:t,status:e,objectURL:s},bubbles:!0}))}_createObjectURL(t){return"undefined"!=typeof URL&&"function"==typeof URL.createObjectURL?URL.createObjectURL(t):null}_revokeObjectURL(t){"undefined"!=typeof URL&&"function"==typeof URL.revokeObjectURL&&URL.revokeObjectURL(t)}abort(){this._abortController&&(this._abortController.abort(),this._abortController=null)}async fetch(t,e={}){if(!t)return this._setError({message:"url attribute is required."}),null;const s=this._doFetch(t,e);return this._promise=s,s}async _doFetch(t,e){this.abort();const s=new AbortController;this._abortController=s;const{signal:r}=s,n=++this._gen;this._setLoading(!0),this._setError(null);const{method:o="GET",body:i=null,contentType:a=null,forceText:l=!1,responseType:c="auto"}=e,h={...e.headers??{}};try{a&&!h["Content-Type"]&&(h["Content-Type"]=a);const e={method:o,headers:h,signal:r};"GET"!==o&&"HEAD"!==o&&null!==i&&(e.body=i);const s=await globalThis.fetch(t,e);if(n!==this._gen)return null;if(!s.ok){const t=await s.text().catch(()=>""),e={status:s.status,statusText:s.statusText,body:t};return this._setError(e),this._setResponse(null,s.status),this._setLoading(!1),null}if("HEAD"===o)this._setResponse(null,s.status);else if(l){const t=await s.text();this._setResponse(t,s.status)}else if("blob"===c){const t=await s.blob();this._setResponse(t,s.status,this._createObjectURL(t))}else if("arrayBuffer"===c){const t=await s.arrayBuffer();this._setResponse(t,s.status)}else if("text"===c){const t=await s.text();this._setResponse(t,s.status)}else if("json"===c){const t=await s.json();this._setResponse(t,s.status)}else{if((s.headers.get("Content-Type")||"").includes("application/json")){const t=await s.json();this._setResponse(t,s.status)}else{const t=await s.text();this._setResponse(t,s.status)}}return this._setLoading(!1),this._value}catch(t){return n!==this._gen?null:"AbortError"===t.name?(this._setLoading(!1),null):(this._setError(t),this._setResponse(null,0),this._setLoading(!1),null)}finally{this._abortController===s&&(this._abortController=null)}}}let a=!1;function l(t){const e=t.target;if(!(e instanceof Element))return;const s=e.closest(`[${n.triggerAttribute}]`);if(!s)return;const r=s.getAttribute(n.triggerAttribute);if(!r)return;const o=customElements.get(n.tagNames.fetch),i=document.getElementById(r);if(!(o&&i instanceof o))return;const a=i;a.url&&(t.preventDefault(),a.fetch())}class c extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...i.wcBindable,properties:[...i.wcBindable.properties,{name:"trigger",event:"wcs-fetch:trigger-changed"}],inputs:[{name:"url"},{name:"method"},{name:"target"},{name:"manual"},{name:"body"},{name:"responseType"},{name:"trigger"}]};static get observedAttributes(){return["url"]}_core;_body=null;_trigger=!1;_connectedCallbackPromise=Promise.resolve();_autoPending=!1;_connectResolve=null;_lastFetchedUrl=null;_internals=null;constructor(){super(),this._internals=this._initInternals(),this._wireStates({"wcs-fetch:loading-changed":t=>({loading:!0===t}),"wcs-fetch:error":t=>({error:null!=t})}),this._core=new i(this)}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,r]of Object.entries(t))this.addEventListener(s,t=>{const s=this.hasAttribute("debug-states");for(const[n,o]of Object.entries(r(t.detail))){try{o?e.add(n):e.delete(n)}catch{}s&&this.toggleAttribute(`data-wcs-state-${n}`,o)}})}get url(){return this.getAttribute("url")||""}set url(t){null==t?this.removeAttribute("url"):this.setAttribute("url",t)}get method(){return(this.getAttribute("method")||"GET").toUpperCase()}set method(t){null==t?this.removeAttribute("method"):this.setAttribute("method",t)}get target(){return this.getAttribute("target")}set target(t){null==t?this.removeAttribute("target"):this.setAttribute("target",t)}get responseType(){return this.getAttribute("response-type")||"auto"}set responseType(t){null==t?this.removeAttribute("response-type"):this.setAttribute("response-type",t)}get value(){return this._core.value}get loading(){return this._core.loading}get error(){return this._core.error}get status(){return this._core.status}get objectURL(){return this._core.objectURL}get promise(){return this._core.promise}get connectedCallbackPromise(){return this._connectedCallbackPromise}get manual(){return this.hasAttribute("manual")}set manual(t){t?this.setAttribute("manual",""):this.removeAttribute("manual")}get body(){return this._body}set body(t){this._body=t??null}get trigger(){return this._trigger}set trigger(t){if(!!t){if(!this.url)return;this._trigger=!0,this.fetch().finally(()=>{this._trigger=!1,this.dispatchEvent(new CustomEvent("wcs-fetch:trigger-changed",{detail:!1,bubbles:!0}))})}}_collectHeaders(){const t={},e=this.querySelectorAll(n.tagNames.fetchHeader);for(const s of e){const e=s.headerName,r=s.headerValue;e&&(t[e]=r)}return t}_isNativeBodyInit(t){return t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ArrayBuffer||ArrayBuffer.isView(t)}_collectBody(t){if(null!==t)return"string"==typeof t||this._isNativeBodyInit(t)?{body:t,contentType:null}:{body:JSON.stringify(t),contentType:"application/json"};const e=this.querySelector(n.tagNames.fetchBody);return e?{body:e.bodyContent||null,contentType:e.contentType}:{body:null,contentType:null}}abort(){this._core.abort()}_scheduleAutoFetch(){this._autoPending||(this._autoPending=!0,queueMicrotask(()=>{this._autoPending=!1;const t=this._connectResolve;this._connectResolve=null;const e=this.url;this.isConnected&&!this.manual&&e&&e!==this._lastFetchedUrl?this.fetch().finally(()=>t?.()):t?.()}))}async fetch(){this._lastFetchedUrl=this.url;const t=this._collectHeaders(),e=this._body;this._body=null;const{body:s,contentType:r}=this._collectBody(e);s instanceof FormData&&Object.keys(t).some(t=>"content-type"===t.toLowerCase())&&console.warn("[@wcstack/fetch] A manual Content-Type header was set alongside a FormData body. This drops the multipart boundary the browser adds automatically; remove the Content-Type header (e.g. the <wcs-fetch-header>) to fix multipart uploads.");const n=await this._core.fetch(this.url,{method:this.method,headers:t,body:s,contentType:r,forceText:!!this.target,responseType:this.responseType});if(this.target&&null!==n){const t=document.getElementById(this.target);t&&(t.innerHTML=n)}return n}attributeChangedCallback(t,e,s){"url"===t&&this._scheduleAutoFetch()}connectedCallback(){this.style.display="none",n.autoTrigger&&(a||(a=!0,document.addEventListener("click",l))),!this.manual&&this.url&&(this._connectedCallbackPromise=new Promise(t=>{this._connectResolve=t})),this._scheduleAutoFetch()}disconnectedCallback(){this.abort(),this._lastFetchedUrl=null,this._connectResolve?.(),this._connectResolve=null}}class h extends HTMLElement{connectedCallback(){this.style.display="none"}get headerName(){return this.getAttribute("name")||""}get headerValue(){return this.getAttribute("value")||""}}class u extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}get contentType(){return this.getAttribute("type")||"application/json"}get bodyContent(){return this.textContent?.trim()||""}}class d extends HTMLElement{static get observedAttributes(){return["target","root","root-margin","threshold","disabled"]}_observer=null;_done=!1;get target(){return this.getAttribute("target")||""}set target(t){this.setAttribute("target",t)}get root(){return this.getAttribute("root")}set root(t){null===t?this.removeAttribute("root"):this.setAttribute("root",t)}get rootMargin(){return this.getAttribute("root-margin")||"0px"}set rootMargin(t){this.setAttribute("root-margin",t)}get threshold(){const t=Number(this.getAttribute("threshold")??"0");return Number.isFinite(t)?t:0}set threshold(t){this.setAttribute("threshold",String(t))}get disabled(){return this.hasAttribute("disabled")}set disabled(t){t?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get once(){return this.hasAttribute("once")}set once(t){t?this.setAttribute("once",""):this.removeAttribute("once")}connectedCallback(){this._observe()}disconnectedCallback(){this._disconnectObserver()}attributeChangedCallback(){this.isConnected&&this._observe()}_observe(){this._disconnectObserver(),this._done||this.disabled||!this.target||"undefined"==typeof IntersectionObserver||(this._observer=new IntersectionObserver(t=>{t.some(t=>t.isIntersecting)&&this._triggerFetch()},{root:this._resolveRoot(),rootMargin:this.rootMargin,threshold:this.threshold}),this._observer.observe(this))}_disconnectObserver(){this._observer&&(this._observer.disconnect(),this._observer=null)}_resolveRoot(){return this.root&&document.getElementById(this.root)||null}_triggerFetch(){const t=document.getElementById(this.target);t instanceof c&&(t.loading||(t.trigger=!0,this.once&&(this._done=!0,this._disconnectObserver())))}}function g(e){var s;e&&("boolean"==typeof(s=e).autoTrigger&&(t.autoTrigger=s.autoTrigger),"string"==typeof s.triggerAttribute&&(t.triggerAttribute=s.triggerAttribute),s.tagNames&&Object.assign(t.tagNames,s.tagNames),r=null),customElements.get(n.tagNames.fetch)||customElements.define(n.tagNames.fetch,c),customElements.get(n.tagNames.fetchHeader)||customElements.define(n.tagNames.fetchHeader,h),customElements.get(n.tagNames.fetchBody)||customElements.define(n.tagNames.fetchBody,u),customElements.get(n.tagNames.infiniteScroll)||customElements.define(n.tagNames.infiniteScroll,d)}export{i as FetchCore,c as WcsFetch,d as WcsInfiniteScroll,g as bootstrapFetch,o as getConfig};
2
2
  //# sourceMappingURL=index.esm.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/core/FetchCore.ts","../src/autoTrigger.ts","../src/components/Fetch.ts","../src/components/FetchHeader.ts","../src/components/FetchBody.ts","../src/components/InfiniteScroll.ts","../src/bootstrapFetch.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n fetch: string;\n fetchHeader: string;\n fetchBody: string;\n infiniteScroll: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-fetchtarget\",\n tagNames: {\n fetch: \"wcs-fetch\",\n fetchHeader: \"wcs-fetch-header\",\n fetchBody: \"wcs-fetch-body\",\n infiniteScroll: \"wcs-infinite-scroll\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import { IWcBindable } from \"../types.js\";\n\nexport type FetchResponseType = \"auto\" | \"json\" | \"text\" | \"blob\" | \"arrayBuffer\";\n\nexport interface FetchRequestOptions {\n method?: string;\n headers?: Record<string, string>;\n body?: BodyInit | null;\n contentType?: string | null;\n forceText?: boolean;\n // How to read the response body. \"auto\" (default) sniffs Content-Type (JSON or\n // text). \"blob\"/\"arrayBuffer\" enable binary downloads; \"blob\" additionally\n // publishes a managed `objectURL`. `forceText` (HTML-replace mode) takes\n // priority over this.\n responseType?: FetchResponseType;\n}\n\nexport class FetchCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"value\", event: \"wcs-fetch:response\", getter: (e: Event) => (e as CustomEvent).detail.value },\n { name: \"loading\", event: \"wcs-fetch:loading-changed\" },\n { name: \"error\", event: \"wcs-fetch:error\" },\n { name: \"status\", event: \"wcs-fetch:response\", getter: (e: Event) => (e as CustomEvent).detail.status },\n // Managed object URL for a `responseType: \"blob\"` response (null otherwise).\n // The Core revokes the previous URL on each new response and on dispose, so\n // a consumer can bind it straight into <img src> without lifecycle glue.\n { name: \"objectURL\", event: \"wcs-fetch:response\", getter: (e: Event) => (e as CustomEvent).detail.objectURL },\n ],\n inputs: [\n { name: \"url\" },\n { name: \"method\" },\n ],\n commands: [\n { name: \"fetch\", async: true },\n { name: \"abort\" },\n ],\n };\n\n private _target: EventTarget;\n private _value: any = null;\n private _loading: boolean = false;\n private _error: any = null;\n private _status: number = 0;\n private _objectURL: string | null = null;\n private _abortController: AbortController | null = null;\n private _promise: Promise<any> = Promise.resolve(null);\n // Generation guard (§3.4): bumped on dispose() (and each fetch start). An\n // in-flight request that settles after dispose / a superseding start has a\n // stale `gen` and MUST NOT write state to a torn-down element. A boolean flag\n // is insufficient (dispose→observe would let stale work slip through).\n private _gen = 0;\n // SSR (§3.8): no asynchronous probe to await, 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 get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). Fetch is command-driven with no subscription to\n // establish, so observe() is an idempotent no-op that resolves once ready;\n // dispose() invalidates any in-flight request and aborts it.\n observe(): Promise<void> {\n return this._ready;\n }\n\n dispose(): void {\n this._gen++;\n this.abort();\n // Release any outstanding blob object URL on teardown (the other revoke point\n // is _setResponse, which drops the previous URL when a new response arrives).\n if (this._objectURL !== null) {\n this._revokeObjectURL(this._objectURL);\n this._objectURL = null;\n }\n }\n\n get value(): any {\n return this._value;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): any {\n return this._error;\n }\n\n get status(): number {\n return this._status;\n }\n\n get objectURL(): string | null {\n return this._objectURL;\n }\n\n get promise(): Promise<any> {\n return this._promise;\n }\n\n private _setLoading(loading: boolean): void {\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-fetch:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: any): void {\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-fetch:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _setResponse(value: any, status: number, objectURL: string | null = null): void {\n // Revoke the previous blob object URL before replacing it. Any new response\n // (success, HTTP error, or network error all funnel through here) supersedes\n // the prior one, so the old URL is no longer needed; this plus dispose()\n // revocation keeps blob downloads leak-free.\n if (this._objectURL !== null) {\n this._revokeObjectURL(this._objectURL);\n }\n this._objectURL = objectURL;\n this._value = value;\n this._status = status;\n this._target.dispatchEvent(new CustomEvent(\"wcs-fetch:response\", {\n detail: { value, status, objectURL },\n bubbles: true,\n }));\n }\n\n // Object URL lifecycle for responseType: \"blob\". The Core owns the blob's\n // object URL (mirrors RecorderCore) so a consumer can bind `objectURL` straight\n // into <img src>/<a href> without managing createObjectURL/revokeObjectURL. Both\n // helpers tolerate environments without URL.createObjectURL (SSR / headless).\n private _createObjectURL(blob: Blob): string | null {\n if (typeof URL !== \"undefined\" && typeof URL.createObjectURL === \"function\") {\n return URL.createObjectURL(blob);\n }\n return null;\n }\n\n private _revokeObjectURL(url: string): void {\n if (typeof URL !== \"undefined\" && typeof URL.revokeObjectURL === \"function\") {\n URL.revokeObjectURL(url);\n }\n }\n\n abort(): void {\n if (this._abortController) {\n this._abortController.abort();\n this._abortController = null;\n }\n }\n\n async fetch(url: string, options: FetchRequestOptions = {}): Promise<any> {\n // never-throw (§3.6): 引数バリデーション失敗は例外ではなく error プロパティに\n // 流し、サニタイズ値(null)を返す。command-token 経路からの呼び出しが unhandled\n // rejection にならず、「fetch() は全終了ケースで resolve」契約とも整合する。\n if (!url) {\n this._setError({ message: \"url attribute is required.\" });\n return null;\n }\n\n const p = this._doFetch(url, options);\n this._promise = p;\n return p;\n }\n\n private async _doFetch(url: string, options: FetchRequestOptions): Promise<any> {\n // 進行中のリクエストをキャンセル\n this.abort();\n\n // Hold the controller in a local so the finally block (which can run after a\n // subsequent fetch has already replaced this._abortController) only clears the\n // field when it still owns it. Without the identity check, an aborted earlier\n // request's finally would null out the controller of the request that superseded\n // it, leaving the later request un-abortable.\n const ac = new AbortController();\n this._abortController = ac;\n const { signal } = ac;\n\n // Capture the generation at async start (§3.4). A completion that runs after\n // dispose() (which bumps _gen) is stale and must not write state.\n const gen = ++this._gen;\n\n this._setLoading(true);\n this._setError(null);\n\n const {\n method = \"GET\",\n body = null,\n contentType = null,\n forceText = false,\n responseType = \"auto\",\n } = options;\n\n // Copy the caller's headers so the contentType injection below never mutates\n // the object passed in by a headless consumer (the Shell already builds a\n // fresh object, but direct FetchCore users may reuse theirs).\n const headers: Record<string, string> = { ...(options.headers ?? {}) };\n\n try {\n if (contentType && !headers[\"Content-Type\"]) {\n headers[\"Content-Type\"] = contentType;\n }\n\n const requestInit: RequestInit = {\n method,\n headers,\n signal,\n };\n\n if (method !== \"GET\" && method !== \"HEAD\" && body !== null) {\n requestInit.body = body;\n }\n\n const response = await globalThis.fetch(url, requestInit);\n\n // A stale generation means dispose() (or a superseding fetch) ran while the\n // request was in flight. Drop the result without touching torn-down state.\n if (gen !== this._gen) {\n return null;\n }\n\n if (!response.ok) {\n const errorBody = await response.text().catch(() => \"\");\n const error = { status: response.status, statusText: response.statusText, body: errorBody };\n this._setError(error);\n // Notify `status` observers on HTTP errors too. The `status` property is\n // surfaced via the `wcs-fetch:response` event (getter reads detail.status),\n // so without dispatching it here a bind() subscriber would never see the\n // error status (404, 500, ...). `value` is reset to null on error.\n this._setResponse(null, response.status);\n this._setLoading(false);\n return null;\n }\n\n if (method === \"HEAD\") {\n // HEAD responses carry no body by spec. Reading it as JSON would throw a\n // parse error on the empty body (and end up as a spurious `error`), so skip\n // body reading entirely and surface only the status with a null value.\n this._setResponse(null, response.status);\n } else if (forceText) {\n // HTML-replace mode (the Shell sets forceText when `target` is present)\n // always reads text and takes priority over responseType.\n const text = await response.text();\n this._setResponse(text, response.status);\n } else if (responseType === \"blob\") {\n const blob = await response.blob();\n // Publish a managed object URL alongside the Blob so consumers can bind it\n // directly into <img src> etc.\n this._setResponse(blob, response.status, this._createObjectURL(blob));\n } else if (responseType === \"arrayBuffer\") {\n const buffer = await response.arrayBuffer();\n this._setResponse(buffer, response.status);\n } else if (responseType === \"text\") {\n const text = await response.text();\n this._setResponse(text, response.status);\n } else if (responseType === \"json\") {\n const data = await response.json();\n this._setResponse(data, response.status);\n } else {\n // \"auto\" (default): sniff Content-Type — JSON when it says so, else text.\n const responseContentType = response.headers.get(\"Content-Type\") || \"\";\n if (responseContentType.includes(\"application/json\")) {\n const data = await response.json();\n this._setResponse(data, response.status);\n } else {\n const text = await response.text();\n this._setResponse(text, response.status);\n }\n }\n\n this._setLoading(false);\n return this._value;\n } catch (e: any) {\n // Stale completion (dispose / superseding fetch ran during a later await\n // such as response.json()). Drop the result without writing state.\n if (gen !== this._gen) {\n return null;\n }\n if (e.name === \"AbortError\") {\n // A matching generation means this is an explicit abort() of the current\n // request (a superseding fetch bumps _gen and is caught by the stale guard\n // above; dispose() likewise bumps _gen). Explicit abort clears loading so\n // observers leave the in-flight state.\n this._setLoading(false);\n return null;\n }\n this._setError(e);\n // Reset value/status on network errors too, mirroring the HTTP-error path\n // (`_setResponse(null, response.status)`). Without this, a prior successful\n // request's value/status would linger while `error` is non-null, showing\n // observers an inconsistent state (e.g. status=200 alongside a network\n // error). status=0 is the web-platform convention for \"no HTTP response\"\n // (matches XMLHttpRequest.status on network failure) and the initial value.\n this._setResponse(null, 0);\n this._setLoading(false);\n return null;\n } finally {\n if (this._abortController === ac) {\n this._abortController = null;\n }\n }\n }\n}\n","import { config } from \"./config.js\";\nimport type { Fetch } from \"./components/Fetch.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const fetchId = triggerElement.getAttribute(config.triggerAttribute);\n if (!fetchId) return;\n\n // Resolve the registered constructor at call time instead of importing Fetch\n // as a value. The value import created a components/Fetch.ts ⇄ autoTrigger.ts\n // cycle (Fetch.connectedCallback() calls registerAutoTrigger()). instanceof\n // against the customElements registry keeps the exact same identity guarantee\n // — only the registered <wcs-fetch> class matches — without the import cycle.\n const FetchCtor = customElements.get(config.tagNames.fetch);\n const el = document.getElementById(fetchId);\n if (!FetchCtor || !(el instanceof FetchCtor)) return;\n const fetchElement = el as Fetch;\n\n // Skip when the target has no url. fetch() is fire-and-forget here (its returned\n // promise is intentionally not awaited), and FetchCore.fetch() rejects synchronously\n // on an empty url. Without this guard that rejection would surface as an unhandled\n // promise rejection. Treat a url-less target as \"nothing to do\", consistent with the\n // other early returns above.\n if (!fetchElement.url) return;\n\n // Suppress the element's default action so a fetch can fire without navigating.\n // Intentional: do not attach data-fetchtarget to an element whose default action\n // you also want (real <a href> link, form-submit button) — it will be cancelled.\n // See README \"Optional DOM Triggering\".\n event.preventDefault();\n fetchElement.fetch();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport { IWcBindable } from \"../types.js\";\nimport { FetchCore, FetchResponseType } from \"../core/FetchCore.js\";\nimport { FetchHeader } from \"./FetchHeader.js\";\nimport { FetchBody } from \"./FetchBody.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\nexport class Fetch extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...FetchCore.wcBindable,\n properties: [\n ...FetchCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-fetch:trigger-changed\" },\n ],\n // Shell-level input surface. The Core declares only the portable `url` / `method`;\n // the Shell adds the DOM-driven settable surface. No `attribute` hints are given:\n // these setters already reflect to their attributes themselves, so a binding system\n // that mirrors inputs[].attribute would set the attribute twice. `commands`\n // (fetch / abort) are inherited unchanged from the Core via the spread above.\n inputs: [\n { name: \"url\" },\n { name: \"method\" },\n { name: \"target\" },\n { name: \"manual\" },\n { name: \"body\" },\n { name: \"responseType\" },\n { name: \"trigger\" },\n ],\n };\n static get observedAttributes(): string[] { return [\"url\"]; }\n\n private _core: FetchCore;\n private _body: any = null;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n // Auto-fetch coalescing state (see _scheduleAutoFetch).\n private _autoPending: boolean = false;\n private _connectResolve: (() => void) | null = null;\n private _lastFetchedUrl: string | null = null;\n\n constructor() {\n super();\n this._core = new FetchCore(this);\n }\n\n // Input setters normalize null/undefined to attribute removal instead of\n // letting setAttribute stringify them (\"undefined\" url would auto-fetch\n // /undefined, \"undefined\" method is an invalid HTTP method). The binder\n // already skips undefined writes; this guards direct JS assignment too.\n get url(): string {\n return this.getAttribute(\"url\") || \"\";\n }\n\n set url(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"url\");\n } else {\n this.setAttribute(\"url\", value);\n }\n }\n\n get method(): string {\n return (this.getAttribute(\"method\") || \"GET\").toUpperCase();\n }\n\n set method(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"method\");\n } else {\n this.setAttribute(\"method\", value);\n }\n }\n\n get target(): string | null {\n return this.getAttribute(\"target\");\n }\n\n set target(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"target\");\n } else {\n this.setAttribute(\"target\", value);\n }\n }\n\n // Response body interpretation. Backed by the `response-type` attribute so it is\n // settable from HTML, JS, or a binding. An unknown value falls through to the\n // Core's \"auto\" branch. `target` (HTML-replace mode) overrides this.\n get responseType(): FetchResponseType {\n return (this.getAttribute(\"response-type\") as FetchResponseType) || \"auto\";\n }\n\n set responseType(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"response-type\");\n } else {\n this.setAttribute(\"response-type\", value);\n }\n }\n\n get value(): any {\n return this._core.value;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get status(): number {\n return this._core.status;\n }\n\n get objectURL(): string | null {\n return this._core.objectURL;\n }\n\n get promise(): Promise<any> {\n return this._core.promise;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n if (value) {\n this.setAttribute(\"manual\", \"\");\n } else {\n this.removeAttribute(\"manual\");\n }\n }\n\n get body(): any {\n return this._body;\n }\n\n set body(value: any) {\n // Normalize undefined to null: _collectBody treats \"!== null\" as \"body was\n // provided\", so a raw undefined would serialize as a JSON request body.\n this._body = value ?? null;\n }\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n const v = !!value;\n if (v) {\n // Skip when url is empty. fetch() is fire-and-forget here (its returned\n // promise is intentionally only chained with .finally() to reset the flag,\n // never .catch()'d), and FetchCore.fetch() rejects on an empty url. Without\n // this guard that rejection — re-thrown by .finally() — surfaces as an\n // unhandled promise rejection. Mirrors the url-less guard in autoTrigger.\n //\n // Leave `_trigger` false (do not set it) and emit no event: nothing ran, so\n // surfacing a `wcs-fetch:trigger-changed` \"completion\" would lie to observers.\n // Keeping the flag false also avoids stalling — once url is provided, writing\n // `true` again is a real false→true transition that triggers the fetch.\n if (!this.url) return;\n this._trigger = true;\n this.fetch().finally(() => {\n this._trigger = false;\n this.dispatchEvent(new CustomEvent(\"wcs-fetch:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n });\n }\n }\n\n private _collectHeaders(): Record<string, string> {\n const headers: Record<string, string> = {};\n const headerElements = this.querySelectorAll<FetchHeader>(config.tagNames.fetchHeader);\n for (const el of headerElements) {\n const name = el.headerName;\n const value = el.headerValue;\n if (name) {\n headers[name] = value;\n }\n }\n return headers;\n }\n\n // fetch がネイティブに扱える BodyInit か判定する。これらは JSON.stringify せず\n // 素通しし、Content-Type をブラウザに委ねる (FormData の multipart boundary、\n // Blob の type、URLSearchParams の application/x-www-form-urlencoded を自動付与\n // させるため、_collectBody は contentType に null を返す)。ReadableStream は\n // RequestInit.duplex: 'half' を要するため初版では対象外とし、従来どおり扱う。\n private _isNativeBodyInit(value: unknown): value is BodyInit {\n return value instanceof Blob // File は Blob のサブクラス\n || value instanceof FormData\n || value instanceof URLSearchParams\n || value instanceof ArrayBuffer\n || ArrayBuffer.isView(value); // TypedArray / DataView\n }\n\n private _collectBody(bodySnapshot: any): { body: BodyInit | null; contentType: string | null } {\n // JS API経由のbodyが優先\n if (bodySnapshot !== null) {\n // 文字列はそのまま。Content-Type はユーザーのヘッダ指定に委ねる。\n if (typeof bodySnapshot === \"string\") {\n return { body: bodySnapshot, contentType: null };\n }\n // ネイティブ BodyInit (Blob/File/FormData/URLSearchParams/ArrayBuffer/TypedArray)\n // は素通し。Content-Type はブラウザに委ねるため null を返す。\n if (this._isNativeBodyInit(bodySnapshot)) {\n return { body: bodySnapshot, contentType: null };\n }\n // それ以外のオブジェクトは JSON 化する。\n return { body: JSON.stringify(bodySnapshot), contentType: \"application/json\" };\n }\n\n // サブタグからbodyを取得\n const bodyElement = this.querySelector<FetchBody>(config.tagNames.fetchBody);\n if (bodyElement) {\n return {\n body: bodyElement.bodyContent || null,\n contentType: bodyElement.contentType,\n };\n }\n\n return { body: null, contentType: null };\n }\n\n abort(): void {\n this._core.abort();\n }\n\n /**\n * Coalesce auto-fetch requests in the current task into a single microtask.\n *\n * Multiple synchronous input writes in the same tick — e.g. a `...` spread\n * writing `url` before `manual` — collapse into one decision made against the\n * FINAL element state, so the spread application order can no longer trigger a\n * stray fetch. The microtask re-reads `isConnected` / `manual` / `url` at fire\n * time; whatever was written last wins.\n *\n * Only the implicit auto-fetch (url attribute change, connect-time) is routed\n * here. Explicit triggers — the `trigger` setter, the `fetch` command, and\n * autoTrigger (data-fetchtarget clicks) — must fire immediately and stay on\n * their own synchronous paths.\n *\n * The connect-time promise (connectedCallbackPromise) is resolved here in\n * EVERY exit path, including the no-fetch branch, so awaiting it never hangs\n * when the final state turns out to be manual / url-less / disconnected.\n */\n private _scheduleAutoFetch(): void {\n if (this._autoPending) {\n return;\n }\n this._autoPending = true;\n queueMicrotask(() => {\n this._autoPending = false;\n const resolveConnect = this._connectResolve;\n this._connectResolve = null;\n const url = this.url;\n // Same-value guard (Phase 4): skip a redundant auto-fetch for the url we\n // last fetched. A spread re-evaluation rewrites every input each cycle, so\n // the `url` setter calls setAttribute with an unchanged value and fires\n // attributeChangedCallback again; without this guard an unrelated state\n // change would refetch. Auto-path only — explicit fetch()/trigger/command\n // stay unconditional (a manual refresh of the same url must work), and\n // `_lastFetchedUrl` is reset on disconnect so a remount refetches.\n if (this.isConnected && !this.manual && url && url !== this._lastFetchedUrl) {\n // fetch() cannot reject here: FetchCore swallows network/HTTP errors and\n // only rejects on an empty url, which the `url` guard above rules out.\n this.fetch().finally(() => resolveConnect?.());\n } else {\n resolveConnect?.();\n }\n });\n }\n\n async fetch(): Promise<any> {\n // Record the url for the auto-fetch same-value guard. Every fetch (explicit\n // included) updates it so a later auto-write of the same url is treated as a\n // no-op rather than a duplicate request.\n this._lastFetchedUrl = this.url;\n const headers = this._collectHeaders();\n\n // Snapshot and reset `body` synchronously, before any await. The body is a\n // one-shot input; resetting it after the await (when another caller may have\n // already set a new body for the next request) would silently drop that value.\n const bodySnapshot = this._body;\n this._body = null;\n const { body, contentType } = this._collectBody(bodySnapshot);\n\n // FormData に手動で Content-Type を付けると、ブラウザが付与するはずの multipart\n // boundary が失われてサーバー側でパースできなくなる。ヘッダはユーザー指定を\n // 尊重して素通しするが、この典型的な誤設定は警告する。\n if (body instanceof FormData &&\n Object.keys(headers).some((name) => name.toLowerCase() === \"content-type\")) {\n console.warn(\n \"[@wcstack/fetch] A manual Content-Type header was set alongside a FormData body. \" +\n \"This drops the multipart boundary the browser adds automatically; remove the \" +\n \"Content-Type header (e.g. the <wcs-fetch-header>) to fix multipart uploads.\",\n );\n }\n\n const result = await this._core.fetch(this.url, {\n method: this.method,\n headers,\n body,\n contentType,\n forceText: !!this.target,\n responseType: this.responseType,\n });\n\n // HTML置換モード\n // Security: the response is injected as raw innerHTML without sanitization.\n // This is an opt-in convenience for trusted fragments only; the primary,\n // recommended path is state-driven binding via @wcstack/state. Do not point\n // `target` at an untrusted endpoint (XSS risk). See README \"HTML Replace Mode\".\n if (this.target && result !== null) {\n const targetElement = document.getElementById(this.target);\n if (targetElement) {\n targetElement.innerHTML = result;\n }\n }\n\n return result;\n }\n\n attributeChangedCallback(name: string, _oldValue: string | null, _newValue: string | null): void {\n // Re-fetch on url changes, but intentionally do NOT update\n // `_connectedCallbackPromise`. Per the wc-bindable connectedCallbackPromise\n // protocol that promise represents the one-shot \"connect-time initialization\n // is done\" signal; it resolves once and is not re-armed for later url-driven\n // requests. Await `promise` if you need to track a specific re-fetch.\n //\n // Defer the decision to a microtask (see _scheduleAutoFetch) instead of\n // fetching synchronously here: a `...` spread writes `url` before `manual`,\n // so a synchronous fetch would fire before `manual` is applied. The final\n // state (isConnected / manual / url) is re-read at microtask time.\n if (name === \"url\") {\n this._scheduleAutoFetch();\n }\n }\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // Only the initial connect-time fetch is tracked by connectedCallbackPromise.\n // Arm a deferred here when an auto-fetch looks likely; the scheduled\n // microtask resolves it (in every exit path, so awaiting never hangs). The\n // actual fetch decision is re-evaluated at microtask time against the final\n // state, so a spread that sets `manual` after `url` still suppresses it.\n if (!this.manual && this.url) {\n this._connectedCallbackPromise = new Promise<void>((resolve) => {\n this._connectResolve = resolve;\n });\n }\n this._scheduleAutoFetch();\n }\n\n disconnectedCallback(): void {\n this.abort();\n // Reset the same-value guard so a remount (reconnect with the same url)\n // refetches rather than being skipped as a duplicate.\n this._lastFetchedUrl = null;\n // Resolve any armed connect-time deferred before detaching. A synchronous\n // remove()→append() before the scheduled microtask fires would otherwise let\n // the second connectedCallback overwrite _connectResolve, orphaning the first\n // deferred and hanging any caller that already awaited connectedCallbackPromise.\n // Disconnection makes connect-time init moot, so resolving (never hanging) is\n // correct; the pending microtask then sees _connectResolve === null and no-ops.\n this._connectResolve?.();\n this._connectResolve = null;\n }\n}\n","export class FetchHeader extends HTMLElement {\n connectedCallback(): void {\n this.style.display = \"none\";\n }\n\n get headerName(): string {\n return this.getAttribute(\"name\") || \"\";\n }\n\n get headerValue(): string {\n return this.getAttribute(\"value\") || \"\";\n }\n}\n","export class FetchBody extends HTMLElement {\n constructor() {\n super();\n // スロットなしのShadow DOMでlight DOM(bodyテキスト)の描画を抑制\n this.attachShadow({ mode: \"open\" });\n }\n\n get contentType(): string {\n return this.getAttribute(\"type\") || \"application/json\";\n }\n\n get bodyContent(): string {\n return this.textContent?.trim() || \"\";\n }\n}\n","import { Fetch } from \"./Fetch.js\";\n\nexport class InfiniteScroll extends HTMLElement {\n static get observedAttributes(): string[] {\n return [\"target\", \"root\", \"root-margin\", \"threshold\", \"disabled\"];\n }\n\n private _observer: IntersectionObserver | null = null;\n private _done: boolean = false;\n\n get target(): string {\n return this.getAttribute(\"target\") || \"\";\n }\n\n set target(value: string) {\n this.setAttribute(\"target\", value);\n }\n\n get root(): string | null {\n return this.getAttribute(\"root\");\n }\n\n set root(value: string | null) {\n if (value === null) {\n this.removeAttribute(\"root\");\n } else {\n this.setAttribute(\"root\", value);\n }\n }\n\n get rootMargin(): string {\n return this.getAttribute(\"root-margin\") || \"0px\";\n }\n\n set rootMargin(value: string) {\n this.setAttribute(\"root-margin\", value);\n }\n\n get threshold(): number {\n const value = Number(this.getAttribute(\"threshold\") ?? \"0\");\n return Number.isFinite(value) ? value : 0;\n }\n\n set threshold(value: number) {\n this.setAttribute(\"threshold\", String(value));\n }\n\n get disabled(): boolean {\n return this.hasAttribute(\"disabled\");\n }\n\n set disabled(value: boolean) {\n if (value) {\n this.setAttribute(\"disabled\", \"\");\n } else {\n this.removeAttribute(\"disabled\");\n }\n }\n\n get once(): boolean {\n return this.hasAttribute(\"once\");\n }\n\n set once(value: boolean) {\n if (value) {\n this.setAttribute(\"once\", \"\");\n } else {\n this.removeAttribute(\"once\");\n }\n }\n\n connectedCallback(): void {\n this._observe();\n }\n\n disconnectedCallback(): void {\n this._disconnectObserver();\n }\n\n attributeChangedCallback(): void {\n if (this.isConnected) {\n this._observe();\n }\n }\n\n private _observe(): void {\n this._disconnectObserver();\n\n if (this._done || this.disabled || !this.target || typeof IntersectionObserver === \"undefined\") {\n return;\n }\n\n this._observer = new IntersectionObserver((entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n this._triggerFetch();\n }\n }, {\n root: this._resolveRoot(),\n rootMargin: this.rootMargin,\n threshold: this.threshold,\n });\n this._observer.observe(this);\n }\n\n private _disconnectObserver(): void {\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n }\n\n private _resolveRoot(): Element | Document | null {\n if (!this.root) return null;\n return document.getElementById(this.root) || null;\n }\n\n private _triggerFetch(): void {\n const target = document.getElementById(this.target);\n if (!(target instanceof Fetch)) {\n return;\n }\n\n if (target.loading) {\n return;\n }\n\n target.trigger = true;\n\n if (this.once) {\n this._done = true;\n this._disconnectObserver();\n }\n }\n}","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapFetch(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { Fetch } from \"./components/Fetch.js\";\nimport { FetchHeader } from \"./components/FetchHeader.js\";\nimport { FetchBody } from \"./components/FetchBody.js\";\nimport { InfiniteScroll } from \"./components/InfiniteScroll.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.fetch)) {\n customElements.define(config.tagNames.fetch, Fetch);\n }\n if (!customElements.get(config.tagNames.fetchHeader)) {\n customElements.define(config.tagNames.fetchHeader, FetchHeader);\n }\n if (!customElements.get(config.tagNames.fetchBody)) {\n customElements.define(config.tagNames.fetchBody, FetchBody);\n }\n if (!customElements.get(config.tagNames.infiniteScroll)) {\n customElements.define(config.tagNames.infiniteScroll, InfiniteScroll);\n }\n}\n"],"names":["_config","autoTrigger","triggerAttribute","tagNames","fetch","fetchHeader","fetchBody","infiniteScroll","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","FetchCore","EventTarget","static","protocol","version","properties","name","event","getter","e","detail","value","status","objectURL","inputs","commands","async","_target","_value","_loading","_error","_status","_objectURL","_abortController","_promise","Promise","resolve","_gen","_ready","constructor","target","super","this","ready","observe","dispose","abort","_revokeObjectURL","loading","error","promise","_setLoading","dispatchEvent","CustomEvent","bubbles","_setError","_setResponse","_createObjectURL","blob","URL","createObjectURL","url","revokeObjectURL","options","message","p","_doFetch","ac","AbortController","signal","gen","method","body","contentType","forceText","responseType","headers","requestInit","response","globalThis","ok","errorBody","text","catch","statusText","buffer","arrayBuffer","data","json","get","includes","registered","handleClick","Element","triggerElement","closest","fetchId","getAttribute","FetchCtor","customElements","el","document","getElementById","fetchElement","preventDefault","Fetch","HTMLElement","wcBindable","observedAttributes","_core","_body","_trigger","_connectedCallbackPromise","_autoPending","_connectResolve","_lastFetchedUrl","removeAttribute","setAttribute","toUpperCase","connectedCallbackPromise","manual","hasAttribute","trigger","finally","_collectHeaders","headerElements","querySelectorAll","headerName","headerValue","_isNativeBodyInit","Blob","FormData","URLSearchParams","ArrayBuffer","isView","_collectBody","bodySnapshot","JSON","stringify","bodyElement","querySelector","bodyContent","_scheduleAutoFetch","queueMicrotask","resolveConnect","isConnected","some","toLowerCase","console","warn","result","targetElement","innerHTML","attributeChangedCallback","_oldValue","_newValue","connectedCallback","style","display","addEventListener","disconnectedCallback","FetchHeader","FetchBody","attachShadow","mode","textContent","trim","InfiniteScroll","_observer","_done","root","rootMargin","threshold","Number","isFinite","String","disabled","once","_observe","_disconnectObserver","IntersectionObserver","entries","entry","isIntersecting","_triggerFetch","_resolveRoot","disconnect","bootstrapFetch","userConfig","partialConfig","assign","define"],"mappings":"AAaA,MAAMA,EAA2B,CAC/BC,aAAa,EACbC,iBAAkB,mBAClBC,SAAU,CACRC,MAAO,YACPC,YAAa,mBACbC,UAAW,iBACXC,eAAgB,wBAIpB,SAASC,EAAcC,GACrB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpDC,OAAOC,OAAOF,GACd,IAAK,MA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,IAAoBC,EOhDpBD,IPiDqC,kBADjBC,EO/CZD,GPgDapM,cACvBD,EAAQC,YAAcqM,EAAcrM,aAEQ,iBAAnCqM,EAAcpM,mBACvBF,EAAQE,iBAAmBoM,EAAcpM,kBAEvCoM,EAAcnM,UAChBO,OAAO6L,OAAOvM,EAAQG,SAAUmM,EAAcnM,UAEhDa,EAAe,MQxDV4F,eAAeV,IAAIjF,EAAOd,SAASC,QACtCwG,eAAe4F,OAAOvL,EAAOd,SAASC,MAAO8G,GAE1CN,eAAeV,IAAIjF,EAAOd,SAASE,cACtCuG,eAAe4F,OAAOvL,EAAOd,SAASE,YAAaqK,GAEhD9D,eAAeV,IAAIjF,EAAOd,SAASG,YACtCsG,eAAe4F,OAAOvL,EAAOd,SAASG,UAAWqK,GAE9C/D,eAAeV,IAAIjF,EAAOd,SAASI,iBACtCqG,eAAe4F,OAAOvL,EAAOd,SAASI,eAAgByK,EDR1D"}
1
+ {"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/core/FetchCore.ts","../src/autoTrigger.ts","../src/components/Fetch.ts","../src/components/FetchHeader.ts","../src/components/FetchBody.ts","../src/components/InfiniteScroll.ts","../src/bootstrapFetch.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n fetch: string;\n fetchHeader: string;\n fetchBody: string;\n infiniteScroll: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-fetchtarget\",\n tagNames: {\n fetch: \"wcs-fetch\",\n fetchHeader: \"wcs-fetch-header\",\n fetchBody: \"wcs-fetch-body\",\n infiniteScroll: \"wcs-infinite-scroll\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import { IWcBindable } from \"../types.js\";\n\nexport type FetchResponseType = \"auto\" | \"json\" | \"text\" | \"blob\" | \"arrayBuffer\";\n\nexport interface FetchRequestOptions {\n method?: string;\n headers?: Record<string, string>;\n body?: BodyInit | null;\n contentType?: string | null;\n forceText?: boolean;\n // How to read the response body. \"auto\" (default) sniffs Content-Type (JSON or\n // text). \"blob\"/\"arrayBuffer\" enable binary downloads; \"blob\" additionally\n // publishes a managed `objectURL`. `forceText` (HTML-replace mode) takes\n // priority over this.\n responseType?: FetchResponseType;\n}\n\nexport class FetchCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"value\", event: \"wcs-fetch:response\", getter: (e: Event) => (e as CustomEvent).detail.value },\n { name: \"loading\", event: \"wcs-fetch:loading-changed\" },\n { name: \"error\", event: \"wcs-fetch:error\" },\n { name: \"status\", event: \"wcs-fetch:response\", getter: (e: Event) => (e as CustomEvent).detail.status },\n // Managed object URL for a `responseType: \"blob\"` response (null otherwise).\n // The Core revokes the previous URL on each new response and on dispose, so\n // a consumer can bind it straight into <img src> without lifecycle glue.\n { name: \"objectURL\", event: \"wcs-fetch:response\", getter: (e: Event) => (e as CustomEvent).detail.objectURL },\n ],\n inputs: [\n { name: \"url\" },\n { name: \"method\" },\n ],\n commands: [\n { name: \"fetch\", async: true },\n { name: \"abort\" },\n ],\n };\n\n private _target: EventTarget;\n private _value: any = null;\n private _loading: boolean = false;\n private _error: any = null;\n private _status: number = 0;\n private _objectURL: string | null = null;\n private _abortController: AbortController | null = null;\n private _promise: Promise<any> = Promise.resolve(null);\n // Generation guard (§3.4): bumped on dispose() (and each fetch start). An\n // in-flight request that settles after dispose / a superseding start has a\n // stale `gen` and MUST NOT write state to a torn-down element. A boolean flag\n // is insufficient (dispose→observe would let stale work slip through).\n private _gen = 0;\n // SSR (§3.8): no asynchronous probe to await, 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 get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). Fetch is command-driven with no subscription to\n // establish, so observe() is an idempotent no-op that resolves once ready;\n // dispose() invalidates any in-flight request and aborts it.\n observe(): Promise<void> {\n return this._ready;\n }\n\n dispose(): void {\n this._gen++;\n this.abort();\n // Release any outstanding blob object URL on teardown (the other revoke point\n // is _setResponse, which drops the previous URL when a new response arrives).\n if (this._objectURL !== null) {\n this._revokeObjectURL(this._objectURL);\n this._objectURL = null;\n }\n }\n\n get value(): any {\n return this._value;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): any {\n return this._error;\n }\n\n get status(): number {\n return this._status;\n }\n\n get objectURL(): string | null {\n return this._objectURL;\n }\n\n get promise(): Promise<any> {\n return this._promise;\n }\n\n private _setLoading(loading: boolean): void {\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-fetch:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: any): void {\n // Same-value guard (async-io-node-guidelines.md §3.3). `error` is state-ish,\n // so suppressing redundant null→null dispatches (every fetch start clears a\n // usually-already-null error) avoids a spurious wcs-fetch:error per successful\n // request. Reference identity is sufficient: each failure builds a fresh\n // object, and the clear path always passes null.\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-fetch:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _setResponse(value: any, status: number, objectURL: string | null = null): void {\n // Revoke the previous blob object URL before replacing it. Any new response\n // (success, HTTP error, or network error all funnel through here) supersedes\n // the prior one, so the old URL is no longer needed; this plus dispose()\n // revocation keeps blob downloads leak-free.\n if (this._objectURL !== null) {\n this._revokeObjectURL(this._objectURL);\n }\n this._objectURL = objectURL;\n this._value = value;\n this._status = status;\n this._target.dispatchEvent(new CustomEvent(\"wcs-fetch:response\", {\n detail: { value, status, objectURL },\n bubbles: true,\n }));\n }\n\n // Object URL lifecycle for responseType: \"blob\". The Core owns the blob's\n // object URL (mirrors RecorderCore) so a consumer can bind `objectURL` straight\n // into <img src>/<a href> without managing createObjectURL/revokeObjectURL. Both\n // helpers tolerate environments without URL.createObjectURL (SSR / headless).\n private _createObjectURL(blob: Blob): string | null {\n if (typeof URL !== \"undefined\" && typeof URL.createObjectURL === \"function\") {\n return URL.createObjectURL(blob);\n }\n return null;\n }\n\n private _revokeObjectURL(url: string): void {\n if (typeof URL !== \"undefined\" && typeof URL.revokeObjectURL === \"function\") {\n URL.revokeObjectURL(url);\n }\n }\n\n abort(): void {\n if (this._abortController) {\n this._abortController.abort();\n this._abortController = null;\n }\n }\n\n async fetch(url: string, options: FetchRequestOptions = {}): Promise<any> {\n // never-throw (§3.6): 引数バリデーション失敗は例外ではなく error プロパティに\n // 流し、サニタイズ値(null)を返す。command-token 経路からの呼び出しが unhandled\n // rejection にならず、「fetch() は全終了ケースで resolve」契約とも整合する。\n if (!url) {\n this._setError({ message: \"url attribute is required.\" });\n return null;\n }\n\n const p = this._doFetch(url, options);\n this._promise = p;\n return p;\n }\n\n private async _doFetch(url: string, options: FetchRequestOptions): Promise<any> {\n // 進行中のリクエストをキャンセル\n this.abort();\n\n // Hold the controller in a local so the finally block (which can run after a\n // subsequent fetch has already replaced this._abortController) only clears the\n // field when it still owns it. Without the identity check, an aborted earlier\n // request's finally would null out the controller of the request that superseded\n // it, leaving the later request un-abortable.\n const ac = new AbortController();\n this._abortController = ac;\n const { signal } = ac;\n\n // Capture the generation at async start (§3.4). A completion that runs after\n // dispose() (which bumps _gen) is stale and must not write state.\n const gen = ++this._gen;\n\n this._setLoading(true);\n this._setError(null);\n\n const {\n method = \"GET\",\n body = null,\n contentType = null,\n forceText = false,\n responseType = \"auto\",\n } = options;\n\n // Copy the caller's headers so the contentType injection below never mutates\n // the object passed in by a headless consumer (the Shell already builds a\n // fresh object, but direct FetchCore users may reuse theirs).\n const headers: Record<string, string> = { ...(options.headers ?? {}) };\n\n try {\n if (contentType && !headers[\"Content-Type\"]) {\n headers[\"Content-Type\"] = contentType;\n }\n\n const requestInit: RequestInit = {\n method,\n headers,\n signal,\n };\n\n if (method !== \"GET\" && method !== \"HEAD\" && body !== null) {\n requestInit.body = body;\n }\n\n const response = await globalThis.fetch(url, requestInit);\n\n // A stale generation means dispose() (or a superseding fetch) ran while the\n // request was in flight. Drop the result without touching torn-down state.\n if (gen !== this._gen) {\n return null;\n }\n\n if (!response.ok) {\n const errorBody = await response.text().catch(() => \"\");\n const error = { status: response.status, statusText: response.statusText, body: errorBody };\n this._setError(error);\n // Notify `status` observers on HTTP errors too. The `status` property is\n // surfaced via the `wcs-fetch:response` event (getter reads detail.status),\n // so without dispatching it here a bind() subscriber would never see the\n // error status (404, 500, ...). `value` is reset to null on error.\n this._setResponse(null, response.status);\n this._setLoading(false);\n return null;\n }\n\n if (method === \"HEAD\") {\n // HEAD responses carry no body by spec. Reading it as JSON would throw a\n // parse error on the empty body (and end up as a spurious `error`), so skip\n // body reading entirely and surface only the status with a null value.\n this._setResponse(null, response.status);\n } else if (forceText) {\n // HTML-replace mode (the Shell sets forceText when `target` is present)\n // always reads text and takes priority over responseType.\n const text = await response.text();\n this._setResponse(text, response.status);\n } else if (responseType === \"blob\") {\n const blob = await response.blob();\n // Publish a managed object URL alongside the Blob so consumers can bind it\n // directly into <img src> etc.\n this._setResponse(blob, response.status, this._createObjectURL(blob));\n } else if (responseType === \"arrayBuffer\") {\n const buffer = await response.arrayBuffer();\n this._setResponse(buffer, response.status);\n } else if (responseType === \"text\") {\n const text = await response.text();\n this._setResponse(text, response.status);\n } else if (responseType === \"json\") {\n const data = await response.json();\n this._setResponse(data, response.status);\n } else {\n // \"auto\" (default): sniff Content-Type — JSON when it says so, else text.\n const responseContentType = response.headers.get(\"Content-Type\") || \"\";\n if (responseContentType.includes(\"application/json\")) {\n const data = await response.json();\n this._setResponse(data, response.status);\n } else {\n const text = await response.text();\n this._setResponse(text, response.status);\n }\n }\n\n this._setLoading(false);\n return this._value;\n } catch (e: any) {\n // Stale completion (dispose / superseding fetch ran during a later await\n // such as response.json()). Drop the result without writing state.\n if (gen !== this._gen) {\n return null;\n }\n if (e.name === \"AbortError\") {\n // A matching generation means this is an explicit abort() of the current\n // request (a superseding fetch bumps _gen and is caught by the stale guard\n // above; dispose() likewise bumps _gen). Explicit abort clears loading so\n // observers leave the in-flight state.\n this._setLoading(false);\n return null;\n }\n this._setError(e);\n // Reset value/status on network errors too, mirroring the HTTP-error path\n // (`_setResponse(null, response.status)`). Without this, a prior successful\n // request's value/status would linger while `error` is non-null, showing\n // observers an inconsistent state (e.g. status=200 alongside a network\n // error). status=0 is the web-platform convention for \"no HTTP response\"\n // (matches XMLHttpRequest.status on network failure) and the initial value.\n this._setResponse(null, 0);\n this._setLoading(false);\n return null;\n } finally {\n if (this._abortController === ac) {\n this._abortController = null;\n }\n }\n }\n}\n","import { config } from \"./config.js\";\nimport type { Fetch } from \"./components/Fetch.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const fetchId = triggerElement.getAttribute(config.triggerAttribute);\n if (!fetchId) return;\n\n // Resolve the registered constructor at call time instead of importing Fetch\n // as a value. The value import created a components/Fetch.ts ⇄ autoTrigger.ts\n // cycle (Fetch.connectedCallback() calls registerAutoTrigger()). instanceof\n // against the customElements registry keeps the exact same identity guarantee\n // — only the registered <wcs-fetch> class matches — without the import cycle.\n const FetchCtor = customElements.get(config.tagNames.fetch);\n const el = document.getElementById(fetchId);\n if (!FetchCtor || !(el instanceof FetchCtor)) return;\n const fetchElement = el as Fetch;\n\n // Skip when the target has no url. fetch() is fire-and-forget here (its returned\n // promise is intentionally not awaited), and FetchCore.fetch() rejects synchronously\n // on an empty url. Without this guard that rejection would surface as an unhandled\n // promise rejection. Treat a url-less target as \"nothing to do\", consistent with the\n // other early returns above.\n if (!fetchElement.url) return;\n\n // Suppress the element's default action so a fetch can fire without navigating.\n // Intentional: do not attach data-fetchtarget to an element whose default action\n // you also want (real <a href> link, form-submit button) — it will be cancelled.\n // See README \"Optional DOM Triggering\".\n event.preventDefault();\n fetchElement.fetch();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport { IWcBindable } from \"../types.js\";\nimport { FetchCore, FetchResponseType } from \"../core/FetchCore.js\";\nimport { FetchHeader } from \"./FetchHeader.js\";\nimport { FetchBody } from \"./FetchBody.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\nexport class Fetch extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...FetchCore.wcBindable,\n properties: [\n ...FetchCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-fetch:trigger-changed\" },\n ],\n // Shell-level input surface. The Core declares only the portable `url` / `method`;\n // the Shell adds the DOM-driven settable surface. No `attribute` hints are given:\n // these setters already reflect to their attributes themselves, so a binding system\n // that mirrors inputs[].attribute would set the attribute twice. `commands`\n // (fetch / abort) are inherited unchanged from the Core via the spread above.\n inputs: [\n { name: \"url\" },\n { name: \"method\" },\n { name: \"target\" },\n { name: \"manual\" },\n { name: \"body\" },\n { name: \"responseType\" },\n { name: \"trigger\" },\n ],\n };\n static get observedAttributes(): string[] { return [\"url\"]; }\n\n private _core: FetchCore;\n private _body: any = null;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n // Auto-fetch coalescing state (see _scheduleAutoFetch).\n private _autoPending: boolean = false;\n private _connectResolve: (() => void) | null = null;\n private _lastFetchedUrl: string | null = null;\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n // State reflection is wired BEFORE the Core is constructed (canonical\n // order): a Core that dispatches synchronously from its constructor\n // (e.g. speech's unsupported-changed) would otherwise fire before the\n // listeners exist. FetchCore doesn't do that, so this is equivalent here,\n // but every Shell keeps the same order.\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-fetch:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-fetch:error\": (d) => ({ error: d != null }),\n });\n this._core = new FetchCore(this);\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 // Input setters normalize null/undefined to attribute removal instead of\n // letting setAttribute stringify them (\"undefined\" url would auto-fetch\n // /undefined, \"undefined\" method is an invalid HTTP method). The binder\n // already skips undefined writes; this guards direct JS assignment too.\n get url(): string {\n return this.getAttribute(\"url\") || \"\";\n }\n\n set url(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"url\");\n } else {\n this.setAttribute(\"url\", value);\n }\n }\n\n get method(): string {\n return (this.getAttribute(\"method\") || \"GET\").toUpperCase();\n }\n\n set method(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"method\");\n } else {\n this.setAttribute(\"method\", value);\n }\n }\n\n get target(): string | null {\n return this.getAttribute(\"target\");\n }\n\n set target(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"target\");\n } else {\n this.setAttribute(\"target\", value);\n }\n }\n\n // Response body interpretation. Backed by the `response-type` attribute so it is\n // settable from HTML, JS, or a binding. An unknown value falls through to the\n // Core's \"auto\" branch. `target` (HTML-replace mode) overrides this.\n get responseType(): FetchResponseType {\n return (this.getAttribute(\"response-type\") as FetchResponseType) || \"auto\";\n }\n\n set responseType(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"response-type\");\n } else {\n this.setAttribute(\"response-type\", value);\n }\n }\n\n get value(): any {\n return this._core.value;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get status(): number {\n return this._core.status;\n }\n\n get objectURL(): string | null {\n return this._core.objectURL;\n }\n\n get promise(): Promise<any> {\n return this._core.promise;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n if (value) {\n this.setAttribute(\"manual\", \"\");\n } else {\n this.removeAttribute(\"manual\");\n }\n }\n\n get body(): any {\n return this._body;\n }\n\n set body(value: any) {\n // Normalize undefined to null: _collectBody treats \"!== null\" as \"body was\n // provided\", so a raw undefined would serialize as a JSON request body.\n this._body = value ?? null;\n }\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n const v = !!value;\n if (v) {\n // Skip when url is empty. fetch() is fire-and-forget here (its returned\n // promise is intentionally only chained with .finally() to reset the flag,\n // never .catch()'d), and FetchCore.fetch() rejects on an empty url. Without\n // this guard that rejection — re-thrown by .finally() — surfaces as an\n // unhandled promise rejection. Mirrors the url-less guard in autoTrigger.\n //\n // Leave `_trigger` false (do not set it) and emit no event: nothing ran, so\n // surfacing a `wcs-fetch:trigger-changed` \"completion\" would lie to observers.\n // Keeping the flag false also avoids stalling — once url is provided, writing\n // `true` again is a real false→true transition that triggers the fetch.\n if (!this.url) return;\n this._trigger = true;\n this.fetch().finally(() => {\n this._trigger = false;\n this.dispatchEvent(new CustomEvent(\"wcs-fetch:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n });\n }\n }\n\n private _collectHeaders(): Record<string, string> {\n const headers: Record<string, string> = {};\n const headerElements = this.querySelectorAll<FetchHeader>(config.tagNames.fetchHeader);\n for (const el of headerElements) {\n const name = el.headerName;\n const value = el.headerValue;\n if (name) {\n headers[name] = value;\n }\n }\n return headers;\n }\n\n // fetch がネイティブに扱える BodyInit か判定する。これらは JSON.stringify せず\n // 素通しし、Content-Type をブラウザに委ねる (FormData の multipart boundary、\n // Blob の type、URLSearchParams の application/x-www-form-urlencoded を自動付与\n // させるため、_collectBody は contentType に null を返す)。ReadableStream は\n // RequestInit.duplex: 'half' を要するため初版では対象外とし、従来どおり扱う。\n private _isNativeBodyInit(value: unknown): value is BodyInit {\n return value instanceof Blob // File は Blob のサブクラス\n || value instanceof FormData\n || value instanceof URLSearchParams\n || value instanceof ArrayBuffer\n || ArrayBuffer.isView(value); // TypedArray / DataView\n }\n\n private _collectBody(bodySnapshot: any): { body: BodyInit | null; contentType: string | null } {\n // JS API経由のbodyが優先\n if (bodySnapshot !== null) {\n // 文字列はそのまま。Content-Type はユーザーのヘッダ指定に委ねる。\n if (typeof bodySnapshot === \"string\") {\n return { body: bodySnapshot, contentType: null };\n }\n // ネイティブ BodyInit (Blob/File/FormData/URLSearchParams/ArrayBuffer/TypedArray)\n // は素通し。Content-Type はブラウザに委ねるため null を返す。\n if (this._isNativeBodyInit(bodySnapshot)) {\n return { body: bodySnapshot, contentType: null };\n }\n // それ以外のオブジェクトは JSON 化する。\n return { body: JSON.stringify(bodySnapshot), contentType: \"application/json\" };\n }\n\n // サブタグからbodyを取得\n const bodyElement = this.querySelector<FetchBody>(config.tagNames.fetchBody);\n if (bodyElement) {\n return {\n body: bodyElement.bodyContent || null,\n contentType: bodyElement.contentType,\n };\n }\n\n return { body: null, contentType: null };\n }\n\n abort(): void {\n this._core.abort();\n }\n\n /**\n * Coalesce auto-fetch requests in the current task into a single microtask.\n *\n * Multiple synchronous input writes in the same tick — e.g. a `...` spread\n * writing `url` before `manual` — collapse into one decision made against the\n * FINAL element state, so the spread application order can no longer trigger a\n * stray fetch. The microtask re-reads `isConnected` / `manual` / `url` at fire\n * time; whatever was written last wins.\n *\n * Only the implicit auto-fetch (url attribute change, connect-time) is routed\n * here. Explicit triggers — the `trigger` setter, the `fetch` command, and\n * autoTrigger (data-fetchtarget clicks) — must fire immediately and stay on\n * their own synchronous paths.\n *\n * The connect-time promise (connectedCallbackPromise) is resolved here in\n * EVERY exit path, including the no-fetch branch, so awaiting it never hangs\n * when the final state turns out to be manual / url-less / disconnected.\n */\n private _scheduleAutoFetch(): void {\n if (this._autoPending) {\n return;\n }\n this._autoPending = true;\n queueMicrotask(() => {\n this._autoPending = false;\n const resolveConnect = this._connectResolve;\n this._connectResolve = null;\n const url = this.url;\n // Same-value guard (Phase 4): skip a redundant auto-fetch for the url we\n // last fetched. A spread re-evaluation rewrites every input each cycle, so\n // the `url` setter calls setAttribute with an unchanged value and fires\n // attributeChangedCallback again; without this guard an unrelated state\n // change would refetch. Auto-path only — explicit fetch()/trigger/command\n // stay unconditional (a manual refresh of the same url must work), and\n // `_lastFetchedUrl` is reset on disconnect so a remount refetches.\n if (this.isConnected && !this.manual && url && url !== this._lastFetchedUrl) {\n // fetch() cannot reject here: FetchCore swallows network/HTTP errors and\n // only rejects on an empty url, which the `url` guard above rules out.\n this.fetch().finally(() => resolveConnect?.());\n } else {\n resolveConnect?.();\n }\n });\n }\n\n async fetch(): Promise<any> {\n // Record the url for the auto-fetch same-value guard. Every fetch (explicit\n // included) updates it so a later auto-write of the same url is treated as a\n // no-op rather than a duplicate request.\n this._lastFetchedUrl = this.url;\n const headers = this._collectHeaders();\n\n // Snapshot and reset `body` synchronously, before any await. The body is a\n // one-shot input; resetting it after the await (when another caller may have\n // already set a new body for the next request) would silently drop that value.\n const bodySnapshot = this._body;\n this._body = null;\n const { body, contentType } = this._collectBody(bodySnapshot);\n\n // FormData に手動で Content-Type を付けると、ブラウザが付与するはずの multipart\n // boundary が失われてサーバー側でパースできなくなる。ヘッダはユーザー指定を\n // 尊重して素通しするが、この典型的な誤設定は警告する。\n if (body instanceof FormData &&\n Object.keys(headers).some((name) => name.toLowerCase() === \"content-type\")) {\n console.warn(\n \"[@wcstack/fetch] A manual Content-Type header was set alongside a FormData body. \" +\n \"This drops the multipart boundary the browser adds automatically; remove the \" +\n \"Content-Type header (e.g. the <wcs-fetch-header>) to fix multipart uploads.\",\n );\n }\n\n const result = await this._core.fetch(this.url, {\n method: this.method,\n headers,\n body,\n contentType,\n forceText: !!this.target,\n responseType: this.responseType,\n });\n\n // HTML置換モード\n // Security: the response is injected as raw innerHTML without sanitization.\n // This is an opt-in convenience for trusted fragments only; the primary,\n // recommended path is state-driven binding via @wcstack/state. Do not point\n // `target` at an untrusted endpoint (XSS risk). See README \"HTML Replace Mode\".\n if (this.target && result !== null) {\n const targetElement = document.getElementById(this.target);\n if (targetElement) {\n targetElement.innerHTML = result;\n }\n }\n\n return result;\n }\n\n attributeChangedCallback(name: string, _oldValue: string | null, _newValue: string | null): void {\n // Re-fetch on url changes, but intentionally do NOT update\n // `_connectedCallbackPromise`. Per the wc-bindable connectedCallbackPromise\n // protocol that promise represents the one-shot \"connect-time initialization\n // is done\" signal; it resolves once and is not re-armed for later url-driven\n // requests. Await `promise` if you need to track a specific re-fetch.\n //\n // Defer the decision to a microtask (see _scheduleAutoFetch) instead of\n // fetching synchronously here: a `...` spread writes `url` before `manual`,\n // so a synchronous fetch would fire before `manual` is applied. The final\n // state (isConnected / manual / url) is re-read at microtask time.\n if (name === \"url\") {\n this._scheduleAutoFetch();\n }\n }\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // Only the initial connect-time fetch is tracked by connectedCallbackPromise.\n // Arm a deferred here when an auto-fetch looks likely; the scheduled\n // microtask resolves it (in every exit path, so awaiting never hangs). The\n // actual fetch decision is re-evaluated at microtask time against the final\n // state, so a spread that sets `manual` after `url` still suppresses it.\n if (!this.manual && this.url) {\n this._connectedCallbackPromise = new Promise<void>((resolve) => {\n this._connectResolve = resolve;\n });\n }\n this._scheduleAutoFetch();\n }\n\n disconnectedCallback(): void {\n this.abort();\n // Reset the same-value guard so a remount (reconnect with the same url)\n // refetches rather than being skipped as a duplicate.\n this._lastFetchedUrl = null;\n // Resolve any armed connect-time deferred before detaching. A synchronous\n // remove()→append() before the scheduled microtask fires would otherwise let\n // the second connectedCallback overwrite _connectResolve, orphaning the first\n // deferred and hanging any caller that already awaited connectedCallbackPromise.\n // Disconnection makes connect-time init moot, so resolving (never hanging) is\n // correct; the pending microtask then sees _connectResolve === null and no-ops.\n this._connectResolve?.();\n this._connectResolve = null;\n }\n}\n","export class FetchHeader extends HTMLElement {\n connectedCallback(): void {\n this.style.display = \"none\";\n }\n\n get headerName(): string {\n return this.getAttribute(\"name\") || \"\";\n }\n\n get headerValue(): string {\n return this.getAttribute(\"value\") || \"\";\n }\n}\n","export class FetchBody extends HTMLElement {\n constructor() {\n super();\n // スロットなしのShadow DOMでlight DOM(bodyテキスト)の描画を抑制\n this.attachShadow({ mode: \"open\" });\n }\n\n get contentType(): string {\n return this.getAttribute(\"type\") || \"application/json\";\n }\n\n get bodyContent(): string {\n return this.textContent?.trim() || \"\";\n }\n}\n","import { Fetch } from \"./Fetch.js\";\n\nexport class InfiniteScroll extends HTMLElement {\n static get observedAttributes(): string[] {\n return [\"target\", \"root\", \"root-margin\", \"threshold\", \"disabled\"];\n }\n\n private _observer: IntersectionObserver | null = null;\n private _done: boolean = false;\n\n get target(): string {\n return this.getAttribute(\"target\") || \"\";\n }\n\n set target(value: string) {\n this.setAttribute(\"target\", value);\n }\n\n get root(): string | null {\n return this.getAttribute(\"root\");\n }\n\n set root(value: string | null) {\n if (value === null) {\n this.removeAttribute(\"root\");\n } else {\n this.setAttribute(\"root\", value);\n }\n }\n\n get rootMargin(): string {\n return this.getAttribute(\"root-margin\") || \"0px\";\n }\n\n set rootMargin(value: string) {\n this.setAttribute(\"root-margin\", value);\n }\n\n get threshold(): number {\n const value = Number(this.getAttribute(\"threshold\") ?? \"0\");\n return Number.isFinite(value) ? value : 0;\n }\n\n set threshold(value: number) {\n this.setAttribute(\"threshold\", String(value));\n }\n\n get disabled(): boolean {\n return this.hasAttribute(\"disabled\");\n }\n\n set disabled(value: boolean) {\n if (value) {\n this.setAttribute(\"disabled\", \"\");\n } else {\n this.removeAttribute(\"disabled\");\n }\n }\n\n get once(): boolean {\n return this.hasAttribute(\"once\");\n }\n\n set once(value: boolean) {\n if (value) {\n this.setAttribute(\"once\", \"\");\n } else {\n this.removeAttribute(\"once\");\n }\n }\n\n connectedCallback(): void {\n this._observe();\n }\n\n disconnectedCallback(): void {\n this._disconnectObserver();\n }\n\n attributeChangedCallback(): void {\n if (this.isConnected) {\n this._observe();\n }\n }\n\n private _observe(): void {\n this._disconnectObserver();\n\n if (this._done || this.disabled || !this.target || typeof IntersectionObserver === \"undefined\") {\n return;\n }\n\n this._observer = new IntersectionObserver((entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n this._triggerFetch();\n }\n }, {\n root: this._resolveRoot(),\n rootMargin: this.rootMargin,\n threshold: this.threshold,\n });\n this._observer.observe(this);\n }\n\n private _disconnectObserver(): void {\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n }\n\n private _resolveRoot(): Element | Document | null {\n if (!this.root) return null;\n return document.getElementById(this.root) || null;\n }\n\n private _triggerFetch(): void {\n const target = document.getElementById(this.target);\n if (!(target instanceof Fetch)) {\n return;\n }\n\n if (target.loading) {\n return;\n }\n\n target.trigger = true;\n\n if (this.once) {\n this._done = true;\n this._disconnectObserver();\n }\n }\n}","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapFetch(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { Fetch } from \"./components/Fetch.js\";\nimport { FetchHeader } from \"./components/FetchHeader.js\";\nimport { FetchBody } from \"./components/FetchBody.js\";\nimport { InfiniteScroll } from \"./components/InfiniteScroll.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.fetch)) {\n customElements.define(config.tagNames.fetch, Fetch);\n }\n if (!customElements.get(config.tagNames.fetchHeader)) {\n customElements.define(config.tagNames.fetchHeader, FetchHeader);\n }\n if (!customElements.get(config.tagNames.fetchBody)) {\n customElements.define(config.tagNames.fetchBody, FetchBody);\n }\n if (!customElements.get(config.tagNames.infiniteScroll)) {\n customElements.define(config.tagNames.infiniteScroll, InfiniteScroll);\n }\n}\n"],"names":["_config","autoTrigger","triggerAttribute","tagNames","fetch","fetchHeader","fetchBody","infiniteScroll","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","FetchCore","EventTarget","static","protocol","version","properties","name","event","getter","e","detail","value","status","objectURL","inputs","commands","async","_target","_value","_loading","_error","_status","_objectURL","_abortController","_promise","Promise","resolve","_gen","_ready","constructor","target","super","this","ready","observe","dispose","abort","_revokeObjectURL","loading","error","promise","_setLoading","dispatchEvent","CustomEvent","bubbles","_setError","_setResponse","_createObjectURL","blob","URL","createObjectURL","url","revokeObjectURL","options","message","p","_doFetch","ac","AbortController","signal","gen","method","body","contentType","forceText","responseType","headers","requestInit","response","globalThis","ok","errorBody","text","catch","statusText","buffer","arrayBuffer","data","json","get","includes","registered","handleClick","Element","triggerElement","closest","fetchId","getAttribute","FetchCtor","customElements","el","document","getElementById","fetchElement","preventDefault","Fetch","HTMLElement","wcBindable","observedAttributes","_core","_body","_trigger","_connectedCallbackPromise","_autoPending","_connectResolve","_lastFetchedUrl","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","add","delete","map","toStates","entries","addEventListener","debug","hasAttribute","on","toggleAttribute","removeAttribute","setAttribute","toUpperCase","connectedCallbackPromise","manual","trigger","finally","_collectHeaders","headerElements","querySelectorAll","headerName","headerValue","_isNativeBodyInit","Blob","FormData","URLSearchParams","ArrayBuffer","isView","_collectBody","bodySnapshot","JSON","stringify","bodyElement","querySelector","bodyContent","_scheduleAutoFetch","queueMicrotask","resolveConnect","isConnected","some","toLowerCase","console","warn","result","targetElement","innerHTML","attributeChangedCallback","_oldValue","_newValue","connectedCallback","style","display","disconnectedCallback","FetchHeader","FetchBody","attachShadow","mode","textContent","trim","InfiniteScroll","_observer","_done","root","rootMargin","threshold","Number","isFinite","String","disabled","once","_observe","_disconnectObserver","IntersectionObserver","entry","isIntersecting","_triggerFetch","_resolveRoot","disconnect","bootstrapFetch","userConfig","partialConfig","assign","define"],"mappings":"AAaA,MA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aAEQ,iBAAnCoN,EAAcnN,mBACvBF,EAAQE,iBAAmBmN,EAAcnN,kBAEvCmN,EAAclN,UAChBO,OAAO4M,OAAOtN,EAAQG,SAAUkN,EAAclN,UAEhDa,EAAe,MQxDV4F,eAAeV,IAAIjF,EAAOd,SAASC,QACtCwG,eAAe2G,OAAOtM,EAAOd,SAASC,MAAO8G,GAE1CN,eAAeV,IAAIjF,EAAOd,SAASE,cACtCuG,eAAe2G,OAAOtM,EAAOd,SAASE,YAAaqL,GAEhD9E,eAAeV,IAAIjF,EAAOd,SAASG,YACtCsG,eAAe2G,OAAOtM,EAAOd,SAASG,UAAWqL,GAE9C/E,eAAeV,IAAIjF,EAAOd,SAASI,iBACtCqG,eAAe2G,OAAOtM,EAAOd,SAASI,eAAgByL,EDR1D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/fetch",
3
- "version": "1.15.0",
3
+ "version": "1.17.0",
4
4
  "description": "Declarative fetch component for Web Components. Framework-agnostic async data fetching via wc-bindable-protocol.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.esm.js",