@wcstack/upload 1.20.0 → 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 CHANGED
@@ -202,6 +202,7 @@ npm install @wcstack/upload
202
202
  | `progress` | `number` | `0` | `0` から `100` の進捗率 |
203
203
  | `error` | `any` | `null` | バリデーション、ネットワーク、レスポンスのエラー |
204
204
  | `status` | `number` | `0` | HTTP レスポンスステータス |
205
+ | `errorInfo` | `WcsIoErrorInfo \| null` | `null` | serializable な失敗 taxonomy(安定 `code` / `phase` / `recoverable`)。追加的で `error` は不変。`code` は `capability-missing` / `invalid-argument` / `network` / `http-error`。`abort()` は失敗ではない(`errorInfo` を立てない) |
205
206
  | `promise` | `Promise<any>` | resolved `null` | 現在のアップロード Promise |
206
207
 
207
208
  ### メソッド
package/README.md CHANGED
@@ -202,6 +202,7 @@ In this setup, upload becomes a bindable async node:
202
202
  | `progress` | `number` | `0` | Upload progress from `0` to `100` |
203
203
  | `error` | `any` | `null` | Validation, network, or response error |
204
204
  | `status` | `number` | `0` | HTTP response status |
205
+ | `errorInfo` | `WcsIoErrorInfo \| null` | `null` | Serializable failure taxonomy (stable `code` / `phase` / `recoverable`). Additive — `error` is unchanged; `code` is `capability-missing`, `invalid-argument`, `network`, or `http-error`. An `abort()` is not a failure (no `errorInfo`) |
205
206
  | `promise` | `Promise<any>` | resolved `null` | Current upload promise |
206
207
 
207
208
  ### Methods
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
- readonly version: 1;
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[];
@@ -54,6 +108,8 @@ interface WcsUploadCoreValues<T = unknown> {
54
108
  progress: number;
55
109
  error: WcsUploadError | Error | null;
56
110
  status: number;
111
+ /** Last failure's serializable taxonomy (stable code/phase/recoverable), or null. */
112
+ errorInfo: WcsIoErrorInfo | null;
57
113
  }
58
114
  /**
59
115
  * Value types for the Shell (`<wcs-upload>`) — extends Core with `trigger` and `files`.
@@ -80,15 +136,17 @@ interface UploadRequestOptions {
80
136
  }
81
137
  declare class UploadCore extends EventTarget {
82
138
  static wcBindable: IWcBindable;
139
+ private static readonly REQUIRED_CAPABILITIES;
83
140
  private _target;
84
141
  private _value;
85
142
  private _loading;
86
143
  private _progress;
87
144
  private _error;
88
145
  private _status;
146
+ private _errorInfo;
89
147
  private _xhr;
90
148
  private _promise;
91
- private _gen;
149
+ private _lane;
92
150
  private _ready;
93
151
  constructor(target?: EventTarget);
94
152
  get ready(): Promise<void>;
@@ -100,11 +158,31 @@ declare class UploadCore extends EventTarget {
100
158
  get error(): any;
101
159
  get status(): number;
102
160
  get promise(): Promise<any>;
161
+ /**
162
+ * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /
163
+ * `recoverable` / `capabilityId`), or null. Exposed as an additive wc-bindable
164
+ * property (event `wcs-upload:error-info-changed`); the existing `error`
165
+ * property/event are unchanged. An abort() is not a failure (no errorInfo).
166
+ */
167
+ get errorInfo(): WcsIoErrorInfo | null;
168
+ /**
169
+ * Whether the required platform capability (`web.xhr`) is available right now —
170
+ * decided by call-time feature detection, not User-Agent. Core-only, additive.
171
+ */
172
+ get supported(): boolean;
173
+ /**
174
+ * Full platform assessment (availability / readiness / preconditions), probed at
175
+ * call time. Core-only opt-in dev / sidecar view.
176
+ */
177
+ get platformAssessment(): PlatformAssessment;
178
+ private _commitStep;
103
179
  private _setLoading;
104
180
  private _setProgress;
105
181
  private _setError;
106
182
  setError(error: any): void;
107
183
  private _setResponse;
184
+ private _setErrorInfo;
185
+ private _commitErrorInfo;
108
186
  abort(): void;
109
187
  upload(url: string, files: FileList | File[], options?: UploadRequestOptions): Promise<any>;
110
188
  private _doUpload;
@@ -143,6 +221,7 @@ declare class WcsUpload extends HTMLElement {
143
221
  get progress(): number;
144
222
  get error(): any;
145
223
  get status(): number;
224
+ get errorInfo(): WcsIoErrorInfo | null;
146
225
  get promise(): Promise<any>;
147
226
  get trigger(): boolean;
148
227
  set trigger(value: boolean);
@@ -156,5 +235,21 @@ declare class WcsUpload extends HTMLElement {
156
235
  disconnectedCallback(): void;
157
236
  }
158
237
 
159
- export { UploadCore, WcsUpload, bootstrapUpload, getConfig };
160
- export type { IWritableConfig, IWritableTagNames, UploadRequestOptions, WcsUploadCoreValues, WcsUploadError, WcsUploadValues };
238
+ /**
239
+ * uploadCapabilities.ts
240
+ *
241
+ * Upload node 固有の capability registry と error code。汎用の assess 機構・型は
242
+ * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から
243
+ * import する。node 固有の宣言はこのハンドライトファイルに置き、生成コピーとは分離する。
244
+ */
245
+
246
+ /** 安定した upload error code(taxonomy)。値は公開キーとして固定。 */
247
+ declare const WCS_UPLOAD_ERROR_CODE: {
248
+ readonly CapabilityMissing: "capability-missing";
249
+ readonly InvalidArgument: "invalid-argument";
250
+ readonly Network: "network";
251
+ readonly HttpError: "http-error";
252
+ };
253
+
254
+ export { UploadCore, WCS_UPLOAD_ERROR_CODE, WcsUpload, bootstrapUpload, getConfig };
255
+ export type { IWritableConfig, IWritableTagNames, UploadRequestOptions, WcsIoErrorInfo, WcsIoErrorPhase, WcsUploadCoreValues, WcsUploadError, WcsUploadValues };