@wcstack/contacts 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 +6 -0
- package/README.md +7 -0
- package/dist/index.d.ts +110 -16
- package/dist/index.esm.js +498 -57
- 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
|
@@ -54,6 +54,12 @@ npm install @wcstack/contacts
|
|
|
54
54
|
| `loading` | `wcs-contacts:loading-changed` | ピッカーダイアログが開いている間`true`。 |
|
|
55
55
|
| `error` | `wcs-contacts:error` | 真のプラットフォーム失敗(`select()`が投げた`DOMException`/`Error`)、または unsupported 経路ではプレーンオブジェクト`{ message: "Contact Picker API is not supported in this browser." }`、無ければ`null`。 |
|
|
56
56
|
| `cancelled` | `wcs-contacts:cancelled-changed` | ユーザーがピッカーを閉じたら`true`(`error`とは分離)。 |
|
|
57
|
+
| `errorInfo` | `wcs-contacts:error-info-changed` | serializable な失敗 taxonomy(安定 `code` / `phase` / `recoverable`)、または `null`。追加的で `error` の shape は不変。`code` は unsupported なら `capability-missing`、真の失敗なら `select-failed`。 |
|
|
58
|
+
|
|
59
|
+
**並行制御。** 連絡先ピッカーはシステムに1つのモーダル面なので、`<wcs-contacts>` は共有
|
|
60
|
+
io-core lane を `exhaust` policy で用いる: 1つの `select()` が進行中の間、2回目の呼び出しは
|
|
61
|
+
冪等な **no-op**(2つ目のピッカーを開かず `null` を返す)となり、進行中の呼び出しの結果を
|
|
62
|
+
汚さない。
|
|
57
63
|
|
|
58
64
|
## コマンド
|
|
59
65
|
|
package/README.md
CHANGED
|
@@ -55,6 +55,13 @@ npm install @wcstack/contacts
|
|
|
55
55
|
| `loading` | `wcs-contacts:loading-changed` | `true` while the picker dialog is open. |
|
|
56
56
|
| `error` | `wcs-contacts:error` | A true platform failure (a `DOMException`/`Error` from `select()`), or the plain object `{ message: "Contact Picker API is not supported in this browser." }` on the unsupported path, or `null`. |
|
|
57
57
|
| `cancelled` | `wcs-contacts:cancelled-changed` | `true` when the user dismissed the picker (kept separate from `error`). |
|
|
58
|
+
| `errorInfo` | `wcs-contacts:error-info-changed` | Serializable failure taxonomy (stable `code` / `phase` / `recoverable`), or `null`. Additive — the `error` shape is unchanged; `code` is `capability-missing` when unsupported or `select-failed` on a genuine failure. |
|
|
59
|
+
|
|
60
|
+
**Concurrency.** The contact picker is a single system-modal surface, so
|
|
61
|
+
`<wcs-contacts>` runs its calls through the shared io-core lane with the `exhaust`
|
|
62
|
+
policy: while one `select()` is in flight, a second call is an idempotent **no-op**
|
|
63
|
+
(it returns `null` without opening a second picker), leaving the in-flight call's
|
|
64
|
+
result untouched.
|
|
58
65
|
|
|
59
66
|
## Commands
|
|
60
67
|
|
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[];
|
|
@@ -86,6 +140,7 @@ interface WcsContactsCoreValues {
|
|
|
86
140
|
loading: boolean;
|
|
87
141
|
error: any;
|
|
88
142
|
cancelled: boolean;
|
|
143
|
+
errorInfo: WcsIoErrorInfo | null;
|
|
89
144
|
}
|
|
90
145
|
/**
|
|
91
146
|
* Value types for the Shell (`<wcs-contacts>`) — identical observable surface
|
|
@@ -103,27 +158,31 @@ declare function getConfig(): IConfig;
|
|
|
103
158
|
* `navigator.contacts.select(properties, options)` exposed through the
|
|
104
159
|
* wc-bindable protocol.
|
|
105
160
|
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
161
|
+
* Concurrency is owned by the shared `OperationLane` (io-core) with the `exhaust`
|
|
162
|
+
* policy: the contact picker is a single system-modal surface, so while one
|
|
163
|
+
* select() is in flight a new call is rejected as an idempotent no-op instead of
|
|
164
|
+
* starting a second `navigator.contacts.select()`. This replaces the earlier
|
|
165
|
+
* dispose-only `_gen` guard, which relied on the platform rejecting the second call
|
|
166
|
+
* with `InvalidStateError` — but that let the rejected second call reset/overwrite
|
|
167
|
+
* the still-pending first call's `error`/`loading` state. The lane's owner
|
|
168
|
+
* generation still invalidates any in-flight select() on dispose().
|
|
112
169
|
*
|
|
113
|
-
* The
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
170
|
+
* The Contact Picker API accepts no `AbortSignal`, so the lane runs with
|
|
171
|
+
* `withSignal: false`. `select()` takes **two** positional arguments
|
|
172
|
+
* (`properties`, `options`) rather than one — the command-token argument
|
|
173
|
+
* pass-through does not special-case argument count, so this requires no protocol
|
|
174
|
+
* change.
|
|
118
175
|
*/
|
|
119
176
|
declare class ContactsCore extends EventTarget {
|
|
120
177
|
static wcBindable: IWcBindable;
|
|
178
|
+
private static readonly REQUIRED_CAPABILITIES;
|
|
121
179
|
private _target;
|
|
122
180
|
private _value;
|
|
123
181
|
private _loading;
|
|
124
182
|
private _error;
|
|
125
183
|
private _cancelled;
|
|
126
|
-
private
|
|
184
|
+
private _errorInfo;
|
|
185
|
+
private _lane;
|
|
127
186
|
private _ready;
|
|
128
187
|
constructor(target?: EventTarget);
|
|
129
188
|
get ready(): Promise<void>;
|
|
@@ -131,13 +190,32 @@ declare class ContactsCore extends EventTarget {
|
|
|
131
190
|
get loading(): boolean;
|
|
132
191
|
get error(): any;
|
|
133
192
|
get cancelled(): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /
|
|
195
|
+
* `recoverable` / `capabilityId`), or null. Exposed as an additive wc-bindable
|
|
196
|
+
* property (event `wcs-contacts:error-info-changed`); the existing `error`
|
|
197
|
+
* property/event are unchanged.
|
|
198
|
+
*/
|
|
199
|
+
get errorInfo(): WcsIoErrorInfo | null;
|
|
200
|
+
/**
|
|
201
|
+
* Whether the required platform capability (`web.contacts`) is available right
|
|
202
|
+
* now — decided by call-time feature detection, not User-Agent. Core-only,
|
|
203
|
+
* additive.
|
|
204
|
+
*/
|
|
205
|
+
get supported(): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Full platform assessment (availability / readiness / preconditions), probed at
|
|
208
|
+
* call time. Core-only opt-in dev / sidecar view.
|
|
209
|
+
*/
|
|
210
|
+
get platformAssessment(): PlatformAssessment;
|
|
134
211
|
observe(): Promise<void>;
|
|
135
212
|
dispose(): void;
|
|
136
213
|
private _setLoading;
|
|
137
214
|
private _setValue;
|
|
138
215
|
private _setError;
|
|
139
216
|
private _setCancelled;
|
|
140
|
-
private
|
|
217
|
+
private _setErrorInfo;
|
|
218
|
+
private _commitErrorInfo;
|
|
141
219
|
select(properties: ContactProperty[], options?: ContactsSelectOptions): Promise<ContactInfo[] | null>;
|
|
142
220
|
}
|
|
143
221
|
|
|
@@ -166,11 +244,27 @@ declare class WcsContacts extends HTMLElement {
|
|
|
166
244
|
get loading(): boolean;
|
|
167
245
|
get error(): any;
|
|
168
246
|
get cancelled(): boolean;
|
|
247
|
+
get errorInfo(): WcsIoErrorInfo | null;
|
|
169
248
|
get connectedCallbackPromise(): Promise<void>;
|
|
170
249
|
select(properties: ContactProperty[], options?: ContactsSelectOptions): Promise<ContactInfo[] | null>;
|
|
171
250
|
connectedCallback(): void;
|
|
172
251
|
disconnectedCallback(): void;
|
|
173
252
|
}
|
|
174
253
|
|
|
175
|
-
|
|
176
|
-
|
|
254
|
+
/**
|
|
255
|
+
* contactsCapabilities.ts
|
|
256
|
+
*
|
|
257
|
+
* Contact Picker node 固有の capability registry と error code。汎用の assess 機構・
|
|
258
|
+
* 型は `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)
|
|
259
|
+
* から import する。node 固有の宣言はこのハンドライトファイルに置き、生成コピーとは
|
|
260
|
+
* 分離する。
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
/** 安定した contacts error code(taxonomy)。値は公開キーとして固定。 */
|
|
264
|
+
declare const WCS_CONTACTS_ERROR_CODE: {
|
|
265
|
+
readonly CapabilityMissing: "capability-missing";
|
|
266
|
+
readonly SelectFailed: "select-failed";
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
export { ContactsCore, WCS_CONTACTS_ERROR_CODE, WcsContacts, bootstrapContacts, getConfig };
|
|
270
|
+
export type { ContactAddress, ContactInfo, ContactProperty, ContactsSelectOptions, IWritableConfig, IWritableTagNames, WcsContactsCoreValues, WcsContactsValues, WcsIoErrorInfo, WcsIoErrorPhase };
|