@wcstack/permission 4.22.0 → 4.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/auto.min.js CHANGED
@@ -1,2 +1,2 @@
1
- const e={tagNames:{permission:"wcs-permission"}};var t="@wcstack/permission",s="4.22.0";const n=new Set(["camera","microphone","geolocation","midi","clipboard-read","clipboard-write","screen-wake-lock","idle-detection","accelerometer","gyroscope","magnetometer","ambient-light-sensor","display-capture"]);class i extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"state",event:"wcs-permission:change",semantics:"state"},{name:"granted",event:"wcs-permission:change",semantics:"state",getter:e=>"granted"===e.detail},{name:"denied",event:"wcs-permission:change",semantics:"state",getter:e=>"denied"===e.detail},{name:"prompt",event:"wcs-permission:change",semantics:"state",getter:e=>"prompt"===e.detail},{name:"unsupported",event:"wcs-permission:change",semantics:"state",getter:e=>"unsupported"===e.detail}],commands:[]};_target;_descriptor=null;_state="prompt";_permissionStatus=null;_permissionSubscribed=!1;_permGen=0;_ready=Promise.resolve();constructor(e,t){super(),this._target=t??this,e&&(this._descriptor=e,this._ready=this._initPermission())}get state(){return this._state}get granted(){return"granted"===this._state}get denied(){return"denied"===this._state}get prompt(){return"prompt"===this._state}get unsupported(){return"unsupported"===this._state}get ready(){return this._ready}_setState(e){this._state!==e&&(this._state=e,this._target.dispatchEvent(new CustomEvent("wcs-permission:change",{detail:e,bubbles:!0})))}observe(e){return this._descriptor=e,this._permissionSubscribed||(this._ready=this._initPermission()),this._ready}dispose(){this._permissionSubscribed=!1,this._permGen++,this._permissionStatus&&(this._permissionStatus.removeEventListener("change",this._onPermissionChange),this._permissionStatus=null)}_initPermission(){if(!this._descriptor||!this._descriptor.name)return this._setState("unsupported"),Promise.resolve();if(null!==function(e){const t=globalThis;if(!1===t.isSecureContext)return"insecure-context";if(!n.has(e))return null;const s=t.document?.permissionsPolicy??t.document?.featurePolicy;if(void 0===s||"function"!=typeof s.allowsFeature)return null;try{return s.allowsFeature(e)?null:"policy-blocked"}catch{return null}}(this._descriptor.name))return this._setState("unsupported"),Promise.resolve();if("undefined"==typeof navigator||!navigator.permissions||"function"!=typeof navigator.permissions.query)return this._setState("unsupported"),Promise.resolve();this._permissionSubscribed=!0;const e=++this._permGen;return navigator.permissions.query(this._descriptor).then(t=>{e===this._permGen&&(this._permissionStatus=t,this._setState(t.state),t.addEventListener("change",this._onPermissionChange))},()=>{e===this._permGen&&this._setState("unsupported")})}_onPermissionChange=e=>{const t=e.target;this._setState(t.state)}}function r(e,t){let s=Object.getPrototypeOf(e);for(;null!==s;){const e=Object.getOwnPropertyDescriptor(s,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;s=Object.getPrototypeOf(s)}return!1}const o=new WeakSet;function a(e,t,s){if(o.has(e))return;o.add(e);const n=e.localName??"element";console.warn(`[wcs/input-as-attribute] <${n}> has the attribute ${t}="${s}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,e)}const c=new WeakMap;function u(e,t){let s=c.get(e);return void 0===s&&(s=new Map,c.set(e,s)),s.has(t)||s.set(t,e.getAttribute(t)),s.get(t)}function l(e,t,s){null===s?e.removeAttribute(t):e.setAttribute(t,s)}function d(e,t,s){const n=u(e,t);l(e,t,void 0===s?n:s?"":null)}const h=()=>{};class p extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...i.wcBindable,inputs:[{name:"name",attribute:"name"},{name:"userVisibleOnly",attribute:"user-visible-only"},{name:"sysex",attribute:"sysex"}],commands:[]};_core;_connectedCallbackPromise=Promise.resolve();_observePending=!1;_connectResolve=h;_internals=null;constructor(){super(),this._core=new i(null,this),this._internals=this._initInternals(),this._wireStates({"wcs-permission:change":e=>({granted:"granted"===e,denied:"denied"===e,prompt:"prompt"===e,unsupported:"unsupported"===e})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const e=this.attachInternals();return e.states.add("wcs-probe"),e.states.delete("wcs-probe"),e}catch{return null}}_wireStates(e){if(null===this._internals)return;const t=this._internals.states;for(const[s,n]of Object.entries(e))this.addEventListener(s,e=>{const s=this.hasAttribute("debug-states");for(const[i,r]of Object.entries(n(e.detail))){try{r?t.add(i):t.delete(i)}catch{}s&&this.toggleAttribute(`data-wcs-state-${i}`,r)}})}get name(){return this.getAttribute("name")??""}set name(e){!function(e,t,s){const n=u(e,t);l(e,t,void 0===s?n:null===s?null:String(s))}(this,"name",e)}get userVisibleOnly(){return this.hasAttribute("user-visible-only")}set userVisibleOnly(e){d(this,"user-visible-only",e)}get sysex(){return this.hasAttribute("sysex")}set sysex(e){d(this,"sysex",e)}get state(){return this._core.state}get granted(){return this._core.granted}get denied(){return this._core.denied}get prompt(){return this._core.prompt}get unsupported(){return this._core.unsupported}get connectedCallbackPromise(){return this._connectedCallbackPromise}_descriptor(){const e={name:this.name};return this.userVisibleOnly&&(e.userVisibleOnly=!0),this.sysex&&(e.sysex=!0),e}_scheduleObserve(){this._observePending||(this._observePending=!0,queueMicrotask(()=>{this._observePending=!1;const e=this._connectResolve;this._connectResolve=h,this.isConnected?this._core.observe(this._descriptor()).then(e):e()}))}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,s=t?.inputs;if(void 0===s)return;const n=e.getAttribute;for(const t of s){const s=t.name,i="function"==typeof n?n.call(e,s.toLowerCase()):null;if(null!==i&&i.startsWith("[object ")&&a(e,s,i),!Object.prototype.hasOwnProperty.call(e,s))continue;if(!r(e,s))continue;const o=e,c=o[s];delete o[s],o[s]=c}}(this),this.style.display="none",this._connectedCallbackPromise=new Promise(e=>{this._connectResolve=e}),this._scheduleObserve()}disconnectedCallback(){this._core.dispose(),this._connectResolve(),this._connectResolve=h}}const m=Symbol.for("wcstack.package"),_=new WeakSet;function g(e,t){Object.defineProperty(e,m,{value:t,configurable:!0})}function b(e,t,s,n,i){if(void 0!==n&&(s===n||s.prototype instanceof n))return;const r=s[m];if(r===i||_.has(e))return;_.add(e);const o=i.slice(0,i.lastIndexOf("@"));console.warn(`[${o}] [wcs/package-twice] <${t}> is already defined by ${r??`another copy of ${o} that does not name its version`}; this copy, ${i}, does nothing. Load each package once.`)}function f(n=customElements){!function(e,t,s){for(const[n,i]of s){const s=e.get(n);void 0===s?(g(i,t),e.define(n,i)):b(e,n,s,i,t)}}(n,`${t}@${s}`,[[e.tagNames.permission,p]])}var y;f(y);
1
+ const e={tagNames:{permission:"wcs-permission"}};var t="@wcstack/permission",s="4.24.0";const n=new Set(["camera","microphone","geolocation","midi","clipboard-read","clipboard-write","screen-wake-lock","idle-detection","accelerometer","gyroscope","magnetometer","ambient-light-sensor","display-capture"]);class i extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"state",event:"wcs-permission:change",semantics:"state"},{name:"granted",event:"wcs-permission:change",semantics:"state",getter:e=>"granted"===e.detail},{name:"denied",event:"wcs-permission:change",semantics:"state",getter:e=>"denied"===e.detail},{name:"prompt",event:"wcs-permission:change",semantics:"state",getter:e=>"prompt"===e.detail},{name:"unsupported",event:"wcs-permission:change",semantics:"state",getter:e=>"unsupported"===e.detail}],commands:[]};_target;_descriptor=null;_state="prompt";_permissionStatus=null;_permissionSubscribed=!1;_permGen=0;_ready=Promise.resolve();constructor(e,t){super(),this._target=t??this,e&&(this._descriptor=e,this._ready=this._initPermission())}get state(){return this._state}get granted(){return"granted"===this._state}get denied(){return"denied"===this._state}get prompt(){return"prompt"===this._state}get unsupported(){return"unsupported"===this._state}get ready(){return this._ready}_setState(e){this._state!==e&&(this._state=e,this._target.dispatchEvent(new CustomEvent("wcs-permission:change",{detail:e,bubbles:!0})))}observe(e){return this._descriptor=e,this._permissionSubscribed||(this._ready=this._initPermission()),this._ready}dispose(){this._permissionSubscribed=!1,this._permGen++,this._permissionStatus&&(this._permissionStatus.removeEventListener("change",this._onPermissionChange),this._permissionStatus=null)}_initPermission(){if(!this._descriptor||!this._descriptor.name)return this._setState("unsupported"),Promise.resolve();if(null!==function(e){const t=globalThis;if(!1===t.isSecureContext)return"insecure-context";if(!n.has(e))return null;const s=t.document?.permissionsPolicy??t.document?.featurePolicy;if(void 0===s||"function"!=typeof s.allowsFeature)return null;try{return s.allowsFeature(e)?null:"policy-blocked"}catch{return null}}(this._descriptor.name))return this._setState("unsupported"),Promise.resolve();if("undefined"==typeof navigator||!navigator.permissions||"function"!=typeof navigator.permissions.query)return this._setState("unsupported"),Promise.resolve();this._permissionSubscribed=!0;const e=++this._permGen;return navigator.permissions.query(this._descriptor).then(t=>{e===this._permGen&&(this._permissionStatus=t,this._setState(t.state),t.addEventListener("change",this._onPermissionChange))},()=>{e===this._permGen&&this._setState("unsupported")})}_onPermissionChange=e=>{const t=e.target;this._setState(t.state)}}function r(e,t){let s=Object.getPrototypeOf(e);for(;null!==s;){const e=Object.getOwnPropertyDescriptor(s,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;s=Object.getPrototypeOf(s)}return!1}const o=new WeakSet;function a(e,t,s){if(o.has(e))return;o.add(e);const n=e.localName??"element";console.warn(`[wcs/input-as-attribute] <${n}> has the attribute ${t}="${s}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,e)}const c=new WeakMap;function u(e,t){let s=c.get(e);return void 0===s&&(s=new Map,c.set(e,s)),s.has(t)||s.set(t,e.getAttribute(t)),s.get(t)}function l(e,t,s){null===s?e.removeAttribute(t):e.setAttribute(t,s)}function d(e,t,s){const n=u(e,t);l(e,t,void 0===s?n:s?"":null)}const h=()=>{};class p extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...i.wcBindable,inputs:[{name:"name",attribute:"name"},{name:"userVisibleOnly",attribute:"user-visible-only"},{name:"sysex",attribute:"sysex"}],commands:[]};_core;_connectedCallbackPromise=Promise.resolve();_observePending=!1;_connectResolve=h;_internals=null;constructor(){super(),this._core=new i(null,this),this._internals=this._initInternals(),this._wireStates({"wcs-permission:change":e=>({granted:"granted"===e,denied:"denied"===e,prompt:"prompt"===e,unsupported:"unsupported"===e})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const e=this.attachInternals();return e.states.add("wcs-probe"),e.states.delete("wcs-probe"),e}catch{return null}}_wireStates(e){if(null===this._internals)return;const t=this._internals.states;for(const[s,n]of Object.entries(e))this.addEventListener(s,e=>{const s=this.hasAttribute("debug-states");for(const[i,r]of Object.entries(n(e.detail))){try{r?t.add(i):t.delete(i)}catch{}s&&this.toggleAttribute(`data-wcs-state-${i}`,r)}})}get name(){return this.getAttribute("name")??""}set name(e){!function(e,t,s){const n=u(e,t);l(e,t,void 0===s?n:null===s?null:String(s))}(this,"name",e)}get userVisibleOnly(){return this.hasAttribute("user-visible-only")}set userVisibleOnly(e){d(this,"user-visible-only",e)}get sysex(){return this.hasAttribute("sysex")}set sysex(e){d(this,"sysex",e)}get state(){return this._core.state}get granted(){return this._core.granted}get denied(){return this._core.denied}get prompt(){return this._core.prompt}get unsupported(){return this._core.unsupported}get connectedCallbackPromise(){return this._connectedCallbackPromise}_descriptor(){const e={name:this.name};return this.userVisibleOnly&&(e.userVisibleOnly=!0),this.sysex&&(e.sysex=!0),e}_scheduleObserve(){this._observePending||(this._observePending=!0,queueMicrotask(()=>{this._observePending=!1;const e=this._connectResolve;this._connectResolve=h,this.isConnected?this._core.observe(this._descriptor()).then(e):e()}))}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,s=t?.inputs;if(void 0===s)return;const n=e.getAttribute;for(const t of s){const s=t.name,i="function"==typeof n?n.call(e,s.toLowerCase()):null;if(null!==i&&i.startsWith("[object ")&&a(e,s,i),!Object.prototype.hasOwnProperty.call(e,s))continue;if(!r(e,s))continue;const o=e,c=o[s];delete o[s],o[s]=c}}(this),this.style.display="none",this._connectedCallbackPromise=new Promise(e=>{this._connectResolve=e}),this._scheduleObserve()}connectedMoveCallback(){}disconnectedCallback(){this._core.dispose(),this._connectResolve(),this._connectResolve=h}}const m=Symbol.for("wcstack.package"),_=new WeakSet;function g(e,t){Object.defineProperty(e,m,{value:t,configurable:!0})}function b(e,t,s,n,i){if(void 0!==n&&(s===n||s.prototype instanceof n))return;const r=s[m];if(r===i||_.has(e))return;_.add(e);const o=i.slice(0,i.lastIndexOf("@"));console.warn(`[${o}] [wcs/package-twice] <${t}> is already defined by ${r??`another copy of ${o} that does not name its version`}; this copy, ${i}, does nothing. Load each package once.`)}function f(n=customElements){!function(e,t,s){for(const[n,i]of s){const s=e.get(n);void 0===s?(g(i,t),e.define(n,i)):b(e,n,s,i,t)}}(n,`${t}@${s}`,[[e.tagNames.permission,p]])}var y;f(y);
2
2
  //# sourceMappingURL=auto.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auto.min.js","sources":["../../src/config.ts","../../src/core/platformCapability.ts","../../src/core/PermissionCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Permission.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapPermission.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n permission: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n permission: \"wcs-permission\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapPermission` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/permission] bootstrapPermission: \"${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 {\n IWcBindable, PermissionStateOrUnsupported, WcsPermissionDescriptor,\n} from \"../types.js\";\nimport { featureUnavailable } from \"./platformCapability.js\";\n\n/**\n * Headless permission-state primitive. A thin, framework-agnostic wrapper around\n * the Permissions API exposed through the wc-bindable protocol.\n *\n * Unlike the other @wcstack IO nodes (geolocation / clipboard / sse / …), the\n * Permissions API is **read-only**: it has `query()` but no standard `request()`.\n * Asking the user for a grant is the job of the feature node (`<wcs-geo>` etc.);\n * this node only *observes*. It is therefore a pure element → state monitor with\n * **no commands** — command-token does not apply, only event-token.\n *\n * The single observable is `state` (`navigator.permissions.query(descriptor)`'s\n * `PermissionState`, or `\"unsupported\"`), published via the `wcs-permission:change`\n * event. `granted` / `denied` / `prompt` / `unsupported` are convenience booleans\n * derived from that one event (mirroring how GeolocationCore exposes latitude/…\n * from one `wcs-geo:position` event), so a binding like `hidden@granted` works\n * directly. The live `change` event of the PermissionStatus is tracked so a grant\n * flipping in browser settings flows into the declarative state.\n */\nexport class PermissionCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"state\", event: \"wcs-permission:change\", semantics: \"state\" },\n { name: \"granted\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"granted\" },\n { name: \"denied\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"denied\" },\n { name: \"prompt\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"prompt\" },\n { name: \"unsupported\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"unsupported\" },\n ],\n // No commands: the Permissions API is read-only (query-only). See class docs.\n commands: [],\n };\n\n private _target: EventTarget;\n private _descriptor: WcsPermissionDescriptor | null = null;\n\n private _state: PermissionStateOrUnsupported = \"prompt\";\n\n // Live PermissionStatus handle (when the Permissions API is available), kept so\n // the `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards observe() so a reconnect after dispose() re-queries\n // while a redundant observe() on an already-live subscription does not.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query. Bumped by every _initPermission()\n // and by dispose(). Each in-flight query captures its id and, on resolve, bails\n // unless it is still current — so a query superseded by a rapid (synchronous)\n // disconnect→reconnect, or one that resolves after dispose(), never attaches a\n // listener. A plain boolean cannot cover this: dispose()→observe() flips it\n // false→true again, reopening the window for the stale query to slip through.\n private _permGen: number = 0;\n\n // Resolves once the most recent query settles (or immediately when the API is\n // unsupported). The Shell exposes this as connectedCallbackPromise so SSR can\n // await the first probe before snapshotting the HTML.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(descriptor?: WcsPermissionDescriptor | null, target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Headless ergonomics: when a descriptor is supplied up front, probe the\n // permission state immediately so observers see the real value before the\n // first read. The Shell passes nothing and drives the first query from\n // connectedCallback via observe(), once the element's attributes resolve.\n if (descriptor) {\n this._descriptor = descriptor;\n this._ready = this._initPermission();\n }\n }\n\n get state(): PermissionStateOrUnsupported {\n return this._state;\n }\n\n get granted(): boolean {\n return this._state === \"granted\";\n }\n\n get denied(): boolean {\n return this._state === \"denied\";\n }\n\n get prompt(): boolean {\n return this._state === \"prompt\";\n }\n\n get unsupported(): boolean {\n return this._state === \"unsupported\";\n }\n\n /** Resolves once the current (or initial) query settles. */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setter with event dispatch ---\n\n private _setState(state: PermissionStateOrUnsupported): void {\n // Same-value guard: `state` is the only stored value and the derived booleans\n // change in lockstep with it, so suppressing identical re-dispatches is safe.\n if (this._state === state) return;\n this._state = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-permission:change\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing `descriptor` (e.g. `{ name: \"geolocation\" }`). Idempotent\n * while already subscribed — calling it again only updates the stored descriptor\n * for a *future* re-subscription; it does **not** re-query, even when called with\n * a different descriptor (the Shell binds at a fixed connect-time descriptor and\n * does not re-query on a `name` change in v1). To switch permission mid-life,\n * dispose() first, then observe() the new descriptor. On the first call, or after\n * a dispose(), it issues the query and subscribes to the live `change` event.\n * Returns a promise that resolves once that query settles, for SSR.\n */\n observe(descriptor: WcsPermissionDescriptor): Promise<void> {\n this._descriptor = descriptor;\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n }\n return this._ready;\n }\n\n /**\n * Detach the live permission `change` listener. Call from the Shell's\n * `disconnectedCallback` so a removed element does not leak the subscription.\n * A later reconnect can re-subscribe via observe().\n *\n * Headless callers (using PermissionCore directly, without the Shell) own this\n * lifecycle themselves: call dispose() when the observer is no longer needed,\n * otherwise the live PermissionStatus `change` listener keeps this instance\n * reachable for as long as the status is alive. dispose() is safe to call when\n * never subscribed and may be paired with a later observe() to resume.\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight query so its .then() bails instead of attaching a\n // listener after teardown.\n this._permGen++;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n }\n\n // --- Internal ---\n\n private _initPermission(): Promise<void> {\n // Guard a missing/empty permission name (e.g. a `<wcs-permission>` with no\n // `name` attribute). Such a descriptor would only ever reject at query() and\n // silently fall back to \"unsupported\", which is hard to diagnose. Short-circuit\n // to \"unsupported\" without issuing a doomed query so the misconfiguration\n // surfaces deterministically and no listener is attached.\n if (!this._descriptor || !this._descriptor.name) {\n this._setState(\"unsupported\");\n return Promise.resolve();\n }\n // A feature this page cannot use — not a secure context, or turned off by a\n // Permissions-Policy (a header, an <iframe> without `allow`) — is \"unsupported\",\n // as it is for the element that would acquire it. The Permissions API does not\n // tell: Chromium answers \"granted\" in a policy-blocked frame and \"denied\" on an\n // insecure origin, the same as a user's refusal, which the site settings would\n // fix and these cannot. Neither changes while the page lives, so nothing is\n // subscribed.\n if (featureUnavailable(this._descriptor.name) !== null) {\n this._setState(\"unsupported\");\n return Promise.resolve();\n }\n // The Permissions API is optional. When absent (or it rejects, e.g. the\n // browser does not accept the requested permission name), report \"unsupported\"\n // and leave it at that — there is nothing to retry.\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n // Route through _setState (not a bare assignment) so observers stay in sync\n // with the public state. The same-value guard means no redundant dispatch\n // when the state does not actually change.\n this._setState(\"unsupported\");\n // Intentionally does NOT set _permissionSubscribed: there is no listener to\n // tear down, so a reconnect simply re-probes (idempotent — the same-value\n // guard suppresses any dispatch and no listener is ever attached). Mirrors\n // GeolocationCore's reinitPermission behavior in unsupported environments.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n // Cast: WcsPermissionDescriptor widens `name` to string (and allows extra\n // descriptor members like userVisibleOnly / sysex) where the lib DOM type\n // expects the PermissionName union.\n return navigator.permissions.query(this._descriptor as unknown as PermissionDescriptor).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the current\n // subscription attaches a listener.\n if (gen !== this._permGen) return;\n this._permissionStatus = status;\n this._setState(status.state as PermissionStateOrUnsupported);\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._permGen) return;\n this._setState(\"unsupported\");\n },\n );\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setState(status.state as PermissionStateOrUnsupported);\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 { IWcBindable, PermissionStateOrUnsupported, WcsPermissionDescriptor } from \"../types.js\";\nimport { PermissionCore } from \"../core/PermissionCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\n// 張られた deferred が無いときの _connectResolve(呼んでも何もしない)\nconst nothingArmed = (): void => { /* nothing armed */ };\n\n// Named WcsPermission (not `Permission`) so the class does not shadow any global,\n// and to match the <wcs-geo> / <wcs-ws> convention (WcsGeolocation /\n// WcsWebSocket). The public export keeps the `WcsPermission` name unchanged.\nexport class WcsPermission extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...PermissionCore.wcBindable,\n // Shell-level settable surface. `name` is the permission name; the descriptor\n // extras `user-visible-only` (push) and `sysex` (midi) are boolean flags that\n // reflect idempotently, so a binding system that writes through\n // inputs[].attribute is safe.\n inputs: [\n { name: \"name\", attribute: \"name\" },\n { name: \"userVisibleOnly\", attribute: \"user-visible-only\" },\n { name: \"sysex\", attribute: \"sysex\" },\n ],\n // No commands: read-only monitor (see PermissionCore). The Permissions API has\n // no request() — acquiring a grant is the feature node's job.\n commands: [],\n };\n\n // Created in the Shell constructor with no descriptor so the delegated getters\n // work before connect (returning the default \"prompt\" / false). The actual\n // query is driven from connectedCallback once the element's attributes resolve\n // (programmatically-created elements have no attributes at construction time).\n private _core: PermissionCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n // _scheduleObserve のマイクロタスクが待っている間 true\n private _observePending = false;\n // connectedCallback で張った connectedCallbackPromise を解決する関数。\n // マイクロタスク(の query の決着)か disconnectedCallback が解決する\n private _connectResolve: () => void = nothingArmed;\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new PermissionCore(null, this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-permission:change\": (d) => ({\n granted: d === \"granted\",\n denied: d === \"denied\",\n prompt: d === \"prompt\",\n unsupported: d === \"unsupported\",\n }),\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 (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n // Input setters never let setAttribute stringify null / undefined (an\n // \"undefined\" name would query a permission called \"undefined\"): `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 name(): string {\n return this.getAttribute(\"name\") ?? \"\";\n }\n\n set name(value: string | null | undefined) {\n reflectAttribute(this, \"name\", value);\n }\n\n get userVisibleOnly(): boolean {\n return this.hasAttribute(\"user-visible-only\");\n }\n\n set userVisibleOnly(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"user-visible-only\", value);\n }\n\n get sysex(): boolean {\n return this.hasAttribute(\"sysex\");\n }\n\n set sysex(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"sysex\", value);\n }\n\n // --- Core delegated getters ---\n\n get state(): PermissionStateOrUnsupported {\n return this._core.state;\n }\n\n get granted(): boolean {\n return this._core.granted;\n }\n\n get denied(): boolean {\n return this._core.denied;\n }\n\n get prompt(): boolean {\n return this._core.prompt;\n }\n\n get unsupported(): boolean {\n return this._core.unsupported;\n }\n\n // wc-bindable connectedCallbackPromise protocol: resolves once the connect-time\n // query settles, so SSR (@wcstack/server render.ts) waits for the first probe\n // before snapshotting the HTML. Mirrors WcsGeolocation.connectedCallbackPromise.\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Internal ---\n\n // Build the query descriptor from the current attributes. Only present extras\n // are included so a bare `{ name }` is passed for permissions that take no\n // additional members. The descriptor is fixed at connect time (v1 does not\n // re-query on a `name` change — see README).\n private _descriptor(): WcsPermissionDescriptor {\n const descriptor: WcsPermissionDescriptor = { name: this.name };\n if (this.userVisibleOnly) descriptor.userVisibleOnly = true;\n if (this.sysex) descriptor.sysex = true;\n return descriptor;\n }\n\n // 何を query するか(name / user-visible-only / sysex)はマイクロタスクで、そのときの\n // 入力で 1 回だけ決める(timing-and-firing-contract §23)。router は遷移で同じノードを\n // 入れ直し、新しいルートの params から state が name を書くのはマイクロタスク — その場で\n // query すると、前の name の state を公開し、その購読に留まっていた(docs/seam-apps.md、\n // shift-desk)。その時点で外れていれば何もしない。\n private _scheduleObserve(): void {\n if (this._observePending) return;\n this._observePending = true;\n queueMicrotask(() => {\n this._observePending = false;\n const resolveConnect = this._connectResolve;\n this._connectResolve = nothingArmed;\n if (!this.isConnected) {\n resolveConnect();\n return;\n }\n // Begin observing (or revive the subscription after a reconnect). query()\n // never rejects in a way that escapes — failures surface as the\n // `unsupported` state — so no .catch() is needed.\n void this._core.observe(this._descriptor()).then(resolveConnect);\n });\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 // connectedCallbackPromise (SSR) resolves once the connect-time query settles.\n // The query itself is decided in a microtask (_scheduleObserve), so arm a\n // deferred here; the microtask resolves it on every path, and so does\n // disconnectedCallback, so awaiting it never hangs.\n this._connectedCallbackPromise = new Promise<void>((resolve) => {\n this._connectResolve = resolve;\n });\n this._scheduleObserve();\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n // 同じタスクの remove() → append() では 2 回目の connectedCallback が\n // _connectResolve を上書きし、1 回目の deferred を待つ側が残される。外れた時点で\n // 接続時の初期化は意味を失うので、ここで解決する(Fetch.ts と同じ)。\n this._connectResolve();\n this._connectResolve = nothingArmed;\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 { WcsPermission } from \"./components/Permission.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.permission, WcsPermission],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapPermission(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":["config","tagNames","permission","POLICY_CONTROLLED","Set","PermissionCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","commands","_target","_descriptor","_state","_permissionStatus","_permissionSubscribed","_permGen","_ready","Promise","resolve","constructor","descriptor","target","super","this","_initPermission","state","granted","denied","prompt","unsupported","ready","_setState","dispatchEvent","CustomEvent","bubbles","observe","dispose","removeEventListener","_onPermissionChange","feature","g","globalThis","isSecureContext","has","policy","document","permissionsPolicy","featurePolicy","undefined","allowsFeature","featureUnavailable","navigator","permissions","query","gen","then","status","addEventListener","hasAccessorOnPrototype","proto","Object","getPrototypeOf","getOwnPropertyDescriptor","get","set","toldObjectAttribute","WeakSet","warnObjectAttribute","element","value","add","tag","localName","console","warn","initialAttributes","WeakMap","initialAttribute","el","byName","Map","getAttribute","writeAttribute","removeAttribute","setAttribute","reflectBooleanAttribute","initial","nothingArmed","WcsPermission","HTMLElement","wcBindable","inputs","attribute","_core","_connectedCallbackPromise","_observePending","_connectResolve","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","String","reflectAttribute","userVisibleOnly","sysex","connectedCallbackPromise","_scheduleObserve","queueMicrotask","resolveConnect","isConnected","connectedCallback","declaration","input","call","toLowerCase","startsWith","prototype","hasOwnProperty","record","upgradeProperties","style","display","disconnectedCallback","PACKAGE_STAMP","Symbol","for","warned","stampPackage","cls","pkg","defineProperty","configurable","warnIfAnotherCopy","registry","existing","own","theirs","slice","lastIndexOf","registerComponents","customElements","definitions","define","defineElements"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,WAAY,0DCiJh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UU,EAAmBN,EAAkCO,0BDoDnEP,EACAJ,EACAY,GAEA,IAAK,MAAOlF,EAAKqE,KAAQa,EAAa,CACpC,MAAMP,EAAWD,EAASlF,IAAIQ,QACbvB,IAAbkG,GACFP,EAAaC,EAAKC,GAClBI,EAASS,OAAOnF,EAAKqE,IAErBI,EAAkBC,EAAU1E,EAAK2E,EAAUN,EAAKC,EAEpD,CACF,CChEEc,CAAeV,EAAU,GAAGJ,KAAYA,IAAe,CACrD,CAACrJ,EAAOC,SAASC,WAAY8F,IAEjC,CCVM,IAA4DyD,EAIhEM,EAAmBN"}
1
+ {"version":3,"file":"auto.min.js","sources":["../../src/config.ts","../../src/core/platformCapability.ts","../../src/core/PermissionCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Permission.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapPermission.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n permission: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n permission: \"wcs-permission\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapPermission` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/permission] bootstrapPermission: \"${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 {\n IWcBindable, PermissionStateOrUnsupported, WcsPermissionDescriptor,\n} from \"../types.js\";\nimport { featureUnavailable } from \"./platformCapability.js\";\n\n/**\n * Headless permission-state primitive. A thin, framework-agnostic wrapper around\n * the Permissions API exposed through the wc-bindable protocol.\n *\n * Unlike the other @wcstack IO nodes (geolocation / clipboard / sse / …), the\n * Permissions API is **read-only**: it has `query()` but no standard `request()`.\n * Asking the user for a grant is the job of the feature node (`<wcs-geo>` etc.);\n * this node only *observes*. It is therefore a pure element → state monitor with\n * **no commands** — command-token does not apply, only event-token.\n *\n * The single observable is `state` (`navigator.permissions.query(descriptor)`'s\n * `PermissionState`, or `\"unsupported\"`), published via the `wcs-permission:change`\n * event. `granted` / `denied` / `prompt` / `unsupported` are convenience booleans\n * derived from that one event (mirroring how GeolocationCore exposes latitude/…\n * from one `wcs-geo:position` event), so a binding like `hidden@granted` works\n * directly. The live `change` event of the PermissionStatus is tracked so a grant\n * flipping in browser settings flows into the declarative state.\n */\nexport class PermissionCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"state\", event: \"wcs-permission:change\", semantics: \"state\" },\n { name: \"granted\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"granted\" },\n { name: \"denied\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"denied\" },\n { name: \"prompt\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"prompt\" },\n { name: \"unsupported\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"unsupported\" },\n ],\n // No commands: the Permissions API is read-only (query-only). See class docs.\n commands: [],\n };\n\n private _target: EventTarget;\n private _descriptor: WcsPermissionDescriptor | null = null;\n\n private _state: PermissionStateOrUnsupported = \"prompt\";\n\n // Live PermissionStatus handle (when the Permissions API is available), kept so\n // the `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards observe() so a reconnect after dispose() re-queries\n // while a redundant observe() on an already-live subscription does not.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query. Bumped by every _initPermission()\n // and by dispose(). Each in-flight query captures its id and, on resolve, bails\n // unless it is still current — so a query superseded by a rapid (synchronous)\n // disconnect→reconnect, or one that resolves after dispose(), never attaches a\n // listener. A plain boolean cannot cover this: dispose()→observe() flips it\n // false→true again, reopening the window for the stale query to slip through.\n private _permGen: number = 0;\n\n // Resolves once the most recent query settles (or immediately when the API is\n // unsupported). The Shell exposes this as connectedCallbackPromise so SSR can\n // await the first probe before snapshotting the HTML.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(descriptor?: WcsPermissionDescriptor | null, target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Headless ergonomics: when a descriptor is supplied up front, probe the\n // permission state immediately so observers see the real value before the\n // first read. The Shell passes nothing and drives the first query from\n // connectedCallback via observe(), once the element's attributes resolve.\n if (descriptor) {\n this._descriptor = descriptor;\n this._ready = this._initPermission();\n }\n }\n\n get state(): PermissionStateOrUnsupported {\n return this._state;\n }\n\n get granted(): boolean {\n return this._state === \"granted\";\n }\n\n get denied(): boolean {\n return this._state === \"denied\";\n }\n\n get prompt(): boolean {\n return this._state === \"prompt\";\n }\n\n get unsupported(): boolean {\n return this._state === \"unsupported\";\n }\n\n /** Resolves once the current (or initial) query settles. */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setter with event dispatch ---\n\n private _setState(state: PermissionStateOrUnsupported): void {\n // Same-value guard: `state` is the only stored value and the derived booleans\n // change in lockstep with it, so suppressing identical re-dispatches is safe.\n if (this._state === state) return;\n this._state = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-permission:change\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing `descriptor` (e.g. `{ name: \"geolocation\" }`). Idempotent\n * while already subscribed — calling it again only updates the stored descriptor\n * for a *future* re-subscription; it does **not** re-query, even when called with\n * a different descriptor (the Shell binds at a fixed connect-time descriptor and\n * does not re-query on a `name` change in v1). To switch permission mid-life,\n * dispose() first, then observe() the new descriptor. On the first call, or after\n * a dispose(), it issues the query and subscribes to the live `change` event.\n * Returns a promise that resolves once that query settles, for SSR.\n */\n observe(descriptor: WcsPermissionDescriptor): Promise<void> {\n this._descriptor = descriptor;\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n }\n return this._ready;\n }\n\n /**\n * Detach the live permission `change` listener. Call from the Shell's\n * `disconnectedCallback` so a removed element does not leak the subscription.\n * A later reconnect can re-subscribe via observe().\n *\n * Headless callers (using PermissionCore directly, without the Shell) own this\n * lifecycle themselves: call dispose() when the observer is no longer needed,\n * otherwise the live PermissionStatus `change` listener keeps this instance\n * reachable for as long as the status is alive. dispose() is safe to call when\n * never subscribed and may be paired with a later observe() to resume.\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight query so its .then() bails instead of attaching a\n // listener after teardown.\n this._permGen++;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n }\n\n // --- Internal ---\n\n private _initPermission(): Promise<void> {\n // Guard a missing/empty permission name (e.g. a `<wcs-permission>` with no\n // `name` attribute). Such a descriptor would only ever reject at query() and\n // silently fall back to \"unsupported\", which is hard to diagnose. Short-circuit\n // to \"unsupported\" without issuing a doomed query so the misconfiguration\n // surfaces deterministically and no listener is attached.\n if (!this._descriptor || !this._descriptor.name) {\n this._setState(\"unsupported\");\n return Promise.resolve();\n }\n // A feature this page cannot use — not a secure context, or turned off by a\n // Permissions-Policy (a header, an <iframe> without `allow`) — is \"unsupported\",\n // as it is for the element that would acquire it. The Permissions API does not\n // tell: Chromium answers \"granted\" in a policy-blocked frame and \"denied\" on an\n // insecure origin, the same as a user's refusal, which the site settings would\n // fix and these cannot. Neither changes while the page lives, so nothing is\n // subscribed.\n if (featureUnavailable(this._descriptor.name) !== null) {\n this._setState(\"unsupported\");\n return Promise.resolve();\n }\n // The Permissions API is optional. When absent (or it rejects, e.g. the\n // browser does not accept the requested permission name), report \"unsupported\"\n // and leave it at that — there is nothing to retry.\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n // Route through _setState (not a bare assignment) so observers stay in sync\n // with the public state. The same-value guard means no redundant dispatch\n // when the state does not actually change.\n this._setState(\"unsupported\");\n // Intentionally does NOT set _permissionSubscribed: there is no listener to\n // tear down, so a reconnect simply re-probes (idempotent — the same-value\n // guard suppresses any dispatch and no listener is ever attached). Mirrors\n // GeolocationCore's reinitPermission behavior in unsupported environments.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n // Cast: WcsPermissionDescriptor widens `name` to string (and allows extra\n // descriptor members like userVisibleOnly / sysex) where the lib DOM type\n // expects the PermissionName union.\n return navigator.permissions.query(this._descriptor as unknown as PermissionDescriptor).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the current\n // subscription attaches a listener.\n if (gen !== this._permGen) return;\n this._permissionStatus = status;\n this._setState(status.state as PermissionStateOrUnsupported);\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._permGen) return;\n this._setState(\"unsupported\");\n },\n );\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setState(status.state as PermissionStateOrUnsupported);\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 { IWcBindable, PermissionStateOrUnsupported, WcsPermissionDescriptor } from \"../types.js\";\nimport { PermissionCore } from \"../core/PermissionCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\n// 張られた deferred が無いときの _connectResolve(呼んでも何もしない)\nconst nothingArmed = (): void => { /* nothing armed */ };\n\n// Named WcsPermission (not `Permission`) so the class does not shadow any global,\n// and to match the <wcs-geo> / <wcs-ws> convention (WcsGeolocation /\n// WcsWebSocket). The public export keeps the `WcsPermission` name unchanged.\nexport class WcsPermission extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...PermissionCore.wcBindable,\n // Shell-level settable surface. `name` is the permission name; the descriptor\n // extras `user-visible-only` (push) and `sysex` (midi) are boolean flags that\n // reflect idempotently, so a binding system that writes through\n // inputs[].attribute is safe.\n inputs: [\n { name: \"name\", attribute: \"name\" },\n { name: \"userVisibleOnly\", attribute: \"user-visible-only\" },\n { name: \"sysex\", attribute: \"sysex\" },\n ],\n // No commands: read-only monitor (see PermissionCore). The Permissions API has\n // no request() — acquiring a grant is the feature node's job.\n commands: [],\n };\n\n // Created in the Shell constructor with no descriptor so the delegated getters\n // work before connect (returning the default \"prompt\" / false). The actual\n // query is driven from connectedCallback once the element's attributes resolve\n // (programmatically-created elements have no attributes at construction time).\n private _core: PermissionCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n // _scheduleObserve のマイクロタスクが待っている間 true\n private _observePending = false;\n // connectedCallback で張った connectedCallbackPromise を解決する関数。\n // マイクロタスク(の query の決着)か disconnectedCallback が解決する\n private _connectResolve: () => void = nothingArmed;\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new PermissionCore(null, this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-permission:change\": (d) => ({\n granted: d === \"granted\",\n denied: d === \"denied\",\n prompt: d === \"prompt\",\n unsupported: d === \"unsupported\",\n }),\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 (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n // Input setters never let setAttribute stringify null / undefined (an\n // \"undefined\" name would query a permission called \"undefined\"): `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 name(): string {\n return this.getAttribute(\"name\") ?? \"\";\n }\n\n set name(value: string | null | undefined) {\n reflectAttribute(this, \"name\", value);\n }\n\n get userVisibleOnly(): boolean {\n return this.hasAttribute(\"user-visible-only\");\n }\n\n set userVisibleOnly(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"user-visible-only\", value);\n }\n\n get sysex(): boolean {\n return this.hasAttribute(\"sysex\");\n }\n\n set sysex(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"sysex\", value);\n }\n\n // --- Core delegated getters ---\n\n get state(): PermissionStateOrUnsupported {\n return this._core.state;\n }\n\n get granted(): boolean {\n return this._core.granted;\n }\n\n get denied(): boolean {\n return this._core.denied;\n }\n\n get prompt(): boolean {\n return this._core.prompt;\n }\n\n get unsupported(): boolean {\n return this._core.unsupported;\n }\n\n // wc-bindable connectedCallbackPromise protocol: resolves once the connect-time\n // query settles, so SSR (@wcstack/server render.ts) waits for the first probe\n // before snapshotting the HTML. Mirrors WcsGeolocation.connectedCallbackPromise.\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Internal ---\n\n // Build the query descriptor from the current attributes. Only present extras\n // are included so a bare `{ name }` is passed for permissions that take no\n // additional members. The descriptor is fixed at connect time (v1 does not\n // re-query on a `name` change — see README).\n private _descriptor(): WcsPermissionDescriptor {\n const descriptor: WcsPermissionDescriptor = { name: this.name };\n if (this.userVisibleOnly) descriptor.userVisibleOnly = true;\n if (this.sysex) descriptor.sysex = true;\n return descriptor;\n }\n\n // 何を query するか(name / user-visible-only / sysex)はマイクロタスクで、そのときの\n // 入力で 1 回だけ決める(timing-and-firing-contract §23)。router は遷移で同じノードを\n // 入れ直し、新しいルートの params から state が name を書くのはマイクロタスク — その場で\n // query すると、前の name の state を公開し、その購読に留まっていた(docs/seam-apps.md、\n // shift-desk)。その時点で外れていれば何もしない。\n private _scheduleObserve(): void {\n if (this._observePending) return;\n this._observePending = true;\n queueMicrotask(() => {\n this._observePending = false;\n const resolveConnect = this._connectResolve;\n this._connectResolve = nothingArmed;\n if (!this.isConnected) {\n resolveConnect();\n return;\n }\n // Begin observing (or revive the subscription after a reconnect). query()\n // never rejects in a way that escapes — failures surface as the\n // `unsupported` state — so no .catch() is needed.\n void this._core.observe(this._descriptor()).then(resolveConnect);\n });\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 // connectedCallbackPromise (SSR) resolves once the connect-time query settles.\n // The query itself is decided in a microtask (_scheduleObserve), so arm a\n // deferred here; the microtask resolves it on every path, and so does\n // disconnectedCallback, so awaiting it never hangs.\n this._connectedCallbackPromise = new Promise<void>((resolve) => {\n this._connectResolve = resolve;\n });\n this._scheduleObserve();\n }\n\n // moveBefore() で動かされたとき(並べ替えで動くリストの行): この要素のすることは置かれた場所に\n // よらないので、何も止めず、何も始め直さない。connectedMoveCallback が無いと、ブラウザは代わりに\n // disconnectedCallback と connectedCallback を呼ぶ(docs/timing-and-firing-contract.md §25)\n connectedMoveCallback(): void {}\n\n disconnectedCallback(): void {\n this._core.dispose();\n // 同じタスクの remove() → append() では 2 回目の connectedCallback が\n // _connectResolve を上書きし、1 回目の deferred を待つ側が残される。外れた時点で\n // 接続時の初期化は意味を失うので、ここで解決する(Fetch.ts と同じ)。\n this._connectResolve();\n this._connectResolve = nothingArmed;\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 { WcsPermission } from \"./components/Permission.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.permission, WcsPermission],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapPermission(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":["config","tagNames","permission","POLICY_CONTROLLED","Set","PermissionCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","commands","_target","_descriptor","_state","_permissionStatus","_permissionSubscribed","_permGen","_ready","Promise","resolve","constructor","descriptor","target","super","this","_initPermission","state","granted","denied","prompt","unsupported","ready","_setState","dispatchEvent","CustomEvent","bubbles","observe","dispose","removeEventListener","_onPermissionChange","feature","g","globalThis","isSecureContext","has","policy","document","permissionsPolicy","featurePolicy","undefined","allowsFeature","featureUnavailable","navigator","permissions","query","gen","then","status","addEventListener","hasAccessorOnPrototype","proto","Object","getPrototypeOf","getOwnPropertyDescriptor","get","set","toldObjectAttribute","WeakSet","warnObjectAttribute","element","value","add","tag","localName","console","warn","initialAttributes","WeakMap","initialAttribute","el","byName","Map","getAttribute","writeAttribute","removeAttribute","setAttribute","reflectBooleanAttribute","initial","nothingArmed","WcsPermission","HTMLElement","wcBindable","inputs","attribute","_core","_connectedCallbackPromise","_observePending","_connectResolve","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","String","reflectAttribute","userVisibleOnly","sysex","connectedCallbackPromise","_scheduleObserve","queueMicrotask","resolveConnect","isConnected","connectedCallback","declaration","input","call","toLowerCase","startsWith","prototype","hasOwnProperty","record","upgradeProperties","style","display","connectedMoveCallback","disconnectedCallback","PACKAGE_STAMP","Symbol","for","warned","stampPackage","cls","pkg","defineProperty","configurable","warnIfAnotherCopy","registry","existing","own","theirs","slice","lastIndexOf","registerComponents","customElements","definitions","define","defineElements"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,WAAY,0DCiJh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ClB2I,2CAElB,CC5CM,SAAUU,EAAmBN,EAAkCO,0BDoDnEP,EACAJ,EACAY,GAEA,IAAK,MAAOnF,EAAKsE,KAAQa,EAAa,CACpC,MAAMP,EAAWD,EAASnF,IAAIQ,QACbvB,IAAbmG,GACFP,EAAaC,EAAKC,GAClBI,EAASS,OAAOpF,EAAKsE,IAErBI,EAAkBC,EAAU3E,EAAK4E,EAAUN,EAAKC,EAEpD,CACF,CChEEc,CAAeV,EAAU,GAAGJ,KAAYA,IAAe,CACrD,CAACtJ,EAAOC,SAASC,WAAY8F,IAEjC,CCVM,IAA4D0D,EAIhEM,EAAmBN"}
package/dist/index.d.ts CHANGED
@@ -203,6 +203,7 @@ declare class WcsPermission extends HTMLElement {
203
203
  private _descriptor;
204
204
  private _scheduleObserve;
205
205
  connectedCallback(): void;
206
+ connectedMoveCallback(): void;
206
207
  disconnectedCallback(): void;
207
208
  }
208
209
 
package/dist/index.esm.js CHANGED
@@ -58,7 +58,7 @@ function setConfig(partialConfig) {
58
58
  frozenConfig = null;
59
59
  }
60
60
 
61
- var pkg = {"name":"@wcstack/permission","version":"4.22.0"};
61
+ var pkg = {"name":"@wcstack/permission","version":"4.24.0"};
62
62
 
63
63
  // ===========================================================================
64
64
  // AUTO-GENERATED FILE - DO NOT EDIT.
@@ -593,6 +593,10 @@ class WcsPermission extends HTMLElement {
593
593
  });
594
594
  this._scheduleObserve();
595
595
  }
596
+ // moveBefore() で動かされたとき(並べ替えで動くリストの行): この要素のすることは置かれた場所に
597
+ // よらないので、何も止めず、何も始め直さない。connectedMoveCallback が無いと、ブラウザは代わりに
598
+ // disconnectedCallback と connectedCallback を呼ぶ(docs/timing-and-firing-contract.md §25)
599
+ connectedMoveCallback() { }
596
600
  disconnectedCallback() {
597
601
  this._core.dispose();
598
602
  // 同じタスクの remove() → append() では 2 回目の connectedCallback が
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../../src/config.ts","../../src/core/platformCapability.ts","../../src/core/PermissionCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Permission.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapPermission.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n permission: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n permission: \"wcs-permission\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapPermission` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/permission] bootstrapPermission: \"${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 {\n IWcBindable, PermissionStateOrUnsupported, WcsPermissionDescriptor,\n} from \"../types.js\";\nimport { featureUnavailable } from \"./platformCapability.js\";\n\n/**\n * Headless permission-state primitive. A thin, framework-agnostic wrapper around\n * the Permissions API exposed through the wc-bindable protocol.\n *\n * Unlike the other @wcstack IO nodes (geolocation / clipboard / sse / …), the\n * Permissions API is **read-only**: it has `query()` but no standard `request()`.\n * Asking the user for a grant is the job of the feature node (`<wcs-geo>` etc.);\n * this node only *observes*. It is therefore a pure element → state monitor with\n * **no commands** — command-token does not apply, only event-token.\n *\n * The single observable is `state` (`navigator.permissions.query(descriptor)`'s\n * `PermissionState`, or `\"unsupported\"`), published via the `wcs-permission:change`\n * event. `granted` / `denied` / `prompt` / `unsupported` are convenience booleans\n * derived from that one event (mirroring how GeolocationCore exposes latitude/…\n * from one `wcs-geo:position` event), so a binding like `hidden@granted` works\n * directly. The live `change` event of the PermissionStatus is tracked so a grant\n * flipping in browser settings flows into the declarative state.\n */\nexport class PermissionCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"state\", event: \"wcs-permission:change\", semantics: \"state\" },\n { name: \"granted\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"granted\" },\n { name: \"denied\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"denied\" },\n { name: \"prompt\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"prompt\" },\n { name: \"unsupported\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"unsupported\" },\n ],\n // No commands: the Permissions API is read-only (query-only). See class docs.\n commands: [],\n };\n\n private _target: EventTarget;\n private _descriptor: WcsPermissionDescriptor | null = null;\n\n private _state: PermissionStateOrUnsupported = \"prompt\";\n\n // Live PermissionStatus handle (when the Permissions API is available), kept so\n // the `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards observe() so a reconnect after dispose() re-queries\n // while a redundant observe() on an already-live subscription does not.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query. Bumped by every _initPermission()\n // and by dispose(). Each in-flight query captures its id and, on resolve, bails\n // unless it is still current — so a query superseded by a rapid (synchronous)\n // disconnect→reconnect, or one that resolves after dispose(), never attaches a\n // listener. A plain boolean cannot cover this: dispose()→observe() flips it\n // false→true again, reopening the window for the stale query to slip through.\n private _permGen: number = 0;\n\n // Resolves once the most recent query settles (or immediately when the API is\n // unsupported). The Shell exposes this as connectedCallbackPromise so SSR can\n // await the first probe before snapshotting the HTML.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(descriptor?: WcsPermissionDescriptor | null, target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Headless ergonomics: when a descriptor is supplied up front, probe the\n // permission state immediately so observers see the real value before the\n // first read. The Shell passes nothing and drives the first query from\n // connectedCallback via observe(), once the element's attributes resolve.\n if (descriptor) {\n this._descriptor = descriptor;\n this._ready = this._initPermission();\n }\n }\n\n get state(): PermissionStateOrUnsupported {\n return this._state;\n }\n\n get granted(): boolean {\n return this._state === \"granted\";\n }\n\n get denied(): boolean {\n return this._state === \"denied\";\n }\n\n get prompt(): boolean {\n return this._state === \"prompt\";\n }\n\n get unsupported(): boolean {\n return this._state === \"unsupported\";\n }\n\n /** Resolves once the current (or initial) query settles. */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setter with event dispatch ---\n\n private _setState(state: PermissionStateOrUnsupported): void {\n // Same-value guard: `state` is the only stored value and the derived booleans\n // change in lockstep with it, so suppressing identical re-dispatches is safe.\n if (this._state === state) return;\n this._state = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-permission:change\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing `descriptor` (e.g. `{ name: \"geolocation\" }`). Idempotent\n * while already subscribed — calling it again only updates the stored descriptor\n * for a *future* re-subscription; it does **not** re-query, even when called with\n * a different descriptor (the Shell binds at a fixed connect-time descriptor and\n * does not re-query on a `name` change in v1). To switch permission mid-life,\n * dispose() first, then observe() the new descriptor. On the first call, or after\n * a dispose(), it issues the query and subscribes to the live `change` event.\n * Returns a promise that resolves once that query settles, for SSR.\n */\n observe(descriptor: WcsPermissionDescriptor): Promise<void> {\n this._descriptor = descriptor;\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n }\n return this._ready;\n }\n\n /**\n * Detach the live permission `change` listener. Call from the Shell's\n * `disconnectedCallback` so a removed element does not leak the subscription.\n * A later reconnect can re-subscribe via observe().\n *\n * Headless callers (using PermissionCore directly, without the Shell) own this\n * lifecycle themselves: call dispose() when the observer is no longer needed,\n * otherwise the live PermissionStatus `change` listener keeps this instance\n * reachable for as long as the status is alive. dispose() is safe to call when\n * never subscribed and may be paired with a later observe() to resume.\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight query so its .then() bails instead of attaching a\n // listener after teardown.\n this._permGen++;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n }\n\n // --- Internal ---\n\n private _initPermission(): Promise<void> {\n // Guard a missing/empty permission name (e.g. a `<wcs-permission>` with no\n // `name` attribute). Such a descriptor would only ever reject at query() and\n // silently fall back to \"unsupported\", which is hard to diagnose. Short-circuit\n // to \"unsupported\" without issuing a doomed query so the misconfiguration\n // surfaces deterministically and no listener is attached.\n if (!this._descriptor || !this._descriptor.name) {\n this._setState(\"unsupported\");\n return Promise.resolve();\n }\n // A feature this page cannot use — not a secure context, or turned off by a\n // Permissions-Policy (a header, an <iframe> without `allow`) — is \"unsupported\",\n // as it is for the element that would acquire it. The Permissions API does not\n // tell: Chromium answers \"granted\" in a policy-blocked frame and \"denied\" on an\n // insecure origin, the same as a user's refusal, which the site settings would\n // fix and these cannot. Neither changes while the page lives, so nothing is\n // subscribed.\n if (featureUnavailable(this._descriptor.name) !== null) {\n this._setState(\"unsupported\");\n return Promise.resolve();\n }\n // The Permissions API is optional. When absent (or it rejects, e.g. the\n // browser does not accept the requested permission name), report \"unsupported\"\n // and leave it at that — there is nothing to retry.\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n // Route through _setState (not a bare assignment) so observers stay in sync\n // with the public state. The same-value guard means no redundant dispatch\n // when the state does not actually change.\n this._setState(\"unsupported\");\n // Intentionally does NOT set _permissionSubscribed: there is no listener to\n // tear down, so a reconnect simply re-probes (idempotent — the same-value\n // guard suppresses any dispatch and no listener is ever attached). Mirrors\n // GeolocationCore's reinitPermission behavior in unsupported environments.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n // Cast: WcsPermissionDescriptor widens `name` to string (and allows extra\n // descriptor members like userVisibleOnly / sysex) where the lib DOM type\n // expects the PermissionName union.\n return navigator.permissions.query(this._descriptor as unknown as PermissionDescriptor).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the current\n // subscription attaches a listener.\n if (gen !== this._permGen) return;\n this._permissionStatus = status;\n this._setState(status.state as PermissionStateOrUnsupported);\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._permGen) return;\n this._setState(\"unsupported\");\n },\n );\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setState(status.state as PermissionStateOrUnsupported);\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 { IWcBindable, PermissionStateOrUnsupported, WcsPermissionDescriptor } from \"../types.js\";\nimport { PermissionCore } from \"../core/PermissionCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\n// 張られた deferred が無いときの _connectResolve(呼んでも何もしない)\nconst nothingArmed = (): void => { /* nothing armed */ };\n\n// Named WcsPermission (not `Permission`) so the class does not shadow any global,\n// and to match the <wcs-geo> / <wcs-ws> convention (WcsGeolocation /\n// WcsWebSocket). The public export keeps the `WcsPermission` name unchanged.\nexport class WcsPermission extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...PermissionCore.wcBindable,\n // Shell-level settable surface. `name` is the permission name; the descriptor\n // extras `user-visible-only` (push) and `sysex` (midi) are boolean flags that\n // reflect idempotently, so a binding system that writes through\n // inputs[].attribute is safe.\n inputs: [\n { name: \"name\", attribute: \"name\" },\n { name: \"userVisibleOnly\", attribute: \"user-visible-only\" },\n { name: \"sysex\", attribute: \"sysex\" },\n ],\n // No commands: read-only monitor (see PermissionCore). The Permissions API has\n // no request() — acquiring a grant is the feature node's job.\n commands: [],\n };\n\n // Created in the Shell constructor with no descriptor so the delegated getters\n // work before connect (returning the default \"prompt\" / false). The actual\n // query is driven from connectedCallback once the element's attributes resolve\n // (programmatically-created elements have no attributes at construction time).\n private _core: PermissionCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n // _scheduleObserve のマイクロタスクが待っている間 true\n private _observePending = false;\n // connectedCallback で張った connectedCallbackPromise を解決する関数。\n // マイクロタスク(の query の決着)か disconnectedCallback が解決する\n private _connectResolve: () => void = nothingArmed;\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new PermissionCore(null, this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-permission:change\": (d) => ({\n granted: d === \"granted\",\n denied: d === \"denied\",\n prompt: d === \"prompt\",\n unsupported: d === \"unsupported\",\n }),\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 (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n // Input setters never let setAttribute stringify null / undefined (an\n // \"undefined\" name would query a permission called \"undefined\"): `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 name(): string {\n return this.getAttribute(\"name\") ?? \"\";\n }\n\n set name(value: string | null | undefined) {\n reflectAttribute(this, \"name\", value);\n }\n\n get userVisibleOnly(): boolean {\n return this.hasAttribute(\"user-visible-only\");\n }\n\n set userVisibleOnly(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"user-visible-only\", value);\n }\n\n get sysex(): boolean {\n return this.hasAttribute(\"sysex\");\n }\n\n set sysex(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"sysex\", value);\n }\n\n // --- Core delegated getters ---\n\n get state(): PermissionStateOrUnsupported {\n return this._core.state;\n }\n\n get granted(): boolean {\n return this._core.granted;\n }\n\n get denied(): boolean {\n return this._core.denied;\n }\n\n get prompt(): boolean {\n return this._core.prompt;\n }\n\n get unsupported(): boolean {\n return this._core.unsupported;\n }\n\n // wc-bindable connectedCallbackPromise protocol: resolves once the connect-time\n // query settles, so SSR (@wcstack/server render.ts) waits for the first probe\n // before snapshotting the HTML. Mirrors WcsGeolocation.connectedCallbackPromise.\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Internal ---\n\n // Build the query descriptor from the current attributes. Only present extras\n // are included so a bare `{ name }` is passed for permissions that take no\n // additional members. The descriptor is fixed at connect time (v1 does not\n // re-query on a `name` change — see README).\n private _descriptor(): WcsPermissionDescriptor {\n const descriptor: WcsPermissionDescriptor = { name: this.name };\n if (this.userVisibleOnly) descriptor.userVisibleOnly = true;\n if (this.sysex) descriptor.sysex = true;\n return descriptor;\n }\n\n // 何を query するか(name / user-visible-only / sysex)はマイクロタスクで、そのときの\n // 入力で 1 回だけ決める(timing-and-firing-contract §23)。router は遷移で同じノードを\n // 入れ直し、新しいルートの params から state が name を書くのはマイクロタスク — その場で\n // query すると、前の name の state を公開し、その購読に留まっていた(docs/seam-apps.md、\n // shift-desk)。その時点で外れていれば何もしない。\n private _scheduleObserve(): void {\n if (this._observePending) return;\n this._observePending = true;\n queueMicrotask(() => {\n this._observePending = false;\n const resolveConnect = this._connectResolve;\n this._connectResolve = nothingArmed;\n if (!this.isConnected) {\n resolveConnect();\n return;\n }\n // Begin observing (or revive the subscription after a reconnect). query()\n // never rejects in a way that escapes — failures surface as the\n // `unsupported` state — so no .catch() is needed.\n void this._core.observe(this._descriptor()).then(resolveConnect);\n });\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 // connectedCallbackPromise (SSR) resolves once the connect-time query settles.\n // The query itself is decided in a microtask (_scheduleObserve), so arm a\n // deferred here; the microtask resolves it on every path, and so does\n // disconnectedCallback, so awaiting it never hangs.\n this._connectedCallbackPromise = new Promise<void>((resolve) => {\n this._connectResolve = resolve;\n });\n this._scheduleObserve();\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n // 同じタスクの remove() → append() では 2 回目の connectedCallback が\n // _connectResolve を上書きし、1 回目の deferred を待つ側が残される。外れた時点で\n // 接続時の初期化は意味を失うので、ここで解決する(Fetch.ts と同じ)。\n this._connectResolve();\n this._connectResolve = nothingArmed;\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 { WcsPermission } from \"./components/Permission.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.permission, WcsPermission],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapPermission(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":[],"mappings":"AAQA,MAAM,OAAO,GAAoB;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,UAAU,EAAE,gBAAgB;AAC7B,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,O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","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Permission.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapPermission.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n permission: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n permission: \"wcs-permission\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapPermission` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/permission] bootstrapPermission: \"${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 {\n IWcBindable, PermissionStateOrUnsupported, WcsPermissionDescriptor,\n} from \"../types.js\";\nimport { featureUnavailable } from \"./platformCapability.js\";\n\n/**\n * Headless permission-state primitive. A thin, framework-agnostic wrapper around\n * the Permissions API exposed through the wc-bindable protocol.\n *\n * Unlike the other @wcstack IO nodes (geolocation / clipboard / sse / …), the\n * Permissions API is **read-only**: it has `query()` but no standard `request()`.\n * Asking the user for a grant is the job of the feature node (`<wcs-geo>` etc.);\n * this node only *observes*. It is therefore a pure element → state monitor with\n * **no commands** — command-token does not apply, only event-token.\n *\n * The single observable is `state` (`navigator.permissions.query(descriptor)`'s\n * `PermissionState`, or `\"unsupported\"`), published via the `wcs-permission:change`\n * event. `granted` / `denied` / `prompt` / `unsupported` are convenience booleans\n * derived from that one event (mirroring how GeolocationCore exposes latitude/…\n * from one `wcs-geo:position` event), so a binding like `hidden@granted` works\n * directly. The live `change` event of the PermissionStatus is tracked so a grant\n * flipping in browser settings flows into the declarative state.\n */\nexport class PermissionCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"state\", event: \"wcs-permission:change\", semantics: \"state\" },\n { name: \"granted\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"granted\" },\n { name: \"denied\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"denied\" },\n { name: \"prompt\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"prompt\" },\n { name: \"unsupported\", event: \"wcs-permission:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"unsupported\" },\n ],\n // No commands: the Permissions API is read-only (query-only). See class docs.\n commands: [],\n };\n\n private _target: EventTarget;\n private _descriptor: WcsPermissionDescriptor | null = null;\n\n private _state: PermissionStateOrUnsupported = \"prompt\";\n\n // Live PermissionStatus handle (when the Permissions API is available), kept so\n // the `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards observe() so a reconnect after dispose() re-queries\n // while a redundant observe() on an already-live subscription does not.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query. Bumped by every _initPermission()\n // and by dispose(). Each in-flight query captures its id and, on resolve, bails\n // unless it is still current — so a query superseded by a rapid (synchronous)\n // disconnect→reconnect, or one that resolves after dispose(), never attaches a\n // listener. A plain boolean cannot cover this: dispose()→observe() flips it\n // false→true again, reopening the window for the stale query to slip through.\n private _permGen: number = 0;\n\n // Resolves once the most recent query settles (or immediately when the API is\n // unsupported). The Shell exposes this as connectedCallbackPromise so SSR can\n // await the first probe before snapshotting the HTML.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(descriptor?: WcsPermissionDescriptor | null, target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Headless ergonomics: when a descriptor is supplied up front, probe the\n // permission state immediately so observers see the real value before the\n // first read. The Shell passes nothing and drives the first query from\n // connectedCallback via observe(), once the element's attributes resolve.\n if (descriptor) {\n this._descriptor = descriptor;\n this._ready = this._initPermission();\n }\n }\n\n get state(): PermissionStateOrUnsupported {\n return this._state;\n }\n\n get granted(): boolean {\n return this._state === \"granted\";\n }\n\n get denied(): boolean {\n return this._state === \"denied\";\n }\n\n get prompt(): boolean {\n return this._state === \"prompt\";\n }\n\n get unsupported(): boolean {\n return this._state === \"unsupported\";\n }\n\n /** Resolves once the current (or initial) query settles. */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setter with event dispatch ---\n\n private _setState(state: PermissionStateOrUnsupported): void {\n // Same-value guard: `state` is the only stored value and the derived booleans\n // change in lockstep with it, so suppressing identical re-dispatches is safe.\n if (this._state === state) return;\n this._state = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-permission:change\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing `descriptor` (e.g. `{ name: \"geolocation\" }`). Idempotent\n * while already subscribed — calling it again only updates the stored descriptor\n * for a *future* re-subscription; it does **not** re-query, even when called with\n * a different descriptor (the Shell binds at a fixed connect-time descriptor and\n * does not re-query on a `name` change in v1). To switch permission mid-life,\n * dispose() first, then observe() the new descriptor. On the first call, or after\n * a dispose(), it issues the query and subscribes to the live `change` event.\n * Returns a promise that resolves once that query settles, for SSR.\n */\n observe(descriptor: WcsPermissionDescriptor): Promise<void> {\n this._descriptor = descriptor;\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n }\n return this._ready;\n }\n\n /**\n * Detach the live permission `change` listener. Call from the Shell's\n * `disconnectedCallback` so a removed element does not leak the subscription.\n * A later reconnect can re-subscribe via observe().\n *\n * Headless callers (using PermissionCore directly, without the Shell) own this\n * lifecycle themselves: call dispose() when the observer is no longer needed,\n * otherwise the live PermissionStatus `change` listener keeps this instance\n * reachable for as long as the status is alive. dispose() is safe to call when\n * never subscribed and may be paired with a later observe() to resume.\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight query so its .then() bails instead of attaching a\n // listener after teardown.\n this._permGen++;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n }\n\n // --- Internal ---\n\n private _initPermission(): Promise<void> {\n // Guard a missing/empty permission name (e.g. a `<wcs-permission>` with no\n // `name` attribute). Such a descriptor would only ever reject at query() and\n // silently fall back to \"unsupported\", which is hard to diagnose. Short-circuit\n // to \"unsupported\" without issuing a doomed query so the misconfiguration\n // surfaces deterministically and no listener is attached.\n if (!this._descriptor || !this._descriptor.name) {\n this._setState(\"unsupported\");\n return Promise.resolve();\n }\n // A feature this page cannot use — not a secure context, or turned off by a\n // Permissions-Policy (a header, an <iframe> without `allow`) — is \"unsupported\",\n // as it is for the element that would acquire it. The Permissions API does not\n // tell: Chromium answers \"granted\" in a policy-blocked frame and \"denied\" on an\n // insecure origin, the same as a user's refusal, which the site settings would\n // fix and these cannot. Neither changes while the page lives, so nothing is\n // subscribed.\n if (featureUnavailable(this._descriptor.name) !== null) {\n this._setState(\"unsupported\");\n return Promise.resolve();\n }\n // The Permissions API is optional. When absent (or it rejects, e.g. the\n // browser does not accept the requested permission name), report \"unsupported\"\n // and leave it at that — there is nothing to retry.\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n // Route through _setState (not a bare assignment) so observers stay in sync\n // with the public state. The same-value guard means no redundant dispatch\n // when the state does not actually change.\n this._setState(\"unsupported\");\n // Intentionally does NOT set _permissionSubscribed: there is no listener to\n // tear down, so a reconnect simply re-probes (idempotent — the same-value\n // guard suppresses any dispatch and no listener is ever attached). Mirrors\n // GeolocationCore's reinitPermission behavior in unsupported environments.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n // Cast: WcsPermissionDescriptor widens `name` to string (and allows extra\n // descriptor members like userVisibleOnly / sysex) where the lib DOM type\n // expects the PermissionName union.\n return navigator.permissions.query(this._descriptor as unknown as PermissionDescriptor).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the current\n // subscription attaches a listener.\n if (gen !== this._permGen) return;\n this._permissionStatus = status;\n this._setState(status.state as PermissionStateOrUnsupported);\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._permGen) return;\n this._setState(\"unsupported\");\n },\n );\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setState(status.state as PermissionStateOrUnsupported);\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 { IWcBindable, PermissionStateOrUnsupported, WcsPermissionDescriptor } from \"../types.js\";\nimport { PermissionCore } from \"../core/PermissionCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\n// 張られた deferred が無いときの _connectResolve(呼んでも何もしない)\nconst nothingArmed = (): void => { /* nothing armed */ };\n\n// Named WcsPermission (not `Permission`) so the class does not shadow any global,\n// and to match the <wcs-geo> / <wcs-ws> convention (WcsGeolocation /\n// WcsWebSocket). The public export keeps the `WcsPermission` name unchanged.\nexport class WcsPermission extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...PermissionCore.wcBindable,\n // Shell-level settable surface. `name` is the permission name; the descriptor\n // extras `user-visible-only` (push) and `sysex` (midi) are boolean flags that\n // reflect idempotently, so a binding system that writes through\n // inputs[].attribute is safe.\n inputs: [\n { name: \"name\", attribute: \"name\" },\n { name: \"userVisibleOnly\", attribute: \"user-visible-only\" },\n { name: \"sysex\", attribute: \"sysex\" },\n ],\n // No commands: read-only monitor (see PermissionCore). The Permissions API has\n // no request() — acquiring a grant is the feature node's job.\n commands: [],\n };\n\n // Created in the Shell constructor with no descriptor so the delegated getters\n // work before connect (returning the default \"prompt\" / false). The actual\n // query is driven from connectedCallback once the element's attributes resolve\n // (programmatically-created elements have no attributes at construction time).\n private _core: PermissionCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n // _scheduleObserve のマイクロタスクが待っている間 true\n private _observePending = false;\n // connectedCallback で張った connectedCallbackPromise を解決する関数。\n // マイクロタスク(の query の決着)か disconnectedCallback が解決する\n private _connectResolve: () => void = nothingArmed;\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new PermissionCore(null, this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-permission:change\": (d) => ({\n granted: d === \"granted\",\n denied: d === \"denied\",\n prompt: d === \"prompt\",\n unsupported: d === \"unsupported\",\n }),\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 (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n // Input setters never let setAttribute stringify null / undefined (an\n // \"undefined\" name would query a permission called \"undefined\"): `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 name(): string {\n return this.getAttribute(\"name\") ?? \"\";\n }\n\n set name(value: string | null | undefined) {\n reflectAttribute(this, \"name\", value);\n }\n\n get userVisibleOnly(): boolean {\n return this.hasAttribute(\"user-visible-only\");\n }\n\n set userVisibleOnly(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"user-visible-only\", value);\n }\n\n get sysex(): boolean {\n return this.hasAttribute(\"sysex\");\n }\n\n set sysex(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"sysex\", value);\n }\n\n // --- Core delegated getters ---\n\n get state(): PermissionStateOrUnsupported {\n return this._core.state;\n }\n\n get granted(): boolean {\n return this._core.granted;\n }\n\n get denied(): boolean {\n return this._core.denied;\n }\n\n get prompt(): boolean {\n return this._core.prompt;\n }\n\n get unsupported(): boolean {\n return this._core.unsupported;\n }\n\n // wc-bindable connectedCallbackPromise protocol: resolves once the connect-time\n // query settles, so SSR (@wcstack/server render.ts) waits for the first probe\n // before snapshotting the HTML. Mirrors WcsGeolocation.connectedCallbackPromise.\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Internal ---\n\n // Build the query descriptor from the current attributes. Only present extras\n // are included so a bare `{ name }` is passed for permissions that take no\n // additional members. The descriptor is fixed at connect time (v1 does not\n // re-query on a `name` change — see README).\n private _descriptor(): WcsPermissionDescriptor {\n const descriptor: WcsPermissionDescriptor = { name: this.name };\n if (this.userVisibleOnly) descriptor.userVisibleOnly = true;\n if (this.sysex) descriptor.sysex = true;\n return descriptor;\n }\n\n // 何を query するか(name / user-visible-only / sysex)はマイクロタスクで、そのときの\n // 入力で 1 回だけ決める(timing-and-firing-contract §23)。router は遷移で同じノードを\n // 入れ直し、新しいルートの params から state が name を書くのはマイクロタスク — その場で\n // query すると、前の name の state を公開し、その購読に留まっていた(docs/seam-apps.md、\n // shift-desk)。その時点で外れていれば何もしない。\n private _scheduleObserve(): void {\n if (this._observePending) return;\n this._observePending = true;\n queueMicrotask(() => {\n this._observePending = false;\n const resolveConnect = this._connectResolve;\n this._connectResolve = nothingArmed;\n if (!this.isConnected) {\n resolveConnect();\n return;\n }\n // Begin observing (or revive the subscription after a reconnect). query()\n // never rejects in a way that escapes — failures surface as the\n // `unsupported` state — so no .catch() is needed.\n void this._core.observe(this._descriptor()).then(resolveConnect);\n });\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 // connectedCallbackPromise (SSR) resolves once the connect-time query settles.\n // The query itself is decided in a microtask (_scheduleObserve), so arm a\n // deferred here; the microtask resolves it on every path, and so does\n // disconnectedCallback, so awaiting it never hangs.\n this._connectedCallbackPromise = new Promise<void>((resolve) => {\n this._connectResolve = resolve;\n });\n this._scheduleObserve();\n }\n\n // moveBefore() で動かされたとき(並べ替えで動くリストの行): この要素のすることは置かれた場所に\n // よらないので、何も止めず、何も始め直さない。connectedMoveCallback が無いと、ブラウザは代わりに\n // disconnectedCallback と connectedCallback を呼ぶ(docs/timing-and-firing-contract.md §25)\n connectedMoveCallback(): void {}\n\n disconnectedCallback(): void {\n this._core.dispose();\n // 同じタスクの remove() → append() では 2 回目の connectedCallback が\n // _connectResolve を上書きし、1 回目の deferred を待つ側が残される。外れた時点で\n // 接続時の初期化は意味を失うので、ここで解決する(Fetch.ts と同じ)。\n this._connectResolve();\n this._connectResolve = nothingArmed;\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 { WcsPermission } from \"./components/Permission.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.permission, WcsPermission],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapPermission(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":[],"mappings":"AAQA,MAAM,OAAO,GAAoB;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,UAAU,EAAE,gBAAgB;AAC7B,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,MA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,UAA4B,EAAE,QAAgC,EAAA;IAChG,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;IACA,kBAAkB,CAAC,QAAQ,CAAC;AAC9B;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/permission",
3
- "version": "4.22.0",
3
+ "version": "4.24.0",
4
4
  "description": "Declarative permission-state component for Web Components. Framework-agnostic Permissions API monitor via wc-bindable-protocol.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.esm.js",