@wcstack/media-query 4.0.0-rc.7 → 4.0.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +2 -0
- package/README.md +2 -0
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +54 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -112,6 +112,8 @@ CDN(バージョン固定): `https://esm.run/@wcstack/media-query@3.5.4/auto
|
|
|
112
112
|
|
|
113
113
|
`query` は唯一の入力で、`wcBindable.inputs` に `attribute: "query"` で宣言されています。upgrade 前のプロパティ代入は接続時に取り込まれます(property upgrade)。
|
|
114
114
|
|
|
115
|
+
**`null` と `undefined`。** 属性に対応する入力(`query`)は、`null` を「クリア」として扱います。属性を外し、入力は既定値 — クエリなし、「何も監視しない」— に戻ります。`undefined` は「値が無い」で、属性を最初の書き込みの前の状態 — マークアップに書かれた値、無ければ属性なし — に戻します。どちらも文字列 `"null"` / `"undefined"` として書くことはありません(`@wcstack/state` は `undefined` を書きませんが、React 19 は値のあった prop を外したときに書き、直接の代入でも届きます)。接続中はどちらも、属性の変更と同じく購読し直します。
|
|
116
|
+
|
|
115
117
|
## 観測可能プロパティ(出力)
|
|
116
118
|
|
|
117
119
|
| プロパティ | イベント | semantics | 説明 |
|
package/README.md
CHANGED
|
@@ -112,6 +112,8 @@ Every bound state path must be declared up front — binding an undeclared path
|
|
|
112
112
|
|
|
113
113
|
`query` is the only input, declared in `wcBindable.inputs` with `attribute: "query"`. Property assignment before the element is upgraded is picked up on connect (property upgrade).
|
|
114
114
|
|
|
115
|
+
**`null` and `undefined`.** The input backed by an attribute (`query`) takes `null` as "clear": the attribute is removed and the input falls back to its default — no query, "watch nothing". `undefined` means "no value supplied": the attribute goes back to what it was before the first write — the value written in the markup, or none. Neither is ever written as the string `"null"` / `"undefined"`. (`@wcstack/state` never writes `undefined`; React 19 does when a prop that had a value is removed, and so can a direct assignment.) While connected, either one re-subscribes, like any change of the attribute.
|
|
116
|
+
|
|
115
117
|
## Observable Properties (outputs)
|
|
116
118
|
|
|
117
119
|
| Property | Event | Semantics | Description |
|
package/dist/auto.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={tagNames:{mediaQuery:"wcs-media-query"}},t=Object.freeze({matched:!1,media:"",supported:!1}),s=Object.freeze({matched:!1,media:"",supported:!0});class n extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"matched",event:"wcs-media-query:change",semantics:"state",getter:e=>e.detail.matched},{name:"media",event:"wcs-media-query:change",semantics:"state",getter:e=>e.detail.media},{name:"supported",event:"wcs-media-query:change",semantics:"state",getter:e=>e.detail.supported}],commands:[]};_target;_snapshot=t;_query="";_unsubscribe=null;_subscribed=!1;_gen=0;_injectedMatchMedia;_ready=Promise.resolve();constructor(e,t){super(),this._target=e??this,this._injectedMatchMedia=t?.matchMedia??null}get ready(){return this._ready}get query(){return this._query}get matched(){return this._snapshot.matched}get media(){return this._snapshot.media}get supported(){return this._snapshot.supported}observe(e=this._query){return this._subscribed&&e===this._query||(this._teardown(),this._query=e,this._subscribed=!0,this._subscribe(e)),this._ready}dispose(){this._subscribed=!1,this._teardown()}_resolveMatchMedia(){if(null!==this._injectedMatchMedia)return this._injectedMatchMedia;const e=globalThis;return"function"==typeof e.matchMedia?t=>e.matchMedia(t):null}_subscribe(e){const n=++this._gen,i=this._resolveMatchMedia();if(null===i)return void this._apply(t);if(""===e)return void this._apply(s);let r=null;try{r=i(e);const t=()=>{n===this._gen&&this._apply(this._read(r))};this._unsubscribe=function(e,t){if("function"==typeof e.addEventListener&&"function"==typeof e.removeEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);if("function"==typeof e.addListener&&"function"==typeof e.removeListener)return e.addListener(t),()=>e.removeListener(t);return()=>{}}(r,t)}catch{r=null,this._unsubscribe=null}this._apply(null===r?s:this._read(r))}_teardown(){if(this._gen++,null!==this._unsubscribe){const e=this._unsubscribe;this._unsubscribe=null;try{e()}catch{}}}_read(e){return{matched:!0===e.matches,media:"string"==typeof e.media?e.media:"",supported:!0}}_apply(e){const t=this._snapshot;t.matched===e.matched&&t.media===e.media&&t.supported===e.supported||(this._snapshot=e,this._target.dispatchEvent(new CustomEvent("wcs-media-query:change",{detail:e,bubbles:!0})))}}function i(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}
|
|
1
|
+
const e={tagNames:{mediaQuery:"wcs-media-query"}},t=Object.freeze({matched:!1,media:"",supported:!1}),s=Object.freeze({matched:!1,media:"",supported:!0});class n extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"matched",event:"wcs-media-query:change",semantics:"state",getter:e=>e.detail.matched},{name:"media",event:"wcs-media-query:change",semantics:"state",getter:e=>e.detail.media},{name:"supported",event:"wcs-media-query:change",semantics:"state",getter:e=>e.detail.supported}],commands:[]};_target;_snapshot=t;_query="";_unsubscribe=null;_subscribed=!1;_gen=0;_injectedMatchMedia;_ready=Promise.resolve();constructor(e,t){super(),this._target=e??this,this._injectedMatchMedia=t?.matchMedia??null}get ready(){return this._ready}get query(){return this._query}get matched(){return this._snapshot.matched}get media(){return this._snapshot.media}get supported(){return this._snapshot.supported}observe(e=this._query){return this._subscribed&&e===this._query||(this._teardown(),this._query=e,this._subscribed=!0,this._subscribe(e)),this._ready}dispose(){this._subscribed=!1,this._teardown()}_resolveMatchMedia(){if(null!==this._injectedMatchMedia)return this._injectedMatchMedia;const e=globalThis;return"function"==typeof e.matchMedia?t=>e.matchMedia(t):null}_subscribe(e){const n=++this._gen,i=this._resolveMatchMedia();if(null===i)return void this._apply(t);if(""===e)return void this._apply(s);let r=null;try{r=i(e);const t=()=>{n===this._gen&&this._apply(this._read(r))};this._unsubscribe=function(e,t){if("function"==typeof e.addEventListener&&"function"==typeof e.removeEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);if("function"==typeof e.addListener&&"function"==typeof e.removeListener)return e.addListener(t),()=>e.removeListener(t);return()=>{}}(r,t)}catch{r=null,this._unsubscribe=null}this._apply(null===r?s:this._read(r))}_teardown(){if(this._gen++,null!==this._unsubscribe){const e=this._unsubscribe;this._unsubscribe=null;try{e()}catch{}}}_read(e){return{matched:!0===e.matches,media:"string"==typeof e.media?e.media:"",supported:!0}}_apply(e){const t=this._snapshot;t.matched===e.matched&&t.media===e.media&&t.supported===e.supported||(this._snapshot=e,this._target.dispatchEvent(new CustomEvent("wcs-media-query:change",{detail:e,bubbles:!0})))}}function i(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 r=new WeakMap;function a(e,t,s){const n=function(e,t){let s=r.get(e);return void 0===s&&(s=new Map,r.set(e,s)),s.has(t)||s.set(t,e.getAttribute(t)),s.get(t)}(e,t);!function(e,t,s){null===s?e.removeAttribute(t):e.setAttribute(t,s)}(e,t,void 0===s?n:null===s?null:String(s))}class c extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...n.wcBindable,inputs:[{name:"query",attribute:"query"}],commands:n.wcBindable.commands};static get observedAttributes(){return["query"]}_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new n(this),this._internals=this._initInternals(),this._wireStates({"wcs-media-query:change":e=>({matched:!0===e.matched,supported:!0===e.supported})})}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 query(){return this.getAttribute("query")??""}set query(e){a(this,"query",e)}get matched(){return this._core.matched}get media(){return this._core.media}get supported(){return this._core.supported}get connectedCallbackPromise(){return this._connectedCallbackPromise}attributeChangedCallback(e,t,s){"query"===e&&this.isConnected&&this._core.observe(s??"")}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,s=t?.inputs;if(void 0!==s)for(const t of s){const s=t.name;if(!Object.prototype.hasOwnProperty.call(e,s))continue;if(!i(e,s))continue;const n=e,r=n[s];delete n[s],n[s]=r}}(this),this.style.display="none",this._connectedCallbackPromise=this._core.observe(this.query)}disconnectedCallback(){this._core.dispose()}}var o;!function(t=customElements){t.get(e.tagNames.mediaQuery)||t.define(e.tagNames.mediaQuery,c)}(o);
|
|
2
2
|
//# sourceMappingURL=auto.min.js.map
|
package/dist/auto.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto.min.js","sources":["../src/config.ts","../src/core/MediaQueryCore.ts","../src/protocol/upgradeProperties.ts","../src/components/MediaQuery.ts","../src/bootstrapMediaQuery.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n mediaQuery: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n mediaQuery: \"wcs-media-query\",\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: `bootstrapMediaQuery` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/media-query] bootstrapMediaQuery: \"${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","import {\n IWcBindable, WcsMatchMedia, WcsMediaQueryCoreOptions, WcsMediaQueryList, WcsMediaQuerySnapshot,\n} from \"../types.js\";\n\nconst UNSUPPORTED_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: false,\n});\n\n// \"matchMedia exists but there is nothing to watch\": an empty query, or a\n// matchMedia call that threw. Same shape as UNSUPPORTED_SNAPSHOT except that\n// `supported` stays honest about the API being present.\nconst IDLE_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: true,\n});\n\n/**\n * Headless media-query primitive. A thin, framework-agnostic wrapper around\n * `window.matchMedia` exposed through the wc-bindable protocol.\n *\n * `observe(query)` subscribes to one `MediaQueryList` and republishes its\n * `matches` / `media` as `matched` / `media` state; a different query while subscribed tears the\n * old list down and subscribes to the new one. Subscribing is synchronous, but\n * — unlike `@wcstack/network` — this Core does keep a `_gen` generation guard\n * (§3.4): each subscription's `change` listener captures the generation it was\n * created under and bails when it is stale, so a `MediaQueryList` whose\n * `removeEventListener` / `removeListener` misbehaves can never write the old\n * query's `matched` over the new query's (docs/media-query-tag-design.md §6).\n *\n * `matchMedia` is universally available in browsers; `supported === false` is\n * the non-browser case (SSR, workers) rather than a browser quirk.\n */\nexport class MediaQueryCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"matched\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.matched },\n { name: \"media\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.media },\n { name: \"supported\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.supported },\n ],\n // Pure monitor: a MediaQueryList has no action to invoke.\n //\n // `matched`, not `matches`: `Element.prototype.matches(selector)` exists on\n // every element, and a wc-bindable property name is read straight off the\n // Shell — a boolean `matches` would shadow the platform method\n // (docs/media-query-tag-design.md §2.1).\n commands: [],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsMediaQuerySnapshot = UNSUPPORTED_SNAPSHOT;\n\n // The query currently subscribed (or last requested). \"\" means \"nothing to watch\".\n private _query = \"\";\n\n // Detaches the live `change` listener of the current subscription, if any.\n private _unsubscribe: (() => void) | null = null;\n\n // True between observe() and dispose(). Guards observe() so a redundant call\n // with the same query does not re-subscribe; dispose() resets it.\n private _subscribed = false;\n\n // Generation guard (§3.4). Bumped by every (re)subscription and by dispose().\n // A `change` listener captures its generation and ignores the event once a\n // newer subscription exists — see the class docs for why this is kept even\n // though subscribing itself is synchronous.\n private _gen = 0;\n\n // Injected matchMedia (tests / non-window hosts). `null` = resolve\n // `globalThis.matchMedia` at call time (§3.7).\n private _injectedMatchMedia: WcsMatchMedia | null;\n\n // SSR (§3.8): no asynchronous probe to await — observe() completes\n // synchronously, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget, options?: WcsMediaQueryCoreOptions) {\n super();\n this._target = target ?? this;\n this._injectedMatchMedia = options?.matchMedia ?? null;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get query(): string {\n return this._query;\n }\n\n get matched(): boolean {\n return this._snapshot.matched;\n }\n\n get media(): string {\n return this._snapshot.media;\n }\n\n get supported(): boolean {\n return this._snapshot.supported;\n }\n\n // Lifecycle (§3.5). Idempotent: observe() with the query already subscribed\n // is a no-op (no double listener, no redundant dispatch). A different query\n // re-subscribes (dispose-then-observe semantics in one call). Omitting the\n // argument keeps the current query — the reconnect case for the Shell.\n // Synchronous overall (no probe to await), so the returned promise is only\n // for API uniformity with other IO nodes.\n observe(query: string = this._query): Promise<void> {\n if (this._subscribed && query === this._query) {\n return this._ready;\n }\n this._teardown();\n this._query = query;\n this._subscribed = true;\n this._subscribe(query);\n return this._ready;\n }\n\n dispose(): void {\n this._subscribed = false;\n this._teardown();\n }\n\n // API resolution is call-time, never cached (§3.7): lets tests install/remove\n // globalThis.matchMedia freely and lets a non-browser host be detected\n // correctly on every observe(). Called as a method of globalThis so the\n // native implementation keeps its `this` (calling it unbound throws).\n private _resolveMatchMedia(): WcsMatchMedia | null {\n if (this._injectedMatchMedia !== null) {\n return this._injectedMatchMedia;\n }\n const g = globalThis as { matchMedia?: WcsMatchMedia };\n return typeof g.matchMedia === \"function\" ? (q: string) => g.matchMedia!(q) : null;\n }\n\n private _subscribe(query: string): void {\n const gen = ++this._gen;\n const matchMedia = this._resolveMatchMedia();\n if (matchMedia === null) {\n this._apply(UNSUPPORTED_SNAPSHOT);\n return;\n }\n if (query === \"\") {\n this._apply(IDLE_SNAPSHOT);\n return;\n }\n // never-throw (§3.6): browsers do not throw on an invalid query string\n // (they return `media: \"not all\"`), but a hostile host or a broken\n // MediaQueryList polyfill might — that must not kill observe().\n let list: WcsMediaQueryList | null = null;\n try {\n list = matchMedia(query);\n const onChange = (): void => {\n if (gen !== this._gen) return; // stale subscription — never write\n this._apply(this._read(list!));\n };\n this._unsubscribe = attachChange(list, onChange);\n } catch {\n list = null;\n this._unsubscribe = null;\n }\n this._apply(list === null ? IDLE_SNAPSHOT : this._read(list));\n }\n\n private _teardown(): void {\n this._gen++;\n if (this._unsubscribe !== null) {\n const unsubscribe = this._unsubscribe;\n this._unsubscribe = null;\n try {\n unsubscribe();\n } catch {\n // never-throw: a list that refuses to detach is already neutralized\n // by the generation bump above.\n }\n }\n }\n\n private _read(list: WcsMediaQueryList): WcsMediaQuerySnapshot {\n return {\n matched: list.matches === true,\n media: typeof list.media === \"string\" ? list.media : \"\",\n supported: true,\n };\n }\n\n // Same-value guard (§3.3 MUST): the native `change` event already fires only\n // when `matches` flips, but this Core still verifies field-by-field before\n // dispatching — a re-subscription to an equivalent query, or a legacy\n // `addListener` double-fire, must not produce a redundant event.\n private _apply(next: WcsMediaQuerySnapshot): void {\n const prev = this._snapshot;\n if (\n prev.matched === next.matched &&\n prev.media === next.media &&\n prev.supported === next.supported\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-media-query:change\", {\n detail: next,\n // Family-wide MUST (async-io-node-guidelines.md §3.3): the event bubbles\n // from the Shell element so document-level consumers can delegate.\n bubbles: true,\n }));\n }\n}\n\n// Subscribe to a MediaQueryList's `change` with whichever listener API it has.\n// Modern engines: EventTarget-style. Old Safari (< 14): the deprecated\n// addListener / removeListener pair. Neither: no live updates — the snapshot\n// taken at observe() is all there is (a static polyfill, for instance).\n// Returns the matching detach function.\nfunction attachChange(list: WcsMediaQueryList, listener: () => void): () => void {\n if (typeof list.addEventListener === \"function\" && typeof list.removeEventListener === \"function\") {\n list.addEventListener(\"change\", listener);\n return () => list.removeEventListener!(\"change\", listener);\n }\n if (typeof list.addListener === \"function\" && typeof list.removeListener === \"function\") {\n list.addListener(listener);\n return () => list.removeListener!(listener);\n }\n return () => {};\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/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\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 for (const input of inputs) {\n const name = input.name;\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","import { IWcBindable } from \"../types.js\";\nimport { MediaQueryCore } from \"../core/MediaQueryCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\n\n/**\n * `<wcs-media-query query=\"(prefers-color-scheme: dark)\">` — declarative\n * `matchMedia` monitor.\n *\n * One attribute (`query`), three outputs (`matched` / `media` / `supported`),\n * no commands. Changing `query` while connected re-subscribes the Core to the\n * new MediaQueryList (docs/media-query-tag-design.md §7).\n */\nexport class WcsMediaQuery extends HTMLElement {\n // SSR (§4.4): observe() completes synchronously, but the Shell still exposes\n // connectedCallbackPromise so SSR (@wcstack/server render.ts) can await it\n // uniformly across all IO nodes before snapshotting the HTML.\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...MediaQueryCore.wcBindable,\n // Shell-level settable surface: the media query string, mirrored to the\n // `query` attribute (idempotent reflect, so a binder writing through\n // inputs[].attribute is safe).\n inputs: [\n { name: \"query\", attribute: \"query\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。network と同型。\n commands: MediaQueryCore.wcBindable.commands,\n };\n\n // `query` is the only attribute worth re-subscribing for; it is the whole\n // configuration of this node.\n static get observedAttributes(): string[] { return [\"query\"]; }\n\n private _core: MediaQueryCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new MediaQueryCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-media-query:change\": (d) => ({\n matched: d.matched === true,\n supported: d.supported === true,\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\n get query(): string {\n return this.getAttribute(\"query\") ?? \"\";\n }\n\n set query(value: string) {\n this.setAttribute(\"query\", value);\n }\n\n // --- Core delegated getters ---\n\n get matched(): boolean {\n return this._core.matched;\n }\n\n get media(): string {\n return this._core.media;\n }\n\n get supported(): boolean {\n return this._core.supported;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Lifecycle ---\n\n attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void {\n // Re-subscribe on a live query change. Removing the attribute (newValue\n // null) is a real change too — it means \"watch nothing\", so `matched`\n // drops to false instead of lingering on the old query's value. Before\n // connect the attribute is simply read by connectedCallback.\n if (name === \"query\" && this.isConnected) {\n this._core.observe(newValue ?? \"\");\n }\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe(this.query);\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapMediaQuery(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n","import { WcsMediaQuery } from \"./components/MediaQuery.js\";\nimport { config } from \"./config.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n if (!registry.get(config.tagNames.mediaQuery)) {\n registry.define(config.tagNames.mediaQuery, WcsMediaQuery);\n }\n}\n"],"names":["config","tagNames","mediaQuery","UNSUPPORTED_SNAPSHOT","Object","freeze","matched","media","supported","IDLE_SNAPSHOT","MediaQueryCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","commands","_target","_snapshot","_query","_unsubscribe","_subscribed","_gen","_injectedMatchMedia","_ready","Promise","resolve","constructor","target","options","super","this","matchMedia","ready","query","observe","_teardown","_subscribe","dispose","_resolveMatchMedia","g","globalThis","q","gen","_apply","list","onChange","_read","listener","addEventListener","removeEventListener","addListener","removeListener","attachChange","unsubscribe","matches","next","prev","dispatchEvent","CustomEvent","bubbles","hasAccessorOnPrototype","proto","getPrototypeOf","descriptor","getOwnPropertyDescriptor","undefined","get","set","WcsMediaQuery","HTMLElement","wcBindable","inputs","attribute","observedAttributes","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","add","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","getAttribute","value","setAttribute","connectedCallbackPromise","attributeChangedCallback","_oldValue","newValue","isConnected","connectedCallback","element","declaration","input","prototype","hasOwnProperty","call","record","upgradeProperties","style","display","disconnectedCallback","registry","customElements","define","registerComponents"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,WAAY,oBCNVC,EAA8CC,OAAOC,OAAO,CAChEC,SAAS,EACTC,MAAO,GACPC,WAAW,IAMPC,EAAuCL,OAAOC,OAAO,CACzDC,SAAS,EACTC,MAAO,GACPC,WAAW,IAmBP,MAAOE,UAAuBC,YAClCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,UAAWC,MAAO,yBAA0BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOf,SACxH,CAAEU,KAAM,QAASC,MAAO,yBAA0BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOd,OACtH,CAAES,KAAM,YAAaC,MAAO,yBAA0BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOb,YAQ5Hc,SAAU,IAGJC,QACAC,UAAmCrB,EAGnCsB,OAAS,GAGTC,aAAoC,KAIpCC,aAAc,EAMdC,KAAO,EAIPC,oBAIAC,OAAwBC,QAAQC,UAExC,WAAAC,CAAYC,EAAsBC,GAChCC,QACAC,KAAKd,QAAUW,GAAUG,KACzBA,KAAKR,oBAAsBM,GAASG,YAAc,IACpD,CAEA,SAAIC,GACF,OAAOF,KAAKP,MACd,CAEA,SAAIU,GACF,OAAOH,KAAKZ,MACd,CAEA,WAAInB,GACF,OAAO+B,KAAKb,UAAUlB,OACxB,CAEA,SAAIC,GACF,OAA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EAA2D5E,aAAa4C,WACvFC,EAASgC,GAAahC,OAC5B,QAAeN,IAAXM,EACJ,IAAK,MAAMiC,KAASjC,EAAQ,CAC1B,MAAM9D,EAAO+F,EAAM/F,KACnB,IAAKZ,OAAO4G,UAAUC,eAAeC,KAAKL,EAAS7F,GAAO,SAC1D,IAAKmD,EAAuB0C,EAAS7F,GAAO,SAC5C,MAAMmG,EAASN,EACTR,EAAQc,EAAOnG,UACdmG,EAAOnG,GACdmG,EAAOnG,GAAQqF,CACjB,CACF,CC0EIe,CAAkB/E,MAClBA,KAAKgF,MAAMC,QAAU,OACrBjF,KAAK6C,0BAA4B7C,KAAK4C,MAAMxC,QAAQJ,KAAKG,MAC3D,CAEA,oBAAA+E,GACElF,KAAK4C,MAAMrC,SACb,ECxII,IAA4D4E,GCI5D,SAA6BA,EAAkCC,gBAC9DD,EAAS/C,IAAIzE,EAAOC,SAASC,aAChCsH,EAASE,OAAO1H,EAAOC,SAASC,WAAYyE,EAEhD,CDJEgD,CAAmBH"}
|
|
1
|
+
{"version":3,"file":"auto.min.js","sources":["../src/config.ts","../src/core/MediaQueryCore.ts","../src/protocol/upgradeProperties.ts","../src/protocol/inputAttribute.ts","../src/components/MediaQuery.ts","../src/bootstrapMediaQuery.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n mediaQuery: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n mediaQuery: \"wcs-media-query\",\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: `bootstrapMediaQuery` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/media-query] bootstrapMediaQuery: \"${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","import {\n IWcBindable, WcsMatchMedia, WcsMediaQueryCoreOptions, WcsMediaQueryList, WcsMediaQuerySnapshot,\n} from \"../types.js\";\n\nconst UNSUPPORTED_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: false,\n});\n\n// \"matchMedia exists but there is nothing to watch\": an empty query, or a\n// matchMedia call that threw. Same shape as UNSUPPORTED_SNAPSHOT except that\n// `supported` stays honest about the API being present.\nconst IDLE_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: true,\n});\n\n/**\n * Headless media-query primitive. A thin, framework-agnostic wrapper around\n * `window.matchMedia` exposed through the wc-bindable protocol.\n *\n * `observe(query)` subscribes to one `MediaQueryList` and republishes its\n * `matches` / `media` as `matched` / `media` state; a different query while subscribed tears the\n * old list down and subscribes to the new one. Subscribing is synchronous, but\n * — unlike `@wcstack/network` — this Core does keep a `_gen` generation guard\n * (§3.4): each subscription's `change` listener captures the generation it was\n * created under and bails when it is stale, so a `MediaQueryList` whose\n * `removeEventListener` / `removeListener` misbehaves can never write the old\n * query's `matched` over the new query's (docs/media-query-tag-design.md §6).\n *\n * `matchMedia` is universally available in browsers; `supported === false` is\n * the non-browser case (SSR, workers) rather than a browser quirk.\n */\nexport class MediaQueryCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"matched\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.matched },\n { name: \"media\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.media },\n { name: \"supported\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.supported },\n ],\n // Pure monitor: a MediaQueryList has no action to invoke.\n //\n // `matched`, not `matches`: `Element.prototype.matches(selector)` exists on\n // every element, and a wc-bindable property name is read straight off the\n // Shell — a boolean `matches` would shadow the platform method\n // (docs/media-query-tag-design.md §2.1).\n commands: [],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsMediaQuerySnapshot = UNSUPPORTED_SNAPSHOT;\n\n // The query currently subscribed (or last requested). \"\" means \"nothing to watch\".\n private _query = \"\";\n\n // Detaches the live `change` listener of the current subscription, if any.\n private _unsubscribe: (() => void) | null = null;\n\n // True between observe() and dispose(). Guards observe() so a redundant call\n // with the same query does not re-subscribe; dispose() resets it.\n private _subscribed = false;\n\n // Generation guard (§3.4). Bumped by every (re)subscription and by dispose().\n // A `change` listener captures its generation and ignores the event once a\n // newer subscription exists — see the class docs for why this is kept even\n // though subscribing itself is synchronous.\n private _gen = 0;\n\n // Injected matchMedia (tests / non-window hosts). `null` = resolve\n // `globalThis.matchMedia` at call time (§3.7).\n private _injectedMatchMedia: WcsMatchMedia | null;\n\n // SSR (§3.8): no asynchronous probe to await — observe() completes\n // synchronously, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget, options?: WcsMediaQueryCoreOptions) {\n super();\n this._target = target ?? this;\n this._injectedMatchMedia = options?.matchMedia ?? null;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get query(): string {\n return this._query;\n }\n\n get matched(): boolean {\n return this._snapshot.matched;\n }\n\n get media(): string {\n return this._snapshot.media;\n }\n\n get supported(): boolean {\n return this._snapshot.supported;\n }\n\n // Lifecycle (§3.5). Idempotent: observe() with the query already subscribed\n // is a no-op (no double listener, no redundant dispatch). A different query\n // re-subscribes (dispose-then-observe semantics in one call). Omitting the\n // argument keeps the current query — the reconnect case for the Shell.\n // Synchronous overall (no probe to await), so the returned promise is only\n // for API uniformity with other IO nodes.\n observe(query: string = this._query): Promise<void> {\n if (this._subscribed && query === this._query) {\n return this._ready;\n }\n this._teardown();\n this._query = query;\n this._subscribed = true;\n this._subscribe(query);\n return this._ready;\n }\n\n dispose(): void {\n this._subscribed = false;\n this._teardown();\n }\n\n // API resolution is call-time, never cached (§3.7): lets tests install/remove\n // globalThis.matchMedia freely and lets a non-browser host be detected\n // correctly on every observe(). Called as a method of globalThis so the\n // native implementation keeps its `this` (calling it unbound throws).\n private _resolveMatchMedia(): WcsMatchMedia | null {\n if (this._injectedMatchMedia !== null) {\n return this._injectedMatchMedia;\n }\n const g = globalThis as { matchMedia?: WcsMatchMedia };\n return typeof g.matchMedia === \"function\" ? (q: string) => g.matchMedia!(q) : null;\n }\n\n private _subscribe(query: string): void {\n const gen = ++this._gen;\n const matchMedia = this._resolveMatchMedia();\n if (matchMedia === null) {\n this._apply(UNSUPPORTED_SNAPSHOT);\n return;\n }\n if (query === \"\") {\n this._apply(IDLE_SNAPSHOT);\n return;\n }\n // never-throw (§3.6): browsers do not throw on an invalid query string\n // (they return `media: \"not all\"`), but a hostile host or a broken\n // MediaQueryList polyfill might — that must not kill observe().\n let list: WcsMediaQueryList | null = null;\n try {\n list = matchMedia(query);\n const onChange = (): void => {\n if (gen !== this._gen) return; // stale subscription — never write\n this._apply(this._read(list!));\n };\n this._unsubscribe = attachChange(list, onChange);\n } catch {\n list = null;\n this._unsubscribe = null;\n }\n this._apply(list === null ? IDLE_SNAPSHOT : this._read(list));\n }\n\n private _teardown(): void {\n this._gen++;\n if (this._unsubscribe !== null) {\n const unsubscribe = this._unsubscribe;\n this._unsubscribe = null;\n try {\n unsubscribe();\n } catch {\n // never-throw: a list that refuses to detach is already neutralized\n // by the generation bump above.\n }\n }\n }\n\n private _read(list: WcsMediaQueryList): WcsMediaQuerySnapshot {\n return {\n matched: list.matches === true,\n media: typeof list.media === \"string\" ? list.media : \"\",\n supported: true,\n };\n }\n\n // Same-value guard (§3.3 MUST): the native `change` event already fires only\n // when `matches` flips, but this Core still verifies field-by-field before\n // dispatching — a re-subscription to an equivalent query, or a legacy\n // `addListener` double-fire, must not produce a redundant event.\n private _apply(next: WcsMediaQuerySnapshot): void {\n const prev = this._snapshot;\n if (\n prev.matched === next.matched &&\n prev.media === next.media &&\n prev.supported === next.supported\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-media-query:change\", {\n detail: next,\n // Family-wide MUST (async-io-node-guidelines.md §3.3): the event bubbles\n // from the Shell element so document-level consumers can delegate.\n bubbles: true,\n }));\n }\n}\n\n// Subscribe to a MediaQueryList's `change` with whichever listener API it has.\n// Modern engines: EventTarget-style. Old Safari (< 14): the deprecated\n// addListener / removeListener pair. Neither: no live updates — the snapshot\n// taken at observe() is all there is (a static polyfill, for instance).\n// Returns the matching detach function.\nfunction attachChange(list: WcsMediaQueryList, listener: () => void): () => void {\n if (typeof list.addEventListener === \"function\" && typeof list.removeEventListener === \"function\") {\n list.addEventListener(\"change\", listener);\n return () => list.removeEventListener!(\"change\", listener);\n }\n if (typeof list.addListener === \"function\" && typeof list.removeListener === \"function\") {\n list.addListener(listener);\n return () => list.removeListener!(listener);\n }\n return () => {};\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/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\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 for (const input of inputs) {\n const name = input.name;\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 } from \"../types.js\";\nimport { MediaQueryCore } from \"../core/MediaQueryCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-media-query query=\"(prefers-color-scheme: dark)\">` — declarative\n * `matchMedia` monitor.\n *\n * One attribute (`query`), three outputs (`matched` / `media` / `supported`),\n * no commands. Changing `query` while connected re-subscribes the Core to the\n * new MediaQueryList (docs/media-query-tag-design.md §7).\n */\nexport class WcsMediaQuery extends HTMLElement {\n // SSR (§4.4): observe() completes synchronously, but the Shell still exposes\n // connectedCallbackPromise so SSR (@wcstack/server render.ts) can await it\n // uniformly across all IO nodes before snapshotting the HTML.\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...MediaQueryCore.wcBindable,\n // Shell-level settable surface: the media query string, mirrored to the\n // `query` attribute (idempotent reflect, so a binder writing through\n // inputs[].attribute is safe).\n inputs: [\n { name: \"query\", attribute: \"query\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。network と同型。\n commands: MediaQueryCore.wcBindable.commands,\n };\n\n // `query` is the only attribute worth re-subscribing for; it is the whole\n // configuration of this node.\n static get observedAttributes(): string[] { return [\"query\"]; }\n\n private _core: MediaQueryCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new MediaQueryCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-media-query:change\": (d) => ({\n matched: d.matched === true,\n supported: d.supported === true,\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\n get query(): string {\n return this.getAttribute(\"query\") ?? \"\";\n }\n\n // Never lets setAttribute stringify null / undefined (matchMedia(\"undefined\")\n // is a valid, never-matching query): `null` removes the attribute (\"watch\n // nothing\"), `undefined` restores the attribute the element started with\n // (wc-bindable producer guidance P1; React 19 and a direct assignment deliver\n // it, @wcstack/state does not). Either way attributeChangedCallback\n // re-subscribes.\n set query(value: string | null | undefined) {\n reflectAttribute(this, \"query\", value);\n }\n\n // --- Core delegated getters ---\n\n get matched(): boolean {\n return this._core.matched;\n }\n\n get media(): string {\n return this._core.media;\n }\n\n get supported(): boolean {\n return this._core.supported;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Lifecycle ---\n\n attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void {\n // Re-subscribe on a live query change. Removing the attribute (newValue\n // null) is a real change too — it means \"watch nothing\", so `matched`\n // drops to false instead of lingering on the old query's value. Before\n // connect the attribute is simply read by connectedCallback.\n if (name === \"query\" && this.isConnected) {\n this._core.observe(newValue ?? \"\");\n }\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe(this.query);\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapMediaQuery(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n","import { WcsMediaQuery } from \"./components/MediaQuery.js\";\nimport { config } from \"./config.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n if (!registry.get(config.tagNames.mediaQuery)) {\n registry.define(config.tagNames.mediaQuery, WcsMediaQuery);\n }\n}\n"],"names":["config","tagNames","mediaQuery","UNSUPPORTED_SNAPSHOT","Object","freeze","matched","media","supported","IDLE_SNAPSHOT","MediaQueryCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","commands","_target","_snapshot","_query","_unsubscribe","_subscribed","_gen","_injectedMatchMedia","_ready","Promise","resolve","constructor","target","options","super","this","matchMedia","ready","query","observe","_teardown","_subscribe","dispose","_resolveMatchMedia","g","globalThis","q","gen","_apply","list","onChange","_read","listener","addEventListener","removeEventListener","addListener","removeListener","attachChange","unsubscribe","matches","next","prev","dispatchEvent","CustomEvent","bubbles","hasAccessorOnPrototype","proto","getPrototypeOf","descriptor","getOwnPropertyDescriptor","undefined","get","set","initialAttributes","WeakMap","reflectAttribute","el","value","initial","byName","Map","has","getAttribute","initialAttribute","removeAttribute","setAttribute","writeAttribute","String","WcsMediaQuery","HTMLElement","wcBindable","inputs","attribute","observedAttributes","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","add","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","connectedCallbackPromise","attributeChangedCallback","_oldValue","newValue","isConnected","connectedCallback","element","declaration","input","prototype","hasOwnProperty","call","record","upgradeProperties","style","display","disconnectedCallback","registry","customElements","define","registerComponents"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,WAAY,oBCNVC,EAA8CC,OAAOC,OAAO,CAChEC,SAAS,EACTC,MAAO,GACPC,WAAW,IAMPC,EAAuCL,OAAOC,OAAO,CACzDC,SAAS,EACTC,MAAO,GACPC,WAAW,IAmBP,MAAOE,UAAuBC,YAClCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,UAAWC,MAAO,yBAA0BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOf,SACx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UC,eAAeC,KAAKL,EAASzG,GAAO,SAC1D,IAAKmD,EAAuBsD,EAASzG,GAAO,SAC5C,MAAM+G,EAASN,EACT1C,EAAQgD,EAAO/G,UACd+G,EAAO/G,GACd+G,EAAO/G,GAAQ+D,CACjB,CACF,CEiFIiD,CAAkB3F,MAClBA,KAAK4F,MAAMC,QAAU,OACrB7F,KAAK4D,0BAA4B5D,KAAK2D,MAAMvD,QAAQJ,KAAKG,MAC3D,CAEA,oBAAA2F,GACE9F,KAAK2D,MAAMpD,SACb,EC/II,IAA4DwF,GCI5D,SAA6BA,EAAkCC,gBAC9DD,EAAS3D,IAAIzE,EAAOC,SAASC,aAChCkI,EAASE,OAAOtI,EAAOC,SAASC,WAAYwF,EAEhD,CDJE6C,CAAmBH"}
|
package/dist/index.d.ts
CHANGED
|
@@ -171,7 +171,7 @@ declare class WcsMediaQuery extends HTMLElement {
|
|
|
171
171
|
private _initInternals;
|
|
172
172
|
private _wireStates;
|
|
173
173
|
get query(): string;
|
|
174
|
-
set query(value: string);
|
|
174
|
+
set query(value: string | null | undefined);
|
|
175
175
|
get matched(): boolean;
|
|
176
176
|
get media(): string;
|
|
177
177
|
get supported(): boolean;
|
package/dist/index.esm.js
CHANGED
|
@@ -305,6 +305,53 @@ function upgradeProperties(element) {
|
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
+
// ===========================================================================
|
|
309
|
+
// AUTO-GENERATED FILE - DO NOT EDIT.
|
|
310
|
+
// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.
|
|
311
|
+
// Run `node scripts/sync-protocol-types.mjs` after editing the source.
|
|
312
|
+
// ===========================================================================
|
|
313
|
+
// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。
|
|
314
|
+
// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:
|
|
315
|
+
// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、
|
|
316
|
+
// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は
|
|
317
|
+
// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。
|
|
318
|
+
// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。
|
|
319
|
+
// - どちらも文字列 "undefined" / "null" として属性に入らない。
|
|
320
|
+
//
|
|
321
|
+
// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは
|
|
322
|
+
// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。
|
|
323
|
+
// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。
|
|
324
|
+
//
|
|
325
|
+
// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run
|
|
326
|
+
// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies
|
|
327
|
+
// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.
|
|
328
|
+
const initialAttributes = new WeakMap();
|
|
329
|
+
/** The attribute as it stood before the first write through these helpers. */
|
|
330
|
+
function initialAttribute(el, name) {
|
|
331
|
+
let byName = initialAttributes.get(el);
|
|
332
|
+
if (byName === undefined) {
|
|
333
|
+
byName = new Map();
|
|
334
|
+
initialAttributes.set(el, byName);
|
|
335
|
+
}
|
|
336
|
+
if (!byName.has(name))
|
|
337
|
+
byName.set(name, el.getAttribute(name));
|
|
338
|
+
return byName.get(name);
|
|
339
|
+
}
|
|
340
|
+
function writeAttribute(el, name, value) {
|
|
341
|
+
if (value === null)
|
|
342
|
+
el.removeAttribute(name);
|
|
343
|
+
else
|
|
344
|
+
el.setAttribute(name, value);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* A value attribute. `value` is written as `String(value)`; `null` removes the attribute;
|
|
348
|
+
* `undefined` restores the attribute the element started with.
|
|
349
|
+
*/
|
|
350
|
+
function reflectAttribute(el, name, value) {
|
|
351
|
+
const initial = initialAttribute(el, name);
|
|
352
|
+
writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));
|
|
353
|
+
}
|
|
354
|
+
|
|
308
355
|
/**
|
|
309
356
|
* `<wcs-media-query query="(prefers-color-scheme: dark)">` — declarative
|
|
310
357
|
* `matchMedia` monitor.
|
|
@@ -398,8 +445,14 @@ class WcsMediaQuery extends HTMLElement {
|
|
|
398
445
|
get query() {
|
|
399
446
|
return this.getAttribute("query") ?? "";
|
|
400
447
|
}
|
|
448
|
+
// Never lets setAttribute stringify null / undefined (matchMedia("undefined")
|
|
449
|
+
// is a valid, never-matching query): `null` removes the attribute ("watch
|
|
450
|
+
// nothing"), `undefined` restores the attribute the element started with
|
|
451
|
+
// (wc-bindable producer guidance P1; React 19 and a direct assignment deliver
|
|
452
|
+
// it, @wcstack/state does not). Either way attributeChangedCallback
|
|
453
|
+
// re-subscribes.
|
|
401
454
|
set query(value) {
|
|
402
|
-
this
|
|
455
|
+
reflectAttribute(this, "query", value);
|
|
403
456
|
}
|
|
404
457
|
// --- Core delegated getters ---
|
|
405
458
|
get matched() {
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/MediaQueryCore.ts","../src/protocol/upgradeProperties.ts","../src/components/MediaQuery.ts","../src/registerComponents.ts","../src/bootstrapMediaQuery.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n mediaQuery: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n mediaQuery: \"wcs-media-query\",\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: `bootstrapMediaQuery` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/media-query] bootstrapMediaQuery: \"${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","import {\n IWcBindable, WcsMatchMedia, WcsMediaQueryCoreOptions, WcsMediaQueryList, WcsMediaQuerySnapshot,\n} from \"../types.js\";\n\nconst UNSUPPORTED_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: false,\n});\n\n// \"matchMedia exists but there is nothing to watch\": an empty query, or a\n// matchMedia call that threw. Same shape as UNSUPPORTED_SNAPSHOT except that\n// `supported` stays honest about the API being present.\nconst IDLE_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: true,\n});\n\n/**\n * Headless media-query primitive. A thin, framework-agnostic wrapper around\n * `window.matchMedia` exposed through the wc-bindable protocol.\n *\n * `observe(query)` subscribes to one `MediaQueryList` and republishes its\n * `matches` / `media` as `matched` / `media` state; a different query while subscribed tears the\n * old list down and subscribes to the new one. Subscribing is synchronous, but\n * — unlike `@wcstack/network` — this Core does keep a `_gen` generation guard\n * (§3.4): each subscription's `change` listener captures the generation it was\n * created under and bails when it is stale, so a `MediaQueryList` whose\n * `removeEventListener` / `removeListener` misbehaves can never write the old\n * query's `matched` over the new query's (docs/media-query-tag-design.md §6).\n *\n * `matchMedia` is universally available in browsers; `supported === false` is\n * the non-browser case (SSR, workers) rather than a browser quirk.\n */\nexport class MediaQueryCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"matched\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.matched },\n { name: \"media\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.media },\n { name: \"supported\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.supported },\n ],\n // Pure monitor: a MediaQueryList has no action to invoke.\n //\n // `matched`, not `matches`: `Element.prototype.matches(selector)` exists on\n // every element, and a wc-bindable property name is read straight off the\n // Shell — a boolean `matches` would shadow the platform method\n // (docs/media-query-tag-design.md §2.1).\n commands: [],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsMediaQuerySnapshot = UNSUPPORTED_SNAPSHOT;\n\n // The query currently subscribed (or last requested). \"\" means \"nothing to watch\".\n private _query = \"\";\n\n // Detaches the live `change` listener of the current subscription, if any.\n private _unsubscribe: (() => void) | null = null;\n\n // True between observe() and dispose(). Guards observe() so a redundant call\n // with the same query does not re-subscribe; dispose() resets it.\n private _subscribed = false;\n\n // Generation guard (§3.4). Bumped by every (re)subscription and by dispose().\n // A `change` listener captures its generation and ignores the event once a\n // newer subscription exists — see the class docs for why this is kept even\n // though subscribing itself is synchronous.\n private _gen = 0;\n\n // Injected matchMedia (tests / non-window hosts). `null` = resolve\n // `globalThis.matchMedia` at call time (§3.7).\n private _injectedMatchMedia: WcsMatchMedia | null;\n\n // SSR (§3.8): no asynchronous probe to await — observe() completes\n // synchronously, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget, options?: WcsMediaQueryCoreOptions) {\n super();\n this._target = target ?? this;\n this._injectedMatchMedia = options?.matchMedia ?? null;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get query(): string {\n return this._query;\n }\n\n get matched(): boolean {\n return this._snapshot.matched;\n }\n\n get media(): string {\n return this._snapshot.media;\n }\n\n get supported(): boolean {\n return this._snapshot.supported;\n }\n\n // Lifecycle (§3.5). Idempotent: observe() with the query already subscribed\n // is a no-op (no double listener, no redundant dispatch). A different query\n // re-subscribes (dispose-then-observe semantics in one call). Omitting the\n // argument keeps the current query — the reconnect case for the Shell.\n // Synchronous overall (no probe to await), so the returned promise is only\n // for API uniformity with other IO nodes.\n observe(query: string = this._query): Promise<void> {\n if (this._subscribed && query === this._query) {\n return this._ready;\n }\n this._teardown();\n this._query = query;\n this._subscribed = true;\n this._subscribe(query);\n return this._ready;\n }\n\n dispose(): void {\n this._subscribed = false;\n this._teardown();\n }\n\n // API resolution is call-time, never cached (§3.7): lets tests install/remove\n // globalThis.matchMedia freely and lets a non-browser host be detected\n // correctly on every observe(). Called as a method of globalThis so the\n // native implementation keeps its `this` (calling it unbound throws).\n private _resolveMatchMedia(): WcsMatchMedia | null {\n if (this._injectedMatchMedia !== null) {\n return this._injectedMatchMedia;\n }\n const g = globalThis as { matchMedia?: WcsMatchMedia };\n return typeof g.matchMedia === \"function\" ? (q: string) => g.matchMedia!(q) : null;\n }\n\n private _subscribe(query: string): void {\n const gen = ++this._gen;\n const matchMedia = this._resolveMatchMedia();\n if (matchMedia === null) {\n this._apply(UNSUPPORTED_SNAPSHOT);\n return;\n }\n if (query === \"\") {\n this._apply(IDLE_SNAPSHOT);\n return;\n }\n // never-throw (§3.6): browsers do not throw on an invalid query string\n // (they return `media: \"not all\"`), but a hostile host or a broken\n // MediaQueryList polyfill might — that must not kill observe().\n let list: WcsMediaQueryList | null = null;\n try {\n list = matchMedia(query);\n const onChange = (): void => {\n if (gen !== this._gen) return; // stale subscription — never write\n this._apply(this._read(list!));\n };\n this._unsubscribe = attachChange(list, onChange);\n } catch {\n list = null;\n this._unsubscribe = null;\n }\n this._apply(list === null ? IDLE_SNAPSHOT : this._read(list));\n }\n\n private _teardown(): void {\n this._gen++;\n if (this._unsubscribe !== null) {\n const unsubscribe = this._unsubscribe;\n this._unsubscribe = null;\n try {\n unsubscribe();\n } catch {\n // never-throw: a list that refuses to detach is already neutralized\n // by the generation bump above.\n }\n }\n }\n\n private _read(list: WcsMediaQueryList): WcsMediaQuerySnapshot {\n return {\n matched: list.matches === true,\n media: typeof list.media === \"string\" ? list.media : \"\",\n supported: true,\n };\n }\n\n // Same-value guard (§3.3 MUST): the native `change` event already fires only\n // when `matches` flips, but this Core still verifies field-by-field before\n // dispatching — a re-subscription to an equivalent query, or a legacy\n // `addListener` double-fire, must not produce a redundant event.\n private _apply(next: WcsMediaQuerySnapshot): void {\n const prev = this._snapshot;\n if (\n prev.matched === next.matched &&\n prev.media === next.media &&\n prev.supported === next.supported\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-media-query:change\", {\n detail: next,\n // Family-wide MUST (async-io-node-guidelines.md §3.3): the event bubbles\n // from the Shell element so document-level consumers can delegate.\n bubbles: true,\n }));\n }\n}\n\n// Subscribe to a MediaQueryList's `change` with whichever listener API it has.\n// Modern engines: EventTarget-style. Old Safari (< 14): the deprecated\n// addListener / removeListener pair. Neither: no live updates — the snapshot\n// taken at observe() is all there is (a static polyfill, for instance).\n// Returns the matching detach function.\nfunction attachChange(list: WcsMediaQueryList, listener: () => void): () => void {\n if (typeof list.addEventListener === \"function\" && typeof list.removeEventListener === \"function\") {\n list.addEventListener(\"change\", listener);\n return () => list.removeEventListener!(\"change\", listener);\n }\n if (typeof list.addListener === \"function\" && typeof list.removeListener === \"function\") {\n list.addListener(listener);\n return () => list.removeListener!(listener);\n }\n return () => {};\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/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\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 for (const input of inputs) {\n const name = input.name;\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","import { IWcBindable } from \"../types.js\";\nimport { MediaQueryCore } from \"../core/MediaQueryCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\n\n/**\n * `<wcs-media-query query=\"(prefers-color-scheme: dark)\">` — declarative\n * `matchMedia` monitor.\n *\n * One attribute (`query`), three outputs (`matched` / `media` / `supported`),\n * no commands. Changing `query` while connected re-subscribes the Core to the\n * new MediaQueryList (docs/media-query-tag-design.md §7).\n */\nexport class WcsMediaQuery extends HTMLElement {\n // SSR (§4.4): observe() completes synchronously, but the Shell still exposes\n // connectedCallbackPromise so SSR (@wcstack/server render.ts) can await it\n // uniformly across all IO nodes before snapshotting the HTML.\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...MediaQueryCore.wcBindable,\n // Shell-level settable surface: the media query string, mirrored to the\n // `query` attribute (idempotent reflect, so a binder writing through\n // inputs[].attribute is safe).\n inputs: [\n { name: \"query\", attribute: \"query\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。network と同型。\n commands: MediaQueryCore.wcBindable.commands,\n };\n\n // `query` is the only attribute worth re-subscribing for; it is the whole\n // configuration of this node.\n static get observedAttributes(): string[] { return [\"query\"]; }\n\n private _core: MediaQueryCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new MediaQueryCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-media-query:change\": (d) => ({\n matched: d.matched === true,\n supported: d.supported === true,\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\n get query(): string {\n return this.getAttribute(\"query\") ?? \"\";\n }\n\n set query(value: string) {\n this.setAttribute(\"query\", value);\n }\n\n // --- Core delegated getters ---\n\n get matched(): boolean {\n return this._core.matched;\n }\n\n get media(): string {\n return this._core.media;\n }\n\n get supported(): boolean {\n return this._core.supported;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Lifecycle ---\n\n attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void {\n // Re-subscribe on a live query change. Removing the attribute (newValue\n // null) is a real change too — it means \"watch nothing\", so `matched`\n // drops to false instead of lingering on the old query's value. Before\n // connect the attribute is simply read by connectedCallback.\n if (name === \"query\" && this.isConnected) {\n this._core.observe(newValue ?? \"\");\n }\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe(this.query);\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","import { WcsMediaQuery } from \"./components/MediaQuery.js\";\nimport { config } from \"./config.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n if (!registry.get(config.tagNames.mediaQuery)) {\n registry.define(config.tagNames.mediaQuery, WcsMediaQuery);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapMediaQuery(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,iBAAiB;AAC9B,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,K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AA,wBAAwB,CAAC,IAAY,EAAE,SAAwB,EAAE,QAAuB,EAAA;;;;;QAKtF,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE;YACxC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;QACpC;IACF;IAEA,iBAAiB,GAAA;;QAEf,iBAAiB,CAAC,IAAI,CAAC;AACvB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM;AAC3B,QAAA,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;IACjE;IAEA,oBAAoB,GAAA;AAClB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACtB;;;ACzIF;;;;AAIG;AACG,SAAU,kBAAkB,CAAC,QAAA,GAAkC,cAAc,EAAA;AACjF,IAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;QAC7C,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IAC5D;AACF;;ACRM,SAAU,mBAAmB,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAChG,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;IACA,kBAAkB,CAAC,QAAQ,CAAC;AAC9B;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/MediaQueryCore.ts","../src/protocol/upgradeProperties.ts","../src/protocol/inputAttribute.ts","../src/components/MediaQuery.ts","../src/registerComponents.ts","../src/bootstrapMediaQuery.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n mediaQuery: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n mediaQuery: \"wcs-media-query\",\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: `bootstrapMediaQuery` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/media-query] bootstrapMediaQuery: \"${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","import {\n IWcBindable, WcsMatchMedia, WcsMediaQueryCoreOptions, WcsMediaQueryList, WcsMediaQuerySnapshot,\n} from \"../types.js\";\n\nconst UNSUPPORTED_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: false,\n});\n\n// \"matchMedia exists but there is nothing to watch\": an empty query, or a\n// matchMedia call that threw. Same shape as UNSUPPORTED_SNAPSHOT except that\n// `supported` stays honest about the API being present.\nconst IDLE_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: true,\n});\n\n/**\n * Headless media-query primitive. A thin, framework-agnostic wrapper around\n * `window.matchMedia` exposed through the wc-bindable protocol.\n *\n * `observe(query)` subscribes to one `MediaQueryList` and republishes its\n * `matches` / `media` as `matched` / `media` state; a different query while subscribed tears the\n * old list down and subscribes to the new one. Subscribing is synchronous, but\n * — unlike `@wcstack/network` — this Core does keep a `_gen` generation guard\n * (§3.4): each subscription's `change` listener captures the generation it was\n * created under and bails when it is stale, so a `MediaQueryList` whose\n * `removeEventListener` / `removeListener` misbehaves can never write the old\n * query's `matched` over the new query's (docs/media-query-tag-design.md §6).\n *\n * `matchMedia` is universally available in browsers; `supported === false` is\n * the non-browser case (SSR, workers) rather than a browser quirk.\n */\nexport class MediaQueryCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"matched\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.matched },\n { name: \"media\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.media },\n { name: \"supported\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.supported },\n ],\n // Pure monitor: a MediaQueryList has no action to invoke.\n //\n // `matched`, not `matches`: `Element.prototype.matches(selector)` exists on\n // every element, and a wc-bindable property name is read straight off the\n // Shell — a boolean `matches` would shadow the platform method\n // (docs/media-query-tag-design.md §2.1).\n commands: [],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsMediaQuerySnapshot = UNSUPPORTED_SNAPSHOT;\n\n // The query currently subscribed (or last requested). \"\" means \"nothing to watch\".\n private _query = \"\";\n\n // Detaches the live `change` listener of the current subscription, if any.\n private _unsubscribe: (() => void) | null = null;\n\n // True between observe() and dispose(). Guards observe() so a redundant call\n // with the same query does not re-subscribe; dispose() resets it.\n private _subscribed = false;\n\n // Generation guard (§3.4). Bumped by every (re)subscription and by dispose().\n // A `change` listener captures its generation and ignores the event once a\n // newer subscription exists — see the class docs for why this is kept even\n // though subscribing itself is synchronous.\n private _gen = 0;\n\n // Injected matchMedia (tests / non-window hosts). `null` = resolve\n // `globalThis.matchMedia` at call time (§3.7).\n private _injectedMatchMedia: WcsMatchMedia | null;\n\n // SSR (§3.8): no asynchronous probe to await — observe() completes\n // synchronously, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget, options?: WcsMediaQueryCoreOptions) {\n super();\n this._target = target ?? this;\n this._injectedMatchMedia = options?.matchMedia ?? null;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get query(): string {\n return this._query;\n }\n\n get matched(): boolean {\n return this._snapshot.matched;\n }\n\n get media(): string {\n return this._snapshot.media;\n }\n\n get supported(): boolean {\n return this._snapshot.supported;\n }\n\n // Lifecycle (§3.5). Idempotent: observe() with the query already subscribed\n // is a no-op (no double listener, no redundant dispatch). A different query\n // re-subscribes (dispose-then-observe semantics in one call). Omitting the\n // argument keeps the current query — the reconnect case for the Shell.\n // Synchronous overall (no probe to await), so the returned promise is only\n // for API uniformity with other IO nodes.\n observe(query: string = this._query): Promise<void> {\n if (this._subscribed && query === this._query) {\n return this._ready;\n }\n this._teardown();\n this._query = query;\n this._subscribed = true;\n this._subscribe(query);\n return this._ready;\n }\n\n dispose(): void {\n this._subscribed = false;\n this._teardown();\n }\n\n // API resolution is call-time, never cached (§3.7): lets tests install/remove\n // globalThis.matchMedia freely and lets a non-browser host be detected\n // correctly on every observe(). Called as a method of globalThis so the\n // native implementation keeps its `this` (calling it unbound throws).\n private _resolveMatchMedia(): WcsMatchMedia | null {\n if (this._injectedMatchMedia !== null) {\n return this._injectedMatchMedia;\n }\n const g = globalThis as { matchMedia?: WcsMatchMedia };\n return typeof g.matchMedia === \"function\" ? (q: string) => g.matchMedia!(q) : null;\n }\n\n private _subscribe(query: string): void {\n const gen = ++this._gen;\n const matchMedia = this._resolveMatchMedia();\n if (matchMedia === null) {\n this._apply(UNSUPPORTED_SNAPSHOT);\n return;\n }\n if (query === \"\") {\n this._apply(IDLE_SNAPSHOT);\n return;\n }\n // never-throw (§3.6): browsers do not throw on an invalid query string\n // (they return `media: \"not all\"`), but a hostile host or a broken\n // MediaQueryList polyfill might — that must not kill observe().\n let list: WcsMediaQueryList | null = null;\n try {\n list = matchMedia(query);\n const onChange = (): void => {\n if (gen !== this._gen) return; // stale subscription — never write\n this._apply(this._read(list!));\n };\n this._unsubscribe = attachChange(list, onChange);\n } catch {\n list = null;\n this._unsubscribe = null;\n }\n this._apply(list === null ? IDLE_SNAPSHOT : this._read(list));\n }\n\n private _teardown(): void {\n this._gen++;\n if (this._unsubscribe !== null) {\n const unsubscribe = this._unsubscribe;\n this._unsubscribe = null;\n try {\n unsubscribe();\n } catch {\n // never-throw: a list that refuses to detach is already neutralized\n // by the generation bump above.\n }\n }\n }\n\n private _read(list: WcsMediaQueryList): WcsMediaQuerySnapshot {\n return {\n matched: list.matches === true,\n media: typeof list.media === \"string\" ? list.media : \"\",\n supported: true,\n };\n }\n\n // Same-value guard (§3.3 MUST): the native `change` event already fires only\n // when `matches` flips, but this Core still verifies field-by-field before\n // dispatching — a re-subscription to an equivalent query, or a legacy\n // `addListener` double-fire, must not produce a redundant event.\n private _apply(next: WcsMediaQuerySnapshot): void {\n const prev = this._snapshot;\n if (\n prev.matched === next.matched &&\n prev.media === next.media &&\n prev.supported === next.supported\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-media-query:change\", {\n detail: next,\n // Family-wide MUST (async-io-node-guidelines.md §3.3): the event bubbles\n // from the Shell element so document-level consumers can delegate.\n bubbles: true,\n }));\n }\n}\n\n// Subscribe to a MediaQueryList's `change` with whichever listener API it has.\n// Modern engines: EventTarget-style. Old Safari (< 14): the deprecated\n// addListener / removeListener pair. Neither: no live updates — the snapshot\n// taken at observe() is all there is (a static polyfill, for instance).\n// Returns the matching detach function.\nfunction attachChange(list: WcsMediaQueryList, listener: () => void): () => void {\n if (typeof list.addEventListener === \"function\" && typeof list.removeEventListener === \"function\") {\n list.addEventListener(\"change\", listener);\n return () => list.removeEventListener!(\"change\", listener);\n }\n if (typeof list.addListener === \"function\" && typeof list.removeListener === \"function\") {\n list.addListener(listener);\n return () => list.removeListener!(listener);\n }\n return () => {};\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/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\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 for (const input of inputs) {\n const name = input.name;\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 } from \"../types.js\";\nimport { MediaQueryCore } from \"../core/MediaQueryCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-media-query query=\"(prefers-color-scheme: dark)\">` — declarative\n * `matchMedia` monitor.\n *\n * One attribute (`query`), three outputs (`matched` / `media` / `supported`),\n * no commands. Changing `query` while connected re-subscribes the Core to the\n * new MediaQueryList (docs/media-query-tag-design.md §7).\n */\nexport class WcsMediaQuery extends HTMLElement {\n // SSR (§4.4): observe() completes synchronously, but the Shell still exposes\n // connectedCallbackPromise so SSR (@wcstack/server render.ts) can await it\n // uniformly across all IO nodes before snapshotting the HTML.\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...MediaQueryCore.wcBindable,\n // Shell-level settable surface: the media query string, mirrored to the\n // `query` attribute (idempotent reflect, so a binder writing through\n // inputs[].attribute is safe).\n inputs: [\n { name: \"query\", attribute: \"query\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。network と同型。\n commands: MediaQueryCore.wcBindable.commands,\n };\n\n // `query` is the only attribute worth re-subscribing for; it is the whole\n // configuration of this node.\n static get observedAttributes(): string[] { return [\"query\"]; }\n\n private _core: MediaQueryCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new MediaQueryCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-media-query:change\": (d) => ({\n matched: d.matched === true,\n supported: d.supported === true,\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\n get query(): string {\n return this.getAttribute(\"query\") ?? \"\";\n }\n\n // Never lets setAttribute stringify null / undefined (matchMedia(\"undefined\")\n // is a valid, never-matching query): `null` removes the attribute (\"watch\n // nothing\"), `undefined` restores the attribute the element started with\n // (wc-bindable producer guidance P1; React 19 and a direct assignment deliver\n // it, @wcstack/state does not). Either way attributeChangedCallback\n // re-subscribes.\n set query(value: string | null | undefined) {\n reflectAttribute(this, \"query\", value);\n }\n\n // --- Core delegated getters ---\n\n get matched(): boolean {\n return this._core.matched;\n }\n\n get media(): string {\n return this._core.media;\n }\n\n get supported(): boolean {\n return this._core.supported;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Lifecycle ---\n\n attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void {\n // Re-subscribe on a live query change. Removing the attribute (newValue\n // null) is a real change too — it means \"watch nothing\", so `matched`\n // drops to false instead of lingering on the old query's value. Before\n // connect the attribute is simply read by connectedCallback.\n if (name === \"query\" && this.isConnected) {\n this._core.observe(newValue ?? \"\");\n }\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe(this.query);\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","import { WcsMediaQuery } from \"./components/MediaQuery.js\";\nimport { config } from \"./config.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n if (!registry.get(config.tagNames.mediaQuery)) {\n registry.define(config.tagNames.mediaQuery, WcsMediaQuery);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapMediaQuery(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,iBAAiB;AAC9B,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IAC/D;AACA,IAAA,OAAO,KAAU;AACnB;AAEA,IAAI,YAAY,GAAmB,IAAI;AAEhC,MAAM,MAAM,GAAY,OAAkB;SA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Q,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IAC5D;AACF;;ACRM,SAAU,mBAAmB,CAAC,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/media-query",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.9",
|
|
4
4
|
"description": "Declarative matchMedia component for Web Components. Framework-agnostic media-query monitor (prefers-color-scheme, prefers-reduced-motion, viewport width) via wc-bindable-protocol.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.esm.js",
|