@wcstack/fetch 1.19.1 → 1.21.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 +42 -4
- package/README.md +43 -4
- package/dist/index.d.ts +106 -6
- package/dist/index.esm.js +600 -86
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -276,6 +276,7 @@ npm install @wcstack/fetch
|
|
|
276
276
|
| `error` | `WcsFetchHttpError \| Error \| null` | HTTP またはネットワークエラー |
|
|
277
277
|
| `status` | `number` | HTTP ステータスコード |
|
|
278
278
|
| `objectURL` | `string \| null` | `response-type="blob"` のレスポンスに対する管理された object URL。それ以外は `null`。Core が新しいレスポンスごとと dispose 時に前の URL を revoke するため、ライフサイクル管理なしで `<img src>` に直接バインドできる |
|
|
279
|
+
| `errorInfo` | `WcsIoErrorInfo \| null` | 直近の失敗の serializable な taxonomy(安定 `code` / `phase` / `recoverable`)、または `null`。追加的で `error` の shape は不変。`wcs-fetch:error-info-changed` を発火 |
|
|
279
280
|
|
|
280
281
|
> **注意:** HTTP エラー時は `value` が `null` にリセットされ、`status` にエラーコードが
|
|
281
282
|
> 入ります。`error` を観測せず `value` のみをバインドしている場合、リクエスト失敗時に
|
|
@@ -396,6 +397,31 @@ unbind();
|
|
|
396
397
|
|
|
397
398
|
Node.js、Deno、Cloudflare Workers など、`EventTarget` と `fetch` が利用可能な環境で動作します。
|
|
398
399
|
|
|
400
|
+
## Capability と error taxonomy
|
|
401
|
+
|
|
402
|
+
**`errorInfo`** は追加的な wc-bindable プロパティです(上のプロパティ表を参照)。既存の
|
|
403
|
+
`error` プロパティ/イベントの shape は**不変**で、`errorInfo` は直近の失敗の serializable な
|
|
404
|
+
taxonomy(`WcsIoErrorInfo`、shape は [TypeScript 型](#typescript-型))を投影し、破壊的変更
|
|
405
|
+
なしに DevTools やアダプタが失敗を分類できるようにします。
|
|
406
|
+
|
|
407
|
+
関連する 2 つのシグナルは `FetchCore` の **Core 限定 opt-in getter** です(`wc-bindable` の
|
|
408
|
+
`properties` ではないため `data-wcs` のバインド対象ではありません):
|
|
409
|
+
|
|
410
|
+
| Getter | 型 | 説明 |
|
|
411
|
+
|--------|-----|------|
|
|
412
|
+
| `supported` | `boolean` | 必須 capability(`web.fetch`)が**今**利用可能か — User-Agent ではなく利用直前の feature detection で判定 |
|
|
413
|
+
| `platformAssessment` | `PlatformAssessment` | capability の完全な assessment(availability / readiness / preconditions)。利用直前に probe |
|
|
414
|
+
|
|
415
|
+
feature detection はリクエスト開始の直前に行い、module 評価時には行いません
|
|
416
|
+
(SSR / worker でも `FetchCore` の import が安全):
|
|
417
|
+
|
|
418
|
+
- `web.fetch` が**欠如**(古いランタイム / 一部 SSR / ヘッドレス)の場合、`fetch()`
|
|
419
|
+
はリクエストを**開始せず**、`errorInfo.code === "capability-missing"` を出して
|
|
420
|
+
`error` に対応メッセージを設定します(汎用のネットワークエラー経路は通りません)。
|
|
421
|
+
- `web.abort-controller` が**欠如**の場合、リクエストは **degraded** で動作します
|
|
422
|
+
(native abort signal なし)。supersede / dispose は機能し、
|
|
423
|
+
`platformAssessment.readiness` は `"degraded"` になります。
|
|
424
|
+
|
|
399
425
|
## URL の監視
|
|
400
426
|
|
|
401
427
|
`<wcs-fetch>` はデフォルトで以下のタイミングに自動的にリクエストを実行します:
|
|
@@ -488,6 +514,7 @@ wcstack アプリケーションでは、**`trigger` によるステート駆動
|
|
|
488
514
|
| `error` | `WcsFetchHttpError \| Error \| null` | エラー情報 |
|
|
489
515
|
| `status` | `number` | HTTP ステータスコード |
|
|
490
516
|
| `objectURL` | `string \| null` | `response-type="blob"` のレスポンスに対する管理された object URL。それ以外は `null` |
|
|
517
|
+
| `errorInfo` | `WcsIoErrorInfo \| null` | 直近の失敗の serializable な taxonomy(安定 `code` / `phase` / `recoverable`)、または `null` |
|
|
491
518
|
| `responseType` | `"auto" \| "json" \| "text" \| "blob" \| "arrayBuffer"` | レスポンスボディの解釈(`response-type` 属性を背後に持つ) |
|
|
492
519
|
| `body` | `any` | リクエストボディ(`fetch()` 後に `null` にリセット) |
|
|
493
520
|
| `trigger` | `boolean` | `true` を設定すると fetch を実行 |
|
|
@@ -535,7 +562,7 @@ wcstack アプリケーションでは、**`trigger` によるステート駆動
|
|
|
535
562
|
|
|
536
563
|
宣言は wc-bindable インターフェースモデルの全体に従い、3 つの独立したサーフェスを持ちます:
|
|
537
564
|
|
|
538
|
-
- **`properties`** — `bind()` がサブスクライブする観測可能な出力(`value`, `loading`, `error`, `status`, `objectURL`、および Shell の `trigger`)
|
|
565
|
+
- **`properties`** — `bind()` がサブスクライブする観測可能な出力(`value`, `loading`, `error`, `status`, `objectURL`, `errorInfo`、および Shell の `trigger`)
|
|
539
566
|
- **`inputs`** — 設定可能なサーフェス(`url`, `method`, …)。ツールやコード生成、リモートプロキシが読み取る宣言的メタデータ
|
|
540
567
|
- **`commands`** — 呼び出し可能なメソッド(`fetch`, `abort`)。`@wcstack/state` のようなバインディングシステムが名前で呼び出せる
|
|
541
568
|
|
|
@@ -558,6 +585,7 @@ static wcBindable = {
|
|
|
558
585
|
getter: (e) => e.detail.status },
|
|
559
586
|
{ name: "objectURL", event: "wcs-fetch:response",
|
|
560
587
|
getter: (e) => e.detail.objectURL },
|
|
588
|
+
{ name: "errorInfo", event: "wcs-fetch:error-info-changed" },
|
|
561
589
|
],
|
|
562
590
|
inputs: [
|
|
563
591
|
{ name: "url" },
|
|
@@ -601,7 +629,7 @@ Shell の inputs は意図的に `attribute` ヒントを持ちません。各
|
|
|
601
629
|
|
|
602
630
|
```typescript
|
|
603
631
|
import type {
|
|
604
|
-
WcsFetchHttpError, WcsFetchCoreValues, WcsFetchValues
|
|
632
|
+
WcsFetchHttpError, WcsFetchCoreValues, WcsFetchValues, WcsIoErrorInfo
|
|
605
633
|
} from "@wcstack/fetch";
|
|
606
634
|
```
|
|
607
635
|
|
|
@@ -613,7 +641,16 @@ interface WcsFetchHttpError {
|
|
|
613
641
|
body: string;
|
|
614
642
|
}
|
|
615
643
|
|
|
616
|
-
//
|
|
644
|
+
// serializable な失敗 taxonomy(`errorInfo` プロパティの値)
|
|
645
|
+
interface WcsIoErrorInfo {
|
|
646
|
+
code: string; // 安定コード: "capability-missing" | "invalid-argument" | "network" | "http-error" | "timeout" | "aborted"
|
|
647
|
+
phase: "probe" | "start" | "execute" | "decode" | "commit" | "dispose";
|
|
648
|
+
recoverable: boolean;
|
|
649
|
+
capabilityId?: string;
|
|
650
|
+
message: string;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
// Core(ヘッドレス)— 6 つの非同期状態プロパティ
|
|
617
654
|
// T のデフォルトは unknown。型引数を渡すと value が型付けされる
|
|
618
655
|
interface WcsFetchCoreValues<T = unknown> {
|
|
619
656
|
value: T;
|
|
@@ -621,6 +658,7 @@ interface WcsFetchCoreValues<T = unknown> {
|
|
|
621
658
|
error: WcsFetchHttpError | Error | null;
|
|
622
659
|
status: number;
|
|
623
660
|
objectURL: string | null; // responseType:"blob" のレスポンスに対する管理された object URL。それ以外は null
|
|
661
|
+
errorInfo: WcsIoErrorInfo | null; // 直近の失敗の serializable な taxonomy。それ以外は null
|
|
624
662
|
}
|
|
625
663
|
|
|
626
664
|
// Shell(<wcs-fetch>)— Core を拡張し trigger を追加
|
|
@@ -775,7 +813,7 @@ bootstrapFetch({
|
|
|
775
813
|
|
|
776
814
|
## 設計メモ
|
|
777
815
|
|
|
778
|
-
- `value`、`loading`、`error`、`status`、`objectURL` は **出力ステート**
|
|
816
|
+
- `value`、`loading`、`error`、`status`、`objectURL`、`errorInfo` は **出力ステート**
|
|
779
817
|
- `url`、`body`、`response-type`、`trigger` は **入力 / コマンドサーフェス**
|
|
780
818
|
- `response-type`(既定 `auto`)はレスポンスボディの読み取り方を選ぶ。`blob` は加えて管理された `objectURL`(新しいレスポンスごと / dispose 時に revoke)を発行する。`target`(HTML リプレースモード)が優先される
|
|
781
819
|
- `trigger` は意図的に単方向: `true` を書き込むと実行、リセットで完了を通知。`url` が空のまま `true` を書き込んだ場合は黙って無視される(fetch なし・イベントなし・フラグは `false` のまま)
|
package/README.md
CHANGED
|
@@ -276,6 +276,7 @@ These properties represent the result of the current request and are the main ob
|
|
|
276
276
|
| `error` | `WcsFetchHttpError \| Error \| null` | HTTP or network error |
|
|
277
277
|
| `status` | `number` | HTTP status code |
|
|
278
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>` |
|
|
279
|
+
| `errorInfo` | `WcsIoErrorInfo \| null` | Serializable failure taxonomy (stable `code` / `phase` / `recoverable`), or `null`. Additive — the `error` shape is unchanged; fires `wcs-fetch:error-info-changed` |
|
|
279
280
|
|
|
280
281
|
> **Note:** On an HTTP error, `value` is reset to `null` and `status` carries the
|
|
281
282
|
> error code. If you bind only `value` (without observing `error`), the previous
|
|
@@ -399,6 +400,32 @@ unbind();
|
|
|
399
400
|
|
|
400
401
|
This works in Node.js, Deno, Cloudflare Workers — anywhere `EventTarget` and `fetch` are available.
|
|
401
402
|
|
|
403
|
+
## Capability & error taxonomy
|
|
404
|
+
|
|
405
|
+
**`errorInfo`** is an additive wc-bindable property (see the property tables
|
|
406
|
+
above): the existing `error` property/event shape is **unchanged**, and `errorInfo`
|
|
407
|
+
projects the last failure's serializable taxonomy (`WcsIoErrorInfo`, shape under
|
|
408
|
+
[TypeScript Types](#typescript-types)) so DevTools and adopters can classify
|
|
409
|
+
failures without any breaking change.
|
|
410
|
+
|
|
411
|
+
Two related signals are **Core-only opt-in getters** on `FetchCore` (not
|
|
412
|
+
`wc-bindable` properties, so not `data-wcs` bind targets):
|
|
413
|
+
|
|
414
|
+
| Getter | Type | Description |
|
|
415
|
+
|--------|------|-------------|
|
|
416
|
+
| `supported` | `boolean` | Whether the required capability (`web.fetch`) is available **now** — call-time feature detection, not User-Agent |
|
|
417
|
+
| `platformAssessment` | `PlatformAssessment` | Full capability assessment (availability / readiness / preconditions), probed at call time |
|
|
418
|
+
|
|
419
|
+
Feature detection runs just before a request starts, never at module load (so
|
|
420
|
+
importing `FetchCore` stays safe under SSR / workers):
|
|
421
|
+
|
|
422
|
+
- If `web.fetch` is **missing** (old runtime / some SSR / headless), `fetch()`
|
|
423
|
+
does **not** start — it surfaces `errorInfo.code === "capability-missing"` and
|
|
424
|
+
sets `error` to a matching message (no generic network-error path).
|
|
425
|
+
- If `web.abort-controller` is **missing**, the request runs **degraded** (no
|
|
426
|
+
native abort signal); supersede / dispose still work, and
|
|
427
|
+
`platformAssessment.readiness` becomes `"degraded"`.
|
|
428
|
+
|
|
402
429
|
## URL Observation
|
|
403
430
|
|
|
404
431
|
By default, `<wcs-fetch>` automatically executes a request when:
|
|
@@ -495,6 +522,7 @@ In wcstack applications, **state-driven triggering via `trigger`** is usually th
|
|
|
495
522
|
| `error` | `WcsFetchHttpError \| Error \| null` | Error info |
|
|
496
523
|
| `status` | `number` | HTTP status code |
|
|
497
524
|
| `objectURL` | `string \| null` | Managed object URL for a `response-type="blob"` response; `null` otherwise |
|
|
525
|
+
| `errorInfo` | `WcsIoErrorInfo \| null` | Serializable failure taxonomy (stable `code` / `phase` / `recoverable`), or `null` |
|
|
498
526
|
| `responseType` | `"auto" \| "json" \| "text" \| "blob" \| "arrayBuffer"` | Response body interpretation (backs the `response-type` attribute) |
|
|
499
527
|
| `body` | `any` | Request body (resets to `null` after `fetch()`) |
|
|
500
528
|
| `trigger` | `boolean` | Set to `true` to execute fetch |
|
|
@@ -542,7 +570,7 @@ Both `FetchCore` and `<wcs-fetch>` declare `wc-bindable-protocol` compliance, ma
|
|
|
542
570
|
|
|
543
571
|
The declaration follows the full wc-bindable interface model — three independent surfaces:
|
|
544
572
|
|
|
545
|
-
- **`properties`** — observable outputs that `bind()` subscribes to (`value`, `loading`, `error`, `status`, `objectURL`, and the Shell's `trigger`)
|
|
573
|
+
- **`properties`** — observable outputs that `bind()` subscribes to (`value`, `loading`, `error`, `status`, `objectURL`, `errorInfo`, and the Shell's `trigger`)
|
|
546
574
|
- **`inputs`** — the settable surface (`url`, `method`, …); declarative metadata that tooling, codegen, and remote proxying read
|
|
547
575
|
- **`commands`** — invocable methods (`fetch`, `abort`); a binding system such as `@wcstack/state` can invoke them by name
|
|
548
576
|
|
|
@@ -565,6 +593,7 @@ static wcBindable = {
|
|
|
565
593
|
getter: (e) => e.detail.status },
|
|
566
594
|
{ name: "objectURL", event: "wcs-fetch:response",
|
|
567
595
|
getter: (e) => e.detail.objectURL },
|
|
596
|
+
{ name: "errorInfo", event: "wcs-fetch:error-info-changed" },
|
|
568
597
|
],
|
|
569
598
|
inputs: [
|
|
570
599
|
{ name: "url" },
|
|
@@ -608,7 +637,7 @@ The Shell's inputs intentionally carry no `attribute` hint: each setter (`url`,
|
|
|
608
637
|
|
|
609
638
|
```typescript
|
|
610
639
|
import type {
|
|
611
|
-
WcsFetchHttpError, WcsFetchCoreValues, WcsFetchValues
|
|
640
|
+
WcsFetchHttpError, WcsFetchCoreValues, WcsFetchValues, WcsIoErrorInfo
|
|
612
641
|
} from "@wcstack/fetch";
|
|
613
642
|
```
|
|
614
643
|
|
|
@@ -620,7 +649,16 @@ interface WcsFetchHttpError {
|
|
|
620
649
|
body: string;
|
|
621
650
|
}
|
|
622
651
|
|
|
623
|
-
//
|
|
652
|
+
// Serializable failure taxonomy (value of the `errorInfo` property)
|
|
653
|
+
interface WcsIoErrorInfo {
|
|
654
|
+
code: string; // stable: "capability-missing" | "invalid-argument" | "network" | "http-error" | "timeout" | "aborted"
|
|
655
|
+
phase: "probe" | "start" | "execute" | "decode" | "commit" | "dispose";
|
|
656
|
+
recoverable: boolean;
|
|
657
|
+
capabilityId?: string;
|
|
658
|
+
message: string;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// Core (headless) — 6 async state properties
|
|
624
662
|
// T defaults to unknown; pass a type argument for typed `value`
|
|
625
663
|
interface WcsFetchCoreValues<T = unknown> {
|
|
626
664
|
value: T;
|
|
@@ -628,6 +666,7 @@ interface WcsFetchCoreValues<T = unknown> {
|
|
|
628
666
|
error: WcsFetchHttpError | Error | null;
|
|
629
667
|
status: number;
|
|
630
668
|
objectURL: string | null; // managed object URL for a responseType:"blob" response, else null
|
|
669
|
+
errorInfo: WcsIoErrorInfo | null; // last failure's serializable taxonomy, else null
|
|
631
670
|
}
|
|
632
671
|
|
|
633
672
|
// Shell (<wcs-fetch>) — extends Core with trigger
|
|
@@ -782,7 +821,7 @@ bootstrapFetch({
|
|
|
782
821
|
|
|
783
822
|
## Design Notes
|
|
784
823
|
|
|
785
|
-
- `value`, `loading`, `error`, `status`, and `
|
|
824
|
+
- `value`, `loading`, `error`, `status`, `objectURL`, and `errorInfo` are **output state**
|
|
786
825
|
- `url`, `body`, `response-type`, and `trigger` are **input / command surface**
|
|
787
826
|
- `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
|
|
788
827
|
- `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`)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* platform-capability.ts
|
|
3
|
+
*
|
|
4
|
+
* Phase 6(docs/architecture-hardening/09-remediation-design.md §7.2 /
|
|
5
|
+
* 07-browser-capability-variance.md)の browser capability 判定と error taxonomy の
|
|
6
|
+
* 汎用プリミティブ。node 固有の capability registry / error code は各パッケージが
|
|
7
|
+
* 別ファイルで宣言し、この汎用層(型 + assess 機構)を import する。
|
|
8
|
+
*
|
|
9
|
+
* 原則:
|
|
10
|
+
* - feature detection は境界(利用直前)で行う。module 評価時に browser global を
|
|
11
|
+
* 参照しない(SSR / worker で import が失敗しない)。
|
|
12
|
+
* - capability ID(`web.fetch` 等)は文字列を global property path として eval せず、
|
|
13
|
+
* registry が ID ごとに副作用のない presence probe を対応付ける。
|
|
14
|
+
* - availability / permission / readiness / activity / operation error を 1 つの
|
|
15
|
+
* `ready / unsupported / error` enum に畳まない。required 欠如は開始しない、
|
|
16
|
+
* optional 欠如は宣言済み fallback で readiness を `degraded` にする。
|
|
17
|
+
*
|
|
18
|
+
* 配置: 本ファイルは /io-core/ の単一正典であり、scripts/sync-io-core.mjs が
|
|
19
|
+
* 各 IO ノードの src/core/ へ生成コピー (AUTO-GENERATED, 編集禁止) を配布する。
|
|
20
|
+
* `protocol/wcBindable.ts` と同じ copy-distribution 方式で、ランタイム依存を導入せず
|
|
21
|
+
* 各パッケージのバンドルへ inline される (zero-runtime-dep / 自己完結 CDN を維持)。
|
|
22
|
+
* 編集はこの正典に対して行い、`node scripts/sync-io-core.mjs` で再配布する。
|
|
23
|
+
*
|
|
24
|
+
* pure(module 評価時に browser global 非参照)。
|
|
25
|
+
*/
|
|
26
|
+
type Availability = "available" | "missing" | "unknown";
|
|
27
|
+
type PermissionState = "granted" | "denied" | "prompt" | "not-applicable" | "unknown";
|
|
28
|
+
type Readiness = "idle" | "ready" | "degraded";
|
|
29
|
+
type Activity = "inactive" | "active";
|
|
30
|
+
type PreconditionState = "satisfied" | "required" | "not-applicable";
|
|
31
|
+
/** operation error の phase(taxonomy)。 */
|
|
32
|
+
type WcsIoErrorPhase = "probe" | "start" | "execute" | "decode" | "commit" | "dispose";
|
|
33
|
+
/** serializable な error info(non-cloneable な cause とは分離。DevTools / remote へは info のみ)。 */
|
|
34
|
+
interface WcsIoErrorInfo {
|
|
35
|
+
readonly code: string;
|
|
36
|
+
readonly phase: WcsIoErrorPhase;
|
|
37
|
+
readonly recoverable: boolean;
|
|
38
|
+
readonly capabilityId?: string;
|
|
39
|
+
readonly message: string;
|
|
40
|
+
}
|
|
41
|
+
interface PlatformAssessment {
|
|
42
|
+
readonly availability: ReadonlyMap<string, Availability>;
|
|
43
|
+
readonly permission: PermissionState;
|
|
44
|
+
readonly readiness: Readiness;
|
|
45
|
+
readonly activity: Activity;
|
|
46
|
+
readonly preconditions: {
|
|
47
|
+
readonly secureContext: PreconditionState;
|
|
48
|
+
readonly userActivation: PreconditionState;
|
|
49
|
+
};
|
|
50
|
+
readonly epoch: number;
|
|
51
|
+
readonly lastError?: WcsIoErrorInfo;
|
|
52
|
+
}
|
|
53
|
+
|
|
1
54
|
interface IWcBindableProperty {
|
|
2
55
|
readonly name: string;
|
|
3
56
|
readonly event: string;
|
|
@@ -13,7 +66,8 @@ interface IWcBindableCommand {
|
|
|
13
66
|
}
|
|
14
67
|
interface IWcBindable {
|
|
15
68
|
readonly protocol: "wc-bindable";
|
|
16
|
-
|
|
69
|
+
/** Integer protocol version. All versions >= 1 are core-compatible. */
|
|
70
|
+
readonly version: number;
|
|
17
71
|
readonly properties: readonly IWcBindableProperty[];
|
|
18
72
|
readonly inputs?: readonly IWcBindableInput[];
|
|
19
73
|
readonly commands?: readonly IWcBindableCommand[];
|
|
@@ -51,7 +105,7 @@ interface WcsFetchHttpError {
|
|
|
51
105
|
body: string;
|
|
52
106
|
}
|
|
53
107
|
/**
|
|
54
|
-
* Value types for FetchCore (headless) — the
|
|
108
|
+
* Value types for FetchCore (headless) — the 6 async state properties.
|
|
55
109
|
* Use with `bind()` from `a wc-bindable binding core` for compile-time type checking.
|
|
56
110
|
*
|
|
57
111
|
* @example
|
|
@@ -68,6 +122,8 @@ interface WcsFetchCoreValues<T = unknown> {
|
|
|
68
122
|
status: number;
|
|
69
123
|
/** Managed object URL for a `responseType: "blob"` response; null otherwise. */
|
|
70
124
|
objectURL: string | null;
|
|
125
|
+
/** Last failure's serializable taxonomy (stable code/phase/recoverable), or null. */
|
|
126
|
+
errorInfo: WcsIoErrorInfo | null;
|
|
71
127
|
}
|
|
72
128
|
/**
|
|
73
129
|
* Value types for the Shell (`<wcs-fetch>`) — extends Core with `trigger`.
|
|
@@ -98,6 +154,7 @@ interface FetchRequestOptions {
|
|
|
98
154
|
contentType?: string | null;
|
|
99
155
|
forceText?: boolean;
|
|
100
156
|
responseType?: FetchResponseType;
|
|
157
|
+
timeout?: number;
|
|
101
158
|
}
|
|
102
159
|
declare class FetchCore extends EventTarget {
|
|
103
160
|
static wcBindable: IWcBindable;
|
|
@@ -107,10 +164,12 @@ declare class FetchCore extends EventTarget {
|
|
|
107
164
|
private _error;
|
|
108
165
|
private _status;
|
|
109
166
|
private _objectURL;
|
|
110
|
-
private _abortController;
|
|
111
167
|
private _promise;
|
|
112
|
-
private
|
|
168
|
+
private _lane;
|
|
113
169
|
private _ready;
|
|
170
|
+
private _errorInfo;
|
|
171
|
+
private static readonly REQUIRED_CAPABILITIES;
|
|
172
|
+
private static readonly OPTIONAL_CAPABILITIES;
|
|
114
173
|
constructor(target?: EventTarget);
|
|
115
174
|
get ready(): Promise<void>;
|
|
116
175
|
observe(): Promise<void>;
|
|
@@ -121,12 +180,34 @@ declare class FetchCore extends EventTarget {
|
|
|
121
180
|
get status(): number;
|
|
122
181
|
get objectURL(): string | null;
|
|
123
182
|
get promise(): Promise<any>;
|
|
183
|
+
/**
|
|
184
|
+
* The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /
|
|
185
|
+
* `recoverable` / `capabilityId`), or null. Exposed as an additive wc-bindable
|
|
186
|
+
* property (event `wcs-fetch:error-info-changed`); the existing `error`
|
|
187
|
+
* property/event are unchanged.
|
|
188
|
+
*/
|
|
189
|
+
get errorInfo(): WcsIoErrorInfo | null;
|
|
190
|
+
/**
|
|
191
|
+
* Whether the required platform capabilities (`web.fetch`) are available right
|
|
192
|
+
* now — the minimal "supported" signal, decided by call-time feature detection,
|
|
193
|
+
* not User-Agent. Additive.
|
|
194
|
+
*/
|
|
195
|
+
get supported(): boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Full platform assessment (availability / readiness / preconditions), probed
|
|
198
|
+
* at call time. `readiness` is `degraded` when only the optional
|
|
199
|
+
* `web.abort-controller` is missing. Dev / sidecar view.
|
|
200
|
+
*/
|
|
201
|
+
get platformAssessment(): PlatformAssessment;
|
|
202
|
+
private _setErrorInfo;
|
|
203
|
+
private _commitErrorInfo;
|
|
124
204
|
private _setLoading;
|
|
125
205
|
private _setError;
|
|
126
206
|
private _setResponse;
|
|
127
207
|
private _createObjectURL;
|
|
128
208
|
private _revokeObjectURL;
|
|
129
209
|
abort(): void;
|
|
210
|
+
private _commitStep;
|
|
130
211
|
fetch(url: string, options?: FetchRequestOptions): Promise<any>;
|
|
131
212
|
private _doFetch;
|
|
132
213
|
}
|
|
@@ -160,6 +241,7 @@ declare class Fetch extends HTMLElement {
|
|
|
160
241
|
get error(): any;
|
|
161
242
|
get status(): number;
|
|
162
243
|
get objectURL(): string | null;
|
|
244
|
+
get errorInfo(): WcsIoErrorInfo | null;
|
|
163
245
|
get promise(): Promise<any>;
|
|
164
246
|
get connectedCallbackPromise(): Promise<void>;
|
|
165
247
|
get manual(): boolean;
|
|
@@ -222,5 +304,23 @@ declare class InfiniteScroll extends HTMLElement {
|
|
|
222
304
|
private _triggerFetch;
|
|
223
305
|
}
|
|
224
306
|
|
|
225
|
-
|
|
226
|
-
|
|
307
|
+
/**
|
|
308
|
+
* fetchCapabilities.ts
|
|
309
|
+
*
|
|
310
|
+
* fetch node 固有の capability registry と error code。汎用の assess 機構・型は
|
|
311
|
+
* `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から
|
|
312
|
+
* import する。node 固有の宣言はこのハンドライトファイルに置き、生成コピーとは分離する。
|
|
313
|
+
*/
|
|
314
|
+
|
|
315
|
+
/** 安定した fetch error code(taxonomy)。値は公開キーとして固定。 */
|
|
316
|
+
declare const WCS_FETCH_ERROR_CODE: {
|
|
317
|
+
readonly CapabilityMissing: "capability-missing";
|
|
318
|
+
readonly InvalidArgument: "invalid-argument";
|
|
319
|
+
readonly Network: "network";
|
|
320
|
+
readonly HttpError: "http-error";
|
|
321
|
+
readonly Timeout: "timeout";
|
|
322
|
+
readonly Aborted: "aborted";
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
export { FetchCore, WCS_FETCH_ERROR_CODE, Fetch as WcsFetch, InfiniteScroll as WcsInfiniteScroll, bootstrapFetch, getConfig };
|
|
326
|
+
export type { FetchRequestOptions, IWritableConfig, IWritableTagNames, WcsFetchCoreValues, WcsFetchHttpError, WcsFetchValues, WcsIoErrorInfo, WcsIoErrorPhase };
|