@wcstack/camera 4.10.0 → 4.11.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/platformCapability.ts","../src/media/getUserMedia.ts","../src/media/permission.ts","../src/media/recording.ts","../src/core/mediaCapabilities.ts","../src/core/CameraCore.ts","../src/protocol/upgradeProperties.ts","../src/protocol/inputAttribute.ts","../src/components/Camera.ts","../src/core/RecorderCore.ts","../src/components/Recorder.ts","../src/registerComponents.ts","../src/bootstrapCamera.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n camera: string;\n recorder: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n camera: \"wcs-camera\",\n recorder: \"wcs-recorder\",\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\n// Internal, mutable live config used by registerComponents (read at call time so\n// setConfig() takes effect without re-import). Public consumers get the deep-frozen\n// clone from getConfig().\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapCamera` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/camera] bootstrapCamera: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /io-core/platform-capability.ts by scripts/sync-io-core.mjs.\n// Run `node scripts/sync-io-core.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * platform-capability.ts\n *\n * Phase 6(docs/architecture-hardening/09-remediation-design.md §7.2 /\n * 07-browser-capability-variance.md)の browser capability 判定と error taxonomy の\n * 汎用プリミティブ。node 固有の capability registry / error code は各パッケージが\n * 別ファイルで宣言し、この汎用層(型 + assess 機構)を import する。\n *\n * 原則:\n * - feature detection は境界(利用直前)で行う。module 評価時に browser global を\n * 参照しない(SSR / worker で import が失敗しない)。\n * - capability ID(`web.fetch` 等)は文字列を global property path として eval せず、\n * registry が ID ごとに副作用のない presence probe を対応付ける。\n * - availability / permission / readiness / activity / operation error を 1 つの\n * `ready / unsupported / error` enum に畳まない。required 欠如は開始しない、\n * optional 欠如は宣言済み fallback で readiness を `degraded` にする。\n *\n * 配置: 本ファイルは /io-core/ の単一正典であり、scripts/sync-io-core.mjs が\n * 各 IO ノードの src/core/ へ生成コピー (AUTO-GENERATED, 編集禁止) を配布する。\n * `protocol/wcBindable.ts` と同じ copy-distribution 方式で、ランタイム依存を導入せず\n * 各パッケージのバンドルへ inline される (zero-runtime-dep / 自己完結 CDN を維持)。\n * 編集はこの正典に対して行い、`node scripts/sync-io-core.mjs` で再配布する。\n *\n * pure(module 評価時に browser global 非参照)。\n */\n\nexport type Availability = \"available\" | \"missing\" | \"unknown\";\nexport type PermissionState = \"granted\" | \"denied\" | \"prompt\" | \"not-applicable\" | \"unknown\";\nexport type Readiness = \"idle\" | \"ready\" | \"degraded\";\nexport type Activity = \"inactive\" | \"active\";\nexport type PreconditionState = \"satisfied\" | \"required\" | \"not-applicable\";\n\n/** operation error の phase(taxonomy)。 */\nexport type WcsIoErrorPhase = \"probe\" | \"start\" | \"execute\" | \"decode\" | \"commit\" | \"dispose\";\n\n/** serializable な error info(non-cloneable な cause とは分離。DevTools / remote へは info のみ)。 */\nexport interface WcsIoErrorInfo {\n readonly code: string;\n readonly phase: WcsIoErrorPhase;\n readonly recoverable: boolean;\n readonly capabilityId?: string;\n readonly message: string;\n}\n\nexport interface PlatformAssessment {\n readonly availability: ReadonlyMap<string, Availability>;\n readonly permission: PermissionState;\n readonly readiness: Readiness;\n readonly activity: Activity;\n readonly preconditions: {\n readonly secureContext: PreconditionState;\n readonly userActivation: PreconditionState;\n };\n readonly epoch: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\n/** capability 1 件の仕様。probe は副作用なく presence を返す(利用直前に呼ぶ)。 */\nexport interface CapabilitySpec {\n readonly probe: () => boolean;\n readonly requiresSecureContext?: boolean;\n readonly requiresUserActivation?: boolean;\n /** browser compatibility dataset のキー(任意・診断用)。 */\n readonly compatKey?: string;\n}\n\nexport type CapabilityRegistry = ReadonlyMap<string, CapabilitySpec>;\n\nexport interface AssessOptions {\n readonly required: readonly string[];\n readonly optional?: readonly string[];\n readonly permission?: PermissionState;\n readonly activity?: Activity;\n readonly epoch?: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\nfunction isSecureContext(): boolean {\n return (globalThis as { isSecureContext?: unknown }).isSecureContext === true;\n}\n\n/**\n * capability を利用直前に評価して PlatformAssessment を作る。\n * required が 1 つでも欠ければ readiness は \"idle\"(開始不可)、\n * required 揃い + optional 欠けは \"degraded\"、全揃いは \"ready\"。\n */\nexport function assessCapabilities(registry: CapabilityRegistry, options: AssessOptions): PlatformAssessment {\n const availability = new Map<string, Availability>();\n const evaluate = (id: string): Availability => {\n const spec = registry.get(id);\n if (spec === undefined) return \"unknown\";\n return spec.probe() ? \"available\" : \"missing\";\n };\n\n let requiredAllAvailable = true;\n for (const id of options.required) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") requiredAllAvailable = false;\n }\n let optionalAllAvailable = true;\n for (const id of options.optional ?? []) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") optionalAllAvailable = false;\n }\n\n const readiness: Readiness = !requiredAllAvailable ? \"idle\" : (optionalAllAvailable ? \"ready\" : \"degraded\");\n\n // preconditions: 対象 capability のいずれかが要求する場合だけ評価する。\n const allIds = [...options.required, ...(options.optional ?? [])];\n const needsSecure = allIds.some((id) => registry.get(id)?.requiresSecureContext === true);\n const needsActivation = allIds.some((id) => registry.get(id)?.requiresUserActivation === true);\n const secureContext: PreconditionState = needsSecure ? (isSecureContext() ? \"satisfied\" : \"required\") : \"not-applicable\";\n const userActivation: PreconditionState = needsActivation ? \"required\" : \"not-applicable\";\n\n return {\n availability,\n permission: options.permission ?? \"not-applicable\",\n readiness,\n activity: options.activity ?? \"inactive\",\n preconditions: { secureContext, userActivation },\n epoch: options.epoch ?? 0,\n lastError: options.lastError,\n };\n}\n\n/** availability から「required がすべて available か」を判定するヘルパ(supported の最低条件)。 */\nexport function requiredCapabilitiesAvailable(assessment: PlatformAssessment, required: readonly string[]): boolean {\n return required.every((id) => assessment.availability.get(id) === \"available\");\n}\n\n/**\n * このページで機能が使えない理由(使える、または分からないなら null)。利用直前に読む。\n *\n * - `\"insecure-context\"`: 安全なコンテキストではない(`isSecureContext === false`)。\n * Permissions API が扱う機能はどれも安全なコンテキストを要る。\n * - `\"policy-blocked\"`: Permissions-Policy(サーバーのヘッダ、または `allow` の無い\n * `<iframe>`)がその機能を切っている。\n *\n * どちらも Permissions API は教えない: Chromium はポリシーで切られた文書でも\n * `granted` を、安全でない origin では `denied` を返す。利用者の拒否と区別するため、\n * 見張り役(`<wcs-permission>`)も取りに行く側も `unsupported` を報告する\n * (docs/v4-direction-2026-10.md の決定、state-field-report)。\n * `isSecureContext` が無い環境(SSR・テスト)は判断しない。\n */\nexport type FeatureUnavailableReason = \"insecure-context\" | \"policy-blocked\";\n\n/** Permissions-Policy が制御する機能(permission 名と同じ文字列)。 */\nconst POLICY_CONTROLLED = new Set([\n \"camera\", \"microphone\", \"geolocation\", \"midi\", \"clipboard-read\", \"clipboard-write\",\n \"screen-wake-lock\", \"idle-detection\", \"accelerometer\", \"gyroscope\", \"magnetometer\",\n \"ambient-light-sensor\", \"display-capture\",\n]);\n\ninterface PolicyLike { allowsFeature(feature: string): boolean }\n\nexport function featureUnavailable(feature: string): FeatureUnavailableReason | null {\n const g = globalThis as { isSecureContext?: unknown; document?: { permissionsPolicy?: PolicyLike; featurePolicy?: PolicyLike } };\n if (g.isSecureContext === false) return \"insecure-context\";\n if (!POLICY_CONTROLLED.has(feature)) return null;\n const policy = g.document?.permissionsPolicy ?? g.document?.featurePolicy;\n if (policy === undefined || typeof policy.allowsFeature !== \"function\") return null;\n try {\n return policy.allowsFeature(feature) ? null : \"policy-blocked\";\n } catch {\n return null;\n }\n}\n\n/** `featureUnavailable` の理由を、作者が直し方を読める文にする。`what` は文頭(「The camera」など)。 */\nexport function featureUnavailableMessage(what: string, feature: string, reason: FeatureUnavailableReason): string {\n return reason === \"insecure-context\"\n ? `${what} needs a secure context (https:, or http://localhost), and this page is not one.`\n : `${what} is turned off for this page by a Permissions-Policy: the server's Permissions-Policy header, ` +\n `or an <iframe> without allow=\"${feature}\". The browser's site settings cannot change that.`;\n}\n","import { CameraConstraints, MediaDeviceSnapshot, WcsMediaErrorDetail } from \"../types.js\";\nimport { featureUnavailable, featureUnavailableMessage } from \"../core/platformCapability.js\";\n\n/** True when getUserMedia is reachable (secure context with a media-devices impl). */\nexport function hasMediaDevices(): boolean {\n return typeof navigator !== \"undefined\"\n && !!navigator.mediaDevices\n && typeof navigator.mediaDevices.getUserMedia === \"function\";\n}\n\n/** True when MediaRecorder is available in this environment. */\nexport function hasMediaRecorder(): boolean {\n return typeof globalThis !== \"undefined\"\n && typeof (globalThis as { MediaRecorder?: unknown }).MediaRecorder === \"function\";\n}\n\n/**\n * Translate a getUserMedia constraints object from the declarative\n * CameraConstraints surface. Always requests a video track; `audio` opts the\n * microphone in. `deviceId` (exact) takes precedence over `facingMode`.\n */\nexport function buildConstraints(c: CameraConstraints): MediaStreamConstraints {\n const video: MediaTrackConstraints = {};\n if (c.deviceId) {\n video.deviceId = { exact: c.deviceId };\n } else if (c.facingMode) {\n video.facingMode = c.facingMode;\n }\n if (typeof c.width === \"number\") video.width = c.width;\n if (typeof c.height === \"number\") video.height = c.height;\n const hasVideoConstraint = Object.keys(video).length > 0;\n return {\n video: hasVideoConstraint ? video : true,\n audio: c.audio === true,\n };\n}\n\n/** Normalize any thrown getUserMedia / MediaRecorder failure into a flat detail. */\nexport function normalizeMediaError(error: unknown): WcsMediaErrorDetail {\n if (error && typeof error === \"object\" && \"name\" in error) {\n const name = String((error as { name: unknown }).name) || \"Error\";\n const message = \"message\" in error && (error as { message?: unknown }).message\n ? String((error as { message: unknown }).message)\n : `Media request failed: ${name}.`;\n return { name, message };\n }\n return { name: \"Error\", message: \"Media request failed.\" };\n}\n\n// getUserMedia is absent on an insecure origin, and in a browser without it: say which.\nfunction unsupportedError(): WcsMediaErrorDetail {\n const reason = featureUnavailable(\"camera\");\n return {\n name: \"unsupported\",\n message: reason === \"insecure-context\"\n ? featureUnavailableMessage(\"getUserMedia\", \"camera\", reason)\n : \"getUserMedia is not available in this browser.\",\n };\n}\n\n/**\n * Why this page cannot use the camera (or, with `audio`, the microphone): not a secure\n * context, or turned off by a Permissions-Policy. `null` when it can, as far as the\n * platform tells. `device` says which one, for the permission output it makes unsupported.\n */\nexport function mediaUnavailable(audio: boolean): { device: \"camera\" | \"microphone\"; error: WcsMediaErrorDetail } | null {\n const camera = featureUnavailable(\"camera\");\n if (camera !== null) {\n return { device: \"camera\", error: { name: \"unsupported\", message: featureUnavailableMessage(\"The camera\", \"camera\", camera) } };\n }\n const microphone = audio ? featureUnavailable(\"microphone\") : null;\n if (microphone !== null) {\n return { device: \"microphone\", error: { name: \"unsupported\", message: featureUnavailableMessage(\"The microphone\", \"microphone\", microphone) } };\n }\n return null;\n}\n\nexport interface UserMediaResult {\n stream?: MediaStream;\n error?: WcsMediaErrorDetail;\n}\n\n/**\n * Request a media stream. Never throws — resolves with `{ stream }` on success or\n * `{ error }` (normalized) on failure / when the API is unavailable.\n */\nexport async function requestUserMedia(constraints: MediaStreamConstraints): Promise<UserMediaResult> {\n if (!hasMediaDevices()) {\n return { error: unsupportedError() };\n }\n try {\n const stream = await navigator.mediaDevices.getUserMedia(constraints);\n return { stream };\n } catch (error) {\n return { error: normalizeMediaError(error) };\n }\n}\n\n/** Stop every track of a stream, releasing the camera/microphone hardware. */\nexport function stopAllTracks(stream: MediaStream | null): void {\n if (!stream) return;\n for (const track of stream.getTracks()) {\n track.stop();\n }\n}\n\n/**\n * Enumerate video input devices as plain snapshots. Labels are only populated\n * after a grant, so this is refreshed post-acquisition. Never throws.\n */\nexport async function enumerateVideoDevices(): Promise<MediaDeviceSnapshot[]> {\n if (!hasMediaDevices() || typeof navigator.mediaDevices.enumerateDevices !== \"function\") {\n return [];\n }\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n return devices\n .filter((d) => d.kind === \"videoinput\")\n .map((d) => ({\n deviceId: d.deviceId,\n label: d.label,\n groupId: d.groupId,\n kind: d.kind,\n }));\n } catch {\n return [];\n }\n}\n","import { MediaPermissionState } from \"../types.js\";\n\n/**\n * Live monitor for a single media permission (`camera` or `microphone`) via the\n * Permissions API. Mirrors PermissionCore's two-phase pattern: an initial query\n * plus a live `change` subscription, guarded by a monotonic generation so a query\n * superseded by a rapid dispose/observe never attaches a stale listener.\n *\n * When the Permissions API is absent or rejects the descriptor (e.g. Firefox does\n * not accept the `camera` / `microphone` descriptor), the watcher reports\n * `\"unsupported\"`. The CameraCore then refines the state from the getUserMedia\n * outcome (granted on success, denied on NotAllowedError).\n */\nexport class MediaPermissionWatcher {\n private _name: \"camera\" | \"microphone\";\n private _onChange: (state: MediaPermissionState) => void;\n private _status: PermissionStatus | null = null;\n private _gen: number = 0;\n private _subscribed: boolean = false;\n\n constructor(name: \"camera\" | \"microphone\", onChange: (state: MediaPermissionState) => void) {\n this._name = name;\n this._onChange = onChange;\n }\n\n /** Issue the initial query and subscribe to live changes. Resolves when settled. */\n observe(): Promise<void> {\n if (this._subscribed) return Promise.resolve();\n if (typeof navigator === \"undefined\" || !navigator.permissions\n || typeof navigator.permissions.query !== \"function\") {\n this._onChange(\"unsupported\");\n return Promise.resolve();\n }\n this._subscribed = true;\n const gen = ++this._gen;\n return navigator.permissions\n .query({ name: this._name as PermissionName })\n .then(\n (status) => {\n if (gen !== this._gen) return;\n this._status = status;\n this._onChange(status.state as MediaPermissionState);\n status.addEventListener(\"change\", this._onStatusChange);\n },\n () => {\n if (gen !== this._gen) return;\n this._onChange(\"unsupported\");\n },\n );\n }\n\n /** Detach the live listener and invalidate any in-flight query. */\n dispose(): void {\n this._subscribed = false;\n this._gen++;\n if (this._status) {\n this._status.removeEventListener(\"change\", this._onStatusChange);\n this._status = null;\n }\n }\n\n private _onStatusChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._onChange(status.state as MediaPermissionState);\n };\n}\n","/**\n * Which streams a recorder is recording right now. A recorder borrows its stream and a\n * camera owns it, and neither holds the other; but a camera that stops its stream while\n * it is hidden ends a recording of it, so it asks here first\n * (`[wcs/camera-keep-alive-missing]`). Counted, since two recorders may record one stream.\n */\nconst recording = new WeakMap<MediaStream, number>();\n\nexport function beginRecording(stream: MediaStream): void {\n recording.set(stream, (recording.get(stream) ?? 0) + 1);\n}\n\nexport function endRecording(stream: MediaStream): void {\n const n = (recording.get(stream) ?? 0) - 1;\n if (n > 0) recording.set(stream, n);\n else recording.delete(stream);\n}\n\nexport function isRecording(stream: MediaStream): boolean {\n return recording.has(stream);\n}\n","/**\n * mediaCapabilities.ts\n *\n * camera / recorder node 固有の error code(taxonomy)と derivation。汎用の error info\n * 型は `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。\n *\n * この 1 ファイルを CameraCore(getUserMedia)と RecorderCore(MediaRecorder)の両方が\n * import する。両 Core は同一の error detail 型(`WcsMediaErrorDetail = { name, message }`、\n * `.name` が DOMException 名 / \"unsupported\" sentinel / 各 Core 固有の合成名)を共有する\n * ため、derivation も 1 本で両者を賄える。lane は持たず(getUserMedia は acquire を\n * `_gen` で switchMap 済み、録画は command-driven)、error taxonomy(errorInfo)のみを採用する。\n */\n\nimport type { WcsMediaErrorDetail } from \"../types.js\";\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した media(camera / recorder)error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_MEDIA_ERROR_CODE = {\n /** getUserMedia / MediaRecorder API 不在(非セキュアコンテキスト含む) — \"unsupported\" sentinel。 */\n CapabilityMissing: \"capability-missing\",\n /** `NotAllowedError` / `SecurityError` — 権限拒否・feature-policy ブロック。 */\n NotAllowed: \"not-allowed\",\n /** `NotFoundError` — 要求した種類のデバイス(カメラ/マイク)が存在しない。 */\n NotFound: \"not-found\",\n /** `NotReadableError` — デバイスがハードウェア障害/他アプリ占有で読めない。 */\n NotReadable: \"not-readable\",\n /** `OverconstrainedError` / `NotSupportedError` — 制約・構成(mimeType 等)が満たせない。 */\n InvalidArgument: \"invalid-argument\",\n /** `NoStreamError` — stream 未 attach で録画開始(前提状態の不備)。 */\n InvalidState: \"invalid-state\",\n /** `AbortError` — 実行途中の中断(retry で回復しうる)。 */\n Aborted: \"aborted\",\n /** その他の実行時失敗(`RecorderError` / 想定外の MediaRecorder エラー等)。 */\n MediaError: \"media-error\",\n} as const;\n\n/**\n * 正規化済み media error(`WcsMediaErrorDetail = { name, message }`)を serializable な\n * error taxonomy に写す。`name` は DOMException 名 / \"unsupported\" sentinel / Core 固有の\n * 合成名(`NoStreamError` / `RecorderError`)。公開 `error` shape は不変で、これはその\n * 付加的な分類。\n *\n * - \"unsupported\" は利用直前の能力欠如 → phase=\"probe\" / capability-missing。\n * - `NotAllowedError` / `SecurityError` は取得開始時の権限拒否 → phase=\"start\" /\n * not-allowed。retry で回復しない。\n * - `NotFoundError` は要求デバイス不在 → phase=\"start\" / not-found。\n * - `NotReadableError` はデバイス占有/ハードウェア障害 → phase=\"start\" / not-readable。\n * - `OverconstrainedError` / `NotSupportedError` は制約・構成が満たせない\n * → phase=\"start\" / invalid-argument。\n * - `NoStreamError`(stream 未 attach で録画開始)は前提状態の不備 → phase=\"start\" /\n * invalid-state。\n * - `AbortError` は実行途中の中断 → phase=\"execute\" / aborted(recoverable=true)。\n * - それ以外(`RecorderError` / runtime MediaRecorder エラー / \"Error\" fallback 等)は\n * phase=\"execute\" / media-error。\n */\nexport function deriveMediaErrorInfo(error: WcsMediaErrorDetail): WcsIoErrorInfo {\n const { name, message } = error;\n if (name === \"unsupported\") {\n return { code: WCS_MEDIA_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n }\n if (name === \"NotAllowedError\" || name === \"SecurityError\") {\n return { code: WCS_MEDIA_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NotFoundError\") {\n return { code: WCS_MEDIA_ERROR_CODE.NotFound, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NotReadableError\") {\n return { code: WCS_MEDIA_ERROR_CODE.NotReadable, phase: \"start\", recoverable: false, message };\n }\n if (name === \"OverconstrainedError\" || name === \"NotSupportedError\") {\n return { code: WCS_MEDIA_ERROR_CODE.InvalidArgument, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NoStreamError\") {\n return { code: WCS_MEDIA_ERROR_CODE.InvalidState, phase: \"start\", recoverable: false, message };\n }\n if (name === \"AbortError\") {\n return { code: WCS_MEDIA_ERROR_CODE.Aborted, phase: \"execute\", recoverable: true, message };\n }\n return { code: WCS_MEDIA_ERROR_CODE.MediaError, phase: \"execute\", recoverable: false, message };\n}\n","import {\n IWcBindable, CameraConstraints, FacingMode, MediaDeviceSnapshot,\n MediaPermissionState, WcsMediaErrorDetail,\n} from \"../types.js\";\nimport {\n buildConstraints, enumerateVideoDevices, hasMediaDevices, mediaUnavailable, requestUserMedia, stopAllTracks,\n} from \"../media/getUserMedia.js\";\nimport { featureUnavailable } from \"./platformCapability.js\";\nimport { MediaPermissionWatcher } from \"../media/permission.js\";\nimport { isRecording } from \"../media/recording.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveMediaErrorInfo } from \"./mediaCapabilities.js\";\n\n/**\n * Headless camera-capture primitive. Wraps getUserMedia + the Permissions API and\n * exposes a `MediaStream` through the wc-bindable protocol — but the live stream is\n * NEVER published as a reactive value. It is a non-serializable live handle: it\n * flows out only via the `wcs-camera:stream-ready` event so a consumer (the preview\n * `<video>`, a `<wcs-recorder>`) can bind it directly to an element property,\n * bypassing serializable state. See docs/camera-recorder-tag-design.md §1/§2.\n *\n * The observable value surface is strictly derived data: `active` (is a stream\n * live — the \"actual\" half of the desired/actual pair), `permission` /\n * `audioPermission` (two-phase: Permissions API monitor + getUserMedia outcome),\n * `deviceId` / `devices`, and `error`. Failures never throw — they surface through\n * `error`.\n */\nexport class CameraCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"active\", event: \"wcs-camera:active-changed\", semantics: \"state\" },\n { name: \"permission\", event: \"wcs-camera:permission-changed\", semantics: \"state\" },\n { name: \"audioPermission\", event: \"wcs-camera:audio-permission-changed\", semantics: \"state\" },\n { name: \"deviceId\", event: \"wcs-camera:device-changed\", semantics: \"state\" },\n { name: \"devices\", event: \"wcs-camera:devices-changed\", semantics: \"state\" },\n { name: \"error\", event: \"wcs-camera:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error` (the DOMException name /\n // \"unsupported\" sentinel); the existing `error` property/event are unchanged.\n // Fires wcs-camera:error-info-changed. No lane — acquisition is switchMap'd by\n // `_gen`, so there is no per-node operation policy to attach here.\n { name: \"errorInfo\", event: \"wcs-camera:error-info-changed\", semantics: \"state\" },\n // Direct-channel handle: event-token only — never bound as a reactive value.\n { name: \"streamReady\", event: \"wcs-camera:stream-ready\", semantics: \"handle\", getter: (e: Event) => (e as CustomEvent).detail },\n // event-token: a bare signal (detail is always null) — surface detail, not the raw Event.\n { name: \"ended\", event: \"wcs-camera:ended\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"start\" },\n { name: \"stop\" },\n { name: \"switchCamera\" },\n ],\n };\n\n private _target: EventTarget;\n\n private _active: boolean = false;\n private _permission: MediaPermissionState = \"prompt\";\n private _audioPermission: MediaPermissionState | null = null;\n private _deviceId: string | null = null;\n private _devices: MediaDeviceSnapshot[] = [];\n private _error: WcsMediaErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n\n // The live stream — internal only, never a reactive value (see class docs).\n private _stream: MediaStream | null = null;\n\n // desired/actual split (wakelock-style): `_desired` is whether the user wants the\n // camera on; `_active` is whether a stream is actually live. The OS can revoke a\n // track (device unplugged / taken by another app) — actual drops while desired\n // stays true, so a later resume()/visibility-restore can re-acquire.\n private _desired: boolean = false;\n\n private _constraints: CameraConstraints = {};\n\n // Monotonic id of the current acquisition lifecycle. Bumped by every acquire and\n // by dispose(). Each in-flight getUserMedia captures it and, on resolve, bails\n // (stopping the just-acquired stream) when superseded — so a constraints change\n // mid-acquire (switchMap-style restart) cannot leave an orphaned stream live.\n private _gen: number = 0;\n\n private _subscribed: boolean = false;\n private _camWatcher: MediaPermissionWatcher | null = null;\n private _micWatcher: MediaPermissionWatcher | null = null;\n\n private _ready: Promise<void> = Promise.resolve();\n\n /** Whether `[wcs/camera-keep-alive-missing]` was said for this element (once per element). */\n private _toldKeepAlive = false;\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get active(): boolean { return this._active; }\n get permission(): MediaPermissionState { return this._permission; }\n get audioPermission(): MediaPermissionState | null { return this._audioPermission; }\n get deviceId(): string | null { return this._deviceId; }\n get devices(): MediaDeviceSnapshot[] { return this._devices; }\n get error(): WcsMediaErrorDetail | null { return this._error; }\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-camera:error-info-changed`), derived from `error`; the existing `error`\n * property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null { return this._errorInfo; }\n get ready(): Promise<void> { return this._ready; }\n\n // --- State setters with event dispatch (same-value guarded) ---\n\n private _setActive(active: boolean): void {\n if (this._active === active) return;\n this._active = active;\n this._dispatch(\"wcs-camera:active-changed\", active);\n }\n\n private _setPermission(state: MediaPermissionState): void {\n if (this._permission === state) return;\n this._permission = state;\n this._dispatch(\"wcs-camera:permission-changed\", state);\n }\n\n private _setAudioPermission(state: MediaPermissionState | null): void {\n if (this._audioPermission === state) return;\n this._audioPermission = state;\n this._dispatch(\"wcs-camera:audio-permission-changed\", state);\n }\n\n private _setDeviceId(id: string | null): void {\n if (this._deviceId === id) return;\n this._deviceId = id;\n this._dispatch(\"wcs-camera:device-changed\", id);\n }\n\n private _setDevices(devices: MediaDeviceSnapshot[]): void {\n if (this._devicesEqual(this._devices, devices)) return;\n this._devices = devices;\n this._dispatch(\"wcs-camera:devices-changed\", devices);\n }\n\n // Errors are dispatched on EVERY non-null occurrence by design — each failure is a\n // distinct event (e.g. retrying getUserMedia and failing again must re-notify), so\n // unlike the value setters this is not content-deduped. Only the null→null\n // transition is collapsed (clearing an already-clear error stays silent). The guard\n // is written on null explicitly so it does NOT depend on callers passing a fresh\n // object: a reused/cached non-null detail would still re-notify.\n private _setError(error: WcsMediaErrorDetail | null): void {\n if (error === null && this._error === null) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // error detail (or null on clear). Fires before the `error` event so an observer\n // binding both sees the classification first, mirroring the io-node family.\n this._commitErrorInfo(error === null ? null : deriveMediaErrorInfo(error));\n this._dispatch(\"wcs-camera:error\", error);\n }\n\n // Called only from _setError (which already collapses the null→null transition), so\n // errorInfo transitions exactly when error does — no separate guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._dispatch(\"wcs-camera:error-info-changed\", info);\n }\n\n private _dispatch(type: string, detail: unknown): void {\n this._target.dispatchEvent(new CustomEvent(type, { detail, bubbles: true }));\n }\n\n private _devicesEqual(a: MediaDeviceSnapshot[], b: MediaDeviceSnapshot[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i].deviceId !== b[i].deviceId || a[i].label !== b[i].label) return false;\n }\n return true;\n }\n\n // --- Public API ---\n\n /**\n * Begin observing permissions for the given constraints. Idempotent while\n * already subscribed. The first call (or one after dispose()) starts the\n * camera/microphone permission monitors. Acquisition itself is driven separately\n * by start() / autostart — observing does not prompt.\n */\n observe(constraints: CameraConstraints): Promise<void> {\n this._constraints = { ...constraints };\n if (!this._subscribed) {\n this._subscribed = true;\n this._ready = this._initPermissions();\n } else {\n // Already live: track the latest constraints and fold any newly-started\n // microphone query into `ready` so awaiting observe() guarantees its initial\n // permission state — symmetric with _initPermissions() on the first observe.\n this._ready = this._ready.then(() => this._reconcileAudioWatcher());\n }\n return this._ready;\n }\n\n /** Acquire the camera (sets desired=true). Prompts on first use. */\n start(): void {\n this._desired = true;\n this._restart();\n }\n\n /** Release the camera (sets desired=false), stopping all tracks. */\n stop(): void {\n this._desired = false;\n this._release();\n }\n\n /**\n * Toggle facingMode (user ↔ environment) and re-acquire if active. This is the\n * headless, DOM-free path: it flips the Core's internal `_constraints` (the single\n * source of truth for a standalone Core) and re-acquires while desired.\n *\n * Note: the `<wcs-camera>` Shell does NOT delegate to this — it keeps the DOM\n * attributes authoritative and drives its own single re-acquire (see Camera.ts\n * switchCamera). Both reach the same end state; the split exists because the Shell\n * must keep its declared attributes in sync, which a Core has no notion of.\n */\n switchCamera(): void {\n const next: FacingMode = this._constraints.facingMode === \"environment\" ? \"user\" : \"environment\";\n this._constraints = { ...this._constraints, facingMode: next, deviceId: undefined };\n if (this._desired) {\n this._restart();\n }\n }\n\n /**\n * Suspend the live stream while keeping `desired` — for page-hidden. Stops tracks\n * (clearing the hardware indicator) but remembers that the camera should resume.\n *\n * Bumps `_gen` to supersede any in-flight acquire: without this, an acquire that\n * resolves *after* the page went hidden would assign `_stream` and set active —\n * re-lighting the camera behind a no-op suspend (the stream had not been assigned\n * yet, so the `if (_stream)` release below could not reach it). The superseded\n * acquire stops its just-acquired orphan stream on resolve (see `_acquire`).\n */\n suspend(): void {\n this._gen++;\n if (this._stream) {\n if (isRecording(this._stream)) this._warnKeepAlive();\n this._release();\n }\n }\n\n // A recording of the stream ends with it: what was recorded becomes the clip, and nothing\n // said why the take was short.\n private _warnKeepAlive(): void {\n if (this._toldKeepAlive) return;\n this._toldKeepAlive = true;\n console.warn(\n \"[@wcstack/camera] [wcs/camera-keep-alive-missing] The page was hidden while this camera's stream was \" +\n \"being recorded, so the camera stopped the stream and the recording ended with it. Keep the camera \" +\n \"on while recording: bind keepAlive to the recording flag (keepAlive: <recording path>). (Said once per element.)\",\n this._target,\n );\n }\n\n /** Re-acquire if the camera is desired but not currently active — for page-visible. */\n resume(): void {\n if (this._desired && !this._active) {\n this._restart();\n }\n }\n\n /**\n * Tear down: stop the stream and detach permission listeners. `active` goes back to false\n * with its event: a route the element leaves keeps its nodes (and their bindings) for the\n * next entry, so a reset nobody heard would leave the page showing a camera that is off.\n */\n dispose(): void {\n this._subscribed = false;\n this._gen++;\n this._desired = false;\n this._release();\n if (hasMediaDevices() && typeof navigator.mediaDevices.removeEventListener === \"function\") {\n navigator.mediaDevices.removeEventListener(\"devicechange\", this._onDeviceChange);\n }\n this._camWatcher?.dispose();\n this._micWatcher?.dispose();\n this._camWatcher = null;\n this._micWatcher = null;\n }\n\n // --- Internal ---\n\n private _initPermissions(): Promise<void> {\n if (!hasMediaDevices()) {\n this._setPermission(\"unsupported\");\n return Promise.resolve();\n }\n // A device this page cannot use (not a secure context, or a Permissions-Policy) is\n // \"unsupported\", not what the Permissions API answers: Chromium says \"granted\" in a\n // policy-blocked frame, which would read as \"allowed\" next to a start that fails.\n const tasks: Promise<void>[] = [];\n if (featureUnavailable(\"camera\") !== null) {\n this._setPermission(\"unsupported\");\n } else {\n this._camWatcher = new MediaPermissionWatcher(\"camera\", (s) => this._setPermission(s));\n tasks.push(this._camWatcher.observe());\n }\n if (this._constraints.audio) {\n tasks.push(this._watchMicrophone());\n } else {\n // A re-observe after dispose() without audio: the microphone state the last\n // subscription left is not what this one asks about (null = audio not requested),\n // as _reconcileAudioWatcher clears it on a live Core.\n this._setAudioPermission(null);\n }\n // Track hot-plug: refresh the device list when a camera is added/removed.\n if (typeof navigator.mediaDevices.addEventListener === \"function\") {\n navigator.mediaDevices.addEventListener(\"devicechange\", this._onDeviceChange);\n }\n return Promise.all(tasks).then(() => undefined);\n }\n\n private _onDeviceChange = (): void => {\n void enumerateVideoDevices().then((devices) => {\n // Guard against a late resolution after dispose.\n if (this._subscribed) this._setDevices(devices);\n });\n };\n\n // Bring the microphone watcher in line with the latest `audio` constraint when\n // observe() is called again on an already-live Core. Returns the new watcher's\n // initial-query promise (so observe() can fold it into `ready`); resolved when\n // nothing started.\n private _reconcileAudioWatcher(): Promise<void> {\n if (this._constraints.audio && !this._micWatcher && hasMediaDevices()) {\n return this._watchMicrophone();\n } else if (!this._constraints.audio && (this._micWatcher || this._audioPermission !== null)) {\n this._micWatcher?.dispose();\n this._micWatcher = null;\n this._setAudioPermission(null);\n }\n return Promise.resolve();\n }\n\n private _watchMicrophone(): Promise<void> {\n if (featureUnavailable(\"microphone\") !== null) {\n this._setAudioPermission(\"unsupported\");\n return Promise.resolve();\n }\n this._micWatcher = new MediaPermissionWatcher(\"microphone\", (s) => this._setAudioPermission(s));\n return this._micWatcher.observe();\n }\n\n private _restart(): void {\n this._release();\n void this._acquire();\n }\n\n private async _acquire(): Promise<void> {\n const gen = ++this._gen;\n // Not asked of the browser when the page cannot use the device: its NotAllowedError\n // would read as the user's refusal, which the site settings would fix and these cannot.\n const off = hasMediaDevices() ? mediaUnavailable(!!this._constraints.audio) : null;\n if (off !== null) {\n this._setError(off.error);\n if (off.device === \"camera\") this._setPermission(\"unsupported\");\n else this._setAudioPermission(\"unsupported\");\n this._desired = false;\n this._setActive(false);\n return;\n }\n const constraints = buildConstraints(this._constraints);\n const { stream, error } = await requestUserMedia(constraints);\n\n // Superseded by a newer acquire (rapid restart) or disposed while in flight:\n // stop the orphan stream and bail without mutating state. The `ended` listeners\n // are attached only AFTER this gen check (below), so stopping the orphan here\n // cannot fire _onTrackEnded — no spurious `ended` event / state mutation. Keep\n // this stop strictly before listener attachment if the order is ever refactored.\n if (gen !== this._gen) {\n stopAllTracks(stream ?? null);\n return;\n }\n\n if (error) {\n this._setError(error);\n if (error.name === \"NotAllowedError\") {\n this._setPermission(\"denied\");\n // Hard denial: drop `desired` so a later visibility-restore (resume()) does\n // not silently re-attempt getUserMedia on every page-visible. A transient\n // failure (NotReadableError = device busy) keeps `desired` so it can recover.\n this._desired = false;\n } else if (error.name === \"unsupported\") {\n this._setPermission(\"unsupported\");\n this._desired = false;\n }\n this._setActive(false);\n return;\n }\n\n const live = stream as MediaStream;\n this._stream = live;\n for (const track of live.getTracks()) {\n track.addEventListener(\"ended\", this._onTrackEnded);\n }\n this._setError(null);\n // getUserMedia success is authoritative for permission.\n this._setPermission(\"granted\");\n // Only assert mic-granted when the grant actually produced an audio track. With\n // today's boolean `audio` this is equivalent to `_constraints.audio`, but it stays\n // correct under a future non-mandatory `{ audio: {...} }` constraint where the\n // browser may grant video while omitting audio.\n if (this._constraints.audio && live.getAudioTracks().length > 0) {\n this._setAudioPermission(\"granted\");\n }\n this._updateDeviceId(live);\n this._setActive(true);\n // Publish the live handle for the direct element→element channel.\n this._dispatch(\"wcs-camera:stream-ready\", live);\n // Labels become available after a grant; refresh the device list.\n const devices = await enumerateVideoDevices();\n if (gen === this._gen) {\n this._setDevices(devices);\n }\n }\n\n private _release(): void {\n if (!this._stream) return;\n for (const track of this._stream.getTracks()) {\n track.removeEventListener(\"ended\", this._onTrackEnded);\n }\n stopAllTracks(this._stream);\n this._stream = null;\n this._setActive(false);\n }\n\n private _onTrackEnded = (): void => {\n // OS revoked a track (unplug / taken by another app). actual drops; desired\n // stays true so resume()/visibility-restore can re-acquire.\n this._release();\n this._dispatch(\"wcs-camera:ended\", null);\n };\n\n private _updateDeviceId(stream: MediaStream): void {\n const videoTrack = stream.getVideoTracks()[0];\n if (videoTrack && typeof videoTrack.getSettings === \"function\") {\n const settings = videoTrack.getSettings();\n this._setDeviceId(settings.deviceId ?? null);\n }\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import {\n IWcBindable, CameraConstraints, FacingMode, MediaDeviceSnapshot, MediaPermissionState,\n WcsMediaErrorDetail,\n} from \"../types.js\";\nimport { CameraCore } from \"../core/CameraCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\nconst PREVIEW_CSS = \":host{display:inline-block}video{display:block;width:100%;height:100%}\";\n\n// One constructed sheet for every preview. A Content-Security-Policy's `style-src` governs\n// `<style>` elements (a shadow root's included) but not constructed sheets, so a page whose\n// policy has no 'unsafe-inline' still gets the preview's layout. A `<style>` is the fallback\n// where constructed sheets are not available.\nlet previewSheet: CSSStyleSheet | null | undefined;\n\nfunction adoptPreviewStyles(root: ShadowRoot): void {\n if (previewSheet === undefined) {\n try {\n previewSheet = new CSSStyleSheet();\n previewSheet.replaceSync(PREVIEW_CSS);\n } catch {\n previewSheet = null;\n }\n }\n if (previewSheet !== null && Array.isArray(root.adoptedStyleSheets)) {\n root.adoptedStyleSheets = [previewSheet];\n return;\n }\n const style = document.createElement(\"style\");\n style.textContent = PREVIEW_CSS;\n root.append(style);\n}\n\n/** Test seam: build the shared sheet again on the next preview. */\nexport function resetPreviewStyles(): void {\n previewSheet = undefined;\n}\n\n/**\n * `<wcs-camera>` — declarative camera capture with a built-in preview.\n *\n * The element owns a `<video>` in its shadow root and assigns the live\n * `MediaStream` to `video.srcObject` internally, so the non-serializable handle\n * never crosses the state boundary (design §1, case B). For consumers (a\n * `<wcs-recorder>`, an external `<video>`), the stream is also published via the\n * `wcs-camera:stream-ready` event-token for the direct element→element channel\n * (design §2).\n *\n * Acquisition is explicit: `start()` / the `autostart` attribute prompt and\n * acquire; merely connecting does not. While the page is hidden the stream is\n * suspended (clearing the camera indicator) and re-acquired on return, unless\n * `keep-alive` is set (e.g. during recording).\n */\nexport class WcsCamera extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...CameraCore.wcBindable,\n inputs: [\n { name: \"audio\", attribute: \"audio\" },\n { name: \"facingMode\", attribute: \"facing-mode\" },\n { name: \"deviceId\", attribute: \"device-id\" },\n { name: \"width\", attribute: \"width\" },\n { name: \"height\", attribute: \"height\" },\n { name: \"autostart\", attribute: \"autostart\" },\n { name: \"keepAlive\", attribute: \"keep-alive\" },\n ],\n commands: CameraCore.wcBindable.commands,\n };\n\n // `autostart` and `keep-alive` are intentionally NOT observed: `autostart` is a\n // connect-time-only acquire trigger (read once by the connect-time decision in\n // _scheduleAcquire's microtask; flipping it later is meaningless), and `keep-alive`\n // is read fresh on every visibilitychange (_onVisibilityChange), so it never needs\n // to drive a re-acquire. The observed set is exactly the constraints that reshape\n // the requested track.\n static observedAttributes = [\"facing-mode\", \"device-id\", \"audio\", \"width\", \"height\"];\n\n private _core: CameraCore;\n private _video: HTMLVideoElement;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n // connectedCallback が張った connectedCallbackPromise を解く関数。接続時の判断を下す\n // _scheduleAcquire のマイクロタスクが(その前に外れたときは disconnectedCallback が)呼ぶ。\n // null でないあいだは「接続時の判断待ち」でもある。\n private _connectResolve: ((value: void | PromiseLike<void>) => void) | null = null;\n // _scheduleAcquire のマイクロタスクが待っている間 true\n private _acquirePending: boolean = false;\n // 接続時の判断待ちに stop() が呼ばれたら true — その判断は autostart でも取得しない\n private _autostartCancelled: boolean = false;\n private _connected: boolean = false;\n // True while switchCamera() rewrites several attributes at once. Each setAttribute /\n // removeAttribute fires its own attributeChangedCallback synchronously; without this\n // guard the FIRST change would re-acquire with the not-yet-updated constraints (and\n // tear active down so the later change's re-acquire is skipped). We suppress the\n // per-attribute re-acquire and drive a single one with the final constraints.\n private _batchingAttrs: boolean = false;\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new CameraCore(this);\n const root = this.attachShadow({ mode: \"open\" });\n adoptPreviewStyles(root);\n this._video = document.createElement(\"video\");\n this._video.autoplay = true;\n this._video.muted = true;\n this._video.setAttribute(\"playsinline\", \"\");\n this._video.setAttribute(\"part\", \"video\");\n root.append(this._video);\n // Bind the live handle to the preview internally — never through state. These\n // self-listeners are intentionally not removed on disconnect (asymmetric with the\n // document-level `visibilitychange` in connect/disconnectedCallback): the target\n // is `this`, so the listeners are collected together with the element — there is\n // no external reference to leak. The visibility listener, by contrast, lives on\n // `document` (outlives the element) and MUST be detached.\n this.addEventListener(\"wcs-camera:stream-ready\", this._onStreamReady as EventListener);\n this.addEventListener(\"wcs-camera:active-changed\", this._onActiveChanged as EventListener);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-camera:active-changed\": (d) => ({ active: d === true }),\n \"wcs-camera:error\": (d) => ({ error: d != null }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (docs/custom-state-reflection-design.md §3.4): attachInternals is\n // absent in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here). Either\n // case silently disables reflection — the component still works, it just doesn't\n // 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 // 式文の三項演算子は ESLint no-unused-expressions に抵触するため if/else。\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 // --- Attribute accessors ---\n //\n // The setters never let setAttribute stringify null / undefined (a \"undefined\"\n // device-id would become an exact constraint no camera matches): `null`\n // removes the attribute (the default), `undefined` restores the attribute the\n // element started with (wc-bindable producer guidance P1; React 19 and a\n // direct assignment deliver it, @wcstack/state does not).\n\n get audio(): boolean { return this.hasAttribute(\"audio\"); }\n set audio(value: boolean | null | undefined) { reflectBooleanAttribute(this, \"audio\", value); }\n\n get facingMode(): FacingMode {\n return this.getAttribute(\"facing-mode\") === \"environment\" ? \"environment\" : \"user\";\n }\n set facingMode(value: FacingMode | null | undefined) { reflectAttribute(this, \"facing-mode\", value); }\n\n // `deviceId` is an input (the `device-id` request) and an output (the device the\n // stream uses, published with `wcs-camera:device-changed`). Reading it gives the\n // device in use once one is known — what the event carries, and what a binder's\n // initial sync reads — and the request until then. The constraints read the\n // request from the attribute (`_constraints`), as <wcs-recorder>'s mimeType does.\n get deviceId(): string { return this._core.deviceId ?? this.getAttribute(\"device-id\") ?? \"\"; }\n set deviceId(value: string | null | undefined) { reflectAttribute(this, \"device-id\", value); }\n\n get width(): number { return this._numberAttr(\"width\"); }\n set width(value: number | null | undefined) { reflectAttribute(this, \"width\", value); }\n\n get height(): number { return this._numberAttr(\"height\"); }\n set height(value: number | null | undefined) { reflectAttribute(this, \"height\", value); }\n\n get autostart(): boolean { return this.hasAttribute(\"autostart\"); }\n set autostart(value: boolean | null | undefined) { reflectBooleanAttribute(this, \"autostart\", value); }\n\n get keepAlive(): boolean { return this.hasAttribute(\"keep-alive\"); }\n set keepAlive(value: boolean | null | undefined) { reflectBooleanAttribute(this, \"keep-alive\", value); }\n\n /** The internal preview `<video>` (for advanced styling/measurement). */\n get videoElement(): HTMLVideoElement { return this._video; }\n\n // --- Core delegated getters ---\n\n get active(): boolean { return this._core.active; }\n get permission(): MediaPermissionState { return this._core.permission; }\n get audioPermission(): MediaPermissionState | null { return this._core.audioPermission; }\n get devices(): MediaDeviceSnapshot[] { return this._core.devices; }\n get error(): WcsMediaErrorDetail | null { return this._core.error; }\n /** The last failure's serializable `WcsIoErrorInfo` (Phase 6 taxonomy), or null. */\n get errorInfo(): WcsIoErrorInfo | null { return this._core.errorInfo; }\n\n get connectedCallbackPromise(): Promise<void> { return this._connectedCallbackPromise; }\n\n // --- Commands ---\n\n start(): void {\n // 制約は属性が正本。接続時の判断・属性の変化はマイクロタスクで Core に渡るので\n // (_scheduleAcquire)、それより先の start() でも、いまの属性の制約で取得するよう渡しておく\n if (this._connected) this._core.observe(this._constraints());\n this._core.start();\n }\n stop(): void {\n // 接続時の判断待ちなら、その autostart を取り消す — 同じタスクの append → stop() で、後の\n // マイクロタスクが取得を始めないように(判断が同期だった頃は、始めた取得を stop() が止めて\n // いた)。権限の監視(observe)は取り消さない。入れ直せば、次の判断は autostart に従う\n if (this._connectResolve !== null) this._autostartCancelled = true;\n this._core.stop();\n }\n\n /**\n * Toggle the front/back camera by updating the DOM attributes (the single source\n * of truth), not just the Core's internal constraints. Deliberately does NOT call\n * `CameraCore.switchCamera()` (which would mutate the Core's constraints behind the\n * DOM's back, leaving the declared attributes stale). `device-id` is removed because\n * it would otherwise take precedence over `facing-mode` (see buildConstraints) —\n * leaving it pinned would silently undo the switch on the next re-acquire. Both\n * attribute writes are batched (see `_batchingAttrs`) so they drive exactly ONE\n * re-acquire here, with the final constraints — never an early acquire on a\n * half-updated state. The DOM and the live camera stay in agreement.\n */\n switchCamera(): void {\n const next: FacingMode = this.facingMode === \"environment\" ? \"user\" : \"environment\";\n this._batchingAttrs = true;\n try {\n this.removeAttribute(\"device-id\");\n this.setAttribute(\"facing-mode\", next);\n } finally {\n this._batchingAttrs = false;\n }\n // Sync the (now-final) constraints and re-acquire once when a stream is live —\n // the same `active`-guarded restart attributeChangedCallback performs.\n this._core.observe(this._constraints());\n if (this._core.active) {\n this._core.start();\n }\n }\n\n // --- Internal ---\n\n private _numberAttr(name: string): number {\n const attr = this.getAttribute(name);\n if (attr === null || attr.trim() === \"\") return NaN;\n const parsed = Number(attr);\n return Number.isFinite(parsed) ? parsed : NaN;\n }\n\n private _constraints(): CameraConstraints {\n const c: CameraConstraints = { audio: this.audio, facingMode: this.facingMode };\n // the request, not `get deviceId()` (the device in use): after switchCamera()\n // removed it, the previous device must not stay pinned\n const requested = this.getAttribute(\"device-id\");\n if (requested) c.deviceId = requested;\n if (Number.isFinite(this.width)) c.width = this.width;\n if (Number.isFinite(this.height)) c.height = this.height;\n return c;\n }\n\n private _onStreamReady = (event: CustomEvent): void => {\n this._video.srcObject = event.detail as MediaStream;\n };\n\n private _onActiveChanged = (event: CustomEvent): void => {\n // Clear the preview when the stream is released so the last frame does not stick.\n if (event.detail === false) {\n this._video.srcObject = null;\n }\n };\n\n // --- Lifecycle ---\n\n // 取得の判断はマイクロタスクで、そのときの属性(制約と autostart)で 1 回だけ行う\n // (timing-and-firing-contract §23)。router は遷移で同じノードを入れ直し、新しいルートの\n // params から state が device-id などを書くのはマイクロタスク — その場で取得すると、前の\n // 制約で getUserMedia を起こし、取得中は active が偽なので新しい制約での取り直しも起きず、\n // 前の制約のストリームが残っていた(docs/seam-apps.md、shift-desk)。同じタスクの制約の\n // 変化もここへまとまる。\n private _scheduleAcquire(): void {\n if (this._acquirePending) return;\n this._acquirePending = true;\n queueMicrotask(() => {\n this._acquirePending = false;\n const resolveConnect = this._connectResolve;\n this._connectResolve = null;\n // 判断の前に外れた要素は何もしない(disconnectedCallback が dispose 済み)\n if (!this._connected) return;\n // Track the constraints (and reconcile the microphone watcher).\n const ready = this._core.observe(this._constraints());\n if (resolveConnect !== null) {\n // 接続時の判断: autostart なら取得する(判断待ちに stop() が呼ばれていなければ)\n if (this.autostart && !this._autostartCancelled) {\n this._core.start();\n }\n this._autostartCancelled = false;\n resolveConnect(ready);\n } else if (this._core.active) {\n // A constraints change re-acquires (switchMap-style restart) only when a stream\n // is actually live. `active` is the deliberate guard (not `desired`): `active`\n // implies `desired` (a stream only goes live under desired), so re-acquiring\n // cannot spuriously re-`desired` a stopped camera. Guarding on `active` rather\n // than `desired` also avoids force-acquiring while suspended/hidden (desired but\n // not active) — the visibility handler owns resume there.\n this._core.start();\n }\n });\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this._connected = true;\n // connectedCallbackPromise は接続時の observe(権限の初期状態)が済むまでを表す。\n // observe は判断と同じマイクロタスクで走るので、ここで張ってそこで解く\n this._connectedCallbackPromise = new Promise<void>((resolve) => {\n this._connectResolve = resolve;\n });\n this._scheduleAcquire();\n document.addEventListener(\"visibilitychange\", this._onVisibilityChange);\n }\n\n disconnectedCallback(): void {\n this._connected = false;\n // 判断の前に外れたら、張った connectedCallbackPromise をここで解く — 同じタスクで\n // 入れ直されると次の connectedCallback が張り替えるので、待つ側が取り残されないように\n this._connectResolve?.();\n this._connectResolve = null;\n this._autostartCancelled = false;\n document.removeEventListener(\"visibilitychange\", this._onVisibilityChange);\n this._core.dispose();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (!this._connected || oldValue === newValue) return;\n // While switchCamera() batches several attribute writes, defer to its single\n // post-batch re-acquire — otherwise the first write would acquire on stale\n // constraints (see `_batchingAttrs`).\n if (this._batchingAttrs) return;\n // 制約の変化は取得の判断(_scheduleAcquire)へまとめる: 接続時の判断待ちならそれが\n // 新しい制約を読み、その後ならストリームが生きているときだけ取り直す\n this._scheduleAcquire();\n }\n\n private _onVisibilityChange = (): void => {\n if (this.keepAlive) return;\n if (document.visibilityState === \"hidden\") {\n this._core.suspend();\n } else {\n this._core.resume();\n }\n };\n}\n","import {\n IWcBindable, RecorderOptions, WcsMediaErrorDetail, WcsRecordedDetail,\n} from \"../types.js\";\nimport { hasMediaRecorder, normalizeMediaError } from \"../media/getUserMedia.js\";\nimport { beginRecording, endRecording } from \"../media/recording.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveMediaErrorInfo } from \"./mediaCapabilities.js\";\n\n/**\n * Headless media-recording primitive. Wraps MediaRecorder, consuming a borrowed\n * `MediaStream` (received via `attachStream` over the direct channel — see\n * docs/camera-recorder-tag-design.md §2) and producing a `Blob` clip.\n *\n * Ownership: the stream is BORROWED, never owned. The Core never stops its tracks\n * — that is the camera's job (the acquirer owns release). Stopping here would tear\n * down a stream that may still be previewing.\n *\n * Non-goal: the Core does NOT subscribe to the borrowed tracks' `ended` and does NOT\n * auto-terminate a recording when the underlying stream dies (camera stop / OS\n * revoke / switchCamera re-acquire). Reacting would mean reaching into a stream we do\n * not own. The MediaRecorder keeps running against the now-dead source until an\n * explicit stop(); the consumer (which owns the camera lifecycle) is responsible for\n * stopping the recording when it tears the stream down. stop() then assembles\n * whatever chunks were captured — never throws.\n *\n * Output: `dataavailable` chunks are collected and assembled into one `Blob` on\n * stop, published via `wcs-recorder:recorded`. The `Blob` is structured-clone\n * friendly (a settled value, unlike MediaStream) so it may flow through state.\n * `objectURL` is a managed string — the Core revokes the previous URL before\n * issuing a new one and on dispose. Failures never throw.\n */\nexport class RecorderCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"recording\", event: \"wcs-recorder:recording-changed\", semantics: \"state\" },\n { name: \"paused\", event: \"wcs-recorder:paused-changed\", semantics: \"state\" },\n { name: \"duration\", event: \"wcs-recorder:duration-changed\", semantics: \"state\" },\n { name: \"mimeType\", event: \"wcs-recorder:mimetype-changed\", semantics: \"state\" },\n { name: \"blob\", event: \"wcs-recorder:recorded\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail?.blob ?? null },\n { name: \"objectURL\", event: \"wcs-recorder:recorded\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail?.objectURL ?? null },\n { name: \"error\", event: \"wcs-recorder:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error` (the DOMException name /\n // \"unsupported\"/\"NoStreamError\"/\"RecorderError\" sentinel); the existing `error`\n // property/event are unchanged. Fires wcs-recorder:error-info-changed. No lane —\n // recording is command-driven.\n { name: \"errorInfo\", event: \"wcs-recorder:error-info-changed\", semantics: \"state\" },\n // event-token: detail = the assembled clip { blob, objectURL, mimeType, duration }.\n { name: \"recorded\", event: \"wcs-recorder:recorded\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n // event-token (timeslice mode): detail = the streamed Blob chunk.\n { name: \"dataavailable\", event: \"wcs-recorder:dataavailable\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"attachStream\" },\n { name: \"start\" },\n { name: \"stop\" },\n { name: \"pause\" },\n { name: \"resume\" },\n ],\n };\n\n private _target: EventTarget;\n\n private _recording: boolean = false;\n private _paused: boolean = false;\n private _duration: number = 0;\n private _mimeType: string = \"\";\n private _blob: Blob | null = null;\n private _objectURL: string | null = null;\n private _error: WcsMediaErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n\n private _recorder: MediaRecorder | null = null;\n private _stream: MediaStream | null = null; // borrowed — never stopped here\n // the stream the live MediaRecorder records (attachStream may swap _stream mid-recording)\n private _recordingStream: MediaStream | null = null;\n private _timeslice: boolean = false;\n private _startTime: number = 0;\n\n // Monotonic id of the current recording lifecycle. Bumped by every start() and\n // dispose(); each MediaRecorder callback bails if stale so a torn-down/restarted\n // recorder's late event cannot mutate state.\n private _gen: number = 0;\n\n // The generation of a recording that dispose() stopped: its MediaRecorder still delivers\n // the clip (onstop comes later in a browser), and only that clip gets through — with the\n // type and duration it had when the element went away.\n private _closing: { gen: number; mimeType: string; duration: number } | null = null;\n\n // SSR: recording is command-driven (attachStream/start), so there is no\n // asynchronous probe to await — readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n /**\n * Whether `[wcs/command-not-ready]` was said in this outage: a `start()` refused because the\n * element is not ready loses what it carried, and `error` alone told only a page that binds it.\n * Said once per outage (docs/v4-direction-2026-10.md, the I/O command policy): a stream arriving\n * resets it. Once per element was once per page life — a route puts the same element back on\n * every entry, so the next outage's lost recording went unsaid (docs/seam-apps.md, shift-desk).\n */\n private _toldNotReady = false;\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get recording(): boolean { return this._recording; }\n get paused(): boolean { return this._paused; }\n // Finalized at stop/pause only — there is no live ticking timer, so this stays 0\n // from start() until the first pause()/stop() (see _elapsed / onstop / onpause).\n get duration(): number { return this._duration; }\n get mimeType(): string { return this._mimeType; }\n get blob(): Blob | null { return this._blob; }\n get objectURL(): string | null { return this._objectURL; }\n get error(): WcsMediaErrorDetail | null { return this._error; }\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-recorder:error-info-changed`), derived from `error`; the existing `error`\n * property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null { return this._errorInfo; }\n get ready(): Promise<void> { return this._ready; }\n\n // --- State setters ---\n\n private _setRecording(v: boolean): void {\n if (this._recording === v) return;\n this._recording = v;\n this._dispatch(\"wcs-recorder:recording-changed\", v);\n }\n\n private _setPaused(v: boolean): void {\n if (this._paused === v) return;\n this._paused = v;\n this._dispatch(\"wcs-recorder:paused-changed\", v);\n }\n\n private _setDuration(v: number): void {\n if (this._duration === v) return;\n this._duration = v;\n this._dispatch(\"wcs-recorder:duration-changed\", v);\n }\n\n private _setMimeType(v: string): void {\n if (this._mimeType === v) return;\n this._mimeType = v;\n this._dispatch(\"wcs-recorder:mimetype-changed\", v);\n }\n\n // Errors are dispatched on EVERY non-null occurrence by design — each failure is a\n // distinct event, so unlike the value setters this is not content-deduped. Only the\n // null→null transition is collapsed (clearing an already-clear error stays silent).\n // The guard is written on null explicitly so it does NOT depend on callers passing a\n // fresh object: a reused/cached non-null detail would still re-notify.\n private _setError(error: WcsMediaErrorDetail | null): void {\n if (error === null && this._error === null) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // error detail (or null on clear). Fires before the `error` event so an observer\n // binding both sees the classification first, mirroring the io-node family.\n this._commitErrorInfo(error === null ? null : deriveMediaErrorInfo(error));\n this._dispatch(\"wcs-recorder:error\", error);\n }\n\n // Called only from _setError (which already collapses the null→null transition), so\n // errorInfo transitions exactly when error does — no separate guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._dispatch(\"wcs-recorder:error-info-changed\", info);\n }\n\n private _dispatch(type: string, detail: unknown): void {\n this._target.dispatchEvent(new CustomEvent(type, { detail, bubbles: true }));\n }\n\n // --- Public API ---\n\n /**\n * Borrow a stream for recording (the direct-channel sink). Synchronous, no\n * await: the live handle is captured by reference and never stored in state.\n * Does NOT stop any previously-borrowed stream — ownership stays with the camera.\n *\n * Re-attaching mid-recording takes effect on the NEXT start(), not the current\n * recording: the live MediaRecorder was already constructed around the previous\n * stream and keeps recording it until stop(). The borrowed reference is swapped so\n * the following start() uses the new stream.\n */\n attachStream(stream: MediaStream): void {\n this._stream = stream;\n // ready again: a start refused in the next outage is said again\n if (stream) this._toldNotReady = false;\n }\n\n /** Start recording the borrowed stream. Never throws — surfaces `error`. */\n start(options: RecorderOptions = {}): void {\n if (!hasMediaRecorder()) {\n this._setError({ name: \"unsupported\", message: \"MediaRecorder is not available in this environment.\" });\n return;\n }\n if (!this._stream) {\n this._setError({ name: \"NoStreamError\", message: \"No stream attached. Wire a camera's stream-ready to attachStream first.\" });\n this._warnNotReady();\n return;\n }\n if (this._recording) return;\n\n const recOptions: MediaRecorderOptions = {};\n if (options.mimeType && this._isTypeSupported(options.mimeType)) {\n recOptions.mimeType = options.mimeType;\n }\n if (typeof options.audioBitsPerSecond === \"number\") recOptions.audioBitsPerSecond = options.audioBitsPerSecond;\n if (typeof options.videoBitsPerSecond === \"number\") recOptions.videoBitsPerSecond = options.videoBitsPerSecond;\n\n let recorder: MediaRecorder;\n try {\n recorder = new MediaRecorder(this._stream, recOptions);\n } catch (error) {\n this._setError(normalizeMediaError(error));\n return;\n }\n\n const gen = ++this._gen;\n // per recording: a clip finishing after a disconnect must not take a later one's chunks\n const chunks: Blob[] = [];\n const stream = this._stream;\n this._timeslice = typeof options.timeslice === \"number\" && options.timeslice > 0;\n const closing = (): boolean => this._closing !== null && this._closing.gen === gen;\n\n recorder.ondataavailable = (event: BlobEvent): void => {\n if (gen !== this._gen && !closing()) return;\n if (event.data && event.data.size > 0) {\n chunks.push(event.data);\n if (gen !== this._gen) return;\n // a browser that resolved no type at start still types the chunks\n if (!this._mimeType && event.data.type) this._setMimeType(event.data.type);\n if (this._timeslice) {\n this._dispatch(\"wcs-recorder:dataavailable\", event.data);\n }\n }\n };\n // Chromium resolves the type only when recording starts (`mimeType` is \"\" until then\n // when none was requested): the resolved type is the one the clip has.\n recorder.onstart = (): void => {\n if (gen === this._gen && recorder.mimeType) this._setMimeType(recorder.mimeType);\n };\n recorder.onstop = (): void => {\n endRecording(stream);\n if (this._recordingStream === stream) this._recordingStream = null;\n if (closing()) {\n // stopped by dispose(): recording / paused / duration were published then\n const { mimeType, duration } = this._closing!;\n this._closing = null;\n this._assembleBlob(chunks, mimeType, duration);\n return;\n }\n if (gen !== this._gen) return;\n // When stopped while paused, `_duration` was already finalized in onpause —\n // recomputing _elapsed() here would wrongly include the paused gap (the\n // clock kept running but `_startTime` was not advanced). Keep the held value.\n if (!this._paused) this._setDuration(this._elapsed());\n this._assembleBlob(chunks, this._mimeType, this._duration);\n this._setPaused(false);\n this._setRecording(false);\n };\n recorder.onerror = (event: Event): void => {\n if (gen !== this._gen) return;\n const err = (event as unknown as { error?: unknown }).error;\n this._setError(normalizeMediaError(err ?? { name: \"RecorderError\" }));\n };\n recorder.onpause = (): void => {\n if (gen !== this._gen) return;\n this._setDuration(this._elapsed());\n this._setPaused(true);\n };\n recorder.onresume = (): void => {\n if (gen !== this._gen) return;\n this._startTime = this._now() - this._duration;\n this._setPaused(false);\n };\n\n this._recorder = recorder;\n this._setError(null);\n this._setMimeType(recorder.mimeType || recOptions.mimeType || \"\");\n this._startTime = this._now();\n this._setDuration(0);\n recorder.start(this._timeslice ? options.timeslice : undefined);\n beginRecording(stream);\n this._recordingStream = stream;\n this._setRecording(true);\n }\n\n private _warnNotReady(): void {\n if (this._toldNotReady) return;\n this._toldNotReady = true;\n console.warn(\n \"[@wcstack/camera] [wcs/command-not-ready] start() was refused: no stream is attached, so nothing is recorded. \" +\n \"It goes to `error` too. Wire a camera's stream to the recorder first. \" +\n \"(Said once until a stream is attached again.)\",\n this._target,\n );\n }\n\n /** Stop recording; the assembled Blob is published from the recorder's onstop. */\n stop(): void {\n if (this._recorder && this._recorder.state !== \"inactive\") {\n this._recorder.stop();\n }\n }\n\n pause(): void {\n if (this._recorder && this._recorder.state === \"recording\") {\n this._recorder.pause();\n }\n }\n\n resume(): void {\n if (this._recorder && this._recorder.state === \"paused\") {\n this._recorder.resume();\n }\n }\n\n /**\n * Establish monitoring (§3.5). Recording is command-driven — there is no listener\n * or subscription to set up here (the borrowed stream arrives via attachStream and\n * recording is driven by start()/stop()), so observe() is an idempotent no-op that\n * resolves once ready. dispose() is its teardown counterpart.\n */\n observe(): Promise<void> {\n return this._ready;\n }\n\n /**\n * Stop in-flight recording, revoke the last object URL, drop the borrowed stream.\n *\n * A recording in progress is not thrown away: it stops, and the clip arrives as\n * `wcs-recorder:recorded` when the MediaRecorder delivers it (later, in a browser) — as it\n * does when the stream's tracks end. `recording` / `paused` go back to false at once, with\n * their events: a route the element leaves keeps its nodes (and their bindings) for the\n * next entry, so a reset nobody heard would leave the page showing a recording that is\n * not there.\n */\n dispose(): void {\n const recorder = this._recorder;\n const inFlight = recorder !== null && recorder.state !== \"inactive\";\n if (inFlight) {\n if (!this._paused) this._setDuration(this._elapsed());\n this._closing = { gen: this._gen, mimeType: this._mimeType, duration: this._duration };\n }\n // Bump the generation so no other callback of this recorder reaches the Core.\n this._gen++;\n this._recorder = null;\n this._revokeUrl();\n // Drop the borrowed reference WITHOUT stopping its tracks — the camera owns it.\n this._stream = null;\n this._setPaused(false);\n this._setRecording(false);\n if (inFlight) {\n try {\n recorder.stop();\n } catch {\n // A recorder already torn down by the environment must not throw here; no clip comes.\n this._closing = null;\n if (this._recordingStream) endRecording(this._recordingStream);\n this._recordingStream = null;\n }\n }\n }\n\n // --- Internal ---\n\n private _assembleBlob(chunks: Blob[], mimeType: string, duration: number): void {\n // the chunks carry the type when the recorder resolved none\n const type = mimeType || chunks[0]?.type || \"\";\n const blob = new Blob(chunks, type ? { type } : undefined);\n // The PREVIOUS clip's object URL is revoked here, before minting the new one — so\n // any consumer still pointing a `<video src>` at the old URL will break once a new\n // recording completes. Consumers must follow the latest `objectURL`/`recorded`\n // value and not pin a stale URL. (The `blob` is unaffected — prefer flowing it.)\n this._revokeUrl();\n const objectURL = this._createUrl(blob);\n this._blob = blob;\n this._objectURL = objectURL;\n const detail: WcsRecordedDetail = {\n blob,\n objectURL,\n mimeType: type,\n duration,\n };\n this._dispatch(\"wcs-recorder:recorded\", detail);\n }\n\n private _revokeUrl(): void {\n if (this._objectURL && typeof URL !== \"undefined\" && typeof URL.revokeObjectURL === \"function\") {\n URL.revokeObjectURL(this._objectURL);\n }\n this._objectURL = null;\n }\n\n private _createUrl(blob: Blob): string {\n if (typeof URL !== \"undefined\" && typeof URL.createObjectURL === \"function\") {\n return URL.createObjectURL(blob);\n }\n return \"\";\n }\n\n // Only called after hasMediaRecorder() has confirmed the API, so MediaRecorder\n // and its isTypeSupported are present.\n private _isTypeSupported(type: string): boolean {\n const MR = (globalThis as { MediaRecorder: { isTypeSupported(t: string): boolean } }).MediaRecorder;\n return MR.isTypeSupported(type);\n }\n\n // performance.now() is universally available wherever MediaRecorder runs\n // (browsers and the happy-dom test env), so no fallback guard is needed.\n private _now(): number {\n return performance.now();\n }\n\n private _elapsed(): number {\n return Math.max(0, Math.round(this._now() - this._startTime));\n }\n}\n","import {\n IWcBindable, RecorderOptions, WcsMediaErrorDetail,\n} from \"../types.js\";\nimport { RecorderCore } from \"../core/RecorderCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-recorder>` — declarative media recording. Wraps RecorderCore and records a\n * borrowed `MediaStream` received via the `attachStream` command (the direct\n * channel from `<wcs-camera>`'s `stream-ready`). It never owns or stops the stream.\n *\n * Recording parameters (`mime-type` / `timeslice` / bitrates) are mirrored\n * attributes. The assembled clip is published as `wcs-recorder:recorded`\n * (`{ blob, objectURL, mimeType, duration }`) and the `blob` / `objectURL` value\n * properties — a settled `Blob` is a value and may flow through state.\n */\nexport class WcsRecorder extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...RecorderCore.wcBindable,\n // `mimeType` deliberately appears on TWO surfaces: as an output `property`\n // (inherited from RecorderCore — the browser-resolved recording type, event\n // `mimetype-changed`) and as an `input` (the `mime-type` request attribute). They\n // share a base name but are distinct directions: the property is read-only output\n // (getter → Core), the input is the write-only request (setter → attribute, read\n // back in _options()). See README \"request vs. resolved\".\n inputs: [\n { name: \"mimeType\", attribute: \"mime-type\" },\n { name: \"timeslice\", attribute: \"timeslice\" },\n { name: \"audioBitsPerSecond\", attribute: \"audio-bits\" },\n { name: \"videoBitsPerSecond\", attribute: \"video-bits\" },\n ],\n commands: RecorderCore.wcBindable.commands,\n };\n\n private _core: RecorderCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new RecorderCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-recorder:recording-changed\": (d) => ({ recording: d === true }),\n \"wcs-recorder:paused-changed\": (d) => ({ paused: d === true }),\n \"wcs-recorder:error\": (d) => ({ error: d != null }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (docs/custom-state-reflection-design.md §3.4): attachInternals is\n // absent in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here). Either\n // case silently disables reflection — the component still works, it just doesn't\n // 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 // 式文の三項演算子は ESLint no-unused-expressions に抵触するため if/else。\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n\n // `mimeType` is an OUTPUT value property (the Core-resolved recording type,\n // published via `wcs-recorder:mimetype-changed`), so the getter delegates to the\n // Core — NOT the `mime-type` input attribute. The attribute is a *request*: the\n // browser may pick a different type, or fill one in when none was requested, and\n // bindings must read the actual value. The input side is read straight from the\n // attribute in `_options()`. The setter still writes the request attribute.\n //\n // The setters never let setAttribute stringify null / undefined (a \"undefined\"\n // mime-type would be requested from MediaRecorder): `null` removes the\n // attribute (no request — the browser's default), `undefined` restores the\n // attribute the element started with (wc-bindable producer guidance P1;\n // React 19 and a direct assignment deliver it, @wcstack/state does not).\n get mimeType(): string { return this._core.mimeType; }\n set mimeType(value: string | null | undefined) { reflectAttribute(this, \"mime-type\", value); }\n\n get timeslice(): number { return this._numberAttr(\"timeslice\"); }\n set timeslice(value: number | null | undefined) { reflectAttribute(this, \"timeslice\", value); }\n\n get audioBitsPerSecond(): number { return this._numberAttr(\"audio-bits\"); }\n set audioBitsPerSecond(value: number | null | undefined) { reflectAttribute(this, \"audio-bits\", value); }\n\n get videoBitsPerSecond(): number { return this._numberAttr(\"video-bits\"); }\n set videoBitsPerSecond(value: number | null | undefined) { reflectAttribute(this, \"video-bits\", value); }\n\n // --- Core delegated getters ---\n\n get recording(): boolean { return this._core.recording; }\n get paused(): boolean { return this._core.paused; }\n get duration(): number { return this._core.duration; }\n get blob(): Blob | null { return this._core.blob; }\n get objectURL(): string | null { return this._core.objectURL; }\n get error(): WcsMediaErrorDetail | null { return this._core.error; }\n /** The last failure's serializable `WcsIoErrorInfo` (Phase 6 taxonomy), or null. */\n get errorInfo(): WcsIoErrorInfo | null { return this._core.errorInfo; }\n\n // --- Commands ---\n\n /** Borrow a stream (the direct-channel sink). */\n attachStream(stream: MediaStream): void {\n this._core.attachStream(stream);\n }\n\n start(): void {\n this._core.start(this._options());\n }\n\n stop(): void { this._core.stop(); }\n pause(): void { this._core.pause(); }\n resume(): void { this._core.resume(); }\n\n // --- Internal ---\n\n private _numberAttr(name: string): number {\n const attr = this.getAttribute(name);\n if (attr === null || attr.trim() === \"\") return NaN;\n const parsed = Number(attr);\n return Number.isFinite(parsed) ? parsed : NaN;\n }\n\n private _options(): RecorderOptions {\n const o: RecorderOptions = {};\n // Read the requested type from the input attribute directly — `get mimeType()` is\n // the resolved OUTPUT value, not the request.\n const requested = this.getAttribute(\"mime-type\") ?? \"\";\n if (requested) o.mimeType = requested;\n if (Number.isFinite(this.timeslice)) o.timeslice = this.timeslice;\n if (Number.isFinite(this.audioBitsPerSecond)) o.audioBitsPerSecond = this.audioBitsPerSecond;\n if (Number.isFinite(this.videoBitsPerSecond)) o.videoBitsPerSecond = this.videoBitsPerSecond;\n return o;\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","import { WcsCamera } from \"./components/Camera.js\";\nimport { WcsRecorder } from \"./components/Recorder.js\";\nimport { config } from \"./config.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n if (!registry.get(config.tagNames.camera)) {\n registry.define(config.tagNames.camera, WcsCamera);\n }\n if (!registry.get(config.tagNames.recorder)) {\n registry.define(config.tagNames.recorder, WcsRecorder);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapCamera(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":[],"mappings":"AASA,MAAM,OAAO,GAAoB;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,MAAM,EAAE,YAAY;AACpB,QAAA,QAAQ,EAAE,cAAc;AACzB,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IAC/D;AACA,IAAA,OAAO,KAAU;AACnB;AAEA,IAAI,YAAY,GAAmB,IAAI;AAEvC;AACA;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iB,CAAC,IAAI,CAAC;AACvB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM;QAC3B,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACvD;IAEA,oBAAoB,GAAA;AAClB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACtB;;;AClLF;;;;AAIG;AACG,SAAU,kBAAkB,CAAC,QAAA,GAAkC,cAAc,EAAA;AACjF,IAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACzC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IACpD;AACA,IAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAC3C,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IACxD;AACF;;ACZM,SAAU,eAAe,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAC5F,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;IACA,kBAAkB,CAAC,QAAQ,CAAC;AAC9B;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../../src/config.ts","../../src/core/platformCapability.ts","../../src/media/getUserMedia.ts","../../src/media/permission.ts","../../src/media/recording.ts","../../src/core/mediaCapabilities.ts","../../src/core/CameraCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Camera.ts","../../src/core/RecorderCore.ts","../../src/components/Recorder.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapCamera.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n camera: string;\n recorder: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n camera: \"wcs-camera\",\n recorder: \"wcs-recorder\",\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\n// Internal, mutable live config used by registerComponents (read at call time so\n// setConfig() takes effect without re-import). Public consumers get the deep-frozen\n// clone from getConfig().\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapCamera` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/camera] bootstrapCamera: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /io-core/platform-capability.ts by scripts/sync-io-core.mjs.\n// Run `node scripts/sync-io-core.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * platform-capability.ts\n *\n * Phase 6(docs/architecture-hardening/09-remediation-design.md §7.2 /\n * 07-browser-capability-variance.md)の browser capability 判定と error taxonomy の\n * 汎用プリミティブ。node 固有の capability registry / error code は各パッケージが\n * 別ファイルで宣言し、この汎用層(型 + assess 機構)を import する。\n *\n * 原則:\n * - feature detection は境界(利用直前)で行う。module 評価時に browser global を\n * 参照しない(SSR / worker で import が失敗しない)。\n * - capability ID(`web.fetch` 等)は文字列を global property path として eval せず、\n * registry が ID ごとに副作用のない presence probe を対応付ける。\n * - availability / permission / readiness / activity / operation error を 1 つの\n * `ready / unsupported / error` enum に畳まない。required 欠如は開始しない、\n * optional 欠如は宣言済み fallback で readiness を `degraded` にする。\n *\n * 配置: 本ファイルは /io-core/ の単一正典であり、scripts/sync-io-core.mjs が\n * 各 IO ノードの src/core/ へ生成コピー (AUTO-GENERATED, 編集禁止) を配布する。\n * `protocol/wcBindable.ts` と同じ copy-distribution 方式で、ランタイム依存を導入せず\n * 各パッケージのバンドルへ inline される (zero-runtime-dep / 自己完結 CDN を維持)。\n * 編集はこの正典に対して行い、`node scripts/sync-io-core.mjs` で再配布する。\n *\n * pure(module 評価時に browser global 非参照)。\n */\n\nexport type Availability = \"available\" | \"missing\" | \"unknown\";\nexport type PermissionState = \"granted\" | \"denied\" | \"prompt\" | \"not-applicable\" | \"unknown\";\nexport type Readiness = \"idle\" | \"ready\" | \"degraded\";\nexport type Activity = \"inactive\" | \"active\";\nexport type PreconditionState = \"satisfied\" | \"required\" | \"not-applicable\";\n\n/** operation error の phase(taxonomy)。 */\nexport type WcsIoErrorPhase = \"probe\" | \"start\" | \"execute\" | \"decode\" | \"commit\" | \"dispose\";\n\n/** serializable な error info(non-cloneable な cause とは分離。DevTools / remote へは info のみ)。 */\nexport interface WcsIoErrorInfo {\n readonly code: string;\n readonly phase: WcsIoErrorPhase;\n readonly recoverable: boolean;\n readonly capabilityId?: string;\n readonly message: string;\n}\n\nexport interface PlatformAssessment {\n readonly availability: ReadonlyMap<string, Availability>;\n readonly permission: PermissionState;\n readonly readiness: Readiness;\n readonly activity: Activity;\n readonly preconditions: {\n readonly secureContext: PreconditionState;\n readonly userActivation: PreconditionState;\n };\n readonly epoch: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\n/** capability 1 件の仕様。probe は副作用なく presence を返す(利用直前に呼ぶ)。 */\nexport interface CapabilitySpec {\n readonly probe: () => boolean;\n readonly requiresSecureContext?: boolean;\n readonly requiresUserActivation?: boolean;\n /** browser compatibility dataset のキー(任意・診断用)。 */\n readonly compatKey?: string;\n}\n\nexport type CapabilityRegistry = ReadonlyMap<string, CapabilitySpec>;\n\nexport interface AssessOptions {\n readonly required: readonly string[];\n readonly optional?: readonly string[];\n readonly permission?: PermissionState;\n readonly activity?: Activity;\n readonly epoch?: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\nfunction isSecureContext(): boolean {\n return (globalThis as { isSecureContext?: unknown }).isSecureContext === true;\n}\n\n/**\n * capability を利用直前に評価して PlatformAssessment を作る。\n * required が 1 つでも欠ければ readiness は \"idle\"(開始不可)、\n * required 揃い + optional 欠けは \"degraded\"、全揃いは \"ready\"。\n */\nexport function assessCapabilities(registry: CapabilityRegistry, options: AssessOptions): PlatformAssessment {\n const availability = new Map<string, Availability>();\n const evaluate = (id: string): Availability => {\n const spec = registry.get(id);\n if (spec === undefined) return \"unknown\";\n return spec.probe() ? \"available\" : \"missing\";\n };\n\n let requiredAllAvailable = true;\n for (const id of options.required) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") requiredAllAvailable = false;\n }\n let optionalAllAvailable = true;\n for (const id of options.optional ?? []) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") optionalAllAvailable = false;\n }\n\n const readiness: Readiness = !requiredAllAvailable ? \"idle\" : (optionalAllAvailable ? \"ready\" : \"degraded\");\n\n // preconditions: 対象 capability のいずれかが要求する場合だけ評価する。\n const allIds = [...options.required, ...(options.optional ?? [])];\n const needsSecure = allIds.some((id) => registry.get(id)?.requiresSecureContext === true);\n const needsActivation = allIds.some((id) => registry.get(id)?.requiresUserActivation === true);\n const secureContext: PreconditionState = needsSecure ? (isSecureContext() ? \"satisfied\" : \"required\") : \"not-applicable\";\n const userActivation: PreconditionState = needsActivation ? \"required\" : \"not-applicable\";\n\n return {\n availability,\n permission: options.permission ?? \"not-applicable\",\n readiness,\n activity: options.activity ?? \"inactive\",\n preconditions: { secureContext, userActivation },\n epoch: options.epoch ?? 0,\n lastError: options.lastError,\n };\n}\n\n/** availability から「required がすべて available か」を判定するヘルパ(supported の最低条件)。 */\nexport function requiredCapabilitiesAvailable(assessment: PlatformAssessment, required: readonly string[]): boolean {\n return required.every((id) => assessment.availability.get(id) === \"available\");\n}\n\n/**\n * このページで機能が使えない理由(使える、または分からないなら null)。利用直前に読む。\n *\n * - `\"insecure-context\"`: 安全なコンテキストではない(`isSecureContext === false`)。\n * Permissions API が扱う機能はどれも安全なコンテキストを要る。\n * - `\"policy-blocked\"`: Permissions-Policy(サーバーのヘッダ、または `allow` の無い\n * `<iframe>`)がその機能を切っている。\n *\n * どちらも Permissions API は教えない: Chromium はポリシーで切られた文書でも\n * `granted` を、安全でない origin では `denied` を返す。利用者の拒否と区別するため、\n * 見張り役(`<wcs-permission>`)も取りに行く側も `unsupported` を報告する\n * (docs/v4-direction-2026-10.md の決定、state-field-report)。\n * `isSecureContext` が無い環境(SSR・テスト)は判断しない。\n */\nexport type FeatureUnavailableReason = \"insecure-context\" | \"policy-blocked\";\n\n/** Permissions-Policy が制御する機能(permission 名と同じ文字列)。 */\nconst POLICY_CONTROLLED = new Set([\n \"camera\", \"microphone\", \"geolocation\", \"midi\", \"clipboard-read\", \"clipboard-write\",\n \"screen-wake-lock\", \"idle-detection\", \"accelerometer\", \"gyroscope\", \"magnetometer\",\n \"ambient-light-sensor\", \"display-capture\",\n]);\n\ninterface PolicyLike { allowsFeature(feature: string): boolean }\n\nexport function featureUnavailable(feature: string): FeatureUnavailableReason | null {\n const g = globalThis as { isSecureContext?: unknown; document?: { permissionsPolicy?: PolicyLike; featurePolicy?: PolicyLike } };\n if (g.isSecureContext === false) return \"insecure-context\";\n if (!POLICY_CONTROLLED.has(feature)) return null;\n const policy = g.document?.permissionsPolicy ?? g.document?.featurePolicy;\n if (policy === undefined || typeof policy.allowsFeature !== \"function\") return null;\n try {\n return policy.allowsFeature(feature) ? null : \"policy-blocked\";\n } catch {\n return null;\n }\n}\n\n/** `featureUnavailable` の理由を、作者が直し方を読める文にする。`what` は文頭(「The camera」など)。 */\nexport function featureUnavailableMessage(what: string, feature: string, reason: FeatureUnavailableReason): string {\n return reason === \"insecure-context\"\n ? `${what} needs a secure context (https:, or http://localhost), and this page is not one.`\n : `${what} is turned off for this page by a Permissions-Policy: the server's Permissions-Policy header, ` +\n `or an <iframe> without allow=\"${feature}\". The browser's site settings cannot change that.`;\n}\n","import { CameraConstraints, MediaDeviceSnapshot, WcsMediaErrorDetail } from \"../types.js\";\nimport { featureUnavailable, featureUnavailableMessage } from \"../core/platformCapability.js\";\n\n/** True when getUserMedia is reachable (secure context with a media-devices impl). */\nexport function hasMediaDevices(): boolean {\n return typeof navigator !== \"undefined\"\n && !!navigator.mediaDevices\n && typeof navigator.mediaDevices.getUserMedia === \"function\";\n}\n\n/** True when MediaRecorder is available in this environment. */\nexport function hasMediaRecorder(): boolean {\n return typeof globalThis !== \"undefined\"\n && typeof (globalThis as { MediaRecorder?: unknown }).MediaRecorder === \"function\";\n}\n\n/**\n * Translate a getUserMedia constraints object from the declarative\n * CameraConstraints surface. Always requests a video track; `audio` opts the\n * microphone in. `deviceId` (exact) takes precedence over `facingMode`.\n */\nexport function buildConstraints(c: CameraConstraints): MediaStreamConstraints {\n const video: MediaTrackConstraints = {};\n if (c.deviceId) {\n video.deviceId = { exact: c.deviceId };\n } else if (c.facingMode) {\n video.facingMode = c.facingMode;\n }\n if (typeof c.width === \"number\") video.width = c.width;\n if (typeof c.height === \"number\") video.height = c.height;\n const hasVideoConstraint = Object.keys(video).length > 0;\n return {\n video: hasVideoConstraint ? video : true,\n audio: c.audio === true,\n };\n}\n\n/** Normalize any thrown getUserMedia / MediaRecorder failure into a flat detail. */\nexport function normalizeMediaError(error: unknown): WcsMediaErrorDetail {\n if (error && typeof error === \"object\" && \"name\" in error) {\n const name = String((error as { name: unknown }).name) || \"Error\";\n const message = \"message\" in error && (error as { message?: unknown }).message\n ? String((error as { message: unknown }).message)\n : `Media request failed: ${name}.`;\n return { name, message };\n }\n return { name: \"Error\", message: \"Media request failed.\" };\n}\n\n// getUserMedia is absent on an insecure origin, and in a browser without it: say which.\nfunction unsupportedError(): WcsMediaErrorDetail {\n const reason = featureUnavailable(\"camera\");\n return {\n name: \"unsupported\",\n message: reason === \"insecure-context\"\n ? featureUnavailableMessage(\"getUserMedia\", \"camera\", reason)\n : \"getUserMedia is not available in this browser.\",\n };\n}\n\n/**\n * Why this page cannot use the camera (or, with `audio`, the microphone): not a secure\n * context, or turned off by a Permissions-Policy. `null` when it can, as far as the\n * platform tells. `device` says which one, for the permission output it makes unsupported.\n */\nexport function mediaUnavailable(audio: boolean): { device: \"camera\" | \"microphone\"; error: WcsMediaErrorDetail } | null {\n const camera = featureUnavailable(\"camera\");\n if (camera !== null) {\n return { device: \"camera\", error: { name: \"unsupported\", message: featureUnavailableMessage(\"The camera\", \"camera\", camera) } };\n }\n const microphone = audio ? featureUnavailable(\"microphone\") : null;\n if (microphone !== null) {\n return { device: \"microphone\", error: { name: \"unsupported\", message: featureUnavailableMessage(\"The microphone\", \"microphone\", microphone) } };\n }\n return null;\n}\n\nexport interface UserMediaResult {\n stream?: MediaStream;\n error?: WcsMediaErrorDetail;\n}\n\n/**\n * Request a media stream. Never throws — resolves with `{ stream }` on success or\n * `{ error }` (normalized) on failure / when the API is unavailable.\n */\nexport async function requestUserMedia(constraints: MediaStreamConstraints): Promise<UserMediaResult> {\n if (!hasMediaDevices()) {\n return { error: unsupportedError() };\n }\n try {\n const stream = await navigator.mediaDevices.getUserMedia(constraints);\n return { stream };\n } catch (error) {\n return { error: normalizeMediaError(error) };\n }\n}\n\n/** Stop every track of a stream, releasing the camera/microphone hardware. */\nexport function stopAllTracks(stream: MediaStream | null): void {\n if (!stream) return;\n for (const track of stream.getTracks()) {\n track.stop();\n }\n}\n\n/**\n * Enumerate video input devices as plain snapshots. Labels are only populated\n * after a grant, so this is refreshed post-acquisition. Never throws.\n */\nexport async function enumerateVideoDevices(): Promise<MediaDeviceSnapshot[]> {\n if (!hasMediaDevices() || typeof navigator.mediaDevices.enumerateDevices !== \"function\") {\n return [];\n }\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n return devices\n .filter((d) => d.kind === \"videoinput\")\n .map((d) => ({\n deviceId: d.deviceId,\n label: d.label,\n groupId: d.groupId,\n kind: d.kind,\n }));\n } catch {\n return [];\n }\n}\n","import { MediaPermissionState } from \"../types.js\";\n\n/**\n * Live monitor for a single media permission (`camera` or `microphone`) via the\n * Permissions API. Mirrors PermissionCore's two-phase pattern: an initial query\n * plus a live `change` subscription, guarded by a monotonic generation so a query\n * superseded by a rapid dispose/observe never attaches a stale listener.\n *\n * When the Permissions API is absent or rejects the descriptor (e.g. Firefox does\n * not accept the `camera` / `microphone` descriptor), the watcher reports\n * `\"unsupported\"`. The CameraCore then refines the state from the getUserMedia\n * outcome (granted on success, denied on NotAllowedError).\n */\nexport class MediaPermissionWatcher {\n private _name: \"camera\" | \"microphone\";\n private _onChange: (state: MediaPermissionState) => void;\n private _status: PermissionStatus | null = null;\n private _gen: number = 0;\n private _subscribed: boolean = false;\n\n constructor(name: \"camera\" | \"microphone\", onChange: (state: MediaPermissionState) => void) {\n this._name = name;\n this._onChange = onChange;\n }\n\n /** Issue the initial query and subscribe to live changes. Resolves when settled. */\n observe(): Promise<void> {\n if (this._subscribed) return Promise.resolve();\n if (typeof navigator === \"undefined\" || !navigator.permissions\n || typeof navigator.permissions.query !== \"function\") {\n this._onChange(\"unsupported\");\n return Promise.resolve();\n }\n this._subscribed = true;\n const gen = ++this._gen;\n return navigator.permissions\n .query({ name: this._name as PermissionName })\n .then(\n (status) => {\n if (gen !== this._gen) return;\n this._status = status;\n this._onChange(status.state as MediaPermissionState);\n status.addEventListener(\"change\", this._onStatusChange);\n },\n () => {\n if (gen !== this._gen) return;\n this._onChange(\"unsupported\");\n },\n );\n }\n\n /** Detach the live listener and invalidate any in-flight query. */\n dispose(): void {\n this._subscribed = false;\n this._gen++;\n if (this._status) {\n this._status.removeEventListener(\"change\", this._onStatusChange);\n this._status = null;\n }\n }\n\n private _onStatusChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._onChange(status.state as MediaPermissionState);\n };\n}\n","/**\n * Which streams a recorder is recording right now. A recorder borrows its stream and a\n * camera owns it, and neither holds the other; but a camera that stops its stream while\n * it is hidden ends a recording of it, so it asks here first\n * (`[wcs/camera-keep-alive-missing]`). Counted, since two recorders may record one stream.\n */\nconst recording = new WeakMap<MediaStream, number>();\n\nexport function beginRecording(stream: MediaStream): void {\n recording.set(stream, (recording.get(stream) ?? 0) + 1);\n}\n\nexport function endRecording(stream: MediaStream): void {\n const n = (recording.get(stream) ?? 0) - 1;\n if (n > 0) recording.set(stream, n);\n else recording.delete(stream);\n}\n\nexport function isRecording(stream: MediaStream): boolean {\n return recording.has(stream);\n}\n","/**\n * mediaCapabilities.ts\n *\n * camera / recorder node 固有の error code(taxonomy)と derivation。汎用の error info\n * 型は `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。\n *\n * この 1 ファイルを CameraCore(getUserMedia)と RecorderCore(MediaRecorder)の両方が\n * import する。両 Core は同一の error detail 型(`WcsMediaErrorDetail = { name, message }`、\n * `.name` が DOMException 名 / \"unsupported\" sentinel / 各 Core 固有の合成名)を共有する\n * ため、derivation も 1 本で両者を賄える。lane は持たず(getUserMedia は acquire を\n * `_gen` で switchMap 済み、録画は command-driven)、error taxonomy(errorInfo)のみを採用する。\n */\n\nimport type { WcsMediaErrorDetail } from \"../types.js\";\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した media(camera / recorder)error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_MEDIA_ERROR_CODE = {\n /** getUserMedia / MediaRecorder API 不在(非セキュアコンテキスト含む) — \"unsupported\" sentinel。 */\n CapabilityMissing: \"capability-missing\",\n /** `NotAllowedError` / `SecurityError` — 権限拒否・feature-policy ブロック。 */\n NotAllowed: \"not-allowed\",\n /** `NotFoundError` — 要求した種類のデバイス(カメラ/マイク)が存在しない。 */\n NotFound: \"not-found\",\n /** `NotReadableError` — デバイスがハードウェア障害/他アプリ占有で読めない。 */\n NotReadable: \"not-readable\",\n /** `OverconstrainedError` / `NotSupportedError` — 制約・構成(mimeType 等)が満たせない。 */\n InvalidArgument: \"invalid-argument\",\n /** `NoStreamError` — stream 未 attach で録画開始(前提状態の不備)。 */\n InvalidState: \"invalid-state\",\n /** `AbortError` — 実行途中の中断(retry で回復しうる)。 */\n Aborted: \"aborted\",\n /** その他の実行時失敗(`RecorderError` / 想定外の MediaRecorder エラー等)。 */\n MediaError: \"media-error\",\n} as const;\n\n/**\n * 正規化済み media error(`WcsMediaErrorDetail = { name, message }`)を serializable な\n * error taxonomy に写す。`name` は DOMException 名 / \"unsupported\" sentinel / Core 固有の\n * 合成名(`NoStreamError` / `RecorderError`)。公開 `error` shape は不変で、これはその\n * 付加的な分類。\n *\n * - \"unsupported\" は利用直前の能力欠如 → phase=\"probe\" / capability-missing。\n * - `NotAllowedError` / `SecurityError` は取得開始時の権限拒否 → phase=\"start\" /\n * not-allowed。retry で回復しない。\n * - `NotFoundError` は要求デバイス不在 → phase=\"start\" / not-found。\n * - `NotReadableError` はデバイス占有/ハードウェア障害 → phase=\"start\" / not-readable。\n * - `OverconstrainedError` / `NotSupportedError` は制約・構成が満たせない\n * → phase=\"start\" / invalid-argument。\n * - `NoStreamError`(stream 未 attach で録画開始)は前提状態の不備 → phase=\"start\" /\n * invalid-state。\n * - `AbortError` は実行途中の中断 → phase=\"execute\" / aborted(recoverable=true)。\n * - それ以外(`RecorderError` / runtime MediaRecorder エラー / \"Error\" fallback 等)は\n * phase=\"execute\" / media-error。\n */\nexport function deriveMediaErrorInfo(error: WcsMediaErrorDetail): WcsIoErrorInfo {\n const { name, message } = error;\n if (name === \"unsupported\") {\n return { code: WCS_MEDIA_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n }\n if (name === \"NotAllowedError\" || name === \"SecurityError\") {\n return { code: WCS_MEDIA_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NotFoundError\") {\n return { code: WCS_MEDIA_ERROR_CODE.NotFound, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NotReadableError\") {\n return { code: WCS_MEDIA_ERROR_CODE.NotReadable, phase: \"start\", recoverable: false, message };\n }\n if (name === \"OverconstrainedError\" || name === \"NotSupportedError\") {\n return { code: WCS_MEDIA_ERROR_CODE.InvalidArgument, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NoStreamError\") {\n return { code: WCS_MEDIA_ERROR_CODE.InvalidState, phase: \"start\", recoverable: false, message };\n }\n if (name === \"AbortError\") {\n return { code: WCS_MEDIA_ERROR_CODE.Aborted, phase: \"execute\", recoverable: true, message };\n }\n return { code: WCS_MEDIA_ERROR_CODE.MediaError, phase: \"execute\", recoverable: false, message };\n}\n","import {\n IWcBindable, CameraConstraints, FacingMode, MediaDeviceSnapshot,\n MediaPermissionState, WcsMediaErrorDetail,\n} from \"../types.js\";\nimport {\n buildConstraints, enumerateVideoDevices, hasMediaDevices, mediaUnavailable, requestUserMedia, stopAllTracks,\n} from \"../media/getUserMedia.js\";\nimport { featureUnavailable } from \"./platformCapability.js\";\nimport { MediaPermissionWatcher } from \"../media/permission.js\";\nimport { isRecording } from \"../media/recording.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveMediaErrorInfo } from \"./mediaCapabilities.js\";\n\n/**\n * Headless camera-capture primitive. Wraps getUserMedia + the Permissions API and\n * exposes a `MediaStream` through the wc-bindable protocol — but the live stream is\n * NEVER published as a reactive value. It is a non-serializable live handle: it\n * flows out only via the `wcs-camera:stream-ready` event so a consumer (the preview\n * `<video>`, a `<wcs-recorder>`) can bind it directly to an element property,\n * bypassing serializable state. See docs/camera-recorder-tag-design.md §1/§2.\n *\n * The observable value surface is strictly derived data: `active` (is a stream\n * live — the \"actual\" half of the desired/actual pair), `permission` /\n * `audioPermission` (two-phase: Permissions API monitor + getUserMedia outcome),\n * `deviceId` / `devices`, and `error`. Failures never throw — they surface through\n * `error`.\n */\nexport class CameraCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"active\", event: \"wcs-camera:active-changed\", semantics: \"state\" },\n { name: \"permission\", event: \"wcs-camera:permission-changed\", semantics: \"state\" },\n { name: \"audioPermission\", event: \"wcs-camera:audio-permission-changed\", semantics: \"state\" },\n { name: \"deviceId\", event: \"wcs-camera:device-changed\", semantics: \"state\" },\n { name: \"devices\", event: \"wcs-camera:devices-changed\", semantics: \"state\" },\n { name: \"error\", event: \"wcs-camera:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error` (the DOMException name /\n // \"unsupported\" sentinel); the existing `error` property/event are unchanged.\n // Fires wcs-camera:error-info-changed. No lane — acquisition is switchMap'd by\n // `_gen`, so there is no per-node operation policy to attach here.\n { name: \"errorInfo\", event: \"wcs-camera:error-info-changed\", semantics: \"state\" },\n // Direct-channel handle: event-token only — never bound as a reactive value.\n { name: \"streamReady\", event: \"wcs-camera:stream-ready\", semantics: \"handle\", getter: (e: Event) => (e as CustomEvent).detail },\n // event-token: a bare signal (detail is always null) — surface detail, not the raw Event.\n { name: \"ended\", event: \"wcs-camera:ended\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"start\" },\n { name: \"stop\" },\n { name: \"switchCamera\" },\n ],\n };\n\n private _target: EventTarget;\n\n private _active: boolean = false;\n private _permission: MediaPermissionState = \"prompt\";\n private _audioPermission: MediaPermissionState | null = null;\n private _deviceId: string | null = null;\n private _devices: MediaDeviceSnapshot[] = [];\n private _error: WcsMediaErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n\n // The live stream — internal only, never a reactive value (see class docs).\n private _stream: MediaStream | null = null;\n\n // desired/actual split (wakelock-style): `_desired` is whether the user wants the\n // camera on; `_active` is whether a stream is actually live. The OS can revoke a\n // track (device unplugged / taken by another app) — actual drops while desired\n // stays true, so a later resume()/visibility-restore can re-acquire.\n private _desired: boolean = false;\n\n private _constraints: CameraConstraints = {};\n\n // Monotonic id of the current acquisition lifecycle. Bumped by every acquire and\n // by dispose(). Each in-flight getUserMedia captures it and, on resolve, bails\n // (stopping the just-acquired stream) when superseded — so a constraints change\n // mid-acquire (switchMap-style restart) cannot leave an orphaned stream live.\n private _gen: number = 0;\n\n private _subscribed: boolean = false;\n private _camWatcher: MediaPermissionWatcher | null = null;\n private _micWatcher: MediaPermissionWatcher | null = null;\n\n private _ready: Promise<void> = Promise.resolve();\n\n /** Whether `[wcs/camera-keep-alive-missing]` was said for this element (once per element). */\n private _toldKeepAlive = false;\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get active(): boolean { return this._active; }\n get permission(): MediaPermissionState { return this._permission; }\n get audioPermission(): MediaPermissionState | null { return this._audioPermission; }\n get deviceId(): string | null { return this._deviceId; }\n get devices(): MediaDeviceSnapshot[] { return this._devices; }\n get error(): WcsMediaErrorDetail | null { return this._error; }\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-camera:error-info-changed`), derived from `error`; the existing `error`\n * property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null { return this._errorInfo; }\n get ready(): Promise<void> { return this._ready; }\n\n // --- State setters with event dispatch (same-value guarded) ---\n\n private _setActive(active: boolean): void {\n if (this._active === active) return;\n this._active = active;\n this._dispatch(\"wcs-camera:active-changed\", active);\n }\n\n private _setPermission(state: MediaPermissionState): void {\n if (this._permission === state) return;\n this._permission = state;\n this._dispatch(\"wcs-camera:permission-changed\", state);\n }\n\n private _setAudioPermission(state: MediaPermissionState | null): void {\n if (this._audioPermission === state) return;\n this._audioPermission = state;\n this._dispatch(\"wcs-camera:audio-permission-changed\", state);\n }\n\n private _setDeviceId(id: string | null): void {\n if (this._deviceId === id) return;\n this._deviceId = id;\n this._dispatch(\"wcs-camera:device-changed\", id);\n }\n\n private _setDevices(devices: MediaDeviceSnapshot[]): void {\n if (this._devicesEqual(this._devices, devices)) return;\n this._devices = devices;\n this._dispatch(\"wcs-camera:devices-changed\", devices);\n }\n\n // Errors are dispatched on EVERY non-null occurrence by design — each failure is a\n // distinct event (e.g. retrying getUserMedia and failing again must re-notify), so\n // unlike the value setters this is not content-deduped. Only the null→null\n // transition is collapsed (clearing an already-clear error stays silent). The guard\n // is written on null explicitly so it does NOT depend on callers passing a fresh\n // object: a reused/cached non-null detail would still re-notify.\n private _setError(error: WcsMediaErrorDetail | null): void {\n if (error === null && this._error === null) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // error detail (or null on clear). Fires before the `error` event so an observer\n // binding both sees the classification first, mirroring the io-node family.\n this._commitErrorInfo(error === null ? null : deriveMediaErrorInfo(error));\n this._dispatch(\"wcs-camera:error\", error);\n }\n\n // Called only from _setError (which already collapses the null→null transition), so\n // errorInfo transitions exactly when error does — no separate guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._dispatch(\"wcs-camera:error-info-changed\", info);\n }\n\n private _dispatch(type: string, detail: unknown): void {\n this._target.dispatchEvent(new CustomEvent(type, { detail, bubbles: true }));\n }\n\n private _devicesEqual(a: MediaDeviceSnapshot[], b: MediaDeviceSnapshot[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i].deviceId !== b[i].deviceId || a[i].label !== b[i].label) return false;\n }\n return true;\n }\n\n // --- Public API ---\n\n /**\n * Begin observing permissions for the given constraints. Idempotent while\n * already subscribed. The first call (or one after dispose()) starts the\n * camera/microphone permission monitors. Acquisition itself is driven separately\n * by start() / autostart — observing does not prompt.\n */\n observe(constraints: CameraConstraints): Promise<void> {\n this._constraints = { ...constraints };\n if (!this._subscribed) {\n this._subscribed = true;\n this._ready = this._initPermissions();\n } else {\n // Already live: track the latest constraints and fold any newly-started\n // microphone query into `ready` so awaiting observe() guarantees its initial\n // permission state — symmetric with _initPermissions() on the first observe.\n this._ready = this._ready.then(() => this._reconcileAudioWatcher());\n }\n return this._ready;\n }\n\n /** Acquire the camera (sets desired=true). Prompts on first use. */\n start(): void {\n this._desired = true;\n this._restart();\n }\n\n /** Release the camera (sets desired=false), stopping all tracks. */\n stop(): void {\n this._desired = false;\n this._release();\n }\n\n /**\n * Toggle facingMode (user ↔ environment) and re-acquire if active. This is the\n * headless, DOM-free path: it flips the Core's internal `_constraints` (the single\n * source of truth for a standalone Core) and re-acquires while desired.\n *\n * Note: the `<wcs-camera>` Shell does NOT delegate to this — it keeps the DOM\n * attributes authoritative and drives its own single re-acquire (see Camera.ts\n * switchCamera). Both reach the same end state; the split exists because the Shell\n * must keep its declared attributes in sync, which a Core has no notion of.\n */\n switchCamera(): void {\n const next: FacingMode = this._constraints.facingMode === \"environment\" ? \"user\" : \"environment\";\n this._constraints = { ...this._constraints, facingMode: next, deviceId: undefined };\n if (this._desired) {\n this._restart();\n }\n }\n\n /**\n * Suspend the live stream while keeping `desired` — for page-hidden. Stops tracks\n * (clearing the hardware indicator) but remembers that the camera should resume.\n *\n * Bumps `_gen` to supersede any in-flight acquire: without this, an acquire that\n * resolves *after* the page went hidden would assign `_stream` and set active —\n * re-lighting the camera behind a no-op suspend (the stream had not been assigned\n * yet, so the `if (_stream)` release below could not reach it). The superseded\n * acquire stops its just-acquired orphan stream on resolve (see `_acquire`).\n */\n suspend(): void {\n this._gen++;\n if (this._stream) {\n if (isRecording(this._stream)) this._warnKeepAlive();\n this._release();\n }\n }\n\n // A recording of the stream ends with it: what was recorded becomes the clip, and nothing\n // said why the take was short.\n private _warnKeepAlive(): void {\n if (this._toldKeepAlive) return;\n this._toldKeepAlive = true;\n console.warn(\n \"[@wcstack/camera] [wcs/camera-keep-alive-missing] The page was hidden while this camera's stream was \" +\n \"being recorded, so the camera stopped the stream and the recording ended with it. Keep the camera \" +\n \"on while recording: bind keepAlive to the recording flag (keepAlive: <recording path>). (Said once per element.)\",\n this._target,\n );\n }\n\n /** Re-acquire if the camera is desired but not currently active — for page-visible. */\n resume(): void {\n if (this._desired && !this._active) {\n this._restart();\n }\n }\n\n /**\n * Tear down: stop the stream and detach permission listeners. `active` goes back to false\n * with its event: a route the element leaves keeps its nodes (and their bindings) for the\n * next entry, so a reset nobody heard would leave the page showing a camera that is off.\n */\n dispose(): void {\n this._subscribed = false;\n this._gen++;\n this._desired = false;\n this._release();\n if (hasMediaDevices() && typeof navigator.mediaDevices.removeEventListener === \"function\") {\n navigator.mediaDevices.removeEventListener(\"devicechange\", this._onDeviceChange);\n }\n this._camWatcher?.dispose();\n this._micWatcher?.dispose();\n this._camWatcher = null;\n this._micWatcher = null;\n }\n\n // --- Internal ---\n\n private _initPermissions(): Promise<void> {\n if (!hasMediaDevices()) {\n this._setPermission(\"unsupported\");\n return Promise.resolve();\n }\n // A device this page cannot use (not a secure context, or a Permissions-Policy) is\n // \"unsupported\", not what the Permissions API answers: Chromium says \"granted\" in a\n // policy-blocked frame, which would read as \"allowed\" next to a start that fails.\n const tasks: Promise<void>[] = [];\n if (featureUnavailable(\"camera\") !== null) {\n this._setPermission(\"unsupported\");\n } else {\n this._camWatcher = new MediaPermissionWatcher(\"camera\", (s) => this._setPermission(s));\n tasks.push(this._camWatcher.observe());\n }\n if (this._constraints.audio) {\n tasks.push(this._watchMicrophone());\n } else {\n // A re-observe after dispose() without audio: the microphone state the last\n // subscription left is not what this one asks about (null = audio not requested),\n // as _reconcileAudioWatcher clears it on a live Core.\n this._setAudioPermission(null);\n }\n // Track hot-plug: refresh the device list when a camera is added/removed.\n if (typeof navigator.mediaDevices.addEventListener === \"function\") {\n navigator.mediaDevices.addEventListener(\"devicechange\", this._onDeviceChange);\n }\n return Promise.all(tasks).then(() => undefined);\n }\n\n private _onDeviceChange = (): void => {\n void enumerateVideoDevices().then((devices) => {\n // Guard against a late resolution after dispose.\n if (this._subscribed) this._setDevices(devices);\n });\n };\n\n // Bring the microphone watcher in line with the latest `audio` constraint when\n // observe() is called again on an already-live Core. Returns the new watcher's\n // initial-query promise (so observe() can fold it into `ready`); resolved when\n // nothing started.\n private _reconcileAudioWatcher(): Promise<void> {\n if (this._constraints.audio && !this._micWatcher && hasMediaDevices()) {\n return this._watchMicrophone();\n } else if (!this._constraints.audio && (this._micWatcher || this._audioPermission !== null)) {\n this._micWatcher?.dispose();\n this._micWatcher = null;\n this._setAudioPermission(null);\n }\n return Promise.resolve();\n }\n\n private _watchMicrophone(): Promise<void> {\n if (featureUnavailable(\"microphone\") !== null) {\n this._setAudioPermission(\"unsupported\");\n return Promise.resolve();\n }\n this._micWatcher = new MediaPermissionWatcher(\"microphone\", (s) => this._setAudioPermission(s));\n return this._micWatcher.observe();\n }\n\n private _restart(): void {\n this._release();\n void this._acquire();\n }\n\n private async _acquire(): Promise<void> {\n const gen = ++this._gen;\n // Not asked of the browser when the page cannot use the device: its NotAllowedError\n // would read as the user's refusal, which the site settings would fix and these cannot.\n const off = hasMediaDevices() ? mediaUnavailable(!!this._constraints.audio) : null;\n if (off !== null) {\n this._setError(off.error);\n if (off.device === \"camera\") this._setPermission(\"unsupported\");\n else this._setAudioPermission(\"unsupported\");\n this._desired = false;\n this._setActive(false);\n return;\n }\n const constraints = buildConstraints(this._constraints);\n const { stream, error } = await requestUserMedia(constraints);\n\n // Superseded by a newer acquire (rapid restart) or disposed while in flight:\n // stop the orphan stream and bail without mutating state. The `ended` listeners\n // are attached only AFTER this gen check (below), so stopping the orphan here\n // cannot fire _onTrackEnded — no spurious `ended` event / state mutation. Keep\n // this stop strictly before listener attachment if the order is ever refactored.\n if (gen !== this._gen) {\n stopAllTracks(stream ?? null);\n return;\n }\n\n if (error) {\n this._setError(error);\n if (error.name === \"NotAllowedError\") {\n this._setPermission(\"denied\");\n // Hard denial: drop `desired` so a later visibility-restore (resume()) does\n // not silently re-attempt getUserMedia on every page-visible. A transient\n // failure (NotReadableError = device busy) keeps `desired` so it can recover.\n this._desired = false;\n } else if (error.name === \"unsupported\") {\n this._setPermission(\"unsupported\");\n this._desired = false;\n }\n this._setActive(false);\n return;\n }\n\n const live = stream as MediaStream;\n this._stream = live;\n for (const track of live.getTracks()) {\n track.addEventListener(\"ended\", this._onTrackEnded);\n }\n this._setError(null);\n // getUserMedia success is authoritative for permission.\n this._setPermission(\"granted\");\n // Only assert mic-granted when the grant actually produced an audio track. With\n // today's boolean `audio` this is equivalent to `_constraints.audio`, but it stays\n // correct under a future non-mandatory `{ audio: {...} }` constraint where the\n // browser may grant video while omitting audio.\n if (this._constraints.audio && live.getAudioTracks().length > 0) {\n this._setAudioPermission(\"granted\");\n }\n this._updateDeviceId(live);\n this._setActive(true);\n // Publish the live handle for the direct element→element channel.\n this._dispatch(\"wcs-camera:stream-ready\", live);\n // Labels become available after a grant; refresh the device list.\n const devices = await enumerateVideoDevices();\n if (gen === this._gen) {\n this._setDevices(devices);\n }\n }\n\n private _release(): void {\n if (!this._stream) return;\n for (const track of this._stream.getTracks()) {\n track.removeEventListener(\"ended\", this._onTrackEnded);\n }\n stopAllTracks(this._stream);\n this._stream = null;\n this._setActive(false);\n }\n\n private _onTrackEnded = (): void => {\n // OS revoked a track (unplug / taken by another app). actual drops; desired\n // stays true so resume()/visibility-restore can re-acquire.\n this._release();\n this._dispatch(\"wcs-camera:ended\", null);\n };\n\n private _updateDeviceId(stream: MediaStream): void {\n const videoTrack = stream.getVideoTracks()[0];\n if (videoTrack && typeof videoTrack.getSettings === \"function\") {\n const settings = videoTrack.getSettings();\n this._setDeviceId(settings.deviceId ?? null);\n }\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import {\n IWcBindable, CameraConstraints, FacingMode, MediaDeviceSnapshot, MediaPermissionState,\n WcsMediaErrorDetail,\n} from \"../types.js\";\nimport { CameraCore } from \"../core/CameraCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\nconst PREVIEW_CSS = \":host{display:inline-block}video{display:block;width:100%;height:100%}\";\n\n// One constructed sheet for every preview. A Content-Security-Policy's `style-src` governs\n// `<style>` elements (a shadow root's included) but not constructed sheets, so a page whose\n// policy has no 'unsafe-inline' still gets the preview's layout. A `<style>` is the fallback\n// where constructed sheets are not available.\nlet previewSheet: CSSStyleSheet | null | undefined;\n\nfunction adoptPreviewStyles(root: ShadowRoot): void {\n if (previewSheet === undefined) {\n try {\n previewSheet = new CSSStyleSheet();\n previewSheet.replaceSync(PREVIEW_CSS);\n } catch {\n previewSheet = null;\n }\n }\n if (previewSheet !== null && Array.isArray(root.adoptedStyleSheets)) {\n root.adoptedStyleSheets = [previewSheet];\n return;\n }\n const style = document.createElement(\"style\");\n style.textContent = PREVIEW_CSS;\n root.append(style);\n}\n\n/** Test seam: build the shared sheet again on the next preview. */\nexport function resetPreviewStyles(): void {\n previewSheet = undefined;\n}\n\n/**\n * `<wcs-camera>` — declarative camera capture with a built-in preview.\n *\n * The element owns a `<video>` in its shadow root and assigns the live\n * `MediaStream` to `video.srcObject` internally, so the non-serializable handle\n * never crosses the state boundary (design §1, case B). For consumers (a\n * `<wcs-recorder>`, an external `<video>`), the stream is also published via the\n * `wcs-camera:stream-ready` event-token for the direct element→element channel\n * (design §2).\n *\n * Acquisition is explicit: `start()` / the `autostart` attribute prompt and\n * acquire; merely connecting does not. While the page is hidden the stream is\n * suspended (clearing the camera indicator) and re-acquired on return, unless\n * `keep-alive` is set (e.g. during recording).\n */\nexport class WcsCamera extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...CameraCore.wcBindable,\n inputs: [\n { name: \"audio\", attribute: \"audio\" },\n { name: \"facingMode\", attribute: \"facing-mode\" },\n { name: \"deviceId\", attribute: \"device-id\" },\n { name: \"width\", attribute: \"width\" },\n { name: \"height\", attribute: \"height\" },\n { name: \"autostart\", attribute: \"autostart\" },\n { name: \"keepAlive\", attribute: \"keep-alive\" },\n ],\n commands: CameraCore.wcBindable.commands,\n };\n\n // `autostart` and `keep-alive` are intentionally NOT observed: `autostart` is a\n // connect-time-only acquire trigger (read once by the connect-time decision in\n // _scheduleAcquire's microtask; flipping it later is meaningless), and `keep-alive`\n // is read fresh on every visibilitychange (_onVisibilityChange), so it never needs\n // to drive a re-acquire. The observed set is exactly the constraints that reshape\n // the requested track.\n static observedAttributes = [\"facing-mode\", \"device-id\", \"audio\", \"width\", \"height\"];\n\n private _core: CameraCore;\n private _video: HTMLVideoElement;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n // connectedCallback が張った connectedCallbackPromise を解く関数。接続時の判断を下す\n // _scheduleAcquire のマイクロタスクが(その前に外れたときは disconnectedCallback が)呼ぶ。\n // null でないあいだは「接続時の判断待ち」でもある。\n private _connectResolve: ((value: void | PromiseLike<void>) => void) | null = null;\n // _scheduleAcquire のマイクロタスクが待っている間 true\n private _acquirePending: boolean = false;\n // 接続時の判断待ちに stop() が呼ばれたら true — その判断は autostart でも取得しない\n private _autostartCancelled: boolean = false;\n private _connected: boolean = false;\n // True while switchCamera() rewrites several attributes at once. Each setAttribute /\n // removeAttribute fires its own attributeChangedCallback synchronously; without this\n // guard the FIRST change would re-acquire with the not-yet-updated constraints (and\n // tear active down so the later change's re-acquire is skipped). We suppress the\n // per-attribute re-acquire and drive a single one with the final constraints.\n private _batchingAttrs: boolean = false;\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new CameraCore(this);\n const root = this.attachShadow({ mode: \"open\" });\n adoptPreviewStyles(root);\n this._video = document.createElement(\"video\");\n this._video.autoplay = true;\n this._video.muted = true;\n this._video.setAttribute(\"playsinline\", \"\");\n this._video.setAttribute(\"part\", \"video\");\n root.append(this._video);\n // Bind the live handle to the preview internally — never through state. These\n // self-listeners are intentionally not removed on disconnect (asymmetric with the\n // document-level `visibilitychange` in connect/disconnectedCallback): the target\n // is `this`, so the listeners are collected together with the element — there is\n // no external reference to leak. The visibility listener, by contrast, lives on\n // `document` (outlives the element) and MUST be detached.\n this.addEventListener(\"wcs-camera:stream-ready\", this._onStreamReady as EventListener);\n this.addEventListener(\"wcs-camera:active-changed\", this._onActiveChanged as EventListener);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-camera:active-changed\": (d) => ({ active: d === true }),\n \"wcs-camera:error\": (d) => ({ error: d != null }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (docs/custom-state-reflection-design.md §3.4): attachInternals is\n // absent in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here). Either\n // case silently disables reflection — the component still works, it just doesn't\n // 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 // 式文の三項演算子は ESLint no-unused-expressions に抵触するため if/else。\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 // --- Attribute accessors ---\n //\n // The setters never let setAttribute stringify null / undefined (a \"undefined\"\n // device-id would become an exact constraint no camera matches): `null`\n // removes the attribute (the default), `undefined` restores the attribute the\n // element started with (wc-bindable producer guidance P1; React 19 and a\n // direct assignment deliver it, @wcstack/state does not).\n\n get audio(): boolean { return this.hasAttribute(\"audio\"); }\n set audio(value: boolean | null | undefined) { reflectBooleanAttribute(this, \"audio\", value); }\n\n get facingMode(): FacingMode {\n return this.getAttribute(\"facing-mode\") === \"environment\" ? \"environment\" : \"user\";\n }\n set facingMode(value: FacingMode | null | undefined) { reflectAttribute(this, \"facing-mode\", value); }\n\n // `deviceId` is an input (the `device-id` request) and an output (the device the\n // stream uses, published with `wcs-camera:device-changed`). Reading it gives the\n // device in use once one is known — what the event carries, and what a binder's\n // initial sync reads — and the request until then. The constraints read the\n // request from the attribute (`_constraints`), as <wcs-recorder>'s mimeType does.\n get deviceId(): string { return this._core.deviceId ?? this.getAttribute(\"device-id\") ?? \"\"; }\n set deviceId(value: string | null | undefined) { reflectAttribute(this, \"device-id\", value); }\n\n get width(): number { return this._numberAttr(\"width\"); }\n set width(value: number | null | undefined) { reflectAttribute(this, \"width\", value); }\n\n get height(): number { return this._numberAttr(\"height\"); }\n set height(value: number | null | undefined) { reflectAttribute(this, \"height\", value); }\n\n get autostart(): boolean { return this.hasAttribute(\"autostart\"); }\n set autostart(value: boolean | null | undefined) { reflectBooleanAttribute(this, \"autostart\", value); }\n\n get keepAlive(): boolean { return this.hasAttribute(\"keep-alive\"); }\n set keepAlive(value: boolean | null | undefined) { reflectBooleanAttribute(this, \"keep-alive\", value); }\n\n /** The internal preview `<video>` (for advanced styling/measurement). */\n get videoElement(): HTMLVideoElement { return this._video; }\n\n // --- Core delegated getters ---\n\n get active(): boolean { return this._core.active; }\n get permission(): MediaPermissionState { return this._core.permission; }\n get audioPermission(): MediaPermissionState | null { return this._core.audioPermission; }\n get devices(): MediaDeviceSnapshot[] { return this._core.devices; }\n get error(): WcsMediaErrorDetail | null { return this._core.error; }\n /** The last failure's serializable `WcsIoErrorInfo` (Phase 6 taxonomy), or null. */\n get errorInfo(): WcsIoErrorInfo | null { return this._core.errorInfo; }\n\n get connectedCallbackPromise(): Promise<void> { return this._connectedCallbackPromise; }\n\n // --- Commands ---\n\n start(): void {\n // 制約は属性が正本。接続時の判断・属性の変化はマイクロタスクで Core に渡るので\n // (_scheduleAcquire)、それより先の start() でも、いまの属性の制約で取得するよう渡しておく\n if (this._connected) this._core.observe(this._constraints());\n this._core.start();\n }\n stop(): void {\n // 接続時の判断待ちなら、その autostart を取り消す — 同じタスクの append → stop() で、後の\n // マイクロタスクが取得を始めないように(判断が同期だった頃は、始めた取得を stop() が止めて\n // いた)。権限の監視(observe)は取り消さない。入れ直せば、次の判断は autostart に従う\n if (this._connectResolve !== null) this._autostartCancelled = true;\n this._core.stop();\n }\n\n /**\n * Toggle the front/back camera by updating the DOM attributes (the single source\n * of truth), not just the Core's internal constraints. Deliberately does NOT call\n * `CameraCore.switchCamera()` (which would mutate the Core's constraints behind the\n * DOM's back, leaving the declared attributes stale). `device-id` is removed because\n * it would otherwise take precedence over `facing-mode` (see buildConstraints) —\n * leaving it pinned would silently undo the switch on the next re-acquire. Both\n * attribute writes are batched (see `_batchingAttrs`) so they drive exactly ONE\n * re-acquire here, with the final constraints — never an early acquire on a\n * half-updated state. The DOM and the live camera stay in agreement.\n */\n switchCamera(): void {\n const next: FacingMode = this.facingMode === \"environment\" ? \"user\" : \"environment\";\n this._batchingAttrs = true;\n try {\n this.removeAttribute(\"device-id\");\n this.setAttribute(\"facing-mode\", next);\n } finally {\n this._batchingAttrs = false;\n }\n // Sync the (now-final) constraints and re-acquire once when a stream is live —\n // the same `active`-guarded restart attributeChangedCallback performs.\n this._core.observe(this._constraints());\n if (this._core.active) {\n this._core.start();\n }\n }\n\n // --- Internal ---\n\n private _numberAttr(name: string): number {\n const attr = this.getAttribute(name);\n if (attr === null || attr.trim() === \"\") return NaN;\n const parsed = Number(attr);\n return Number.isFinite(parsed) ? parsed : NaN;\n }\n\n private _constraints(): CameraConstraints {\n const c: CameraConstraints = { audio: this.audio, facingMode: this.facingMode };\n // the request, not `get deviceId()` (the device in use): after switchCamera()\n // removed it, the previous device must not stay pinned\n const requested = this.getAttribute(\"device-id\");\n if (requested) c.deviceId = requested;\n if (Number.isFinite(this.width)) c.width = this.width;\n if (Number.isFinite(this.height)) c.height = this.height;\n return c;\n }\n\n private _onStreamReady = (event: CustomEvent): void => {\n this._video.srcObject = event.detail as MediaStream;\n };\n\n private _onActiveChanged = (event: CustomEvent): void => {\n // Clear the preview when the stream is released so the last frame does not stick.\n if (event.detail === false) {\n this._video.srcObject = null;\n }\n };\n\n // --- Lifecycle ---\n\n // 取得の判断はマイクロタスクで、そのときの属性(制約と autostart)で 1 回だけ行う\n // (timing-and-firing-contract §23)。router は遷移で同じノードを入れ直し、新しいルートの\n // params から state が device-id などを書くのはマイクロタスク — その場で取得すると、前の\n // 制約で getUserMedia を起こし、取得中は active が偽なので新しい制約での取り直しも起きず、\n // 前の制約のストリームが残っていた(docs/seam-apps.md、shift-desk)。同じタスクの制約の\n // 変化もここへまとまる。\n private _scheduleAcquire(): void {\n if (this._acquirePending) return;\n this._acquirePending = true;\n queueMicrotask(() => {\n this._acquirePending = false;\n const resolveConnect = this._connectResolve;\n this._connectResolve = null;\n // 判断の前に外れた要素は何もしない(disconnectedCallback が dispose 済み)\n if (!this._connected) return;\n // Track the constraints (and reconcile the microphone watcher).\n const ready = this._core.observe(this._constraints());\n if (resolveConnect !== null) {\n // 接続時の判断: autostart なら取得する(判断待ちに stop() が呼ばれていなければ)\n if (this.autostart && !this._autostartCancelled) {\n this._core.start();\n }\n this._autostartCancelled = false;\n resolveConnect(ready);\n } else if (this._core.active) {\n // A constraints change re-acquires (switchMap-style restart) only when a stream\n // is actually live. `active` is the deliberate guard (not `desired`): `active`\n // implies `desired` (a stream only goes live under desired), so re-acquiring\n // cannot spuriously re-`desired` a stopped camera. Guarding on `active` rather\n // than `desired` also avoids force-acquiring while suspended/hidden (desired but\n // not active) — the visibility handler owns resume there.\n this._core.start();\n }\n });\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this._connected = true;\n // connectedCallbackPromise は接続時の observe(権限の初期状態)が済むまでを表す。\n // observe は判断と同じマイクロタスクで走るので、ここで張ってそこで解く\n this._connectedCallbackPromise = new Promise<void>((resolve) => {\n this._connectResolve = resolve;\n });\n this._scheduleAcquire();\n document.addEventListener(\"visibilitychange\", this._onVisibilityChange);\n }\n\n disconnectedCallback(): void {\n this._connected = false;\n // 判断の前に外れたら、張った connectedCallbackPromise をここで解く — 同じタスクで\n // 入れ直されると次の connectedCallback が張り替えるので、待つ側が取り残されないように\n this._connectResolve?.();\n this._connectResolve = null;\n this._autostartCancelled = false;\n document.removeEventListener(\"visibilitychange\", this._onVisibilityChange);\n this._core.dispose();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (!this._connected || oldValue === newValue) return;\n // While switchCamera() batches several attribute writes, defer to its single\n // post-batch re-acquire — otherwise the first write would acquire on stale\n // constraints (see `_batchingAttrs`).\n if (this._batchingAttrs) return;\n // 制約の変化は取得の判断(_scheduleAcquire)へまとめる: 接続時の判断待ちならそれが\n // 新しい制約を読み、その後ならストリームが生きているときだけ取り直す\n this._scheduleAcquire();\n }\n\n private _onVisibilityChange = (): void => {\n if (this.keepAlive) return;\n if (document.visibilityState === \"hidden\") {\n this._core.suspend();\n } else {\n this._core.resume();\n }\n };\n}\n","import {\n IWcBindable, RecorderOptions, WcsMediaErrorDetail, WcsRecordedDetail,\n} from \"../types.js\";\nimport { hasMediaRecorder, normalizeMediaError } from \"../media/getUserMedia.js\";\nimport { beginRecording, endRecording } from \"../media/recording.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveMediaErrorInfo } from \"./mediaCapabilities.js\";\n\n/**\n * Headless media-recording primitive. Wraps MediaRecorder, consuming a borrowed\n * `MediaStream` (received via `attachStream` over the direct channel — see\n * docs/camera-recorder-tag-design.md §2) and producing a `Blob` clip.\n *\n * Ownership: the stream is BORROWED, never owned. The Core never stops its tracks\n * — that is the camera's job (the acquirer owns release). Stopping here would tear\n * down a stream that may still be previewing.\n *\n * Non-goal: the Core does NOT subscribe to the borrowed tracks' `ended` and does NOT\n * auto-terminate a recording when the underlying stream dies (camera stop / OS\n * revoke / switchCamera re-acquire). Reacting would mean reaching into a stream we do\n * not own. The MediaRecorder keeps running against the now-dead source until an\n * explicit stop(); the consumer (which owns the camera lifecycle) is responsible for\n * stopping the recording when it tears the stream down. stop() then assembles\n * whatever chunks were captured — never throws.\n *\n * Output: `dataavailable` chunks are collected and assembled into one `Blob` on\n * stop, published via `wcs-recorder:recorded`. The `Blob` is structured-clone\n * friendly (a settled value, unlike MediaStream) so it may flow through state.\n * `objectURL` is a managed string — the Core revokes the previous URL before\n * issuing a new one and on dispose. Failures never throw.\n */\nexport class RecorderCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"recording\", event: \"wcs-recorder:recording-changed\", semantics: \"state\" },\n { name: \"paused\", event: \"wcs-recorder:paused-changed\", semantics: \"state\" },\n { name: \"duration\", event: \"wcs-recorder:duration-changed\", semantics: \"state\" },\n { name: \"mimeType\", event: \"wcs-recorder:mimetype-changed\", semantics: \"state\" },\n { name: \"blob\", event: \"wcs-recorder:recorded\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail?.blob ?? null },\n { name: \"objectURL\", event: \"wcs-recorder:recorded\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail?.objectURL ?? null },\n { name: \"error\", event: \"wcs-recorder:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error` (the DOMException name /\n // \"unsupported\"/\"NoStreamError\"/\"RecorderError\" sentinel); the existing `error`\n // property/event are unchanged. Fires wcs-recorder:error-info-changed. No lane —\n // recording is command-driven.\n { name: \"errorInfo\", event: \"wcs-recorder:error-info-changed\", semantics: \"state\" },\n // event-token: detail = the assembled clip { blob, objectURL, mimeType, duration }.\n { name: \"recorded\", event: \"wcs-recorder:recorded\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n // event-token (timeslice mode): detail = the streamed Blob chunk.\n { name: \"dataavailable\", event: \"wcs-recorder:dataavailable\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"attachStream\" },\n { name: \"start\" },\n { name: \"stop\" },\n { name: \"pause\" },\n { name: \"resume\" },\n ],\n };\n\n private _target: EventTarget;\n\n private _recording: boolean = false;\n private _paused: boolean = false;\n private _duration: number = 0;\n private _mimeType: string = \"\";\n private _blob: Blob | null = null;\n private _objectURL: string | null = null;\n private _error: WcsMediaErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n\n private _recorder: MediaRecorder | null = null;\n private _stream: MediaStream | null = null; // borrowed — never stopped here\n // the stream the live MediaRecorder records (attachStream may swap _stream mid-recording)\n private _recordingStream: MediaStream | null = null;\n private _timeslice: boolean = false;\n private _startTime: number = 0;\n\n // Monotonic id of the current recording lifecycle. Bumped by every start() and\n // dispose(); each MediaRecorder callback bails if stale so a torn-down/restarted\n // recorder's late event cannot mutate state.\n private _gen: number = 0;\n\n // The generation of a recording that dispose() stopped: its MediaRecorder still delivers\n // the clip (onstop comes later in a browser), and only that clip gets through — with the\n // type and duration it had when the element went away.\n private _closing: { gen: number; mimeType: string; duration: number } | null = null;\n\n // SSR: recording is command-driven (attachStream/start), so there is no\n // asynchronous probe to await — readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n /**\n * Whether `[wcs/command-not-ready]` was said in this outage: a `start()` refused because the\n * element is not ready loses what it carried, and `error` alone told only a page that binds it.\n * Said once per outage (docs/v4-direction-2026-10.md, the I/O command policy): a stream arriving\n * resets it. Once per element was once per page life — a route puts the same element back on\n * every entry, so the next outage's lost recording went unsaid (docs/seam-apps.md, shift-desk).\n */\n private _toldNotReady = false;\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get recording(): boolean { return this._recording; }\n get paused(): boolean { return this._paused; }\n // Finalized at stop/pause only — there is no live ticking timer, so this stays 0\n // from start() until the first pause()/stop() (see _elapsed / onstop / onpause).\n get duration(): number { return this._duration; }\n get mimeType(): string { return this._mimeType; }\n get blob(): Blob | null { return this._blob; }\n get objectURL(): string | null { return this._objectURL; }\n get error(): WcsMediaErrorDetail | null { return this._error; }\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-recorder:error-info-changed`), derived from `error`; the existing `error`\n * property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null { return this._errorInfo; }\n get ready(): Promise<void> { return this._ready; }\n\n // --- State setters ---\n\n private _setRecording(v: boolean): void {\n if (this._recording === v) return;\n this._recording = v;\n this._dispatch(\"wcs-recorder:recording-changed\", v);\n }\n\n private _setPaused(v: boolean): void {\n if (this._paused === v) return;\n this._paused = v;\n this._dispatch(\"wcs-recorder:paused-changed\", v);\n }\n\n private _setDuration(v: number): void {\n if (this._duration === v) return;\n this._duration = v;\n this._dispatch(\"wcs-recorder:duration-changed\", v);\n }\n\n private _setMimeType(v: string): void {\n if (this._mimeType === v) return;\n this._mimeType = v;\n this._dispatch(\"wcs-recorder:mimetype-changed\", v);\n }\n\n // Errors are dispatched on EVERY non-null occurrence by design — each failure is a\n // distinct event, so unlike the value setters this is not content-deduped. Only the\n // null→null transition is collapsed (clearing an already-clear error stays silent).\n // The guard is written on null explicitly so it does NOT depend on callers passing a\n // fresh object: a reused/cached non-null detail would still re-notify.\n private _setError(error: WcsMediaErrorDetail | null): void {\n if (error === null && this._error === null) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // error detail (or null on clear). Fires before the `error` event so an observer\n // binding both sees the classification first, mirroring the io-node family.\n this._commitErrorInfo(error === null ? null : deriveMediaErrorInfo(error));\n this._dispatch(\"wcs-recorder:error\", error);\n }\n\n // Called only from _setError (which already collapses the null→null transition), so\n // errorInfo transitions exactly when error does — no separate guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._dispatch(\"wcs-recorder:error-info-changed\", info);\n }\n\n private _dispatch(type: string, detail: unknown): void {\n this._target.dispatchEvent(new CustomEvent(type, { detail, bubbles: true }));\n }\n\n // --- Public API ---\n\n /**\n * Borrow a stream for recording (the direct-channel sink). Synchronous, no\n * await: the live handle is captured by reference and never stored in state.\n * Does NOT stop any previously-borrowed stream — ownership stays with the camera.\n *\n * Re-attaching mid-recording takes effect on the NEXT start(), not the current\n * recording: the live MediaRecorder was already constructed around the previous\n * stream and keeps recording it until stop(). The borrowed reference is swapped so\n * the following start() uses the new stream.\n */\n attachStream(stream: MediaStream): void {\n this._stream = stream;\n // ready again: a start refused in the next outage is said again\n if (stream) this._toldNotReady = false;\n }\n\n /** Start recording the borrowed stream. Never throws — surfaces `error`. */\n start(options: RecorderOptions = {}): void {\n if (!hasMediaRecorder()) {\n this._setError({ name: \"unsupported\", message: \"MediaRecorder is not available in this environment.\" });\n return;\n }\n if (!this._stream) {\n this._setError({ name: \"NoStreamError\", message: \"No stream attached. Wire a camera's stream-ready to attachStream first.\" });\n this._warnNotReady();\n return;\n }\n if (this._recording) return;\n\n const recOptions: MediaRecorderOptions = {};\n if (options.mimeType && this._isTypeSupported(options.mimeType)) {\n recOptions.mimeType = options.mimeType;\n }\n if (typeof options.audioBitsPerSecond === \"number\") recOptions.audioBitsPerSecond = options.audioBitsPerSecond;\n if (typeof options.videoBitsPerSecond === \"number\") recOptions.videoBitsPerSecond = options.videoBitsPerSecond;\n\n let recorder: MediaRecorder;\n try {\n recorder = new MediaRecorder(this._stream, recOptions);\n } catch (error) {\n this._setError(normalizeMediaError(error));\n return;\n }\n\n const gen = ++this._gen;\n // per recording: a clip finishing after a disconnect must not take a later one's chunks\n const chunks: Blob[] = [];\n const stream = this._stream;\n this._timeslice = typeof options.timeslice === \"number\" && options.timeslice > 0;\n const closing = (): boolean => this._closing !== null && this._closing.gen === gen;\n\n recorder.ondataavailable = (event: BlobEvent): void => {\n if (gen !== this._gen && !closing()) return;\n if (event.data && event.data.size > 0) {\n chunks.push(event.data);\n if (gen !== this._gen) return;\n // a browser that resolved no type at start still types the chunks\n if (!this._mimeType && event.data.type) this._setMimeType(event.data.type);\n if (this._timeslice) {\n this._dispatch(\"wcs-recorder:dataavailable\", event.data);\n }\n }\n };\n // Chromium resolves the type only when recording starts (`mimeType` is \"\" until then\n // when none was requested): the resolved type is the one the clip has.\n recorder.onstart = (): void => {\n if (gen === this._gen && recorder.mimeType) this._setMimeType(recorder.mimeType);\n };\n recorder.onstop = (): void => {\n endRecording(stream);\n if (this._recordingStream === stream) this._recordingStream = null;\n if (closing()) {\n // stopped by dispose(): recording / paused / duration were published then\n const { mimeType, duration } = this._closing!;\n this._closing = null;\n this._assembleBlob(chunks, mimeType, duration);\n return;\n }\n if (gen !== this._gen) return;\n // When stopped while paused, `_duration` was already finalized in onpause —\n // recomputing _elapsed() here would wrongly include the paused gap (the\n // clock kept running but `_startTime` was not advanced). Keep the held value.\n if (!this._paused) this._setDuration(this._elapsed());\n this._assembleBlob(chunks, this._mimeType, this._duration);\n this._setPaused(false);\n this._setRecording(false);\n };\n recorder.onerror = (event: Event): void => {\n if (gen !== this._gen) return;\n const err = (event as unknown as { error?: unknown }).error;\n this._setError(normalizeMediaError(err ?? { name: \"RecorderError\" }));\n };\n recorder.onpause = (): void => {\n if (gen !== this._gen) return;\n this._setDuration(this._elapsed());\n this._setPaused(true);\n };\n recorder.onresume = (): void => {\n if (gen !== this._gen) return;\n this._startTime = this._now() - this._duration;\n this._setPaused(false);\n };\n\n this._recorder = recorder;\n this._setError(null);\n this._setMimeType(recorder.mimeType || recOptions.mimeType || \"\");\n this._startTime = this._now();\n this._setDuration(0);\n recorder.start(this._timeslice ? options.timeslice : undefined);\n beginRecording(stream);\n this._recordingStream = stream;\n this._setRecording(true);\n }\n\n private _warnNotReady(): void {\n if (this._toldNotReady) return;\n this._toldNotReady = true;\n console.warn(\n \"[@wcstack/camera] [wcs/command-not-ready] start() was refused: no stream is attached, so nothing is recorded. \" +\n \"It goes to `error` too. Wire a camera's stream to the recorder first. \" +\n \"(Said once until a stream is attached again.)\",\n this._target,\n );\n }\n\n /** Stop recording; the assembled Blob is published from the recorder's onstop. */\n stop(): void {\n if (this._recorder && this._recorder.state !== \"inactive\") {\n this._recorder.stop();\n }\n }\n\n pause(): void {\n if (this._recorder && this._recorder.state === \"recording\") {\n this._recorder.pause();\n }\n }\n\n resume(): void {\n if (this._recorder && this._recorder.state === \"paused\") {\n this._recorder.resume();\n }\n }\n\n /**\n * Establish monitoring (§3.5). Recording is command-driven — there is no listener\n * or subscription to set up here (the borrowed stream arrives via attachStream and\n * recording is driven by start()/stop()), so observe() is an idempotent no-op that\n * resolves once ready. dispose() is its teardown counterpart.\n */\n observe(): Promise<void> {\n return this._ready;\n }\n\n /**\n * Stop in-flight recording, revoke the last object URL, drop the borrowed stream.\n *\n * A recording in progress is not thrown away: it stops, and the clip arrives as\n * `wcs-recorder:recorded` when the MediaRecorder delivers it (later, in a browser) — as it\n * does when the stream's tracks end. `recording` / `paused` go back to false at once, with\n * their events: a route the element leaves keeps its nodes (and their bindings) for the\n * next entry, so a reset nobody heard would leave the page showing a recording that is\n * not there.\n */\n dispose(): void {\n const recorder = this._recorder;\n const inFlight = recorder !== null && recorder.state !== \"inactive\";\n if (inFlight) {\n if (!this._paused) this._setDuration(this._elapsed());\n this._closing = { gen: this._gen, mimeType: this._mimeType, duration: this._duration };\n }\n // Bump the generation so no other callback of this recorder reaches the Core.\n this._gen++;\n this._recorder = null;\n this._revokeUrl();\n // Drop the borrowed reference WITHOUT stopping its tracks — the camera owns it.\n this._stream = null;\n this._setPaused(false);\n this._setRecording(false);\n if (inFlight) {\n try {\n recorder.stop();\n } catch {\n // A recorder already torn down by the environment must not throw here; no clip comes.\n this._closing = null;\n if (this._recordingStream) endRecording(this._recordingStream);\n this._recordingStream = null;\n }\n }\n }\n\n // --- Internal ---\n\n private _assembleBlob(chunks: Blob[], mimeType: string, duration: number): void {\n // the chunks carry the type when the recorder resolved none\n const type = mimeType || chunks[0]?.type || \"\";\n const blob = new Blob(chunks, type ? { type } : undefined);\n // The PREVIOUS clip's object URL is revoked here, before minting the new one — so\n // any consumer still pointing a `<video src>` at the old URL will break once a new\n // recording completes. Consumers must follow the latest `objectURL`/`recorded`\n // value and not pin a stale URL. (The `blob` is unaffected — prefer flowing it.)\n this._revokeUrl();\n const objectURL = this._createUrl(blob);\n this._blob = blob;\n this._objectURL = objectURL;\n const detail: WcsRecordedDetail = {\n blob,\n objectURL,\n mimeType: type,\n duration,\n };\n this._dispatch(\"wcs-recorder:recorded\", detail);\n }\n\n private _revokeUrl(): void {\n if (this._objectURL && typeof URL !== \"undefined\" && typeof URL.revokeObjectURL === \"function\") {\n URL.revokeObjectURL(this._objectURL);\n }\n this._objectURL = null;\n }\n\n private _createUrl(blob: Blob): string {\n if (typeof URL !== \"undefined\" && typeof URL.createObjectURL === \"function\") {\n return URL.createObjectURL(blob);\n }\n return \"\";\n }\n\n // Only called after hasMediaRecorder() has confirmed the API, so MediaRecorder\n // and its isTypeSupported are present.\n private _isTypeSupported(type: string): boolean {\n const MR = (globalThis as { MediaRecorder: { isTypeSupported(t: string): boolean } }).MediaRecorder;\n return MR.isTypeSupported(type);\n }\n\n // performance.now() is universally available wherever MediaRecorder runs\n // (browsers and the happy-dom test env), so no fallback guard is needed.\n private _now(): number {\n return performance.now();\n }\n\n private _elapsed(): number {\n return Math.max(0, Math.round(this._now() - this._startTime));\n }\n}\n","import {\n IWcBindable, RecorderOptions, WcsMediaErrorDetail,\n} from \"../types.js\";\nimport { RecorderCore } from \"../core/RecorderCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-recorder>` — declarative media recording. Wraps RecorderCore and records a\n * borrowed `MediaStream` received via the `attachStream` command (the direct\n * channel from `<wcs-camera>`'s `stream-ready`). It never owns or stops the stream.\n *\n * Recording parameters (`mime-type` / `timeslice` / bitrates) are mirrored\n * attributes. The assembled clip is published as `wcs-recorder:recorded`\n * (`{ blob, objectURL, mimeType, duration }`) and the `blob` / `objectURL` value\n * properties — a settled `Blob` is a value and may flow through state.\n */\nexport class WcsRecorder extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...RecorderCore.wcBindable,\n // `mimeType` deliberately appears on TWO surfaces: as an output `property`\n // (inherited from RecorderCore — the browser-resolved recording type, event\n // `mimetype-changed`) and as an `input` (the `mime-type` request attribute). They\n // share a base name but are distinct directions: the property is read-only output\n // (getter → Core), the input is the write-only request (setter → attribute, read\n // back in _options()). See README \"request vs. resolved\".\n inputs: [\n { name: \"mimeType\", attribute: \"mime-type\" },\n { name: \"timeslice\", attribute: \"timeslice\" },\n { name: \"audioBitsPerSecond\", attribute: \"audio-bits\" },\n { name: \"videoBitsPerSecond\", attribute: \"video-bits\" },\n ],\n commands: RecorderCore.wcBindable.commands,\n };\n\n private _core: RecorderCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new RecorderCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-recorder:recording-changed\": (d) => ({ recording: d === true }),\n \"wcs-recorder:paused-changed\": (d) => ({ paused: d === true }),\n \"wcs-recorder:error\": (d) => ({ error: d != null }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (docs/custom-state-reflection-design.md §3.4): attachInternals is\n // absent in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here). Either\n // case silently disables reflection — the component still works, it just doesn't\n // 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 // 式文の三項演算子は ESLint no-unused-expressions に抵触するため if/else。\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n\n // `mimeType` is an OUTPUT value property (the Core-resolved recording type,\n // published via `wcs-recorder:mimetype-changed`), so the getter delegates to the\n // Core — NOT the `mime-type` input attribute. The attribute is a *request*: the\n // browser may pick a different type, or fill one in when none was requested, and\n // bindings must read the actual value. The input side is read straight from the\n // attribute in `_options()`. The setter still writes the request attribute.\n //\n // The setters never let setAttribute stringify null / undefined (a \"undefined\"\n // mime-type would be requested from MediaRecorder): `null` removes the\n // attribute (no request — the browser's default), `undefined` restores the\n // attribute the element started with (wc-bindable producer guidance P1;\n // React 19 and a direct assignment deliver it, @wcstack/state does not).\n get mimeType(): string { return this._core.mimeType; }\n set mimeType(value: string | null | undefined) { reflectAttribute(this, \"mime-type\", value); }\n\n get timeslice(): number { return this._numberAttr(\"timeslice\"); }\n set timeslice(value: number | null | undefined) { reflectAttribute(this, \"timeslice\", value); }\n\n get audioBitsPerSecond(): number { return this._numberAttr(\"audio-bits\"); }\n set audioBitsPerSecond(value: number | null | undefined) { reflectAttribute(this, \"audio-bits\", value); }\n\n get videoBitsPerSecond(): number { return this._numberAttr(\"video-bits\"); }\n set videoBitsPerSecond(value: number | null | undefined) { reflectAttribute(this, \"video-bits\", value); }\n\n // --- Core delegated getters ---\n\n get recording(): boolean { return this._core.recording; }\n get paused(): boolean { return this._core.paused; }\n get duration(): number { return this._core.duration; }\n get blob(): Blob | null { return this._core.blob; }\n get objectURL(): string | null { return this._core.objectURL; }\n get error(): WcsMediaErrorDetail | null { return this._core.error; }\n /** The last failure's serializable `WcsIoErrorInfo` (Phase 6 taxonomy), or null. */\n get errorInfo(): WcsIoErrorInfo | null { return this._core.errorInfo; }\n\n // --- Commands ---\n\n /** Borrow a stream (the direct-channel sink). */\n attachStream(stream: MediaStream): void {\n this._core.attachStream(stream);\n }\n\n start(): void {\n this._core.start(this._options());\n }\n\n stop(): void { this._core.stop(); }\n pause(): void { this._core.pause(); }\n resume(): void { this._core.resume(); }\n\n // --- Internal ---\n\n private _numberAttr(name: string): number {\n const attr = this.getAttribute(name);\n if (attr === null || attr.trim() === \"\") return NaN;\n const parsed = Number(attr);\n return Number.isFinite(parsed) ? parsed : NaN;\n }\n\n private _options(): RecorderOptions {\n const o: RecorderOptions = {};\n // Read the requested type from the input attribute directly — `get mimeType()` is\n // the resolved OUTPUT value, not the request.\n const requested = this.getAttribute(\"mime-type\") ?? \"\";\n if (requested) o.mimeType = requested;\n if (Number.isFinite(this.timeslice)) o.timeslice = this.timeslice;\n if (Number.isFinite(this.audioBitsPerSecond)) o.audioBitsPerSecond = this.audioBitsPerSecond;\n if (Number.isFinite(this.videoBitsPerSecond)) o.videoBitsPerSecond = this.videoBitsPerSecond;\n return o;\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the\n * page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined\n * by another copy of the package — not its class, not a subclass of it, not the same version — warns\n * `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry\n * `\"<package>@<version>\"` under `Symbol.for(\"wcstack.package\")`; a class without it is named\n * \"another copy of <package> that does not name its version\" (an older copy, or one loaded through\n * an entry that does not stamp).\n */\n\n/** The static a class defined through this helper carries: `\"@wcstack/fetch@<version>\"`. */\nexport const PACKAGE_STAMP: unique symbol = Symbol.for(\"wcstack.package\");\n\ntype Stamped = { [PACKAGE_STAMP]?: string };\n\n/** The registries this copy warned about: one warning per package per registry. */\nconst warned = new WeakSet<CustomElementRegistry>();\n\n/**\n * Marks `cls` as defined by `pkg` (`\"@wcstack/fetch@<version>\"`). A subclass inherits the mark, and\n * `defineProperty` writes it even where a parent's mark is read-only.\n */\nexport function stampPackage(cls: CustomElementConstructor, pkg: string): void {\n Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });\n}\n\n/**\n * Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`\n * is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and\n * carries another version or none. Once per registry.\n */\nexport function warnIfAnotherCopy(\n registry: CustomElementRegistry,\n tag: string,\n existing: CustomElementConstructor,\n own: CustomElementConstructor | undefined,\n pkg: string,\n): void {\n if (own !== undefined && (existing === own || existing.prototype instanceof own)) return;\n const theirs = (existing as Stamped)[PACKAGE_STAMP];\n if (theirs === pkg || warned.has(registry)) return;\n warned.add(registry);\n const name = pkg.slice(0, pkg.lastIndexOf(\"@\"));\n console.warn(\n `[${name}] [wcs/package-twice] <${tag}> is already defined by ` +\n `${theirs ?? `another copy of ${name} that does not name its version`}; ` +\n `this copy, ${pkg}, does nothing. Load each package once.`,\n );\n}\n\n/**\n * Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class\n * with `pkg` (`\"@wcstack/fetch@<version>\"`). A tag another copy of the package defined first is left\n * as it is, with the warning above.\n */\nexport function defineElements(\n registry: CustomElementRegistry,\n pkg: string,\n definitions: readonly (readonly [tag: string, cls: CustomElementConstructor])[],\n): void {\n for (const [tag, cls] of definitions) {\n const existing = registry.get(tag);\n if (existing === undefined) {\n stampPackage(cls, pkg);\n registry.define(tag, cls);\n } else {\n warnIfAnotherCopy(registry, tag, existing, cls, pkg);\n }\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\nimport { WcsCamera } from \"./components/Camera.js\";\nimport { WcsRecorder } from \"./components/Recorder.js\";\nimport { config } from \"./config.js\";\nimport { defineElements } from \"./protocol/defineElement.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n defineElements(registry, `${pkg.name}@${pkg.version}`, [\n [config.tagNames.camera, WcsCamera],\n [config.tagNames.recorder, WcsRecorder],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapCamera(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":[],"mappings":"AASA,MAAM,OAAO,GAAoB;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,MAAM,EAAE,YAAY;AACpB,QAAA,QAAQ,EAAE,cAAc;AACzB,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IAC/D;AACA,IAAA,OAAO,KAAU;AACnB;AAEA,IAAI,YAAY,GAAmB,IAAI;AAEvC;AACA;AACA;AACO,MAAM,MAAM,GAAY,OAAkB;SAEjC,SAAS,GAAA;I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